Commit e8a7510016ab11a56ea1c69c47ef28fcee9dd316

Con Kolivas 2014-03-10T13:02:29

Look for autovoltage returning to zero on cta driver and reset stats at that point since the hashrate is unreliable till then.

diff --git a/driver-cointerra.c b/driver-cointerra.c
index 0d9a36c..31a339a 100644
--- a/driver-cointerra.c
+++ b/driver-cointerra.c
@@ -555,6 +555,8 @@ static void cta_parse_rdone(struct cgpu_info *cointerra, struct cointerra_info *
 	}
 }
 
+static void cta_zero_stats(struct cgpu_info *cointerra);
+
 static void cta_parse_debug(struct cointerra_info *info, char *buf)
 {
 	mutex_lock(&info->lock);
@@ -573,6 +575,15 @@ static void cta_parse_debug(struct cointerra_info *info, char *buf)
 	info->power_temps[1] = hu16_from_msg(buf,CTA_STAT_PS_TEMP2);
 
 	mutex_unlock(&info->lock);
+
+	/* Autovoltage is positive only once at startup and eventually drops
+	 * to zero. After that time we reset the stats since they're unreliable
+	 * till then. */
+	if (unlikely(!info->autovoltage_complete && !info->autovoltage)) {
+		info->autovoltage_complete = true;
+		cgtime(&info->thr->cgpu->dev_start_tv);
+		cta_zero_stats(info->thr->cgpu);
+	}
 }
 
 static void cta_parse_msg(struct thr_info *thr, struct cgpu_info *cointerra,
diff --git a/driver-cointerra.h b/driver-cointerra.h
index d8344e8..66e315e 100644
--- a/driver-cointerra.h
+++ b/driver-cointerra.h
@@ -194,6 +194,7 @@ struct cointerra_info {
 	uint16_t ipower_voltage;
 	uint16_t power_temps[2];
 
+	bool autovoltage_complete;
 
 	/* Calculated totals based on work done and nonces found */
 	uint64_t hashes;