]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
usb: core: hub: fix race condition about TRSMRCY of resume
authorChunfeng Yun <chunfeng.yun@mediatek.com>
Wed, 12 May 2021 02:07:38 +0000 (10:07 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 May 2021 08:08:31 +0000 (10:08 +0200)
commit 975f94c7d6c306b833628baa9aec3f79db1eb3a1 upstream.

This may happen if the port becomes resume status exactly
when usb_port_resume() gets port status, it still need provide
a TRSMCRY time before access the device.

CC: <stable@vger.kernel.org>
Reported-by: Tianping Fang <tianping.fang@mediatek.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Link: https://lore.kernel.org/r/20210512020738.52961-1-chunfeng.yun@mediatek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/core/hub.c

index cd61860cada5ed0f62f034e5c385bd340deda99c..6c89d714adb623daa3e1299272e77b3e75f02a30 100644 (file)
@@ -3574,9 +3574,6 @@ int usb_port_resume(struct usb_device *udev, pm_message_t msg)
                 * sequence.
                 */
                status = hub_port_status(hub, port1, &portstatus, &portchange);
-
-               /* TRSMRCY = 10 msec */
-               msleep(10);
        }
 
  SuspendCleared:
@@ -3591,6 +3588,9 @@ int usb_port_resume(struct usb_device *udev, pm_message_t msg)
                                usb_clear_port_feature(hub->hdev, port1,
                                                USB_PORT_FEAT_C_SUSPEND);
                }
+
+               /* TRSMRCY = 10 msec */
+               msleep(10);
        }
 
        if (udev->persist_enabled)