Commit dbab07a12dbf5b9b4a5c50a072bd1e96e32c552c

Con Kolivas 2013-04-15T20:30:02

Only reset an avalon device with no results when there are no results consecutively.

diff --git a/driver-avalon.c b/driver-avalon.c
index 377a7fa..4ca3952 100644
--- a/driver-avalon.c
+++ b/driver-avalon.c
@@ -929,17 +929,22 @@ static int64_t avalon_scanhash(struct thr_info *thr)
 			       elapsed.tv_sec, elapsed.tv_usec);
 		}
 	}
-	if (unlikely(result_wrong >= avalon_get_work_count ||
-	    (hash_count == 0 && ret != AVA_GETS_RESTART))) {
-		/* This means FPGA controller gave all wrong results, so
-		 * try to reset the Avalon */
-		do_avalon_close(thr);
-		applog(LOG_ERR,
-		       "AVA%i: FPGA controller mess up, %d wrong results", avalon->device_id, result_wrong);
-		dev_error(avalon, REASON_DEV_COMMS_ERROR);
-		sleep(1);
-		avalon_init(avalon);
-		return 0;
+	if (hash_count) {
+		if (avalon->results < AVALON_ARRAY_SIZE)
+			avalon->results++;
+	} else if (unlikely((result_wrong >= avalon_get_work_count ) ||
+		   (ret != AVA_GETS_RESTART && --avalon->results < 0))) {
+			/* Look for all invalid results, or consecutive failure
+			 * to generate any results suggesting the FPGA
+			 * controller has screwed up. */
+			do_avalon_close(thr);
+			applog(LOG_ERR,
+			       "AVA%i: FPGA controller messed up, %d wrong results",
+			       avalon->device_id, result_wrong);
+			dev_error(avalon, REASON_DEV_COMMS_ERROR);
+			sleep(1);
+			avalon_init(avalon);
+			return 0;
 	}
 
 	avalon_rotate_array(avalon);
diff --git a/miner.h b/miner.h
index b4b71ce..3d275da 100644
--- a/miner.h
+++ b/miner.h
@@ -431,6 +431,7 @@ struct cgpu_info {
 	struct work **works;
 	int work_array;
 	int queued;
+	int results;
 #endif
 #ifdef USE_USBUTILS
 	struct cg_usb_info usbinfo;