Discard any reads obtained from the avalon get results thread during a reset.
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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
diff --git a/driver-avalon.c b/driver-avalon.c
index e71cfae..84fa9f3 100644
--- a/driver-avalon.c
+++ b/driver-avalon.c
@@ -668,6 +668,25 @@ static void avalon_parse_results(struct cgpu_info *avalon, struct avalon_info *i
memmove(buf, buf + spare, *offset);
}
+static void __avalon_running_reset(struct cgpu_info *avalon,
+ struct avalon_info *info, int fd)
+{
+ info->reset = true;
+ avalon_reset(avalon, fd, false);
+ avalon_idle(avalon, info, fd);
+ avalon->results = 0;
+ info->reset = false;
+}
+
+static void avalon_running_reset(struct cgpu_info *avalon,
+ struct avalon_info *info, int fd)
+{
+ /* Lock to prevent more work being sent during reset */
+ mutex_lock(&info->qlock);
+ __avalon_running_reset(avalon, info, fd);
+ mutex_unlock(&info->qlock);
+}
+
static void *avalon_get_results(void *userdata)
{
struct cgpu_info *avalon = (struct cgpu_info *)userdata;
@@ -698,13 +717,7 @@ static void *avalon_get_results(void *userdata)
if (unlikely(avalon->results <= -info->miner_count)) {
applog(LOG_ERR, "AVA%d: %d invalid consecutive results, resetting",
avalon->device_id, -avalon->results);
-
- /* Lock to prevent more work being sent during reset */
- mutex_lock(&info->qlock);
- avalon_reset(avalon, fd, false);
- avalon_idle(avalon, info, fd);
- avalon->results = 0;
- mutex_unlock(&info->qlock);
+ avalon_running_reset(avalon, info, fd);
}
if (unlikely(offset + rsize >= AVALON_READBUF_SIZE)) {
@@ -735,6 +748,12 @@ static void *avalon_get_results(void *userdata)
hexdump((uint8_t *)buf, ret);
}
+ /* During a reset, goes on reading but discards anything */
+ if (unlikely(info->reset)) {
+ offset = 0;
+ continue;
+ }
+
memcpy(&readbuf[offset], buf, ret);
offset += ret;
}
@@ -777,8 +796,7 @@ static void *avalon_send_tasks(void *userdata)
"AVA%i: Buffer full before all work queued",
avalon->device_id);
dev_error(avalon, REASON_DEV_COMMS_ERROR);
- avalon_reset(avalon, fd, false);
- avalon_idle(avalon, info, fd);
+ __avalon_running_reset(avalon, info, fd);
break;
}
@@ -799,8 +817,7 @@ static void *avalon_send_tasks(void *userdata)
applog(LOG_ERR, "AVA%i: Comms error(buffer)",
avalon->device_id);
dev_error(avalon, REASON_DEV_COMMS_ERROR);
- avalon_reset(avalon, fd, false);
- avalon_idle(avalon, info, fd);
+ __avalon_running_reset(avalon, info, fd);
break;
}
}
@@ -883,7 +900,7 @@ static void do_avalon_close(struct thr_info *thr)
pthread_cancel(info->read_thr);
pthread_cancel(info->write_thr);
- avalon_reset(avalon, fd, false);
+ __avalon_running_reset(avalon, info, fd);
avalon_idle(avalon, info, fd);
avalon_free_work(thr);
avalon_close(fd);
diff --git a/driver-avalon.h b/driver-avalon.h
index 16c403d..47bad5c 100644
--- a/driver-avalon.h
+++ b/driver-avalon.h
@@ -109,6 +109,7 @@ struct avalon_info {
int nonces;
bool idle;
+ bool reset;
};
#define AVALON_WRITE_SIZE (sizeof(struct avalon_task))