Take into account shed cores on hfa devices when determining how many jobs to send.
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
diff --git a/driver-hashfast.c b/driver-hashfast.c
index a25f846..25f26ae 100644
--- a/driver-hashfast.c
+++ b/driver-hashfast.c
@@ -1023,6 +1023,13 @@ static bool hfa_prepare(struct thr_info *thr)
return true;
}
+/* If this ever returns 0 it means we have shed all the cores which will lead
+ * to no work being done which will trigger the watchdog. */
+static inline int hfa_basejobs(struct hashfast_info *info)
+{
+ return info->usb_init_base.inflight_target - info->shed_count;
+}
+
/* Figure out how many jobs to send. */
static int hfa_jobs(struct cgpu_info *hashfast, struct hashfast_info *info)
{
@@ -1040,13 +1047,16 @@ static int hfa_jobs(struct cgpu_info *hashfast, struct hashfast_info *info)
}
mutex_lock(&info->lock);
- ret = info->usb_init_base.inflight_target - HF_SEQUENCE_DISTANCE(info->hash_sequence_head, info->device_sequence_tail);
+ ret = hfa_basejobs(info) - HF_SEQUENCE_DISTANCE(info->hash_sequence_head, info->device_sequence_tail);
/* Place an upper limit on how many jobs to queue to prevent sending
- * more work than the device can use after a period of outage. */
- if (ret > info->usb_init_base.inflight_target)
- ret = info->usb_init_base.inflight_target;
+ * more work than the device can use after a period of outage. */
+ if (ret > hfa_basejobs(info))
+ ret = hfa_basejobs(info);
mutex_unlock(&info->lock);
+ if (unlikely(ret < 0))
+ ret = 0;
+
out:
return ret;
}
@@ -1338,7 +1348,7 @@ restart:
}
/* Give a full allotment of jobs after a restart, not waiting
* for the status update telling us how much to give. */
- jobs = info->usb_init_base.inflight_target;
+ jobs = hfa_basejobs(info);
} else {
/* Only adjust die clocks if there's no restart since two
* restarts back to back get ignored. */