Always decrease hfa clock speed on a running shutdown and don't try sending an init frame since it will be dropped regardless.
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
diff --git a/driver-hashfast.c b/driver-hashfast.c
index 9446078..e0cc317 100644
--- a/driver-hashfast.c
+++ b/driver-hashfast.c
@@ -772,7 +772,7 @@ out:
return ret;
}
-static bool hfa_running_shutdown(struct cgpu_info *hashfast, struct hashfast_info *info);
+static void hfa_running_shutdown(struct cgpu_info *hashfast, struct hashfast_info *info);
static void hfa_parse_gwq_status(struct cgpu_info *hashfast, struct hashfast_info *info,
struct hf_header *h)
@@ -1389,28 +1389,30 @@ dies_only:
}
}
-static bool hfa_running_shutdown(struct cgpu_info *hashfast, struct hashfast_info *info)
+static void hfa_running_shutdown(struct cgpu_info *hashfast, struct hashfast_info *info)
{
- bool ret;
- int i;
+ /* If the device has already disapperaed, don't drop the clock in case
+ * it was just unplugged as opposed to a failure. */
+ if (hashfast->usbinfo.nodev)
+ return;
- ret = hfa_send_shutdown(hashfast);
- if (!ret)
- goto out;
+ if (info->hash_clock_rate > HFA_CLOCK_DEFAULT) {
+ info->hash_clock_rate -= 10;
+ if (info->hash_clock_rate < HFA_CLOCK_DEFAULT)
+ info->hash_clock_rate = HFA_CLOCK_DEFAULT;
+ applog(LOG_WARNING, "%s %d: Decreasing clock speed to %d with reset",
+ hashfast->drv->name, hashfast->device_id, info->hash_clock_rate);
+ }
+
+ if (!hfa_send_shutdown(hashfast))
+ return;
+
+ if (hashfast->usbinfo.nodev)
+ return;
- /* hfa_reset is the only other place we read from the device so we must
- * inhibit the read thread from reading our response to the
- * OP_USB_INIT */
mutex_lock(&info->rlock);
- ret = hfa_clear_readbuf(hashfast);
- if (ret)
- ret = hfa_reset(hashfast, info);
- for (i = 0; i < info->asic_count; i++)
- info->die_data[i].hash_clock = info->base_clock;
+ hfa_clear_readbuf(hashfast);
mutex_unlock(&info->rlock);
-
-out:
- return ret;
}
static int64_t hfa_scanwork(struct thr_info *thr)
@@ -1434,13 +1436,6 @@ static int64_t hfa_scanwork(struct thr_info *thr)
if (unlikely(share_work_tdiff(hashfast) > fail_time)) {
applog(LOG_WARNING, "%s %d: No valid hashes for over %.0f seconds, shutting down thread",
hashfast->drv->name, hashfast->device_id, fail_time);
- if (info->hash_clock_rate > HFA_CLOCK_DEFAULT) {
- info->hash_clock_rate -= 10;
- if (info->hash_clock_rate < HFA_CLOCK_DEFAULT)
- info->hash_clock_rate = HFA_CLOCK_DEFAULT;
- applog(LOG_WARNING, "%s %d: Decreasing clock speed to %d with reset",
- hashfast->drv->name, hashfast->device_id, info->hash_clock_rate);
- }
hfa_running_shutdown(hashfast, info);
return -1;
}