usb: dwc3-msm: fix possible race condition when data role swapping
Commit a92b616a86a4("usb: dwc3-msm: Switch to freezable workqueue
for sm_work") introduced a freezable workqueue for running
the work sm_work.
But commit 098765bb87de("usb: dwc3-msm: Ensure hardware is reset
during role change") enqueued sm_work into another workqueue
and made it possible for sm_work to be performed by two threads
concurrently.
Bug: 179232088
Change-Id: I5823788706e3ca69dbd3b3a2b6527972ff8139aa
Signed-off-by: Ricky Niu <rickyniu@google.com>
diff --git a/drivers/usb/dwc3/dwc3-msm.c b/drivers/usb/dwc3/dwc3-msm.c
index e96ce35..c39e9a4 100644
--- a/drivers/usb/dwc3/dwc3-msm.c
+++ b/drivers/usb/dwc3/dwc3-msm.c
@@ -2702,7 +2702,7 @@ static int dwc3_msm_suspend(struct dwc3_msm *mdwc, bool hibernation)
/* kick_sm if it is waiting for lpm sequence to finish */
if (test_and_clear_bit(WAIT_FOR_LPM, &mdwc->inputs))
- schedule_delayed_work(&mdwc->sm_work, 0);
+ queue_delayed_work(system_freezable_wq, &mdwc->sm_work, 0);
mutex_unlock(&mdwc->suspend_resume_mutex);