Merge remote-tracking branch 'conman/master'
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 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627
diff --git a/ASIC-README b/ASIC-README
index 310ace0..923a0fb 100644
--- a/ASIC-README
+++ b/ASIC-README
@@ -331,6 +331,12 @@ temperature just below an optimal target. This option allows you to change the
target temperature. When actively cooled below this, the devices will run at
maximum speed.
+--nfu-bits <arg> Set nanofury bits for overclocking range 32-63 (default: 50)
+
+Cgminer by default sets the clockspeed on nanofury devices to the highest that
+is still within USB2 spec. This value allows you to alter the clockspeed, with
+~54 being the optimal but requiring a higher power or USB3 port.
+
BITFURY Devices
diff --git a/api.c b/api.c
index 546d3a6..2b16beb 100644
--- a/api.c
+++ b/api.c
@@ -1940,18 +1940,9 @@ static void ascstatus(struct io_data *io_data, int asc, bool isjson, bool precom
struct cgpu_info *cgpu = get_devices(dev);
float temp = cgpu->temp;
- struct timeval now;
double dev_runtime;
- if (cgpu->dev_start_tv.tv_sec == 0)
- dev_runtime = total_secs;
- else {
- cgtime(&now);
- dev_runtime = tdiff(&now, &(cgpu->dev_start_tv));
- }
-
- if (dev_runtime < 1.0)
- dev_runtime = 1.0;
+ dev_runtime = cgpu_runtime(cgpu);
cgpu->utility = cgpu->accepted / dev_runtime * 60;
diff --git a/cgminer.c b/cgminer.c
index d847bb9..2438274 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -656,6 +656,13 @@ static char *set_int_0_to_200(const char *arg, int *i)
}
#endif
+#ifdef USE_BITFURY
+static char *set_int_32_to_63(const char *arg, int *i)
+{
+ return set_int_range(arg, i, 32, 63);
+}
+#endif
+
static char *set_int_1_to_10(const char *arg, int *i)
{
return set_int_range(arg, i, 1, 10);
@@ -1259,6 +1266,11 @@ static struct opt_table opt_config_table[] = {
opt_set_charp, NULL, &opt_stderr_cmd,
"Use custom pipe cmd for output messages"),
#endif // defined(unix)
+#ifdef USE_BITFURY
+ OPT_WITH_ARG("--nfu-bits",
+ set_int_32_to_63, opt_show_intval, &opt_nf1_bits,
+ "Set nanofury bits for overclocking, range 32-63"),
+#endif
OPT_WITHOUT_ARG("--net-delay",
opt_set_bool, &opt_delaynet,
"Impose small delays in networking to not overload slow routers"),
@@ -2134,12 +2146,10 @@ static void suffix_string(uint64_t val, char *buf, size_t bufsiz, int sigdigits)
}
}
-static void get_statline(char *buf, size_t bufsiz, struct cgpu_info *cgpu)
+double cgpu_runtime(struct cgpu_info *cgpu)
{
- char displayed_hashes[16], displayed_rolling[16];
- uint64_t dh64, dr64;
struct timeval now;
- double dev_runtime, wu;
+ double dev_runtime;
if (cgpu->dev_start_tv.tv_sec == 0)
dev_runtime = total_secs;
@@ -2150,6 +2160,16 @@ static void get_statline(char *buf, size_t bufsiz, struct cgpu_info *cgpu)
if (dev_runtime < 1.0)
dev_runtime = 1.0;
+ return dev_runtime;
+}
+
+static void get_statline(char *buf, size_t bufsiz, struct cgpu_info *cgpu)
+{
+ char displayed_hashes[16], displayed_rolling[16];
+ double dev_runtime, wu;
+ uint64_t dh64, dr64;
+
+ dev_runtime = cgpu_runtime(cgpu);
wu = cgpu->diff1 / dev_runtime * 60.0;
@@ -2354,7 +2374,7 @@ static void check_winsizes(void)
statusy = LINES - 2;
else
statusy = logstart;
- logcursor = statusy + 1;
+ logcursor = statusy;
wresize(statuswin, statusy, x);
getmaxyx(mainwin, y, x);
y -= logcursor;
@@ -3728,8 +3748,6 @@ static struct pool *priority_pool(int choice)
return ret;
}
-static void clear_pool_work(struct pool *pool);
-
/* Specifies whether we can switch to this pool or not. */
static bool pool_unusable(struct pool *pool)
{
@@ -4087,7 +4105,7 @@ static bool test_work_current(struct work *work)
work->gbt ? "GBT " : "", work->pool->pool_no);
}
} else if (have_longpoll)
- applog(LOG_NOTICE, "New block detected on network before longpoll");
+ applog(LOG_NOTICE, "New block detected on network before pool notification");
else
applog(LOG_NOTICE, "New block detected on network");
restart_threads();
@@ -5197,7 +5215,7 @@ void clear_stratum_shares(struct pool *pool)
}
}
-static void clear_pool_work(struct pool *pool)
+void clear_pool_work(struct pool *pool)
{
struct work *work, *tmp;
int cleared = 0;
@@ -5211,6 +5229,9 @@ static void clear_pool_work(struct pool *pool)
}
}
mutex_unlock(stgd_lock);
+
+ if (cleared)
+ applog(LOG_INFO, "Cleared %d work items due to stratum disconnect on pool %d", cleared, pool->pool_no);
}
static int cp_prio(void)
@@ -6069,18 +6090,19 @@ static void update_work_stats(struct thr_info *thr, struct work *work)
}
/* To be used once the work has been tested to be meet diff1 and has had its
- * nonce adjusted. */
-void submit_tested_work(struct thr_info *thr, struct work *work)
+ * nonce adjusted. Returns true if the work target is met. */
+bool submit_tested_work(struct thr_info *thr, struct work *work)
{
struct work *work_out;
update_work_stats(thr, work);
if (!fulltest(work->hash, work->target)) {
applog(LOG_INFO, "Share above target");
- return;
+ return false;
}
work_out = copy_work(work);
submit_work_async(work_out);
+ return true;
}
/* Returns true if nonce for work was a valid share */
@@ -8286,6 +8308,8 @@ begin_bench:
applog(LOG_WARNING, "Pool %d not providing work fast enough", cp->pool_no);
cp->getfail_occasions++;
total_go++;
+ if (!pool_localgen(cp))
+ applog(LOG_INFO, "Increasing queue to %d", ++opt_queue);
}
pool = select_pool(lagging);
retry:
diff --git a/configure.ac b/configure.ac
index 4fda5e9..7bfdc23 100644
--- a/configure.ac
+++ b/configure.ac
@@ -289,9 +289,9 @@ else
fi
if test x$bab$bitfury != xnono; then
- want_libbitfury = true
+ want_libbitfury=true
else
- want_libbitfury = false
+ want_libbitfury=false
fi
AM_CONDITIONAL([NEED_FPGAUTILS], [test x$modminer != xno])
diff --git a/driver-bitfury.c b/driver-bitfury.c
index 3bad374..202c8af 100644
--- a/driver-bitfury.c
+++ b/driver-bitfury.c
@@ -16,6 +16,7 @@
#include "libbitfury.h"
int opt_bxf_temp_target = BXF_TEMP_TARGET / 10;
+int opt_nf1_bits = 50;
/* Wait longer 1/3 longer than it would take for a full nonce range */
#define BF1WAIT 1600
@@ -414,7 +415,7 @@ static bool nf1_detect_one(struct cgpu_info *bitfury, struct bitfury_info *info)
if (val != MCP2210_GPIO_PIN_LOW)
goto out;
- info->osc6_bits = 54;
+ info->osc6_bits = opt_nf1_bits;
if (!nf1_reinit(bitfury, info))
goto out;
diff --git a/driver-bitfury.h b/driver-bitfury.h
index 30d7e4d..e802915 100644
--- a/driver-bitfury.h
+++ b/driver-bitfury.h
@@ -24,6 +24,7 @@
#define BXF_TEMP_HYSTERESIS 30
extern int opt_bxf_temp_target;
+extern int opt_nf1_bits;
#define NF1_PIN_LED 0
#define NF1_PIN_SCK_OVR 5
diff --git a/driver-hashfast.c b/driver-hashfast.c
index d60eae0..072f50e 100644
--- a/driver-hashfast.c
+++ b/driver-hashfast.c
@@ -11,6 +11,7 @@
#include "config.h"
#include <stdbool.h>
+#include <math.h>
#include "miner.h"
#include "usbutils.h"
@@ -24,6 +25,7 @@
#define GP8 0x107 /* x^8 + x^2 + x + 1 */
#define DI8 0x07
+static bool hfa_crc8_set;
static unsigned char crc8_table[256]; /* CRC-8 table */
static void hfa_init_crc8(void)
@@ -31,6 +33,7 @@ static void hfa_init_crc8(void)
int i,j;
unsigned char crc;
+ hfa_crc8_set = true;
for (i = 0; i < 256; i++) {
crc = i;
for (j = 0; j < 8; j++)
@@ -106,6 +109,7 @@ static bool hfa_send_frame(struct cgpu_info *hashfast, uint8_t opcode, uint16_t
int tx_length, ret, amount, id = hashfast->device_id;
uint8_t packet[256];
struct hf_header *p = (struct hf_header *)packet;
+ bool retried = false;
p->preamble = HF_PREAMBLE;
p->operation_code = hfa_cmds[opcode].cmd;
@@ -119,14 +123,30 @@ static bool hfa_send_frame(struct cgpu_info *hashfast, uint8_t opcode, uint16_t
memcpy(&packet[sizeof(struct hf_header)], data, len);
tx_length = sizeof(struct hf_header) + len;
+ if (unlikely(hashfast->usbinfo.nodev))
+ return false;
+
applog(LOG_DEBUG, "HFA %d: Sending %s frame", hashfast->device_id, hfa_cmds[opcode].cmd_name);
+retry:
ret = usb_write(hashfast, (char *)packet, tx_length, &amount,
hfa_cmds[opcode].usb_cmd);
if (unlikely(ret < 0 || amount != tx_length)) {
+ if (hashfast->usbinfo.nodev)
+ return false;
+ if (!retried) {
+ applog(LOG_ERR, "HFA %d: hfa_send_frame: USB Send error, ret %d amount %d vs. tx_length %d, retrying",
+ id, ret, amount, tx_length);
+ retried = true;
+ goto retry;
+ }
applog(LOG_ERR, "HFA %d: hfa_send_frame: USB Send error, ret %d amount %d vs. tx_length %d",
id, ret, amount, tx_length);
return false;
}
+
+ if (retried)
+ applog(LOG_ERR, "HFA %d: hfa_send_frame: recovered OK", id);
+
return true;
}
@@ -137,6 +157,9 @@ static bool hfa_send_packet(struct cgpu_info *hashfast, struct hf_header *h, int
{
int amount, ret, len;
+ if (unlikely(hashfast->usbinfo.nodev))
+ return false;
+
len = sizeof(*h) + h->data_length * 4;
ret = usb_write(hashfast, (char *)h, len, &amount, hfa_cmds[cmd].usb_cmd);
if (ret < 0 || amount != len) {
@@ -199,6 +222,8 @@ static bool hfa_get_data(struct cgpu_info *hashfast, char *buf, int len4)
{
int amount, ret, len = len4 * 4;
+ if (unlikely(hashfast->usbinfo.nodev))
+ return false;
ret = usb_read(hashfast, buf, len, &amount, C_HF_GETDATA);
if (ret)
return false;
@@ -227,7 +252,10 @@ static const char *hf_usb_init_errors[] = {
"Main board FPGA SPI read timeout",
"Main board FPGA Bad magic number",
"Main board FPGA SPI write timeout",
- "Main board FPGA register read/write test failed"
+ "Main board FPGA register read/write test failed",
+ "ASIC core power fault",
+ "Dynamic baud rate change timeout",
+ "Address failure"
};
static bool hfa_reset(struct cgpu_info *hashfast, struct hashfast_info *info)
@@ -264,6 +292,9 @@ static bool hfa_reset(struct cgpu_info *hashfast, struct hashfast_info *info)
hu->crc8 = hfa_crc8((uint8_t *)hu);
applog(LOG_INFO, "HFA%d: Sending OP_USB_INIT with GWQ protocol specified",
hashfast->device_id);
+resend:
+ if (unlikely(hashfast->usbinfo.nodev))
+ return false;
if (!hfa_send_packet(hashfast, (struct hf_header *)hu, HF_USB_CMD(OP_USB_INIT)))
return false;
@@ -272,12 +303,16 @@ static bool hfa_reset(struct cgpu_info *hashfast, struct hashfast_info *info)
// We extend the normal timeout - a complete device initialization, including
// bringing power supplies up from standby, etc., can take over a second.
tryagain:
- for (i = 0; i < 30; i++) {
+ for (i = 0; i < 10; i++) {
ret = hfa_get_header(hashfast, h, &hcrc);
+ if (unlikely(hashfast->usbinfo.nodev))
+ return false;
if (ret)
break;
}
if (!ret) {
+ if (retries++ < 3)
+ goto resend;
applog(LOG_WARNING, "HFA %d: OP_USB_INIT failed!", hashfast->device_id);
return false;
}
@@ -363,6 +398,8 @@ tryagain:
static void hfa_send_shutdown(struct cgpu_info *hashfast)
{
+ if (hashfast->usbinfo.nodev)
+ return;
hfa_send_frame(hashfast, HF_USB_CMD(OP_USB_SHUTDOWN), 0, NULL, 0);
}
@@ -372,6 +409,8 @@ static void hfa_clear_readbuf(struct cgpu_info *hashfast)
char buf[512];
do {
+ if (hashfast->usbinfo.nodev)
+ break;
ret = usb_read(hashfast, buf, 512, &amount, C_HF_CLEAR_READ);
} while (!ret || amount);
}
@@ -395,6 +434,9 @@ static bool hfa_detect_common(struct cgpu_info *hashfast)
return false;
}
+ if (hashfast->usbinfo.nodev)
+ return false;
+
// The per-die status array
info->die_status = calloc(info->asic_count, sizeof(struct hf_g1_die_data));
if (unlikely(!(info->die_status)))
@@ -446,6 +488,9 @@ static void hfa_dfu_boot(struct cgpu_info *hashfast)
{
bool ret;
+ if (unlikely(hashfast->usbinfo.nodev))
+ return;
+
ret = hfa_send_frame(hashfast, HF_USB_CMD(OP_DFU), 0, NULL, 0);
applog(LOG_WARNING, "HFA %d %03d:%03d DFU Boot %s", hashfast->device_id, hashfast->usbinfo.bus_number,
hashfast->usbinfo.device_address, ret ? "Succeeded" : "Failed");
@@ -486,10 +531,10 @@ static struct cgpu_info *hfa_detect_one(libusb_device *dev, struct usb_find_devi
return hashfast;
}
-static void hfa_detect(bool hotplug)
+static void hfa_detect(bool __maybe_unused hotplug)
{
/* Set up the CRC tables only once. */
- if (!hotplug)
+ if (!hfa_crc8_set)
hfa_init_crc8();
usb_detect(&hashfast_drv, hfa_detect_one);
}
@@ -571,6 +616,24 @@ static void hfa_parse_gwq_status(struct cgpu_info *hashfast, struct hashfast_inf
mutex_unlock(&info->lock);
}
+/* Board temperature conversion */
+static float board_temperature(uint16_t adc)
+{
+ float t, r, f, b;
+
+ if (adc < 40 || adc > 650)
+ return((float) 0.0); // Bad count
+
+ b = 3590.0;
+ f = (float)adc / 1023.0;
+ r = 1.0 / (1.0 / f - 1.0);
+ t = log(r) / b;
+ t += 1.0 / (25.0 + 273.15);
+ t = 1.0 / t - 273.15;
+
+ return t;
+}
+
static void hfa_update_die_status(struct cgpu_info *hashfast, struct hashfast_info *info,
struct hf_header *h)
{
@@ -592,8 +655,8 @@ static void hfa_update_die_status(struct cgpu_info *hashfast, struct hashfast_in
for (j = 0; j < 6; j++)
core_voltage[j] = GN_CORE_VOLTAGE(d->die.core_voltage[j]);
- applog(LOG_DEBUG, "HFA %d: die %2d: OP_DIE_STATUS Die temp %.2fC vdd's %.2f %.2f %.2f %.2f %.2f %.2f",
- hashfast->device_id, h->chip_address + i, die_temperature,
+ applog(LOG_DEBUG, "HFA %d: die %2d: OP_DIE_STATUS Temps die %.1fC board %.1fC vdd's %.2f %.2f %.2f %.2f %.2f %.2f",
+ hashfast->device_id, h->chip_address + i, die_temperature, board_temperature(d->temperature),
core_voltage[0], core_voltage[1], core_voltage[2],
core_voltage[3], core_voltage[4], core_voltage[5]);
// XXX Convert board phase currents, voltage, temperature
@@ -601,33 +664,14 @@ static void hfa_update_die_status(struct cgpu_info *hashfast, struct hashfast_in
}
}
-static void search_for_extra_nonce(struct thr_info *thr, struct work *work,
- struct hf_candidate_nonce *n)
-{
- uint32_t nonce = n->nonce;
- int i;
-
- /* No function to test with ntime offsets yet */
- if (n->ntime & HF_NTIME_MASK)
- return;
- for (i = 0; i < 128; i++, nonce++) {
- /* We could break out of this early if nonce wraps or if we
- * find one correct nonce since the chance of more is extremely
- * low but this function will be hit so infrequently we may as
- * well test the entire range with the least code. */
- if (test_nonce(work, nonce))
- submit_tested_work(thr, work);
- }
-}
-
static void hfa_parse_nonce(struct thr_info *thr, struct cgpu_info *hashfast,
struct hashfast_info *info, struct hf_header *h)
{
struct hf_candidate_nonce *n = (struct hf_candidate_nonce *)(h + 1);
int i, num_nonces = h->data_length / U32SIZE(sizeof(struct hf_candidate_nonce));
- applog(LOG_DEBUG, "HFA %d: OP_NONCE: %2d:, num_nonces %d hdata 0x%04x",
- hashfast->device_id, h->chip_address, num_nonces, h->hdata);
+ applog(LOG_DEBUG, "HFA %d: OP_NONCE: %2d/%2d:, num_nonces %d hdata 0x%04x",
+ hashfast->device_id, h->chip_address, h->core_address, num_nonces, h->hdata);
for (i = 0; i < num_nonces; i++, n++) {
struct work *work = NULL;
@@ -650,16 +694,15 @@ static void hfa_parse_nonce(struct thr_info *thr, struct cgpu_info *hashfast,
} else {
applog(LOG_DEBUG, "HFA %d: OP_NONCE: sequence %d: submitting nonce 0x%08x ntime %d",
hashfast->device_id, n->sequence, n->nonce, n->ntime & HF_NTIME_MASK);
- if ((n->nonce & 0xffff0000) == 0x42420000) // XXX REMOVE THIS
- break; // XXX PHONEY EMULATOR NONCE
submit_noffset_nonce(thr, work, n->nonce, n->ntime & HF_NTIME_MASK); // XXX Return value from submit_nonce is error if set
+#if 0 /* Not used */
if (unlikely(n->ntime & HF_NONCE_SEARCH)) {
/* This tells us there is another share in the
* next 128 nonces */
applog(LOG_DEBUG, "HFA %d: OP_NONCE: SEARCH PROXIMITY EVENT FOUND",
hashfast->device_id);
- search_for_extra_nonce(thr, work, n);
}
+#endif
}
}
}
diff --git a/hf_protocol.h b/hf_protocol.h
index d193fdc..b0532c2 100644
--- a/hf_protocol.h
+++ b/hf_protocol.h
@@ -1,5 +1,5 @@
//
-// Copyright 2013 HashFast LLC
+// Copyright 2013, 2014 HashFast Technologies LLC
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
@@ -77,6 +77,9 @@
#define OP_USB_STATS1 137 // Statistics class 1
#define OP_USB_GWQSTATS 138 // GWQ protocol statistics
#define OP_USB_NOTICE 139 // Asynchronous notification event
+#define OP_PING 140 // Echo
+#define OP_CORE_MAP 141 // Return core map
+#define OP_VERSION 142 // Version information
#define OP_USB_DEBUG 255
// HashFast vendor and product ID's
@@ -106,13 +109,26 @@
#define E_BOARD_3 14
#define E_BOARD_4 15
#define E_BOARD_5 16
+#define E_CORE_POWER_FAULT 17
+#define E_BAUD_TIMEOUT 18
+#define E_ADDRESS_FAILURE 19
#define U32SIZE(x) (sizeof(x)/sizeof(uint32_t))
+// Baud rate vs. code for gpi[7:5] coming out of reset
+#define BAUD_RATE_PWRUP_0 115200
+#define BAUD_RATE_PWRUP_1 9600
+#define BAUD_RATE_PWRUP_2 38400
+#define BAUD_RATE_PWRUP_3 57600
+#define BAUD_RATE_PWRUP_4 230400
+#define BAUD_RATE_PWRUP_5 576000
+#define BAUD_RATE_PWRUP_6 921600
+#define BAUD_RATE_PWRUP_7 1152000
+
// Structure definitions, LE platforms
-#if __BYTE_ORDER == __BIG_ENDIAN
+#if __BYTE_ORDER == __BIG_ENDIAN && !defined(WIN32)
#include "hf_protocol_be.h"
#else
// Generic header
diff --git a/miner.h b/miner.h
index 3e5ff36..a4717a6 100644
--- a/miner.h
+++ b/miner.h
@@ -660,6 +660,7 @@ endian_flip128(void __maybe_unused *dest_p, const void __maybe_unused *src_p)
}
#endif
+extern double cgpu_runtime(struct cgpu_info *cgpu);
extern void _quit(int status);
/*
@@ -1016,6 +1017,7 @@ extern pthread_mutex_t restart_lock;
extern pthread_cond_t restart_cond;
extern void clear_stratum_shares(struct pool *pool);
+extern void clear_pool_work(struct pool *pool);
extern void set_target(unsigned char *dest_target, double diff);
extern int restart_wait(struct thr_info *thr, unsigned int mstime);
@@ -1342,7 +1344,7 @@ extern void get_datestamp(char *, size_t, struct timeval *);
extern void inc_hw_errors(struct thr_info *thr);
extern bool test_nonce(struct work *work, uint32_t nonce);
extern bool test_nonce_diff(struct work *work, uint32_t nonce, double diff);
-extern void submit_tested_work(struct thr_info *thr, struct work *work);
+extern bool submit_tested_work(struct thr_info *thr, struct work *work);
extern bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce);
extern bool submit_noffset_nonce(struct thr_info *thr, struct work *work, uint32_t nonce,
int noffset);
diff --git a/usbutils.c b/usbutils.c
index 88ebd07..aba650b 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -2572,20 +2572,20 @@ pipe_retry:
}
if (err == LIBUSB_ERROR_PIPE) {
- int retries = 0;
+ int pipeerr, retries = 0;
do {
cgpu->usbinfo.last_pipe = time(NULL);
cgpu->usbinfo.pipe_count++;
applog(LOG_INFO, "%s%i: libusb pipe error, trying to clear",
cgpu->drv->name, cgpu->device_id);
- err = libusb_clear_halt(dev_handle, endpoint);
+ pipeerr = libusb_clear_halt(dev_handle, endpoint);
applog(LOG_DEBUG, "%s%i: libusb pipe error%scleared",
cgpu->drv->name, cgpu->device_id, err ? " not " : " ");
- if (err)
+ if (pipeerr)
cgpu->usbinfo.clear_fail_count++;
- } while (err && ++retries < USB_RETRY_MAX);
+ } while (pipeerr && ++retries < USB_RETRY_MAX);
if (!err && ++pipe_retries < USB_RETRY_MAX)
goto pipe_retry;
}
@@ -2687,7 +2687,7 @@ int _usb_read(struct cgpu_info *cgpu, int intinfo, int epinfo, char *buf, size_t
if (err && err != LIBUSB_ERROR_TIMEOUT) {
applog(LOG_WARNING, "%s %i %s usb read err:(%d) %s", cgpu->drv->name,
cgpu->device_id, usb_cmdname(cmd), err, libusb_error_name(err));
- if (err != LIBUSB_ERROR_NO_DEVICE) {
+ if (err != LIBUSB_ERROR_NO_DEVICE && err != LIBUSB_ERROR_PIPE) {
err = libusb_reset_device(usbdev->handle);
applog(LOG_WARNING, "%s %i attempted reset got err:(%d) %s",
cgpu->drv->name, cgpu->device_id, err, libusb_error_name(err));
diff --git a/util.c b/util.c
index 9452293..053dae4 100644
--- a/util.c
+++ b/util.c
@@ -1695,6 +1695,8 @@ static bool parse_reconnect(struct pool *pool, json_t *val)
applog(LOG_NOTICE, "Reconnect requested from pool %d to %s", pool->pool_no, address);
+ clear_pool_work(pool);
+
mutex_lock(&pool->stratum_lock);
__suspend_stratum(pool);
tmp = pool->sockaddr_url;