public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] USB: Avoid PM error messages during resume if a device was disconnected
@ 2009-06-04 20:30 Rafael J. Wysocki
  2009-06-04 21:02 ` Greg KH
  0 siblings, 1 reply; 9+ messages in thread
From: Rafael J. Wysocki @ 2009-06-04 20:30 UTC (permalink / raw)
  To: Greg KH; +Cc: Alan Stern, Frans Pop, pm list, LKML, linux-usb

From: Frans Pop <elendil@planet.nl>

Currently if a laptop is suspended e.g. while docked and then resumed after
undocking it, the following errors get generated because the USB hub in the
docking station and the devices connected to it are no longer available:
pm_op(): usb_dev_resume+0x0/0x10 returns -19
PM: Device 1-2 failed to resume: error -19
pm_op(): usb_dev_resume+0x0/0x10 returns -19
PM: Device 1-2.2 failed to resume: error -19
pm_op(): usb_dev_resume+0x0/0x10 returns -19
PM: Device 1-2.3 failed to resume: error -19

As the removal of USB devices while a system is suspended is a relatively
common use case and in most cases not an error, just return success on
-ENODEV. The user gets informed anyway as the USB subsystem generates
regular disconnect messages for the devices shortly afterwards:
usb 1-2: USB disconnect, address 3
usb 1-2.2: USB disconnect, address 4
usblp0: removed
usb 1-2.3: USB disconnect, address 5

Signed-off-by: Frans Pop <elendil@planet.nl>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
Hi Greg,

I can take this patch to the suspend tree, but if you think it should go
through USB, please consider including it into the 2.6.31 push.

Best,
Rafael
---
 drivers/usb/core/driver.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Index: linux-2.6/drivers/usb/core/driver.c
===================================================================
--- linux-2.6.orig/drivers/usb/core/driver.c
+++ linux-2.6/drivers/usb/core/driver.c
@@ -1762,6 +1762,7 @@ int usb_suspend(struct device *dev, pm_m
 int usb_resume(struct device *dev, pm_message_t msg)
 {
 	struct usb_device	*udev;
+	int			status;
 
 	udev = to_usb_device(dev);
 
@@ -1771,7 +1772,14 @@ int usb_resume(struct device *dev, pm_me
 	 */
 	if (udev->skip_sys_resume)
 		return 0;
-	return usb_external_resume_device(udev, msg);
+	status = usb_external_resume_device(udev, msg);
+
+	/* Avoid PM error messages for devices disconnected while suspended
+	 * as we'll display regular disconnect messages just a bit later.
+	 */
+	if (status == -ENODEV)
+		return 0;
+	return status;
 }
 
 #endif /* CONFIG_PM */

^ permalink raw reply	[flat|nested] 9+ messages in thread
* [PATCH] usb: avoid PM error messages during resume if a device was disconnected
@ 2009-03-23 21:11 Frans Pop
  2009-03-23 21:30 ` Frans Pop
  2009-03-23 21:44 ` Alan Stern
  0 siblings, 2 replies; 9+ messages in thread
From: Frans Pop @ 2009-03-23 21:11 UTC (permalink / raw)
  To: linux-usb
  Cc: Alan Stern, Rafael J. Wysocki, linux-pm,
	Linux Kernel Mailing List

Currently if a laptop is suspended e.g. while docked and then resumed after
undocking it, the following errors get generated because the USB hub in the
docking station and the devices connected to it are no longer available:
pm_op(): usb_dev_resume+0x0/0x10 returns -19
PM: Device 1-2 failed to resume: error -19
pm_op(): usb_dev_resume+0x0/0x10 returns -19
PM: Device 1-2.2 failed to resume: error -19
pm_op(): usb_dev_resume+0x0/0x10 returns -19
PM: Device 1-2.3 failed to resume: error -19

As the removal of USB devices while a system is suspended is a relatively
common use case and in most cases not an error, just return success on
-ENODEV. The user gets informed anyway as the USB subsystem generates
regular disconnect messages for the devices shortly afterwards:
usb 1-2: USB disconnect, address 3
usb 1-2.2: USB disconnect, address 4
usblp0: removed
usb 1-2.3: USB disconnect, address 5

Signed-off-by: Frans Pop <elendil@planet.nl>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Rafael J. Wysocki <rjw@sisk.pl>
---

I've walked through the code and AFAICT just returning 0 does not make any
difference for the PM core code.

In a first version of this patch I had the following included just before
the 'return 0':
	pr_info("usb %s: failed to resume: no longer connected\n",
						dev_name(&udev->dev));

Problem with that was that the message got printed twice for each device,
once for .resume and once for .complete. Given that the disconnects are
reported shortly after anyway, I decided the simpler patch might do just
as well.

Cheers,
FJP

diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index d0a21a5..97ea69b 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -1727,6 +1727,10 @@ int usb_external_resume_device(struct usb_device *udev, pm_message_t msg)
 	status = usb_resume_both(udev, msg);
 	udev->last_busy = jiffies;
 	usb_pm_unlock(udev);
+
+	if (status == -ENODEV)
+		return 0;
+
 	if (status == 0)
 		do_unbind_rebind(udev, DO_REBIND);
 

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2009-06-04 21:42 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-04 20:30 [PATCH] USB: Avoid PM error messages during resume if a device was disconnected Rafael J. Wysocki
2009-06-04 21:02 ` Greg KH
  -- strict thread matches above, loose matches on Subject: below --
2009-03-23 21:11 [PATCH] usb: avoid " Frans Pop
2009-03-23 21:30 ` Frans Pop
2009-03-23 21:44 ` Alan Stern
2009-03-23 22:25   ` Frans Pop
2009-03-24 14:11     ` Alan Stern
2009-06-02 21:26       ` Rafael J. Wysocki
2009-06-02 21:48         ` Alan Stern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox