Initially enable support for nonce range support on bfl, splitting nonces up into 3/4 size and only disable it if it fails on work submit.
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 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
diff --git a/driver-bitforce.c b/driver-bitforce.c
index a80acb5..18ee893 100644
--- a/driver-bitforce.c
+++ b/driver-bitforce.c
@@ -201,28 +201,12 @@ void bitforce_init(struct cgpu_info *bitforce)
bitforce->name = strdup(pdevbuf + 7);
}
+ /* Initially enable support for nonce range and disable it later if it
+ * fails */
+ bitforce->nonce_range = true;
bitforce->device_fd = fdDev;
bitforce->sleep_ms = BITFORCE_SLEEP_MS;
- /* Look for nonce range support */
- BFwrite(fdDev, "ZPX", 3);
- BFgets(pdevbuf, sizeof(pdevbuf), fdDev);
- if (strncasecmp(pdevbuf, "ERR", 3)) {
- unsigned char ob[70];
- uint32_t *nonce;
-
- memset(ob, 0, 68);
- sprintf((char *)ob, ">>>>>>>>");
- sprintf((char *)ob + 60, ">>>>>>>>");
- nonce = (uint32_t *)(ob + 56);
- *nonce = htobe32(0x7FFFFFFF);
- BFwrite(fdDev, ob, 68);
- BFgets(pdevbuf, sizeof(pdevbuf), fdDev);
- if (!strncasecmp(pdevbuf, "OK", 2)) {
- applog(LOG_DEBUG, "BFL%i: Found nonce range support");
- bitforce->nonce_range = true;
- }
- }
mutex_unlock(&bitforce->device_mutex);
}
@@ -276,7 +260,10 @@ static bool bitforce_send_work(struct thr_info *thr, struct work *work)
return false;
re_send:
mutex_lock(&bitforce->device_mutex);
- BFwrite(fdDev, "ZDX", 3);
+ if (bitforce->nonce_range)
+ BFwrite(fdDev, "ZPX", 3);
+ else
+ BFwrite(fdDev, "ZDX", 3);
BFgets(pdevbuf, sizeof(pdevbuf), fdDev);
if (!pdevbuf[0] || (pdevbuf[0] == 'B')) {
mutex_unlock(&bitforce->device_mutex);
@@ -285,6 +272,11 @@ re_send:
goto re_send;
} else if (unlikely(pdevbuf[0] != 'O' || pdevbuf[1] != 'K')) {
mutex_unlock(&bitforce->device_mutex);
+ if (bitforce->nonce_range) {
+ applog(LOG_DEBUG, "BFL%i: Disabling nonce range support");
+ bitforce->nonce_range = false;
+ goto re_send;
+ }
applog(LOG_ERR, "BFL%i: Error: Send work reports: %s", bitforce->device_id, pdevbuf);
return false;
}
@@ -292,9 +284,21 @@ re_send:
sprintf((char *)ob, ">>>>>>>>");
memcpy(ob + 8, work->midstate, 32);
memcpy(ob + 8 + 32, work->data + 64, 12);
- sprintf((char *)ob + 8 + 32 + 12, ">>>>>>>>");
+ if (!bitforce->nonce_range) {
+ sprintf((char *)ob + 8 + 32 + 12, ">>>>>>>>");
+ bitforce->end_nonce = 0xffffffff;
+ BFwrite(fdDev, ob, 60);
+ } else {
+ uint32_t *nonce;
+
+ nonce = (uint32_t *)(ob + 8 + 32 + 12);
+ *nonce = work->blk.nonce;
+ nonce = (uint32_t *)(ob + 8 + 32 + 12 + 4);
+ bitforce->end_nonce = *nonce = work->blk.nonce + 0x40000000;
+ sprintf((char *)ob + 8 + 32 + 12 + 8, ">>>>>>>>");
+ BFwrite(fdDev, ob, 68);
+ }
- BFwrite(fdDev, ob, 60);
BFgets(pdevbuf, sizeof(pdevbuf), fdDev);
mutex_unlock(&bitforce->device_mutex);
@@ -364,9 +368,9 @@ static uint64_t bitforce_get_result(struct thr_info *thr, struct work *work)
}
applog(LOG_DEBUG, "BFL%i: waited %dms until %s", bitforce->device_id, bitforce->wait_ms, pdevbuf);
- work->blk.nonce = 0xffffffff;
+ work->blk.nonce = bitforce->end_nonce;
if (pdevbuf[2] == '-')
- return 0xffffffff; /* No valid nonce found */
+ return bitforce->end_nonce; /* No valid nonce found */
else if (pdevbuf[0] == 'I')
return 1; /* Device idle */
else if (strncasecmp(pdevbuf, "NONCE-FOUND", 11)) {
@@ -387,7 +391,7 @@ static uint64_t bitforce_get_result(struct thr_info *thr, struct work *work)
pnoncebuf += 9;
}
- return 0xffffffff;
+ return bitforce->end_nonce;
}
static void bitforce_shutdown(struct thr_info *thr)
diff --git a/miner.h b/miner.h
index cbca935..dde11ed 100644
--- a/miner.h
+++ b/miner.h
@@ -322,6 +322,7 @@ struct cgpu_info {
#ifdef USE_BITFORCE
unsigned int wait_ms;
unsigned int sleep_ms;
+ uint32_t end_nonce;
bool nonce_range;
#endif
pthread_mutex_t device_mutex;