[lkml]   [2018]   [Apr]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH 4.9 049/102] usb: dwc2: Improve gadget state disconnection handling
4.9-stable review patch.  If anyone has any objections, please let me know.


From: John Stultz <>

commit d2471d4a24dfbff5e463d382e2c6fec7d7e25a09 upstream.

In the earlier commit dad3f793f20f ("usb: dwc2: Make sure we
disconnect the gadget state"), I was trying to fix up the
fact that we somehow weren't disconnecting the gadget state,
so that when the OTG port was plugged in the second time we
would get warnings about the state tracking being wrong.

(This seems to be due to a quirk of the HiKey board where
we do not ever get any otg interrupts, particularly the session
end detected signal. Instead we only see status change

The fix there was somewhat simple, as it just made sure to
call dwc2_hsotg_disconnect() before we connected things up
in OTG mode, ensuring the state handling didn't throw errors.

But in looking at a different issue I was seeing with UDC
state handling, I realized that it would be much better
to call dwc2_hsotg_disconnect when we get the state change
signal moving to host mode.

Thus, this patch removes the earlier disconnect call I added
and moves it (and the needed locking) to the host mode

Cc: Wei Xu <>
Cc: Guodong Xu <>
Cc: Amit Pundir <>
Cc: YongQin Liu <>
Cc: John Youn <>
Cc: Minas Harutyunyan <>
Cc: Douglas Anderson <>
Cc: Chen Yu <>
Cc: Felipe Balbi <>
Cc: Greg Kroah-Hartman <>
Acked-by: Minas Harutyunyan <>
Tested-by: Minas Harutyunyan <>
Signed-off-by: John Stultz <>
Signed-off-by: Felipe Balbi <>
Cc: Ben Hutchings <>
Signed-off-by: Greg Kroah-Hartman <>

drivers/usb/dwc2/hcd.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -3220,7 +3220,6 @@ static void dwc2_conn_id_status_change(s
dwc2_core_init(hsotg, false);
spin_lock_irqsave(&hsotg->lock, flags);
- dwc2_hsotg_disconnect(hsotg);
dwc2_hsotg_core_init_disconnected(hsotg, false);
spin_unlock_irqrestore(&hsotg->lock, flags);
@@ -3238,8 +3237,12 @@ static void dwc2_conn_id_status_change(s
if (count > 250)
"Connection id status change timed out\n");
- hsotg->op_state = OTG_STATE_A_HOST;

+ spin_lock_irqsave(&hsotg->lock, flags);
+ dwc2_hsotg_disconnect(hsotg);
+ spin_unlock_irqrestore(&hsotg->lock, flags);
+ hsotg->op_state = OTG_STATE_A_HOST;
/* Initialize the Core for Host mode */
dwc2_core_init(hsotg, false);

 \ /
  Last update: 2018-04-06 16:43    [W:0.221 / U:0.612 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site