Commit 42beb96f77bbf5865b01883e74f414434d3c59dd

ckolivas 2014-02-05T16:28:04

Ensure we iterate over all dies adjusting temperate for hfa by starting iterating after the last die modified.

diff --git a/driver-hashfast.c b/driver-hashfast.c
index 58a06fd..31b7f12 100644
--- a/driver-hashfast.c
+++ b/driver-hashfast.c
@@ -1124,8 +1124,9 @@ fan_only:
 	if (now_t - info->last_restart < 15)
 		return;
 
-	for (i = 0; i < info->asic_count ; i++) {
-		struct hf_die_data *hdd = &info->die_data[i];
+	for (i = 1; i <= info->asic_count ; i++) {
+		int die = (info->last_die_adjusted + i) % info->asic_count;
+		struct hf_die_data *hdd = &info->die_data[die];
 
 		/* Only send a restart no more than every 30 seconds. */
 		if (now_t - hdd->last_restart < 30)
@@ -1148,16 +1149,20 @@ fan_only:
 			/* Have some leeway before throttling speed */
 			if (hdd->temp < opt_hfa_target + HFA_TEMP_HYSTERESIS)
 				break;
-			hfa_decrease_clock(hashfast, info, i);
+			hfa_decrease_clock(hashfast, info, die);
 		} else {
 			/* Temp below target range.*/
 
 			/* Already at max speed */
 			if (hdd->hash_clock == info->hash_clock_rate)
 				continue;
-			hfa_increase_clock(hashfast, info, i);
+			hfa_increase_clock(hashfast, info, die);
 		}
+		/* Keep track of the last die adjusted since we only adjust
+		 * one at a time to ensure we end up iterating over all of
+		 * them. */
 		info->last_restart = hdd->last_restart = now_t;
+		info->last_die_adjusted = die;
 		break;
 	}
 }
diff --git a/driver-hashfast.h b/driver-hashfast.h
index c2fa608..4489ce4 100644
--- a/driver-hashfast.h
+++ b/driver-hashfast.h
@@ -127,6 +127,7 @@ struct hashfast_info {
 	int last_max_temp;
 	int temp_updates;
 	int fanspeed;                               // Fanspeed in percent
+	int last_die_adjusted;
 
 	pthread_t read_thr;
 	time_t last_restart;