Get statistics on how long usb reads and writes wait on the devlock.
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
diff --git a/miner.h b/miner.h
index fdfc779..7bafed0 100644
--- a/miner.h
+++ b/miner.h
@@ -481,6 +481,12 @@ struct cgpu_info {
#endif
#ifdef USE_USBUTILS
struct cg_usb_info usbinfo;
+ int usb_bulk_writes;
+ int usb_bulk_reads;
+ int usb_wlock_total_wait;
+ int usb_rlock_total_wait;
+ int usb_wlock_max_wait;
+ int usb_rlock_max_wait;
#endif
#ifdef USE_MODMINER
char fpgaid;
diff --git a/usbutils.c b/usbutils.c
index c93e920..9f1c37a 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -2301,8 +2301,18 @@ int _usb_read(struct cgpu_info *cgpu, int intinfo, int epinfo, char *buf, size_t
int endlen;
unsigned char *ptr, *usbbuf = cgpu->usbinfo.bulkbuf;
size_t usbbufread;
+ int lock_wait;
+ /* Get statistics on how long reads wait on the devlock */
+ cgpu->usb_bulk_reads++;
+
+ cgtime(&read_start);
DEVLOCK(cgpu, pstate);
+ cgtime(&tv_finish);
+ lock_wait = ms_tdiff(&tv_finish, &read_start);
+ cgpu->usb_rlock_total_wait += lock_wait;
+ if (lock_wait > cgpu->usb_rlock_max_wait)
+ cgpu->usb_rlock_max_wait = lock_wait;
if (cgpu->usbinfo.nodev) {
*buf = '\0';
@@ -2572,8 +2582,18 @@ int _usb_write(struct cgpu_info *cgpu, int intinfo, int epinfo, char *buf, size_
double max, done;
__maybe_unused bool first = true;
int err, sent, tot, pstate;
+ int lock_wait;
+ /* Get statistics on how long writes wait on the devlock */
+ cgpu->usb_bulk_writes++;
+
+ cgtime(&read_start);
DEVLOCK(cgpu, pstate);
+ cgtime(&tv_finish);
+ lock_wait = ms_tdiff(&tv_finish, &read_start);
+ cgpu->usb_wlock_total_wait += lock_wait;
+ if (lock_wait > cgpu->usb_wlock_max_wait)
+ cgpu->usb_wlock_max_wait = lock_wait;
USBDEBUG("USB debug: _usb_write(%s (nodev=%s),intinfo=%d,epinfo=%d,buf='%s',bufsiz=%d,proc=%p,timeout=%u,cmd=%s)", cgpu->drv->name, bool_str(cgpu->usbinfo.nodev), intinfo, epinfo, (char *)str_text(buf), (int)bufsiz, processed, timeout, usb_cmdname(cmd));