public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: dwc2: exit clock_gating when stopping udc caused deadlock
@ 2026-03-10  8:00 xiaoxiao_li
  2026-03-11 14:17 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: xiaoxiao_li @ 2026-03-10  8:00 UTC (permalink / raw)
  To: hminas, gregkh; +Cc: linux-usb, linux-kernel, xiaoxiao_li

dwc2_gadget_exit_clock_gating invoke call_gadget to hold hsotg->lock,
causing dwc2_hsotg_ep_disable_lock unable to acquire the lock,
lead to a deadlock.

To ensure that enabling clock gating before stopping UDC does not
cause the deadlock, we lock exit_clock_gating using
spin_lock_irqsave and spin_unlock_irqrestore.

Signed-off-by: xiaoxiao_li <lxxstone@gmail.com>
---
 drivers/usb/dwc2/gadget.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index d216e26c7..c8b02c27d 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -4607,7 +4607,9 @@ static int dwc2_hsotg_udc_stop(struct usb_gadget *gadget)
 	/* Exit clock gating when driver is stopped. */
 	if (hsotg->params.power_down == DWC2_POWER_DOWN_PARAM_NONE &&
 	    hsotg->bus_suspended && !hsotg->params.no_clock_gating) {
+		spin_lock_irqsave(&hsotg->lock, flags);
 		dwc2_gadget_exit_clock_gating(hsotg, 0);
+		spin_unlock_irqrestore(&hsotg->lock, flags);
 	}
 
 	/* all endpoints should be shutdown */
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-03-11 14:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-10  8:00 [PATCH] usb: dwc2: exit clock_gating when stopping udc caused deadlock xiaoxiao_li
2026-03-11 14:17 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox