Browse Source

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.

nfactor-troky
Con Kolivas 13 years ago
parent
commit
245552c5b5
  1. 17
      driver-bitforce.c

17
driver-bitforce.c

@ -157,7 +157,7 @@ static bool bitforce_thread_prepare(struct thr_info *thr)
return true; 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; int fdDev = bitforce->device_fd;
char pdevbuf[0x100]; char pdevbuf[0x100];
@ -185,7 +185,7 @@ void bitforce_init(struct cgpu_info *bitforce)
applog(LOG_WARNING, "BFL%i: Re-initialising", bitforce->device_id); applog(LOG_WARNING, "BFL%i: Re-initialising", bitforce->device_id);
biforce_clear_buffer(bitforce); bitforce_clear_buffer(bitforce);
mutex_lock(&bitforce->device_mutex); mutex_lock(&bitforce->device_mutex);
if (fdDev) { if (fdDev) {
@ -270,7 +270,15 @@ static bool bitforce_get_temp(struct cgpu_info *bitforce)
bitforce->dev_thermal_cutoff_count++; 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; return true;
} }
@ -305,6 +313,7 @@ re_send:
goto re_send; goto re_send;
} }
applog(LOG_ERR, "BFL%i: Error: Send work reports: %s", bitforce->device_id, pdevbuf); applog(LOG_ERR, "BFL%i: Error: Send work reports: %s", bitforce->device_id, pdevbuf);
bitforce_clear_buffer(bitforce);
return false; return false;
} }
@ -345,6 +354,7 @@ re_send:
if (unlikely(strncasecmp(pdevbuf, "OK", 2))) { if (unlikely(strncasecmp(pdevbuf, "OK", 2))) {
applog(LOG_ERR, "BFL%i: Error: Send block data reports: %s", bitforce->device_id, pdevbuf); applog(LOG_ERR, "BFL%i: Error: Send block data reports: %s", bitforce->device_id, pdevbuf);
bitforce_clear_buffer(bitforce);
return false; return false;
} }
@ -433,6 +443,7 @@ static int64_t bitforce_get_result(struct thr_info *thr, struct work *work)
return 0; /* Device idle */ return 0; /* Device idle */
else if (strncasecmp(pdevbuf, "NONCE-FOUND", 11)) { else if (strncasecmp(pdevbuf, "NONCE-FOUND", 11)) {
applog(LOG_WARNING, "BFL%i: Error: Get result reports: %s", bitforce->device_id, pdevbuf); applog(LOG_WARNING, "BFL%i: Error: Get result reports: %s", bitforce->device_id, pdevbuf);
bitforce_clear_buffer(bitforce);
return 0; 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->device_not_well_reason = REASON_DEV_COMMS_ERROR;
bitforce->dev_comms_error_count++; bitforce->dev_comms_error_count++;
/* empty read buffer */ /* empty read buffer */
biforce_clear_buffer(bitforce); bitforce_clear_buffer(bitforce);
} }
return ret; return ret;
} }

Loading…
Cancel
Save