Commit 9b45daba6b0fc2c85d6d3b0616c5144e5ffcd569

Con Kolivas 2013-06-25T19:39:42

Add an --avalon-cutoff feature which puts the avalon idle should it reach this temperature, defaulting to 60, re-enabling it when it gets to target temperature.

diff --git a/ASIC-README b/ASIC-README
index a3c46e2..ff758ab 100644
--- a/ASIC-README
+++ b/ASIC-README
@@ -79,11 +79,25 @@ possible to plug a USB cable from a PC into the Avalon device and mine using
 cgminer as per any other device. It will autodetect and hotplug using default
 options. You can customise the avalon behaviour by using the avalon-options
 command, and adjust its fan control-temperature relationship with avalon-temp.
+By default the avalon will also cut off when its temperature reaches 60
+degrees.
+
+Avalon commands:
+
+--avalon-cutoff <arg> Set avalon overheat cut off temperature (default: 60)
+--avalon-options <arg> Set avalon options baud:miners:asic:timeout:freq
+--avalon-temp <arg> Set avalon target temperature (default: 50)
+
+eg:
+--avalon-cutoff 65
+
+This will cut off the avalon should it get up to 65 degrees and will then
+re-enable it when it gets to the target temperature as specified by avalon-temp.
 
 eg:
---avalon-temp 50
+--avalon-temp 55
 
-This will adjust fanspeed to keep the temperature at or slightly below 50.
+This will adjust fanspeed to keep the temperature at or slightly below 55.
 If you wish the fans to run at maximum speed, setting the target temperature
 very low such as 0 will achieve this. This option can be added to the "More
 options" entry in the web interface if you do not have a direct way of setting
diff --git a/README b/README
index b46059a..5b94fe5 100644
--- a/README
+++ b/README
@@ -233,6 +233,7 @@ See SCRYPT-README for more information regarding litecoin mining.
 ASIC and FPGA mining boards (BFL ASIC, BitForce, Icarus, ModMiner, Ztex)
 only options:
 
+--avalon-cutoff <arg> Set avalon overheat cut off temperature (default: 60)
 --avalon-options <arg> Set avalon options baud:miners:asic:timeout:freq
 --avalon-temp <arg> Set avalon target temperature (default: 50)
 --bfl-range         Use nonce range on bitforce devices if supported
diff --git a/cgminer.c b/cgminer.c
index 1c349e0..ae12bbb 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -1057,6 +1057,9 @@ static struct opt_table opt_config_table[] = {
 		     opt_hidden),
 #endif
 #ifdef USE_AVALON
+	OPT_WITH_ARG("--avalon-cutoff",
+		     set_int_0_to_100, opt_show_intval, &opt_avalon_overheat,
+		     "Set avalon overheat cut off temperature"),
 	OPT_WITH_ARG("--avalon-options",
 		     set_avalon_options, NULL, NULL,
 		     "Set avalon options baud:miners:asic:timeout:freq"),
diff --git a/driver-avalon.c b/driver-avalon.c
index 270b813..b6c79e8 100644
--- a/driver-avalon.c
+++ b/driver-avalon.c
@@ -41,6 +41,7 @@
 #include "util.h"
 
 int opt_avalon_temp = AVALON_TEMP_TARGET;
+int opt_avalon_overheat = AVALON_TEMP_OVERHEAT;
 static int option_offset = -1;
 struct device_drv avalon_drv;
 
@@ -870,7 +871,7 @@ static void *avalon_send_tasks(void *userdata)
 				break;
 			}
 
-			if (likely(j < avalon->queued)) {
+			if (likely(j < avalon->queued && !info->overheat)) {
 				info->idle = false;
 				avalon_init_task(&at, 0, 0, info->fan_pwm,
 						info->timeout, info->asic_count,
@@ -1059,6 +1060,13 @@ static void avalon_update_temps(struct cgpu_info *avalon, struct avalon_info *in
 		info->temp_history_index = 0;
 		info->temp_sum = 0;
 	}
+	if (unlikely(info->temp_old >= opt_avalon_overheat)) {
+		applog(LOG_WARNING, "AVA%d overheat! Idling", avalon->device_id);
+		info->overheat = true;
+	} else if (info->overheat && info->temp_old <= opt_avalon_temp) {
+		applog(LOG_WARNING, "AVA%d cooled, restarting", avalon->device_id);
+		info->overheat = false;
+	}
 }
 
 static void get_avalon_statline_before(char *buf, struct cgpu_info *avalon)
diff --git a/driver-avalon.h b/driver-avalon.h
index 5619b96..7a0df4d 100644
--- a/driver-avalon.h
+++ b/driver-avalon.h
@@ -27,6 +27,7 @@
 #define AVALON_DEFAULT_FAN_MIN_PWM 0x20 /*  20% */
 #define AVALON_TEMP_TARGET 50
 #define AVALON_TEMP_HYSTERESIS 3
+#define AVALON_TEMP_OVERHEAT 60
 
 #define AVALON_DEFAULT_TIMEOUT 0x2D
 #define AVALON_DEFAULT_FREQUENCY 282
@@ -119,6 +120,7 @@ struct avalon_info {
 
 	bool idle;
 	bool reset;
+	bool overheat;
 };
 
 #define AVALON_WRITE_SIZE (sizeof(struct avalon_task))
@@ -139,6 +141,7 @@ ASSERT1(sizeof(uint32_t) == 4);
 
 extern struct avalon_info **avalon_info;
 extern int opt_avalon_temp;
+extern int opt_avalon_overheat;
 
 #endif /* USE_AVALON */
 #endif	/* AVALON_H */