diff mbox

usbhid: correct PM failure with closed devices

Message ID 1429103925-31304-1-git-send-email-oneukum@suse.de (mailing list archive)
State New, archived
Delegated to: Jiri Kosina
Headers show

Commit Message

Oliver Neukum April 15, 2015, 1:18 p.m. UTC
When usbhid closes a device which was awake only because remote
wakeup was required but not provided, the interface must go through
a get/put cycle or the core will never reattempt to suspend the device.
This brakes runtime PM for all joysticks.

Signed-off-by: Oliver Neukum <oneukum@suse.de>
---
 drivers/hid/usbhid/hid-core.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Alan Stern April 15, 2015, 2:56 p.m. UTC | #1
On Wed, 15 Apr 2015, Oliver Neukum wrote:

> When usbhid closes a device which was awake only because remote
> wakeup was required but not provided, the interface must go through
> a get/put cycle or the core will never reattempt to suspend the device.
> This brakes runtime PM for all joysticks.
> 
> Signed-off-by: Oliver Neukum <oneukum@suse.de>

This seems reasonable, although it would be nice if there was a way to 
do this without waking up the device if it was already in runtime 
suspend.  Perhaps make the get/put conditional on 
pm_runtime_active(&usbhid->intf->dev)?  It's okay to do the get/put 
cycle after setting needs_remote_wakeup to 0.

By the way, how does the HID core handle the case where the device file 
is closed long after the device has disconnected?

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index bfbe1be..63d1f0f 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -734,7 +734,15 @@  void usbhid_close(struct hid_device *hid)
 		hid_cancel_delayed_stuff(usbhid);
 		if (!(hid->quirks & HID_QUIRK_ALWAYS_POLL)) {
 			usb_kill_urb(usbhid->urbin);
+			/*
+			 * We need a put on the interface to force
+			 * a recheck needed in case only a lack
+			 * of capability to do remote wakeup
+			 * kept us awake
+			 */
+			usb_autopm_get_interface(usbhid->intf);
 			usbhid->intf->needs_remote_wakeup = 0;
+			usb_autopm_put_interface(usbhid->intf);
 		}
 	} else {
 		spin_unlock_irq(&usbhid->lock);