[RFC 1/7] usb: Always return 0 or -EBUSY to the runtime PM core.

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Sarah Sharp
Date: Thursday, December 30, 2010 - 4:21 pm

The PM core reacts badly when the return code from usb_runtime_suspend()
is not 0, -EAGAIN, or -EBUSY.  The PM core regards this as a fatal error,
and refuses to run anymore PM helper functions.  In particular,
usbfs_open() and other usbfs functions will fail because the PM core will
return an error code when usb_autoresume_device() is called.  This causes
libusb and/or lsusb to either hang or segfault.

If a USB device cannot suspend for some reason (e.g. a hub doesn't report
it has remote wakeup capabilities), we still want lsusb and other
userspace programs to work.  So return -EBUSY, which will fill people's
log files with failed tries, but will ensure userspace still works.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
---
 drivers/usb/core/driver.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index b9278a1..a6d9297 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -1660,6 +1660,11 @@ static int usb_runtime_suspend(struct device *dev)
 		return -EAGAIN;
 
 	status = usb_suspend_both(udev, PMSG_AUTO_SUSPEND);
+	/* The PM core reacts badly core unless the return code is 0,
+	 * -EAGAIN, or -EBUSY, so always return -EBUSY on an error.
+	 */
+	if (status != 0)
+		return -EBUSY;
 	return status;
 }
 
-- 
1.6.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[RFC 0/7] Misc USB and xHCI fixes for 2.6.38, Sarah Sharp, (Thu Dec 30, 4:21 pm)
[RFC 1/7] usb: Always return 0 or -EBUSY to the runtime PM ..., Sarah Sharp, (Thu Dec 30, 4:21 pm)
[RFC 2/7] xhci: Remove old no-op test., Sarah Sharp, (Thu Dec 30, 4:22 pm)
[RFC 4/7] USB: Remove bitmap #define from hcd.h, Sarah Sharp, (Thu Dec 30, 4:22 pm)
[RFC 5/7] USB: Fix usb_add_hcd() checkpatch errors., Sarah Sharp, (Thu Dec 30, 4:22 pm)