Commit f85646c7dbbd130a4eb4f35fd9aa57347df171d2

Con Kolivas 2014-02-22T11:07:23

Set icarus device fail time to be dependent on device speed to avoid falsely detecting failure on slower AMU devices.

diff --git a/driver-icarus.c b/driver-icarus.c
index a757cf4..94acad0 100644
--- a/driver-icarus.c
+++ b/driver-icarus.c
@@ -199,6 +199,8 @@ struct ICARUS_INFO {
 	int read_time;
 	// ms limit for (short=/long=) read_time
 	int read_time_limit;
+	// How long without hashes is considered a failed device
+	int fail_time;
 
 	enum timing_mode timing_mode;
 	bool do_icarus_timing;
@@ -527,7 +529,7 @@ static void set_timing_mode(int this_option_offset, struct cgpu_info *icarus)
 {
 	struct ICARUS_INFO *info = (struct ICARUS_INFO *)(icarus->device_data);
 	enum sub_ident ident;
-	double Hs;
+	double Hs, fail_time;
 	char buf[BUFSIZ+1];
 	char *ptr, *comma, *eq;
 	size_t max;
@@ -664,6 +666,13 @@ static void set_timing_mode(int this_option_offset, struct cgpu_info *icarus)
 			icarus->drv->name, icarus->cgminer_id,
 			timing_mode_str(info->timing_mode),
 			info->read_time, info->read_time_limit, info->Hs);
+
+	/* Set the time to detect a dead device to 10 nonce ranges or 1 minute,
+	 * whichever is larger. */
+	fail_time = info->Hs * 0xffffffffull * 10;
+	if (fail_time < 60)
+		fail_time = 60;
+	info->fail_time = fail_time;
 }
 
 static uint32_t mask(int work_division)
@@ -1276,16 +1285,16 @@ static int64_t icarus_scanwork(struct thr_info *thr)
 	uint32_t values;
 	int64_t hash_count_range;
 
-	if (unlikely(last_getwork - icarus->last_device_valid_work > 60)) {
+	if (unlikely(last_getwork - icarus->last_device_valid_work > info->fail_time)) {
 		if (info->failing) {
-			if (last_getwork - icarus->last_device_valid_work > 120) {
+			if (last_getwork - icarus->last_device_valid_work > info->fail_time + 60) {
 				applog(LOG_ERR, "%s %d: Device failed to respond to restart",
 				       icarus->drv->name, icarus->device_id);
 				return -1;
 			}
 		} else {
-			applog(LOG_WARNING, "%s %d: No valid hashes for over 1 minute, attempting to reset",
-			       icarus->drv->name, icarus->device_id);
+			applog(LOG_WARNING, "%s %d: No valid hashes for over %d secs, attempting to reset",
+			       icarus->drv->name, icarus->device_id, info->fail_time);
 			usb_reset(icarus);
 			info->failing = true;
 		}