From 0d74da8302d492dbb5922ff128c0b351d0b69d72 Mon Sep 17 00:00:00 2001 From: William Wu Date: Fri, 26 May 2017 11:54:15 +0800 Subject: [PATCH] usb: dwc_otg_310: fix reboot test fail in otg host mode When do reboot test with otg cable plugging in, it may casue two issues: 1. system hung when access grstctl reg in dwc_otg_core_reset(); 2. kernel panic when remove the host channel from the free list in assign_and_init_hc(). This patch adds 1.5~2ms delay afer resume USB2 PHY, the time for utmi_clk provided from USB2 PHY to stabilize, and then we can access the usb core registers safely, it can avoid system hung. Also, we avoid to call otg20_hcd_connect_detect() if dwc2 is host mode except force host mode during probe, because we will do the same work in check_id_work() later. This can fix the issue that init usb core and host twice when boot with otg cable and usb device, which may cause kernel panic because of hc list is NULL. Change-Id: I35aa36762c64b14b580b493d213610379676ab56 Signed-off-by: William Wu --- drivers/usb/dwc_otg_310/dwc_otg_hcd_linux.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/dwc_otg_310/dwc_otg_hcd_linux.c b/drivers/usb/dwc_otg_310/dwc_otg_hcd_linux.c index d5451f09e4b5..40a446a140a1 100644 --- a/drivers/usb/dwc_otg_310/dwc_otg_hcd_linux.c +++ b/drivers/usb/dwc_otg_310/dwc_otg_hcd_linux.c @@ -442,6 +442,7 @@ static void otg20_hcd_connect_detect(struct work_struct *work) if (pldata->phy_status == USB_PHY_SUSPEND) { pldata->clock_enable(pldata, 1); pldata->phy_suspend(pldata, USB_PHY_ENABLED); + usleep_range(1500, 2000); } dwc_otg_core_init(core_if); dwc_otg_enable_global_interrupts(core_if); @@ -527,11 +528,10 @@ int otg20_hcd_init(struct platform_device *_dev) dwc_otg_hcd_set_priv_data(dwc_otg_hcd, hcd); dwc_otg_hcd->host_enabled = 1; - if (dwc_otg_is_host_mode(otg_dev->core_if) || - (otg_dev->core_if->usb_mode == USB_MODE_FORCE_HOST)) { + if (otg_dev->core_if->usb_mode == USB_MODE_FORCE_HOST) { INIT_DELAYED_WORK(&dwc_otg_hcd->host_enable_work, otg20_hcd_connect_detect); - schedule_delayed_work(&dwc_otg_hcd->host_enable_work, 0); + schedule_delayed_work(&dwc_otg_hcd->host_enable_work, HZ); } return 0; -- 2.34.1