Commit d3480c7634aa6272daf6edfcc7b575dbe95f70e5

Con Kolivas 2014-01-25T17:32:49

Add throttling control to hfa driver, configurable at command line, nominally set to 85 degrees.

diff --git a/cgminer.c b/cgminer.c
index b2fb715..7df8672 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -646,7 +646,7 @@ static char *set_int_0_to_100(const char *arg, int *i)
 }
 #endif
 
-#if defined(USE_BFLSC) || defined(USE_BITFURY)
+#if defined(USE_BFLSC) || defined(USE_BITFURY) || defined(USE_HASHFAST)
 static char *set_int_0_to_200(const char *arg, int *i)
 {
 	return set_int_range(arg, i, 0, 200);
@@ -1233,6 +1233,9 @@ static struct opt_table opt_config_table[] = {
 	OPT_WITHOUT_ARG("--hfa-pll-bypass",
 			opt_set_bool, &opt_hfa_pll_bypass,
 			opt_hidden),
+	OPT_WITH_ARG("--hfa-temp-overheat",
+		     set_int_0_to_200, opt_show_intval, &opt_hfa_overheat,
+		     "Set the hashfast overheat throttling temperature"),
 #endif
 #ifdef USE_KLONDIKE
 	OPT_WITH_ARG("--klondike-options",
diff --git a/driver-hashfast.c b/driver-hashfast.c
index a95ef3a..f58da8e 100644
--- a/driver-hashfast.c
+++ b/driver-hashfast.c
@@ -20,6 +20,7 @@
 
 int opt_hfa_ntime_roll = 1;
 int opt_hfa_hash_clock = 550;
+int opt_hfa_overheat = 85;
 bool opt_hfa_pll_bypass;
 bool opt_hfa_dfu_boot;
 
@@ -891,7 +892,10 @@ static bool hfa_prepare(struct thr_info *thr)
 /* Figure out how many jobs to send. */
 static int hfa_jobs(struct hashfast_info *info)
 {
-	int ret;
+	int ret = 0;
+
+	if (unlikely(info->overheat))
+		goto out;
 
 	mutex_lock(&info->lock);
 	ret = info->usb_init_base.inflight_target - HF_SEQUENCE_DISTANCE(info->hash_sequence_head, info->device_sequence_tail);
@@ -901,6 +905,7 @@ static int hfa_jobs(struct hashfast_info *info)
 		ret = info->usb_init_base.inflight_target;
 	mutex_unlock(&info->lock);
 
+out:
 	return ret;
 }
 
@@ -1115,6 +1120,15 @@ static void hfa_statline_before(char *buf, size_t bufsiz, struct cgpu_info *hash
 	}
 
 	tailsprintf(buf, bufsiz, " max%3.0fC %3.2fV | ", max_temp, max_volt);
+
+	if (unlikely(max_temp >= opt_hfa_overheat)) {
+		if (!info->overheat) {
+			applog(LOG_WARNING, "HFA %d: Hit throttle temp of %.1f, throttling!",
+			       hashfast->device_id, max_temp);
+			info->overheat = true;
+		}
+	} else if (unlikely(info->overheat))
+		info->overheat = false;
 }
 
 static void hfa_init(struct cgpu_info __maybe_unused *hashfast)
diff --git a/driver-hashfast.h b/driver-hashfast.h
index 76a8660..9766b60 100644
--- a/driver-hashfast.h
+++ b/driver-hashfast.h
@@ -18,6 +18,7 @@
 
 int opt_hfa_ntime_roll;
 int opt_hfa_hash_clock;
+int opt_hfa_overheat;
 bool opt_hfa_pll_bypass;
 bool opt_hfa_dfu_boot;
 
@@ -99,6 +100,7 @@ struct hashfast_info {
 	uint16_t shed_count;                        // Dynamic copy of #cores device has shed for thermal control
 	int no_matching_work;
 	int resets;
+	bool overheat;
 
 	pthread_t read_thr;
 };