Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

USB: core: Disable remote wakeup for freeze/quiesce

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>

authored by

Evan Green and committed by
Greg Kroah-Hartman
9671d550 a03e2dda

+13 -12
+13 -12
drivers/usb/core/driver.c
··· 1533 1533 { 1534 1534 int w; 1535 1535 1536 - /* Remote wakeup is needed only when we actually go to sleep. 1537 - * For things like FREEZE and QUIESCE, if the device is already 1538 - * autosuspended then its current wakeup setting is okay. 1536 + /* 1537 + * For FREEZE/QUIESCE, disable remote wakeups so no interrupts get 1538 + * generated. 1539 1539 */ 1540 1540 if (msg.event == PM_EVENT_FREEZE || msg.event == PM_EVENT_QUIESCE) { 1541 - if (udev->state != USB_STATE_SUSPENDED) 1542 - udev->do_remote_wakeup = 0; 1543 - return; 1541 + w = 0; 1542 + 1543 + } else { 1544 + /* 1545 + * Enable remote wakeup if it is allowed, even if no interface 1546 + * drivers actually want it. 1547 + */ 1548 + w = device_may_wakeup(&udev->dev); 1544 1549 } 1545 1550 1546 - /* Enable remote wakeup if it is allowed, even if no interface drivers 1547 - * actually want it. 1548 - */ 1549 - w = device_may_wakeup(&udev->dev); 1550 - 1551 - /* If the device is autosuspended with the wrong wakeup setting, 1551 + /* 1552 + * If the device is autosuspended with the wrong wakeup setting, 1552 1553 * autoresume now so the setting can be changed. 1553 1554 */ 1554 1555 if (udev->state == USB_STATE_SUSPENDED && w != udev->do_remote_wakeup)