Add error message to libusb pipe error
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/usbutils.c b/usbutils.c
index 58f83bf..393e733 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -2172,13 +2172,16 @@ static char *find_end(unsigned char *buf, unsigned char *ptr, int ptrlen, int to
static int
usb_bulk_transfer(struct libusb_device_handle *dev_handle,
unsigned char endpoint, unsigned char *data, int length,
- int *transferred, unsigned int timeout)
+ int *transferred, unsigned int timeout,
+ struct cgpu_info *cgpu)
{
int err, tries = 0;
err = libusb_bulk_transfer(dev_handle, endpoint, data, length,
transferred, timeout);
if (unlikely(err == LIBUSB_ERROR_PIPE)) {
+ applog(LOG_WARNING, "%s: libusb pipe error, trying to clear",
+ cgpu->drv->name);
do {
err = libusb_clear_halt(dev_handle, endpoint);
if (unlikely(err == LIBUSB_ERROR_NOT_FOUND ||
@@ -2187,6 +2190,8 @@ usb_bulk_transfer(struct libusb_device_handle *dev_handle,
err = libusb_bulk_transfer(dev_handle, endpoint, data,
length, transferred, timeout);
} while (err == LIBUSB_ERROR_PIPE && tries++ < USB_RETRY_MAX);
+ applog(LOG_DEBUG, "%s: libusb pipe error%scleared",
+ cgpu->drv->name, err ? " not " : " ");
}
return err;
@@ -2265,7 +2270,8 @@ int _usb_read(struct cgpu_info *cgpu, int ep, char *buf, size_t bufsiz, int *pro
STATS_TIMEVAL(&tv_start);
err = usb_bulk_transfer(usbdev->handle,
usbdev->found->eps[ep].ep,
- ptr, usbbufread, &got, timeout);
+ ptr, usbbufread, &got, timeout,
+ cgpu);
cgtime(&tv_finish);
USB_STATS(cgpu, &tv_start, &tv_finish, err,
MODE_BULK_READ, cmd, first ? SEQ0 : SEQ1);
@@ -2355,7 +2361,7 @@ int _usb_read(struct cgpu_info *cgpu, int ep, char *buf, size_t bufsiz, int *pro
STATS_TIMEVAL(&tv_start);
err = usb_bulk_transfer(usbdev->handle,
usbdev->found->eps[ep].ep, ptr,
- usbbufread, &got, timeout);
+ usbbufread, &got, timeout, cgpu);
cgtime(&tv_finish);
USB_STATS(cgpu, &tv_start, &tv_finish, err,
MODE_BULK_READ, cmd, first ? SEQ0 : SEQ1);
@@ -2483,7 +2489,7 @@ int _usb_write(struct cgpu_info *cgpu, int ep, char *buf, size_t bufsiz, int *pr
err = usb_bulk_transfer(usbdev->handle,
usbdev->found->eps[ep].ep,
(unsigned char *)buf, bufsiz, &sent,
- timeout);
+ timeout, cgpu);
cgtime(&tv_finish);
USB_STATS(cgpu, &tv_start, &tv_finish, err,
MODE_BULK_WRITE, cmd, first ? SEQ0 : SEQ1);