Merge pull request #438 from kanoi/master ICA/BAS buffered USB
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 72 73 74 75 76 77 78
diff --git a/driver-bflsc.c b/driver-bflsc.c
index 9177d57..76bf3f5 100644
--- a/driver-bflsc.c
+++ b/driver-bflsc.c
@@ -471,6 +471,12 @@ static int write_to_dev(struct cgpu_info *bflsc, int dev, char *buf, int buflen,
struct DataForwardToChain data;
int len;
+ /*
+ * The protocol is syncronous so any previous excess can be
+ * discarded and assumed corrupt data or failed USB transfers
+ */
+ usb_buffer_clear(bflsc);
+
if (dev == 0)
return usb_write(bflsc, buf, buflen, amount, cmd);
@@ -949,6 +955,8 @@ reinit:
mutex_init(&bflsc->device_mutex);
rwlock_init(&sc_info->stat_lock);
+ usb_buffer_enable(bflsc);
+
return true;
unshin:
diff --git a/driver-icarus.c b/driver-icarus.c
index f4d50cb..2d18333 100644
--- a/driver-icarus.c
+++ b/driver-icarus.c
@@ -432,7 +432,6 @@ static int icarus_get_nonce(struct cgpu_info *icarus, unsigned char *buf, struct
if (first)
copy_time(tv_finish, &read_finish);
- // TODO: test if there is more data? to read a 2nd nonce?
if (amt >= read_amount)
return ICA_NONCE_OK;
@@ -830,6 +829,8 @@ static bool icarus_detect_one(struct libusb_device *dev, struct usb_find_devices
set_timing_mode(this_option_offset, icarus);
+ usb_buffer_enable(icarus);
+
return true;
unshin:
@@ -898,6 +899,9 @@ static int64_t icarus_scanhash(struct thr_info *thr, struct work *work,
rev(ob_bin, 32);
rev(ob_bin + 52, 12);
+ // We only want results for the work we are about to send
+ usb_buffer_clear(icarus);
+
err = usb_write(icarus, (char *)ob_bin, sizeof(ob_bin), &amount, C_SENDWORK);
if (err < 0 || amount != sizeof(ob_bin)) {
applog(LOG_ERR, "%s%i: Comms error (werr=%d amt=%d)",
@@ -956,6 +960,20 @@ static int64_t icarus_scanhash(struct thr_info *thr, struct work *work,
hash_count++;
hash_count *= info->fpga_count;
+#if 0
+ // This appears to only return zero nonce values
+ if (usb_buffer_size(icarus) > 3) {
+ memcpy((char *)&nonce, icarus->usbdev->buffer, sizeof(nonce_bin));
+ nonce = htobe32(nonce);
+ applog(LOG_WARNING, "%s%d: attempting to submit 2nd nonce = 0x%08lX",
+ icarus->drv->name, icarus->device_id,
+ (long unsigned int)nonce);
+ curr_hw_errors = icarus->hw_errors;
+ submit_nonce(thr, work, nonce);
+ was_hw_error = (curr_hw_errors > icarus->hw_errors);
+ }
+#endif
+
if (opt_debug || info->do_icarus_timing)
timersub(&tv_finish, &tv_start, &elapsed);