Public bug reported:

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)

** Affects: libusb (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: amd64 apport-bug vivid

** Patch added: "12_hung_after_resume.diff"
   
https://bugs.launchpad.net/bugs/1455924/+attachment/4398983/+files/12_hung_after_resume.diff

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1455924

Title:
  libusb occasionally hungs after suspend/resume

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/libusb/+bug/1455924/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to