usb: dwc3: Prevent deadlock when wakeup happens through pwr event irq

Consider a scenario when a device which supports auto suspend is
connected to DUT and auto suspend happened. Now, as the device is
disconnected to DUT. Resume_work is called due to extcon notification
of disconnect and then again suspend is expected to schedule. As
a part of disconnect, pwr event irq and DP_HS_PHY_IRQ also got
triggered and now since usb is in lpm, resume work got scheduled
twice. This resume work flushed sm_work which is stuck because
disable_irq call is waiting for pwr_irq call which called resume_work
to complete. This is clearly a circular dependency because
resume work will flush sm_work which is waiting for pwr_irq_thread
to be complete because disable_irq in msm_suspend waits for
pwr_irq_handler to complete.

Solve this by replacing disable_irq api with disable_irq_nosync
so that it doesn't block control suspend.

Below are the sequence of events.

	usb is auto suspended with device connected to DUT.

	Now device is disconnected from DUT and hence resume
	hanppens first and then suspend.

	dwc3_resume_work is called due to extcon as a part of
	disconnect then suspend will be scheduled.

	When dwc3 is still in lpm, i.e dwc3_resume_work did
	not take effect yet.

	Now power event irq is fired because of which resume
	work runs.

	This resume work flushes sm work. Which is currently
	executing msm_suspend where disable_irq is waiting
	for power_irq call to finish which is waiting for
	sm_work to finish.

Change-Id: Ibf6e73663d4acaf997291e7eff6577adeaad6e8a
Signed-off-by: Rohith Kollalsi <quic_rkollals@quicinc.com>
This commit is contained in:
Rohith Kollalsi 2021-10-19 23:03:40 +05:30
parent d16f8f0f02
commit 93f8a37113

View file

@ -2558,7 +2558,7 @@ static int dwc3_msm_suspend(struct dwc3_msm *mdwc, bool force_power_collapse)
dbg_event(0xFF, "pend evt", 0);
/* disable power event irq, hs and ss phy irq is used as wake up src */
disable_irq(mdwc->wakeup_irq[PWR_EVNT_IRQ].irq);
disable_irq_nosync(mdwc->wakeup_irq[PWR_EVNT_IRQ].irq);
dwc3_set_phy_speed_flags(mdwc);
/* Suspend HS PHY */