]> git.baikalelectronics.ru Git - kernel.git/commitdiff
USB: core: Disable remote wakeup for freeze/quiesce
authorEvan Green <evgreen@chromium.org>
Thu, 21 Apr 2022 17:39:26 +0000 (10:39 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 Apr 2022 08:33:52 +0000 (10:33 +0200)
The PM_EVENT_FREEZE and PM_EVENT_QUIESCE messages should cause the
device to stop generating interrupts. USB core was previously allowing
devices that were already runtime suspended to keep remote wakeup
enabled if they had gone down that way. This violates the contract with
pm, and can potentially cause MSI interrupts to be lost.

Change that so that if a device is runtime suspended with remote wakeups
enabled, it will be resumed to ensure remote wakeup is always disabled
across a freeze.

Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Evan Green <evgreen@chromium.org>
Link: https://lore.kernel.org/r/20220421103751.v3.1.I2c636c4decc358f5e6c27b810748904cc69beada@changeid
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/core/driver.c

index 355ed33a21792bab25e02b7dc5845d36eda96937..b87452e228353d12adb502701dd9da9e3d30badc 100644 (file)
@@ -1533,22 +1533,23 @@ static void choose_wakeup(struct usb_device *udev, pm_message_t msg)
 {
        int     w;
 
-       /* Remote wakeup is needed only when we actually go to sleep.
-        * For things like FREEZE and QUIESCE, if the device is already
-        * autosuspended then its current wakeup setting is okay.
+       /*
+        * For FREEZE/QUIESCE, disable remote wakeups so no interrupts get
+        * generated.
         */
        if (msg.event == PM_EVENT_FREEZE || msg.event == PM_EVENT_QUIESCE) {
-               if (udev->state != USB_STATE_SUSPENDED)
-                       udev->do_remote_wakeup = 0;
-               return;
-       }
+               w = 0;
 
-       /* Enable remote wakeup if it is allowed, even if no interface drivers
-        * actually want it.
-        */
-       w = device_may_wakeup(&udev->dev);
+       } else {
+               /*
+                * Enable remote wakeup if it is allowed, even if no interface
+                * drivers actually want it.
+                */
+               w = device_may_wakeup(&udev->dev);
+       }
 
-       /* If the device is autosuspended with the wrong wakeup setting,
+       /*
+        * If the device is autosuspended with the wrong wakeup setting,
         * autoresume now so the setting can be changed.
         */
        if (udev->state == USB_STATE_SUSPENDED && w != udev->do_remote_wakeup)