Skip to content

Commit 3c7af52

Browse files
Wesley Chenggregkh
authored andcommitted
usb: dwc3: gadget: Queue PM runtime idle on disconnect event
There is a scenario where DWC3 runtime suspend is blocked due to the dwc->connected flag still being true while PM usage_count is zero after DWC3 giveback is completed and the USB gadget session is being terminated. This leads to a case where nothing schedules a PM runtime idle for the device. The exact condition is seen with the following sequence: 1. USB bus reset is issued by the host 2. Shortly after, or concurrently, a USB PD DR SWAP request is received (sink->source) 3. USB bus reset event handler runs and issues dwc3_stop_active_transfers(), and pending transfer are stopped 4. DWC3 usage_count decremented to 0, and runtime idle occurs while dwc->connected == true, returns -EBUSY 5. DWC3 disconnect event seen, dwc->connected set to false due to DR swap handling 6. No runtime idle after this point Address this by issuing an asynchronous PM runtime idle call after the disconnect event is completed, as it modifies the dwc->connected flag, which is what blocks the initial runtime idle. Fixes: fc8bb91 ("usb: dwc3: implement runtime PM") Cc: <stable@vger.kernel.org> Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com> Link: https://lore.kernel.org/r/20240103214946.2596-1-quic_wcheng@quicinc.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ff2b89d commit 3c7af52

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/usb/dwc3/gadget.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3989,6 +3989,13 @@ static void dwc3_gadget_disconnect_interrupt(struct dwc3 *dwc)
39893989
usb_gadget_set_state(dwc->gadget, USB_STATE_NOTATTACHED);
39903990

39913991
dwc3_ep0_reset_state(dwc);
3992+
3993+
/*
3994+
* Request PM idle to address condition where usage count is
3995+
* already decremented to zero, but waiting for the disconnect
3996+
* interrupt to set dwc->connected to FALSE.
3997+
*/
3998+
pm_request_idle(dwc->dev);
39923999
}
39934000

39944001
static void dwc3_gadget_reset_interrupt(struct dwc3 *dwc)

0 commit comments

Comments
 (0)