Commit 35bb969d579f47680ea6a766cc89c0f46c543d98

kanoi 2014-05-14T21:26:36

minion - optionally report chip idle_cnt changes

diff --git a/ASIC-README b/ASIC-README
index fd24b96..866afe4 100644
--- a/ASIC-README
+++ b/ASIC-README
@@ -237,6 +237,7 @@ ASIC SPECIFIC COMMANDS
 --minion-freq <arg> Set minion chip frequencies in MHz, single value or comma list, range 100-1400 (default: 1000)
 --minion-temp <arg> Set minion chip temperature threshold, single value or comma list, range 120-160 (default: 135C)
 --minion-overheat   Enable directly halting any chip when the status exceeds 100C
+--minion-idlecount  Report when IdleCount is >0 or changes
 --nfu-bits <arg>    Set nanofury bits for overclocking, range 32-63 (default: 50)
 
 
diff --git a/README b/README
index dbd9d7b..b50f459 100644
--- a/README
+++ b/README
@@ -221,6 +221,7 @@ Options for both config file and command line:
 --minion-freq <arg> Set minion chip frequencies in MHz, single value or comma list, range 100-1400 (default: 1000)
 --minion-temp <arg> Set minion chip temperature threshold, single value or comma list, range 120-160 (default: 135C)
 --minion-overheat   Enable directly halting any chip when the status exceeds 100C
+--minion-idlecount  Report when IdleCount is >0 or changes
 --monitor|-m <arg>  Use custom pipe cmd for output messages
 --nfu-bits <arg>    Set nanofury bits for overclocking, range 32-63 (default: 50)
 --net-delay         Impose small delays in networking to not overload slow routers
diff --git a/cgminer.c b/cgminer.c
index 3a13ded..be27d60 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -242,6 +242,7 @@ static char *opt_set_null;
 char *opt_minion_freq;
 char *opt_minion_temp;
 bool opt_minion_overheat;
+bool opt_minion_idlecount;
 #endif
 
 #ifdef USE_USBUTILS
@@ -1324,6 +1325,9 @@ static struct opt_table opt_config_table[] = {
 	OPT_WITHOUT_ARG("--minion-overheat",
 		     opt_set_bool, &opt_minion_overheat,
 		     "Enable directly halting any chip when the status exceeds 100C"),
+	OPT_WITHOUT_ARG("--minion-idlecount",
+		     opt_set_bool, &opt_minion_idlecount,
+		     "Report when IdleCount is >0 or changes"),
 #endif
 #if defined(unix) || defined(__APPLE__)
 	OPT_WITH_ARG("--monitor|-m",
diff --git a/driver-minion.c b/driver-minion.c
index bfcb20f..941d30f 100644
--- a/driver-minion.c
+++ b/driver-minion.c
@@ -281,6 +281,9 @@ static uint32_t minion_freq[] = {
 #define MINION_STATS_UPDATE_TIME_mS 1000
 #define MINION_STATS_UPDATE_RAND_mS 1000
 
+// Don't report it more than once every ... 5s
+#define MINION_IDLE_MESSAGE_ms 5000
+
 struct minion_status {
 	uint16_t temp;
 	uint16_t cores;
@@ -300,6 +303,8 @@ struct minion_status {
 	double overheattime;
 	uint32_t tempsent;
 	uint32_t idle;
+	uint32_t last_rpt_idle;
+	struct timeval idle_rpt;
 };
 
 // TODO: untested/unused
@@ -2871,6 +2876,9 @@ static int64_t minion_scanwork(__maybe_unused struct thr_info *thr)
 	struct cgpu_info *minioncgpu = thr->cgpu;
 	struct minion_info *minioninfo = (struct minion_info *)(minioncgpu->device_data);
 	int64_t hashcount = 0;
+	struct timeval now;
+	int msdiff;
+	int chip;
 
 	minion_do_work(minioncgpu);
 
@@ -2881,6 +2889,24 @@ static int64_t minion_scanwork(__maybe_unused struct thr_info *thr)
 	}
 	mutex_unlock(&(minioninfo->nonce_lock));
 
+	if (opt_minion_idlecount) {
+		for (chip = 0; chip < MINION_CHIPS; chip++) {
+			if (minioninfo->chip[chip]) {
+				if (minioninfo->chip_status[chip].idle !=
+				    minioninfo->chip_status[chip].last_rpt_idle) {
+					cgtime(&now);
+					msdiff = ms_tdiff(&now, &(minioninfo->chip_status[chip].idle_rpt));
+					if (msdiff >= MINION_IDLE_MESSAGE_ms) {
+						memcpy(&(minioninfo->chip_status[chip].idle_rpt), &now, sizeof(now));
+						applog(LOG_WARNING,
+							"%s%d: chip 1 internal idle increased %08x",
+							minioncgpu->drv->name, minioncgpu->device_id,
+							minioninfo->chip_status[chip].idle);
+					}
+				}
+			}
+		}
+	}
 	/*
 	 * To avoid wasting CPU, wait until we get an interrupt
 	 * before returning back to the main cgminer work loop
diff --git a/miner.h b/miner.h
index a33812a..1b9f2c0 100644
--- a/miner.h
+++ b/miner.h
@@ -1012,6 +1012,7 @@ extern bool opt_bitmain_hwerror;
 extern char *opt_minion_freq;
 extern char *opt_minion_temp;
 extern bool opt_minion_overheat;
+extern bool opt_minion_idlecount;
 #endif
 #ifdef USE_USBUTILS
 extern char *opt_usb_select;