Skip to contentSkip to conversation

USB: Avoid PM error messages during resume if a device was disconnected

PATCH In review Rafael J. Wysocki 2 participants 3 messages Jun 4, 2009 USB

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 USB: Avoid PM error messages during resume if a device was disconnected

From: Frans Pop <[email protected]>

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

---
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(-)
drivers/usb/core/driver.c +9 -1
Index: 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 */
#1 lore raw
Quoted 21 lines · Rafael J. Wysocki

From: Frans Pop <[email protected]>

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

Quoted 8 lines

---
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.

I've now queued it up in my usb tree, as that is probably the best place for it.

thanks,

greg k-h

#2 lore raw
In reply to Rafael J. Wysocki
Quoted 21 lines · Rafael J. Wysocki

From: Frans Pop <[email protected]>

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

Quoted 8 lines

---
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.

I've now queued it up in my usb tree, as that is probably the best place for it.

thanks,

greg k-h