Remove some spurious debug, time out ASICs who are slow to respond
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
diff --git a/driver-drillbit.c b/driver-drillbit.c
index cac0432..e761132 100644
--- a/driver-drillbit.c
+++ b/driver-drillbit.c
@@ -356,9 +356,7 @@ static bool check_for_results(struct thr_info *thr)
chip->has_work = false;
}
-
cleanup:
- bitfury_empty_buffer(bitfury);
return successful_results;
}
@@ -368,7 +366,7 @@ static int64_t bitfury_scanhash(struct thr_info *thr, struct work *work,
struct cgpu_info *bitfury = thr->cgpu;
struct drillbit_info *info = bitfury->device_data;
struct drillbit_chip_info *chip;
- struct timeval tv_now;
+ struct timeval tv_now, tv_start;
int amount, i, j;
int ms_diff;
uint8_t cmd;
@@ -379,9 +377,11 @@ static int64_t bitfury_scanhash(struct thr_info *thr, struct work *work,
result_count = 0;
chip = NULL;
- cgtime(&info->tv_start);
+ cgtime(&tv_start);
ms_diff = TIMEOUT;
- while(chip == NULL) { // wait for a free chip to open up
+
+ // wait for a free chip to send back a result
+ while(chip == NULL) {
result_count += check_for_results(thr);
for(i = 0; i < info->num_chips; i++) {
if(!info->chips[i].has_work) {
@@ -391,15 +391,28 @@ static int64_t bitfury_scanhash(struct thr_info *thr, struct work *work,
}
cgtime(&tv_now);
- ms_diff = ms_tdiff(&tv_now, &info->tv_start);
+ ms_diff = ms_tdiff(&tv_now, &tv_start);
if(ms_diff > TIMEOUT) {
applog(LOG_ERR, "Timed out waiting for any results to come back from ASICs.");
- goto cascade;
+ break;
+ }
+ }
+
+ // check for any chips that have timed out on sending results
+ cgtime(&tv_now);
+ for(i = 0; i < info->num_chips; i++) {
+ if(!info->chips[i].has_work)
+ continue;
+ ms_diff = ms_tdiff(&tv_now, &info->chips[i].tv_start);
+ if(ms_diff > TIMEOUT) {
+ applog(LOG_ERR, "Timing out unresponsive ASIC %d", info->chips[i].chip_id);
+ info->chips[i].has_work = false;
+ chip = &info->chips[i];
}
}
- if(!chip) {
- return 0;
+ if(chip == NULL) {
+ goto cascade;
}
applog(LOG_DEBUG, "Sending work to chip_id %d", chip->chip_id);
@@ -407,20 +420,6 @@ static int64_t bitfury_scanhash(struct thr_info *thr, struct work *work,
memcpy(&request.midstate, work->midstate, 32);
memcpy(&request.data, work->data + 64, 12);
- /*
- tmp = bin2hex(work->midstate, 32);
- applog(LOG_DEBUG, "Midstate %s", tmp);
- free(tmp);
- tmp = bin2hex(work->data+64, 12);
- applog(LOG_DEBUG, "Data %s", tmp);
- free(tmp);*/
-
- applog(LOG_DEBUG, "Data %x %x %x", *((uint32_t*)(work->data+64)),
- *((uint32_t*)(work->data+64+4)), *((uint32_t*)(work->data+64+8)));
-
- uint32_t *data = request.data;
- applog(LOG_DEBUG, "Data in request %x %x %x", data[0],data[1],data[2]);
-
/* Send work to cgminer */
cmd = 'W';
usb_write(bitfury, &cmd, 1, &amount, C_BF_REQWORK);
@@ -439,10 +438,11 @@ static int64_t bitfury_scanhash(struct thr_info *thr, struct work *work,
for(i = 0; i < WORK_HISTORY_LEN-1; i++)
chip->current_work[i] = chip->current_work[i+1];
chip->current_work[WORK_HISTORY_LEN-1] = copy_work(work);
+ cgtime(&chip->tv_start);
applog(LOG_DEBUG, "assigned new current_work=%p", chip->current_work[WORK_HISTORY_LEN-1]);
- bitfury_empty_buffer(bitfury);
cascade:
+ bitfury_empty_buffer(bitfury);
work->blk.nonce = 0xffffffff;
if (unlikely(bitfury->usbinfo.nodev)) {
diff --git a/driver-drillbit.h b/driver-drillbit.h
index 7ab294b..bfb0b1b 100644
--- a/driver-drillbit.h
+++ b/driver-drillbit.h
@@ -13,7 +13,7 @@
#include "miner.h"
#include "usbutils.h"
-#define WORK_HISTORY_LEN 8
+#define WORK_HISTORY_LEN 2
struct drillbit_chip_info;
@@ -25,13 +25,13 @@ struct drillbit_info {
uint32_t serial;
uint8_t num_chips;
struct drillbit_chip_info *chips;
- struct timeval tv_start;
};
struct drillbit_chip_info {
uint16_t chip_id;
struct work *current_work[WORK_HISTORY_LEN];
bool has_work;
+ struct timeval tv_start;
};
#endif /* BITFURY_H */