Skip to content

Commit 3ddaa6a

Browse files
Elson Roy Serraogregkh
authored andcommitted
usb: dwc3: Properly handle processing of pending events
If dwc3 is runtime suspended we defer processing the event buffer until resume, by setting the pending_events flag. Set this flag before triggering resume to avoid race with the runtime resume callback. While handling the pending events, in addition to checking the event buffer we also need to process it. Handle this by explicitly calling dwc3_thread_interrupt(). Also balance the runtime pm get() operation that triggered this processing. Cc: stable@vger.kernel.org Fixes: fc8bb91 ("usb: dwc3: implement runtime PM") Signed-off-by: Elson Roy Serrao <quic_eserrao@quicinc.com> Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com> Reviewed-by: Roger Quadros <rogerq@kernel.org> Link: https://lore.kernel.org/r/20230801192658.19275-1-quic_eserrao@quicinc.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a6ff6e7 commit 3ddaa6a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drivers/usb/dwc3/gadget.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4455,9 +4455,14 @@ static irqreturn_t dwc3_check_event_buf(struct dwc3_event_buffer *evt)
44554455
u32 count;
44564456

44574457
if (pm_runtime_suspended(dwc->dev)) {
4458+
dwc->pending_events = true;
4459+
/*
4460+
* Trigger runtime resume. The get() function will be balanced
4461+
* after processing the pending events in dwc3_process_pending
4462+
* events().
4463+
*/
44584464
pm_runtime_get(dwc->dev);
44594465
disable_irq_nosync(dwc->irq_gadget);
4460-
dwc->pending_events = true;
44614466
return IRQ_HANDLED;
44624467
}
44634468

@@ -4718,6 +4723,8 @@ void dwc3_gadget_process_pending_events(struct dwc3 *dwc)
47184723
{
47194724
if (dwc->pending_events) {
47204725
dwc3_interrupt(dwc->irq_gadget, dwc->ev_buf);
4726+
dwc3_thread_interrupt(dwc->irq_gadget, dwc->ev_buf);
4727+
pm_runtime_put(dwc->dev);
47214728
dwc->pending_events = false;
47224729
enable_irq(dwc->irq_gadget);
47234730
}

0 commit comments

Comments
 (0)