From fb771ab91a6afc7abae77922aa13d52fb443d377 Mon Sep 17 00:00:00 2001 From: William Wu Date: Wed, 27 Sep 2017 10:32:21 +0800 Subject: [PATCH] USB: workaround for specified USB3 PHY disconnection det issue Some special SoCs (e.g. rk322xh) USB3 PHY have problem to detect disconnection, they lose the ability to detect an absence of Rx termination specified in USB3 spec Table 6-21, fortunately, the USB3 PHY can detect port link state change when USB3 device is unplugged, so we can do soft disconnect according to the PLC. Change-Id: I2cbd62fddc8a1f9c5a264d705db43fb0cf3e035c Signed-off-by: William Wu Signed-off-by: Frank Wang --- drivers/usb/core/hub.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 5b96c4256c40..8d0676313f35 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -5028,7 +5028,24 @@ static void port_event(struct usb_hub *hub, int port1) } else { usb_unlock_port(port_dev); usb_lock_device(udev); - usb_reset_device(udev); + + /** + * Some special SoCs (e.g. rk322xh) USB3 PHY lose the + * ability to detect a disconnection when USB3 device + * plug out, fortunately, it can detect port link state + * change here, so we can do soft disconnect according + * to the PLC here. + * + * And we only need to do the soft disconnect for root + * hub. In addition, we just reuse the autosuspend quirk + * but not add a new quirk for this issue. Because this + * issue always occurs with autosuspend problem. + */ + if (!hub->hdev->parent && (hdev->quirks & + USB_QUIRK_AUTO_SUSPEND)) + usb_remove_device(udev); + else + usb_reset_device(udev); usb_unlock_device(udev); usb_lock_port(port_dev); connect_change = 0;