From 245552c5b5a1828c2e2ab461325a22cfab938729 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 3 Aug 2012 09:49:14 +1000 Subject: [PATCH] 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. --- driver-bitforce.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/driver-bitforce.c b/driver-bitforce.c index 88beed41..1cb958b1 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; }