Skip to content
This repository has been archived by the owner on May 27, 2020. It is now read-only.

Commit

Permalink
Icarus: Abandon a scanhash early when work restart requested
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-jr committed Apr 21, 2012
1 parent 1291f5a commit 34f8641
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions driver-icarus.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 34f8641

Please sign in to comment.