From 011512561ab4cccca4be4ac8f3c4100cd0b4686b Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 31 Jan 2014 10:37:59 +1100 Subject: [PATCH] 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. --- miner.h | 3 +++ sgminer.c | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/miner.h b/miner.h index 37cd38b4..248c9ca4 100644 --- a/miner.h +++ b/miner.h @@ -355,6 +355,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; diff --git a/sgminer.c b/sgminer.c index e4194285..4c1090c4 100644 --- a/sgminer.c +++ b/sgminer.c @@ -4436,6 +4436,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); } } @@ -7512,6 +7517,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) @@ -7548,6 +7554,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)