Commit 7fc87129e43c2713ad9f8668cb1e79b50f4d994b

Con Kolivas 2013-12-17T23:51:11

Implement command line control of the bxf target temperature.

diff --git a/ASIC-README b/ASIC-README
index a535c2b..67b16ff 100644
--- a/ASIC-README
+++ b/ASIC-README
@@ -49,8 +49,7 @@ Bitfury devices need the --enable-bitfury option when compiling cgminer.
 
 Currently the BPMC/BGMC BF1 devices AKA redfury/bluefury are supported and
 come up as BF1, along with the Bi*fury USB devices which come up as BXF.
-There are no options available for them. Bitfury USB devices are also set up
-as per the USB ASICs below.
+Bitfury USB devices are also set up as per the USB ASICs below.
 
 
 ---
@@ -132,6 +131,7 @@ ASIC SPECIFIC COMMANDS
 --bitburner-fury-options <arg> Override avalon-options for BitBurner Fury boards baud:miners:asic:timeout:freq
 --bitburner-fury-voltage <arg> Set BitBurner Fury core voltage, in millivolts
 --bitburner-voltage <arg> Set BitBurner (Avalon) core voltage, in millivolts
+--bxf-temp-target <arg> Set target temperature for BXF devices (default: 82)
 --klondike-options <arg> Set klondike options clock:temptarget
 
 
@@ -313,6 +313,15 @@ This will allow you to change or disable the default temperature where cgminer
 throttles BFLSC devices by allowing them to temporarily go idle.
 
 
+BITFURY Devices
+
+--bxf-temp-target <arg> Set target temperature for BXF devices (default: 82)
+
+Cgminer uses dynamic clocking on Bi*fury devices to try and maintain the
+temperature just below an optimal target. This option allows you to change the
+target temperature. When actively cooled below this, the devices will run at
+maximum speed.
+
 ---
 
 This code is provided entirely free of charge by the programmer in his spare
diff --git a/cgminer.c b/cgminer.c
index 089f585..37dc47c 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -72,6 +72,10 @@ char *curly = ":D";
 #include "driver-bflsc.h"
 #endif
 
+#ifdef USE_BITFURY
+#include "driver-bitfury.h"
+#endif
+
 #ifdef USE_HASHFAST
 #include "driver-hashfast.h"
 int opt_hfa_ntime_roll;
@@ -641,7 +645,7 @@ static char *set_int_0_to_100(const char *arg, int *i)
 }
 #endif
 
-#ifdef USE_BFLSC
+#if defined(USE_BFLSC) || defined(USE_BITFURY)
 static char *set_int_0_to_200(const char *arg, int *i)
 {
 	return set_int_range(arg, i, 0, 200);
@@ -1112,6 +1116,11 @@ static struct opt_table opt_config_table[] = {
 		     set_int_0_to_200, opt_show_intval, &opt_bflsc_overheat,
 		     "Set overheat temperature where BFLSC devices throttle, 0 to disable"),
 #endif
+#ifdef USE_BITFURY
+	OPT_WITH_ARG("--bxf-temp-target",
+		     set_int_0_to_200, opt_show_intval, &opt_bxf_temp_target,
+		     "Set target temperature for BXF devices"),
+#endif
 #ifdef HAVE_CURSES
 	OPT_WITHOUT_ARG("--compact",
 			opt_set_bool, &opt_compact,
diff --git a/driver-bitfury.c b/driver-bitfury.c
index 9806048..8d18694 100644
--- a/driver-bitfury.c
+++ b/driver-bitfury.c
@@ -13,6 +13,8 @@
 #include "driver-bitfury.h"
 #include "sha2.h"
 
+int opt_bxf_temp_target = BXF_TEMP_TARGET / 10;
+
 /* Wait longer 1/3 longer than it would take for a full nonce range */
 #define BF1WAIT 1600
 #define BF1MSGSIZE 7
@@ -231,6 +233,7 @@ static bool bxf_detect_one(struct cgpu_info *bitfury, struct bitfury_info *info)
 	       bitfury->drv->name, bitfury->device_id, bitfury->device_path);
 
 	info->total_nonces = 1;
+	info->temp_target = opt_bxf_temp_target * 10;
 	/* This unsets it to make sure it gets set on the first pass */
 	info->maxroll = -1;
 
@@ -398,7 +401,7 @@ static void parse_bxf_temp(struct cgpu_info *bitfury, struct bitfury_info *info,
 	}
 	mutex_unlock(&info->lock);
 
-	if (decitemp > BXF_TEMP_TARGET + BXF_TEMP_HYSTERESIS) {
+	if (decitemp > info->temp_target + BXF_TEMP_HYSTERESIS) {
 		if (info->clocks <= BXF_CLOCK_MIN)
 			goto out;
 		applog(LOG_WARNING, "%s %d: Hit overheat temperature of %d, throttling!",
@@ -406,7 +409,7 @@ static void parse_bxf_temp(struct cgpu_info *bitfury, struct bitfury_info *info,
 		bxf_send_clock(bitfury, info, BXF_CLOCK_MIN);
 		goto out;
 	}
-	if (decitemp > BXF_TEMP_TARGET) {
+	if (decitemp > info->temp_target) {
 		if (info->clocks <= BXF_CLOCK_MIN)
 			goto out;
 		if (decitemp < info->last_decitemp)
@@ -416,7 +419,7 @@ static void parse_bxf_temp(struct cgpu_info *bitfury, struct bitfury_info *info,
 		bxf_send_clock(bitfury, info, info->clocks - 1);
 		goto out;
 	}
-	if (decitemp <= BXF_TEMP_TARGET && decitemp >= BXF_TEMP_TARGET - BXF_TEMP_HYSTERESIS) {
+	if (decitemp <= info->temp_target && decitemp >= info->temp_target - BXF_TEMP_HYSTERESIS) {
 		if (decitemp == info->last_decitemp)
 			goto out;
 		if (decitemp > info->last_decitemp) {
@@ -435,7 +438,7 @@ static void parse_bxf_temp(struct cgpu_info *bitfury, struct bitfury_info *info,
 		bxf_send_clock(bitfury, info, info->clocks + 1);
 		goto out;
 	}
-	/* implies: decitemp < BXF_TEMP_TARGET - BXF_TEMP_HYSTERESIS */
+	/* implies: decitemp < info->temp_target - BXF_TEMP_HYSTERESIS */
 	if (info->clocks >= BXF_CLOCK_DEFAULT)
 		goto out;
 	applog(LOG_DEBUG, "%s %d: Temp %d below target, increasing clock",
diff --git a/driver-bitfury.h b/driver-bitfury.h
index 9ebf575..42a805e 100644
--- a/driver-bitfury.h
+++ b/driver-bitfury.h
@@ -22,6 +22,8 @@
 #define BXF_TEMP_TARGET 820
 #define BXF_TEMP_HYSTERESIS 30
 
+extern int opt_bxf_temp_target;
+
 struct bitfury_info {
 	struct cgpu_info *base_cgpu;
 	struct thr_info *thr;
@@ -44,6 +46,7 @@ struct bitfury_info {
 	double temperature;
 	int last_decitemp;
 	int max_decitemp;
+	int temp_target;
 	int work_id; // Current work->subid
 	int no_matching_work;
 	int maxroll; // Last maxroll sent to device