Clear the bitforce buffer whenever we get an unexpected result as it has likely throttled and we are getting cached responses out of order, and use the temperature monitoring as a kind of watchdog to flush unexpected results.
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-bitforce.c b/driver-bitforce.c
index 88beed4..1cb958b 100644
--- a/driver-bitforce.c
+++ b/driver-bitforce.c
@@ -157,7 +157,7 @@ static bool bitforce_thread_prepare(struct thr_info *thr)
return true;
}
-static void biforce_clear_buffer(struct cgpu_info *bitforce)
+static void bitforce_clear_buffer(struct cgpu_info *bitforce)
{
int fdDev = bitforce->device_fd;
char pdevbuf[0x100];
@@ -185,7 +185,7 @@ void bitforce_init(struct cgpu_info *bitforce)
applog(LOG_WARNING, "BFL%i: Re-initialising", bitforce->device_id);
- biforce_clear_buffer(bitforce);
+ bitforce_clear_buffer(bitforce);
mutex_lock(&bitforce->device_mutex);
if (fdDev) {
@@ -270,7 +270,15 @@ static bool bitforce_get_temp(struct cgpu_info *bitforce)
bitforce->dev_thermal_cutoff_count++;
}
}
+ } else {
+ /* Use the temperature monitor as a kind of watchdog for when
+ * our responses are out of sync and flush the buffer to
+ * hopefully recover */
+ applog(LOG_WARNING, "BFL%i: Garbled response probably throttling, clearing buffer");
+ bitforce_clear_buffer(bitforce);
+ return false;;
}
+
return true;
}
@@ -305,6 +313,7 @@ re_send:
goto re_send;
}
applog(LOG_ERR, "BFL%i: Error: Send work reports: %s", bitforce->device_id, pdevbuf);
+ bitforce_clear_buffer(bitforce);
return false;
}
@@ -345,6 +354,7 @@ re_send:
if (unlikely(strncasecmp(pdevbuf, "OK", 2))) {
applog(LOG_ERR, "BFL%i: Error: Send block data reports: %s", bitforce->device_id, pdevbuf);
+ bitforce_clear_buffer(bitforce);
return false;
}
@@ -433,6 +443,7 @@ static int64_t bitforce_get_result(struct thr_info *thr, struct work *work)
return 0; /* Device idle */
else if (strncasecmp(pdevbuf, "NONCE-FOUND", 11)) {
applog(LOG_WARNING, "BFL%i: Error: Get result reports: %s", bitforce->device_id, pdevbuf);
+ bitforce_clear_buffer(bitforce);
return 0;
}
@@ -521,7 +532,7 @@ static int64_t bitforce_scanhash(struct thr_info *thr, struct work *work, int64_
bitforce->device_not_well_reason = REASON_DEV_COMMS_ERROR;
bitforce->dev_comms_error_count++;
/* empty read buffer */
- biforce_clear_buffer(bitforce);
+ bitforce_clear_buffer(bitforce);
}
return ret;
}