From fba70ff593e095554b0041dc12de8bfc167b0d11 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sun, 26 May 2013 01:51:20 +1000 Subject: [PATCH] Simplify debugging and only discard from avalon read buffer if at least one full result has been discarded. --- driver-avalon.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/driver-avalon.c b/driver-avalon.c index 20e0ed73..3031eb3f 100644 --- a/driver-avalon.c +++ b/driver-avalon.c @@ -650,23 +650,24 @@ static void avalon_parse_results(struct cgpu_info *avalon, struct avalon_info *i if (!found) { spare = *offset - AVALON_READ_SIZE; - if (spare) - applog(LOG_WARNING, "Avalon: Discarding %d bytes from buffer", spare); + /* We are buffering and haven't accumulated one more corrupt + * work result. */ + if (spare < (int)AVALON_READ_SIZE) + return; + applog(LOG_WARNING, "Avalon: Discarding %d bytes from buffer", spare); + + inc_hw_errors(thr); + mutex_lock(&info->lock); + info->no_matching_work++; + mutex_unlock(&info->lock); } else { spare = AVALON_READ_SIZE + i; if (i) applog(LOG_WARNING, "Avalon: Discarding %d bytes from buffer", i); } - if (spare) { - *offset -= spare; - memmove(buf, buf + spare, *offset); - } - if (!found) { - mutex_lock(&info->lock); - info->no_matching_work++; - mutex_unlock(&info->lock); - } + *offset -= spare; + memmove(buf, buf + spare, *offset); } static void *avalon_get_results(void *userdata)