Use usbutils' own cps function for slowing rate of usb writes on avalon.
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
diff --git a/driver-avalon.c b/driver-avalon.c
index 7cced1f..f63f881 100644
--- a/driver-avalon.c
+++ b/driver-avalon.c
@@ -146,9 +146,7 @@ static int avalon_send_task(const struct avalon_task *at, struct cgpu_info *aval
{
uint8_t buf[AVALON_WRITE_SIZE + 4 * AVALON_DEFAULT_ASIC_NUM];
- int delay, ret, i, ep = C_AVALON_TASK;
- struct avalon_info *info;
- cgtimer_t ts_start;
+ int ret, i, ep = C_AVALON_TASK;
uint32_t nonce_range;
size_t nr_len;
@@ -189,10 +187,6 @@ static int avalon_send_task(const struct avalon_task *at, struct cgpu_info *aval
tt |= ((buf[4] & 0x80) ? (1 << 0) : 0);
buf[4] = tt;
#endif
- info = avalon->device_data;
- delay = nr_len * 10 * 1000000;
- delay = delay / info->baud;
- delay += 4000;
if (at->reset) {
ep = C_AVALON_RESET;
@@ -202,11 +196,7 @@ static int avalon_send_task(const struct avalon_task *at, struct cgpu_info *aval
applog(LOG_DEBUG, "Avalon: Sent(%u):", (unsigned int)nr_len);
hexdump(buf, nr_len);
}
- cgsleep_prepare_r(&ts_start);
ret = avalon_write(avalon, (char *)buf, nr_len, ep);
- cgsleep_us_r(&ts_start, delay);
-
- applog(LOG_DEBUG, "Avalon: Sent: Buffer delay: %dus", delay);
return ret;
}
@@ -216,7 +206,6 @@ static int bitburner_send_task(const struct avalon_task *at, struct cgpu_info *a
{
uint8_t buf[AVALON_WRITE_SIZE + 4 * AVALON_DEFAULT_ASIC_NUM];
int ret, ep = C_AVALON_TASK;
- cgtimer_t ts_start;
size_t nr_len;
if (at->nonce_elf)
@@ -253,9 +242,7 @@ static int bitburner_send_task(const struct avalon_task *at, struct cgpu_info *a
applog(LOG_DEBUG, "Avalon: Sent(%u):", (unsigned int)nr_len);
hexdump(buf, nr_len);
}
- cgsleep_prepare_r(&ts_start);
ret = avalon_write(avalon, (char *)buf, nr_len, ep);
- cgsleep_us_r(&ts_start, 3000); // 3 ms = 333 tasks per second, or 1.4 TH/s
return ret;
}
@@ -825,6 +812,9 @@ static bool avalon_detect_one(libusb_device *dev, struct usb_find_devices *found
if (!add_cgpu(avalon))
goto unshin;
+ usb_set_cps(avalon, info->baud / 10);
+ usb_enable_cps(avalon);
+
ret = avalon_reset(avalon, true);
if (ret && !configured)
goto unshin;