Add a call to a driver specific zero stats function when zero stats is called to allow each driver to reset its own stats as well if desired.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
diff --git a/cgminer.c b/cgminer.c
index d5216ab..73d30f9 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -4515,6 +4515,11 @@ void zero_stats(void)
cgpu->diff_rejected = 0;
cgpu->last_share_diff = 0;
mutex_unlock(&hash_lock);
+
+ /* Don't take any locks in the driver zero stats function, as
+ * it's called async from everything else and we don't want to
+ * deadlock. */
+ cgpu->drv->zero_stats(cgpu);
}
}
@@ -7576,6 +7581,7 @@ static void noop_detect(bool __maybe_unused hotplug)
#define noop_flush_work noop_reinit_device
#define noop_update_work noop_reinit_device
#define noop_queue_full noop_get_stats
+#define noop_zero_stats noop_reinit_device
/* Fill missing driver drv functions with noops */
void fill_device_drv(struct device_drv *drv)
@@ -7612,6 +7618,8 @@ void fill_device_drv(struct device_drv *drv)
drv->update_work = &noop_update_work;
if (!drv->queue_full)
drv->queue_full = &noop_queue_full;
+ if (!drv->zero_stats)
+ drv->zero_stats = &noop_zero_stats;
if (!drv->max_diff)
drv->max_diff = 1;
if (!drv->working_diff)
diff --git a/miner.h b/miner.h
index 11b9553..bbb5c31 100644
--- a/miner.h
+++ b/miner.h
@@ -334,6 +334,9 @@ struct device_drv {
void (*thread_shutdown)(struct thr_info *);
void (*thread_enable)(struct thr_info *);
+ /* What should be zeroed in this device when global zero stats is sent */
+ void (*zero_stats)(struct cgpu_info *);
+
// Does it need to be free()d?
bool copy;