From 34f86417cc2e2b9c53712cf3caa5a316031f03c8 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Sat, 21 Apr 2012 10:53:34 -0400 Subject: [PATCH] Icarus: Abandon a scanhash early when work restart requested --- driver-icarus.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/driver-icarus.c b/driver-icarus.c index 8ec76eb5..78e91290 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) {