Use the bxf read thread to set the device target and send its first work item.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
diff --git a/driver-bitfury.c b/driver-bitfury.c
index a7301f9..ccd9d02 100644
--- a/driver-bitfury.c
+++ b/driver-bitfury.c
@@ -246,18 +246,33 @@ static void parse_bxf_temp(struct cgpu_info *bitfury, struct bitfury_info *info,
mutex_unlock(&info->lock);
}
+static void bxf_update_work(struct cgpu_info *bitfury, struct bitfury_info *info);
+
static void *bxf_get_results(void *userdata)
{
struct cgpu_info *bitfury = userdata;
struct bitfury_info *info = bitfury->device_data;
- char threadname[24];
+ char threadname[24], buf[512];
+ int err, amount, len;
snprintf(threadname, 24, "bxf_recv/%d", bitfury->device_id);
- while (likely(!bitfury->shutdown)) {
- int err, amount;
- char buf[512];
+ /* We operate the device at lowest diff since it's not a lot of results
+ * to process and gives us a better indicator of the nonce return rate
+ * and hardware errors. */
+ sprintf(buf, "target ffffffff\n");
+ len = strlen(buf);
+ err = usb_write(bitfury, buf, len, &amount, C_BXF_TARGET);
+ if (!err || amount != len) {
+ applog(LOG_WARNING, "%s %d: Error %d sending work sent %d of %d", bitfury->drv->name,
+ bitfury->device_id, err, amount, len);
+ goto out;
+ }
+ /* Read thread sends the first work item to get the device started
+ * since it will roll ntime and make work itself from there on. */
+ bxf_update_work(bitfury, info);
+ while (likely(!bitfury->shutdown)) {
if (unlikely(bitfury->usbinfo.nodev))
break;
@@ -270,6 +285,7 @@ static void *bxf_get_results(void *userdata)
if (!strncmp(buf, "temp", 4))
parse_bxf_temp(bitfury, info, buf);
}
+out:
return NULL;
}
@@ -483,7 +499,7 @@ static void bxf_send_work(struct cgpu_info *bitfury, struct work *work)
sprintf(buf, "work %s %d\n", hexwork, work->subid);
len = strlen(buf);
err = usb_write(bitfury, buf, len, &amount, C_BXF_WORK);
- if (err) {
+ if (err || amount != len) {
applog(LOG_WARNING, "%s %d: Error %d sending work sent %d of %d", bitfury->drv->name,
bitfury->device_id, err, amount, len);
}
diff --git a/usbutils.h b/usbutils.h
index e810fe1..dfc153a 100644
--- a/usbutils.h
+++ b/usbutils.h
@@ -345,6 +345,7 @@ struct cg_usb_info {
USB_ADD_COMMAND(C_BF1_IDENTIFY, "BF1Identify") \
USB_ADD_COMMAND(C_BXF_READ, "BXFRead") \
USB_ADD_COMMAND(C_BXF_WORK, "BXFWork") \
+ USB_ADD_COMMAND(C_BXF_TARGET, "BXFTarget") \
USB_ADD_COMMAND(C_HF_RESET, "HFReset") \
USB_ADD_COMMAND(C_HF_PLL_CONFIG, "HFPLLConfig") \
USB_ADD_COMMAND(C_HF_ADDRESS, "HFAddress") \