Set the clock rate with a work restart instead of an init when changing to old clocks for hfa
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 76 77
diff --git a/driver-hashfast.c b/driver-hashfast.c
index 363c769..32e2737 100644
--- a/driver-hashfast.c
+++ b/driver-hashfast.c
@@ -614,6 +614,21 @@ static struct cgpu_info *hfa_old_device(struct cgpu_info *hashfast, struct hashf
return found;
}
+static void hfa_set_clock(struct cgpu_info *hashfast, struct hashfast_info *info)
+{
+ uint16_t hdata;
+ int i;
+
+ hdata = (WR_CLOCK_VALUE << WR_COMMAND_SHIFT) | info->hash_clock_rate;
+
+ hfa_send_frame(hashfast, HF_USB_CMD(OP_WORK_RESTART), hdata, (uint8_t *)NULL, 0);
+ /* We won't know what the real clock is in this case without a
+ * usb_init_base message so we have to assume it's what we asked. */
+ info->base_clock = info->hash_clock_rate;
+ for (i = 0; i < info->asic_count; i++)
+ info->die_data[i].hash_clock = info->base_clock;
+}
+
static bool hfa_detect_common(struct cgpu_info *hashfast)
{
struct hashfast_info *info;
@@ -634,26 +649,6 @@ static bool hfa_detect_common(struct cgpu_info *hashfast)
goto out;
}
- info->cgpu = hashfast;
- /* Look for a matching zombie instance and inherit values from it if it
- * exists. */
- info->old_cgpu = hfa_old_device(hashfast, info);
- if (info->old_cgpu) {
- struct hashfast_info *cinfo = info->old_cgpu->device_data;
-
- applog(LOG_INFO, "Found matching zombie device for %s %d at device %d",
- hashfast->drv->name, hashfast->device_id, info->old_cgpu->device_id);
- info->resets = cinfo->resets;
- /* Reset the device with the last hash_clock_rate if it's
- * different. */
- if (info->hash_clock_rate != cinfo->hash_clock_rate) {
- info->hash_clock_rate = cinfo->hash_clock_rate;
- ret = hfa_reset(hashfast, hashfast->device_data);
- if (!ret)
- goto out;
- }
- }
-
// The per-die status array
info->die_status = calloc(info->asic_count, sizeof(struct hf_g1_die_data));
if (unlikely(!(info->die_status)))
@@ -674,6 +669,23 @@ static bool hfa_detect_common(struct cgpu_info *hashfast)
if (!info->works)
quit(1, "Failed to calloc info works in hfa_detect_common");
+ info->cgpu = hashfast;
+ /* Look for a matching zombie instance and inherit values from it if it
+ * exists. */
+ info->old_cgpu = hfa_old_device(hashfast, info);
+ if (info->old_cgpu) {
+ struct hashfast_info *cinfo = info->old_cgpu->device_data;
+
+ applog(LOG_INFO, "Found matching zombie device for %s %d at device %d",
+ hashfast->drv->name, hashfast->device_id, info->old_cgpu->device_id);
+ info->resets = cinfo->resets;
+ /* Set the device with the last hash_clock_rate if it's
+ * different. */
+ if (info->hash_clock_rate != cinfo->hash_clock_rate) {
+ info->hash_clock_rate = cinfo->hash_clock_rate;
+ hfa_set_clock(hashfast, info);
+ }
+ }
out:
if (!ret) {
hfa_send_shutdown(hashfast);