Icarus: Abandon a scanhash early when work restart requested
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
diff --git a/driver-icarus.c b/driver-icarus.c
index 8ec76eb..78e9129 100644
--- a/driver-icarus.c
+++ b/driver-icarus.c
@@ -55,8 +55,8 @@
#include "miner.h"
// 8 second timeout
-#define ICARUS_READ_FAULT_DECISECONDS (10)
-#define ICARUS_READ_FAULT_COUNT (8)
+#define ICARUS_READ_FAULT_DECISECONDS (1)
+#define ICARUS_READ_FAULT_COUNT (80)
struct device_api icarus_api;
@@ -114,7 +114,7 @@ static int icarus_open(const char *devpath)
#endif
}
-static int icarus_gets(unsigned char *buf, size_t bufLen, int fd)
+static int icarus_gets(unsigned char *buf, size_t bufLen, int fd, volatile unsigned long *wr)
{
ssize_t ret = 0;
int rc = 0;
@@ -147,6 +147,8 @@ static int icarus_gets(unsigned char *buf, size_t bufLen, int fd)
}
rc++;
+ if (*wr)
+ return 1;
if (rc == ICARUS_READ_FAULT_COUNT) {
if (epollfd != -1)
close(epollfd);
@@ -202,7 +204,8 @@ static bool icarus_detect_one(const char *devpath)
icarus_write(fd, ob_bin, sizeof(ob_bin));
memset(nonce_bin, 0, sizeof(nonce_bin));
- icarus_gets(nonce_bin, sizeof(nonce_bin), fd);
+ volatile unsigned long wr = 0;
+ icarus_gets(nonce_bin, sizeof(nonce_bin), fd, &wr);
icarus_close(fd);
@@ -273,6 +276,9 @@ static bool icarus_prepare(struct thr_info *thr)
static uint64_t icarus_scanhash(struct thr_info *thr, struct work *work,
__maybe_unused uint64_t max_nonce)
{
+ volatile unsigned long *wr = &work_restart[thr->id].restart;
+ *wr = 0;
+
struct cgpu_info *icarus;
int fd;
int ret;
@@ -308,7 +314,7 @@ static uint64_t icarus_scanhash(struct thr_info *thr, struct work *work,
/* Icarus will return 8 bytes nonces or nothing */
memset(nonce_bin, 0, sizeof(nonce_bin));
- ret = icarus_gets(nonce_bin, sizeof(nonce_bin), fd);
+ ret = icarus_gets(nonce_bin, sizeof(nonce_bin), fd, wr);
nonce_hex = bin2hex(nonce_bin, sizeof(nonce_bin));
if (nonce_hex) {