Browse Source

Merge branch 'drv_zerostats' into bfgminer

Luke Dashjr 11 years ago
parent
commit
833b4b34c8
5 changed files with 45 additions and 1 deletions
  1. 14 1
      driver-avalon.c
  2. 14 0
      driver-bitforce.c
  3. 14 0
      driver-klondike.c
  4. 2 0
      miner.c
  5. 1 0
      miner.h

+ 14 - 1
driver-avalon.c

@@ -513,6 +513,18 @@ static void avalon_clear_readbuf(int fd)
 	} while (ret > 0);
 }
 
+static
+void avalon_zero_stats(struct cgpu_info * const cgpu)
+{
+	struct avalon_info *info = cgpu->device_data;
+	
+	info->temp_max = 0;
+	info->no_matching_work = 0;
+	
+	for (int i = 0; i < info->miner_count; ++i)
+		info->matching_work[i] = 0;
+}
+
 static bool avalon_detect_one(const char *devpath)
 {
 	struct avalon_info *info;
@@ -573,7 +585,7 @@ static bool avalon_detect_one(const char *devpath)
 			    AVALON_TIME_FACTOR) / (float)info->miner_count;
 
 	info->fan_pwm = AVALON_DEFAULT_FAN_MIN_PWM;
-	info->temp_max = 0;
+	avalon_zero_stats(avalon);
 	/* This is for check the temp/fan every 3~4s */
 	info->temp_history_count = (4 / (float)((float)info->timeout * ((float)1.67/0x32))) + 1;
 	if (info->temp_history_count <= 0)
@@ -987,6 +999,7 @@ struct device_drv avalon_drv = {
 	.minerloop = hash_queued_work,
 	.queue_full = avalon_fill,
 	.scanwork = avalon_scanhash,
+	.zero_stats = avalon_zero_stats,
 	.get_api_stats = avalon_api_stats,
 	.reinit_device = avalon_init,
 	.thread_shutdown = avalon_shutdown,

+ 14 - 0
driver-bitforce.c

@@ -1624,6 +1624,19 @@ static bool bitforce_identify(struct cgpu_info *bitforce)
 	return true;
 }
 
+static
+void bitforce_zero_stats(struct cgpu_info * const proc)
+{
+	struct bitforce_data *data = proc->device_data;
+	
+	// These don't get cleared when not-read, so we clear them here
+	data->volts_count = 0;
+	data->temp[0] = data->temp[1] = 0;
+	free(data->volts);
+	
+	proc->avg_wait_f = 0;
+}
+
 static bool bitforce_thread_init(struct thr_info *thr)
 {
 	struct cgpu_info *bitforce = thr->cgpu;
@@ -2658,6 +2671,7 @@ struct device_drv bitforce_queue_api = {
 	.lowl_probe = bitforce_lowl_probe,
 	.minerloop = minerloop_queue,
 	.reinit_device = bitforce_reinit,
+	.zero_stats = bitforce_zero_stats,
 #ifdef HAVE_CURSES
 	.proc_wlogprint_status = bitforce_wlogprint_status,
 	.proc_tui_wlogprint_choices = bitforce_tui_wlogprint_choices,

+ 14 - 0
driver-klondike.c

@@ -697,6 +697,19 @@ static void kln_disable(struct cgpu_info *klncgpu, int dev, bool all)
 	}
 }
 
+static
+void klondike_zero_stats(struct cgpu_info * const proc)
+{
+	struct klondike_info * const klninfo = proc->device_data;
+	
+	for (int devn = klninfo->status[0].kline.ws.slavecount; devn >= 0; --devn)
+		for (int i = klninfo->status[devn].kline.ws.chipcount * 2; --i >= 0; )
+			klninfo->devinfo[devn].chipstats[i] = 0;
+	klninfo->hashcount = klninfo->errorcount = klninfo->noisecount = 0;
+	klninfo->delay_count = klninfo->delay_total = klninfo->delay_min = klninfo->delay_max = 0;
+	klninfo->nonce_count = klninfo->nonce_total = klninfo->nonce_min = klninfo->nonce_max = 0;
+}
+
 static bool klondike_init(struct cgpu_info *klncgpu)
 {
 	struct klondike_info *klninfo = (struct klondike_info *)(klncgpu->device_data);
@@ -1702,6 +1715,7 @@ struct device_drv klondike_drv = {
 	.thread_shutdown = klondike_shutdown,
 	.thread_enable = klondike_thread_enable,
 	
+	.zero_stats = klondike_zero_stats,
 #ifdef HAVE_CURSES
 	.proc_wlogprint_status = klondike_wlogprint_status,
 #endif

+ 2 - 0
miner.c

@@ -7197,6 +7197,8 @@ void zero_stats(void)
 		cgpu->cgminer_stats.getwork_wait_max.tv_sec = 0;
 		cgpu->cgminer_stats.getwork_wait_max.tv_usec = 0;
 		mutex_unlock(&hash_lock);
+		
+		cgpu->drv->zero_stats(cgpu);
 	}
 }
 

+ 1 - 0
miner.h

@@ -316,6 +316,7 @@ struct device_drv {
 	void (*proc_wlogprint_status)(struct cgpu_info *);
 	void (*proc_tui_wlogprint_choices)(struct cgpu_info *);
 	const char *(*proc_tui_handle_choice)(struct cgpu_info *, int input);
+	void (*zero_stats)(struct cgpu_info *);
 
 	// Thread-specific functions
 	bool (*thread_prepare)(struct thr_info *);