I'm trying to make g15daemon correctly recover after suspend/resume and found that it occasionally hungs after resume in libusb's usb_urb_transfer() (linux.c) on this line:
ioctl(dev->fd, IOCTL_USB_REAPURB, &context);
After some research I found that linux kernel internally has lists of pending and completed requests. All requests - successful or not - are moved from pending list to completed list, no requests should be lost. But it looks like after suspend/resume some request may be lost (may be a kernel bug). It that case IOCTL_USB_REAPURB would hung forever since request it's waiting for will never appear on completed list.
There is simple workaround. After preceding IOCTL_USB_DISCARDURB call our request is guaranteed to be completed, so there is no need to use blocking IOCTL_USB_DISCARDURB, we may use non-blocking IOCTL_USB_REAPURBNDELAY instead.
I've attached path for this workaround. It also fixes race condition existed in original code, which may cause corruption of stack.
ProblemType: Bug
DistroRelease: Ubuntu 15.04
Package: libusb-0.1-4 2:0.1.12-25 [modified: lib/x86_64-linux-gnu/libusb-0.1.so.4.4.4]
ProcVersionSignature: Ubuntu 3.19.0-16.16-generic 3.19.3
Uname: Linux 3.19.0-16-generic x86_64
NonfreeKernelModules: fglrx
ApportVersion: 2.17.2-0ubuntu1
Architecture: amd64
CurrentDesktop: KDE
Date: Sun May 17 13:11:00 2015
Dependencies:
gcc-5-base 5.1~rc1-0ubuntu1
libc6 2.21-0ubuntu4
libgcc1 1:5.1~rc1-0ubuntu1
multiarch-support 2.21-0ubuntu4
SourcePackage: libusb
UpgradeStatus: Upgraded to vivid on 2015-04-26 (21 days ago)
I'm trying to make g15daemon correctly recover after suspend/resume and found that it occasionally hungs after resume in libusb's usb_urb_transfer() (linux.c) on this line:
ioctl(dev->fd, IOCTL_USB_REAPURB, &context);
After some research I found that linux kernel internally has lists of pending and completed requests. All requests - successful or not - are moved from pending list to completed list, no requests should be lost. But it looks like after suspend/resume some request may be lost (may be a kernel bug). It that case IOCTL_USB_REAPURB would hung forever since request it's waiting for will never appear on completed list.
There is simple workaround. After preceding IOCTL_USB_ DISCARDURB call our request is guaranteed to be completed, so there is no need to use blocking IOCTL_USB_ DISCARDURB, we may use non-blocking IOCTL_USB_ REAPURBNDELAY instead.
I've attached path for this workaround. It also fixes race condition existed in original code, which may cause corruption of stack.
ProblemType: Bug 64-linux- gnu/libusb- 0.1.so. 4.4.4] ature: Ubuntu 3.19.0- 16.16-generic 3.19.3 dules: fglrx
DistroRelease: Ubuntu 15.04
Package: libusb-0.1-4 2:0.1.12-25 [modified: lib/x86_
ProcVersionSign
Uname: Linux 3.19.0-16-generic x86_64
NonfreeKernelMo
ApportVersion: 2.17.2-0ubuntu1
Architecture: amd64
CurrentDesktop: KDE
Date: Sun May 17 13:11:00 2015
Dependencies:
gcc-5-base 5.1~rc1-0ubuntu1
libc6 2.21-0ubuntu4
libgcc1 1:5.1~rc1-0ubuntu1
multiarch-support 2.21-0ubuntu4
SourcePackage: libusb
UpgradeStatus: Upgraded to vivid on 2015-04-26 (21 days ago)