Add a driver specific flush_work for queued devices that may have work items already queued to abort working on them on the device and discard them.
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 48 49 50
diff --git a/cgminer.c b/cgminer.c
index f01e9a3..48164f5 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -5684,8 +5684,10 @@ static void hash_queued_work(struct thr_info *mythr)
memcpy(&tv_start, &tv_end, sizeof(struct timeval));
}
- if (unlikely(mythr->work_restart))
+ if (unlikely(mythr->work_restart)) {
flush_queue(cgpu);
+ drv->flush_work(cgpu);
+ }
if (unlikely(mythr->pause || cgpu->deven != DEV_ENABLED))
mt_disable(mythr, thr_id, drv);
@@ -6612,6 +6614,9 @@ static void noop_thread_enable(struct thr_info __maybe_unused *thr)
{
}
+#define noop_flush_work noop_reinit_device
+#define noop_queue_full noop_get_stats
+
/* Fill missing driver api functions with noops */
void fill_device_api(struct cgpu_info *cgpu)
{
@@ -6639,8 +6644,10 @@ void fill_device_api(struct cgpu_info *cgpu)
drv->thread_shutdown = &noop_thread_shutdown;
if (!drv->thread_enable)
drv->thread_enable = &noop_thread_enable;
+ if (!drv->flush_work)
+ drv->flush_work = &noop_flush_work;
if (!drv->queue_full)
- drv->queue_full = &noop_get_stats;
+ drv->queue_full = &noop_queue_full;
}
void enable_device(struct cgpu_info *cgpu)
diff --git a/miner.h b/miner.h
index 9f7d3b5..da44dc9 100644
--- a/miner.h
+++ b/miner.h
@@ -300,6 +300,7 @@ struct device_drv {
int64_t (*scanhash)(struct thr_info *, struct work *, int64_t);
int64_t (*scanwork)(struct thr_info *);
bool (*queue_full)(struct cgpu_info *);
+ void (*flush_work)(struct cgpu_info *);
void (*hw_error)(struct thr_info *);
void (*thread_shutdown)(struct thr_info *);