Skip to contentSkip to conversation

USB :core :Prevent USB devices to autosuspend while setting interface

PATCH In review [email protected] 3 participants 3 messages Nov 10, 2017 USB

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 USB :core :Prevent USB devices to autosuspend while setting interface

From: Abhijeet Kumar <[email protected]>

Runtime resume USB device in order to ensure that PM framework knows that the we might be using the device in a short time and doesn't autosuspend the device while we update it's interface. Without this change, if device autosuspends and the kernel polling for block devices is disabled through sysfs at runtime or through bootargs, then storage devices might never unmount since the disconnect IRQ wont be kicked at all.

---
 drivers/usb/core/message.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/usb/core/message.c +5 -0
index 371a07d874a3..54a9accf88cb 100644
@@ -1305,6 +1305,11 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
 	if (iface->unregistering)
 		return -ENODEV;
 
+	/*Letting runtime PM know that we wish to use the device in a
+	 * short time.
+	 */
+	pm_runtime_get(&iface->dev);
+
 	alt = usb_altnum_to_altsetting(iface, alternate);
 	if (!alt) {
 		dev_warn(&dev->dev, "selecting invalid altsetting %d\n",
Signature · 1 line
1.9.1
#1 lore raw
Quoted 20 lines · On Fri, Nov 10, 2017 at 09:32:07PM +0530, [email protected] wrote:

From: Abhijeet Kumar <[email protected]>

Runtime resume USB device in order to ensure that PM framework knows that the we might be using the device in a short time and doesn't autosuspend the device while we update it's interface. Without this change, if device autosuspends and the kernel polling for block devices is disabled through sysfs at runtime or through bootargs, then storage devices might never unmount since the disconnect IRQ wont be kicked at all.

---
 drivers/usb/core/message.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/usb/core/message.c +0 -0
index 371a07d874a3..54a9accf88cb 100644

drivers/usb/core/message.c int usb_set_interface(struct usb_device *dev, int interface, int alternate) · line 1310

Quoted 6 lines
drivers/usb/core/message.c +3 -0
@@ -1305,6 +1305,11 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
 	if (iface->unregistering)
 		return -ENODEV;
 
+	/*Letting runtime PM know that we wish to use the device in a
+	 * short time.
+	 */

Please place comments int the correct style.

drivers/usb/core/message.c int usb_set_interface(struct usb_device *dev, int interface, int alternate) · line 1312

Quoted 2 lines
drivers/usb/core/message.c +2 -0
+	pm_runtime_get(&iface->dev);
+

No dropping of the pm_runtime when we are finished?

This feels really wrong to me...

greg k-h

#2 lore raw
In reply to [email protected]
Quoted 11 lines · On Fri, 10 Nov 2017 [email protected] wrote:

From: Abhijeet Kumar <[email protected]>

Runtime resume USB device in order to ensure that PM framework knows that the we might be using the device in a short time and doesn't autosuspend the device while we update it's interface. Without this change, if device autosuspends and the kernel polling for block devices is disabled through sysfs at runtime or through bootargs, then storage devices might never unmount since the disconnect IRQ wont be kicked at all.

I don't see any reason for doing this. The places that call this subroutine will already have made sure that the device is active. There's no need for an additional runtime_get.

As for disconnect IRQs, they occur whether the device is suspended or not (they are generated by the host controller, not by the device).

Alan Stern