Send a work restart frame when the restart message is received in hashfast scanwork.
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
diff --git a/driver-hashfast.c b/driver-hashfast.c
index 7d2f3fe..659665e 100644
--- a/driver-hashfast.c
+++ b/driver-hashfast.c
@@ -98,9 +98,9 @@ static const struct hf_cmd hf_cmds[] = {
/* Send an arbitrary frame, consisting of an 8 byte header and an optional
* packet body. */
-static int __maybe_unused hashfast_send_frame(struct cgpu_info *hashfast, uint8_t opcode,
- uint8_t chip, uint8_t core, uint16_t hdata,
- uint8_t *data, int len)
+static bool hashfast_send_frame(struct cgpu_info *hashfast, uint8_t opcode,
+ uint8_t chip, uint8_t core, uint16_t hdata,
+ uint8_t *data, int len)
{
int tx_length, ret, amount, id = hashfast->device_id;
uint8_t packet[256];
@@ -122,12 +122,12 @@ static int __maybe_unused hashfast_send_frame(struct cgpu_info *hashfast, uint8_
ret = usb_write(hashfast, (char *)packet, tx_length, &amount,
hf_cmds[opcode].usb_cmd);
- if (ret < 0 || amount != tx_length) {
+ if (unlikely(ret < 0 || amount != tx_length)) {
applog(LOG_ERR, "HF%d: hashfast_send_frame: USB Send error, ret %d amount %d vs. tx_length %d",
id, ret, amount, tx_length);
- return 1;
+ return false;
}
- return 0;
+ return true;
}
static bool hashfast_send_header(struct cgpu_info *hashfast, struct hf_header *h,
@@ -389,8 +389,23 @@ static bool hashfast_prepare(struct thr_info *thr)
return true;
}
-static int64_t hashfast_scanwork(struct thr_info __maybe_unused *thr)
+static int64_t hashfast_scanwork(struct thr_info *thr)
{
+ struct cgpu_info *hashfast = thr->cgpu;
+ struct hashfast_info *info = hashfast->device_data;
+ bool ret;
+
+ if (unlikely(thr->work_restart)) {
+ ret = hashfast_send_frame(hashfast, OP_WORK_RESTART, HF_GWQ_ADDRESS, 0, 0, (uint8_t *)NULL, 0);
+ if (unlikely(!ret))
+ ret = hashfast_reset(hashfast, info);
+ if (unlikely(!ret)) {
+ applog(LOG_ERR, "HFA %d: Failed to reset after write failure, disabling",
+ hashfast->device_id);
+ return -1;
+ }
+ }
+
return 0;
}