Detect non-responsive bitfury devices and try a usb reset on them before killing their instances off after 2 minutes of no activity.
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
diff --git a/driver-bitfury.c b/driver-bitfury.c
index 17da3e2..94e0540 100644
--- a/driver-bitfury.c
+++ b/driver-bitfury.c
@@ -941,17 +941,43 @@ static int64_t bitfury_scanwork(struct thr_info *thr)
{
struct cgpu_info *bitfury = thr->cgpu;
struct bitfury_info *info = bitfury->device_data;
+ int64_t ret = -1;
+
+ if (unlikely(last_getwork - bitfury->last_device_valid_work > 60)) {
+ if (info->failing) {
+ if (last_getwork - bitfury->last_device_valid_work > 120) {
+ applog(LOG_ERR, "%s %d: Device failed to respond to restart",
+ bitfury->drv->name, bitfury->device_id);
+ return ret;
+ }
+ } else {
+ applog(LOG_WARNING, "%s %d: No valid hashes for over 1 minute, attempting to reset",
+ bitfury->drv->name, bitfury->device_id);
+ usb_reset(bitfury);
+ info->failing = true;
+ }
+ }
+
+ if (unlikely(bitfury->usbinfo.nodev))
+ return ret;
switch(info->ident) {
case IDENT_BF1:
- return bf1_scan(thr, bitfury, info);
+ ret = bf1_scan(thr, bitfury, info);
+ break;
case IDENT_BXF:
- return bxf_scan(bitfury, info);
+ ret = bxf_scan(bitfury, info);
+ break;
case IDENT_NF1:
- return nf1_scan(thr, bitfury, info);
+ ret = nf1_scan(thr, bitfury, info);
+ break;
default:
- return 0;
+ ret = 0;
+ break;
}
+ if (ret > 0)
+ info->failing = false;
+ return ret;
}
static void bxf_send_maxroll(struct cgpu_info *bitfury, int maxroll)
diff --git a/driver-bitfury.h b/driver-bitfury.h
index 2257ecf..a9f05a2 100644
--- a/driver-bitfury.h
+++ b/driver-bitfury.h
@@ -51,6 +51,7 @@ struct bitfury_info {
double saved_nonces;
int cycles;
bool valid; /* Set on first valid data being found */
+ bool failing; /* Set when an attempted restart has been sent */
/* BF1 specific data */
uint8_t version;