From f38ab909f02ed1b9bae7f70d195ec6f14e076acf Mon Sep 17 00:00:00 2001 From: lyz Date: Mon, 19 Jan 2015 19:17:37 +0800 Subject: [PATCH] usb: dwc_otg: double check disconnect state when otg state changed When otg stop host mode and before change to device mode hcd_stop function should do something to double check all usb device is disconnect because the disconnect interrupt might be lost. 1.kill all active urbs attached to this hcd 2.set hcd->flags to notify usb core to disconnect all usb devices Signed-off-by: lyz --- drivers/usb/dwc_otg_310/dwc_otg_hcd.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc_otg_310/dwc_otg_hcd.c b/drivers/usb/dwc_otg_310/dwc_otg_hcd.c index 9bde3ba4da05..451424e84204 100755 --- a/drivers/usb/dwc_otg_310/dwc_otg_hcd.c +++ b/drivers/usb/dwc_otg_310/dwc_otg_hcd.c @@ -471,8 +471,9 @@ void dwc_otg_hcd_stop(dwc_otg_hcd_t *hcd) { hprt0_data_t hprt0 = {.d32 = 0 }; struct dwc_otg_platform_data *pldata; - pldata = hcd->core_if->otg_dev->pldata; + dwc_irqflags_t flags; + pldata = hcd->core_if->otg_dev->pldata; DWC_DEBUGPL(DBG_HCD, "DWC OTG HCD STOP\n"); /* @@ -480,6 +481,15 @@ void dwc_otg_hcd_stop(dwc_otg_hcd_t *hcd) * The disconnect will clear the QTD lists (via ..._hcd_urb_dequeue) * and the QH lists (via ..._hcd_endpoint_disable). */ + DWC_SPINLOCK_IRQSAVE(hcd->lock, &flags); + kill_all_urbs(hcd); + DWC_SPINUNLOCK_IRQRESTORE(hcd->lock, flags); + + /* + * Set status flags for the hub driver. + */ + hcd->flags.b.port_connect_status_change = 1; + hcd->flags.b.port_connect_status = 0; /* Turn off all host-specific interrupts. */ dwc_otg_disable_host_interrupts(hcd->core_if); -- 2.34.1