Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1873f86a authored by Mayank Rana's avatar Mayank Rana
Browse files

dwc3-msm: Fix race condition between USB PM suspend and cable connect



dwc3_msm_pm_suspend() is racing against USB cable connect as below:
- Device is power collapse. On connecting USB cable, APPS is resumed and
SMB charger driver is receiving interrupt while Linux power framework
calls each registered peripherals' driver PM resume, and it agains tries
to go into suspend as SMB charger doesn't probably hold wakelock or there
is more interrupt latency in terms of smb charger driver's ISR is called.
- dwc3_msm_pm_resume() schedules resume work. resume_work() is queued but
it is not running.
- Since autosleep is enabled and no wakeup source have yet been taken,
the system will immediately attempt to re-enter PM suspend. Hence USB PM
suspend routine dwc3_msm_pm_suspend() is called which checks USB LPM
status by calling dwc3_msm_suspend() and finds USB is already suspended,
and it marks pm_suspended flag to true.
- dwc3_resume_work() starts running and check pm_suspended flag. If it is
true, it doesn't call dwc3_ext_event_notify() which update vbus/id state
with mdwc->inputs, and schedules sm_work which brings USB out of LPM and
acquires wakeup source to prevent APPS power collapse if USB cable is
connected.

Fix above issue by taking wakeup source i.e. using pm_stay_awake() on
receiving VBUS/ID and power event related notification which makes sure
that system stays out of PM sleep until resume_work and sm_work have had
chance to run.

Also log important handling of important events with sm_work,
pm_stay_awake() and pm_relax() usage with USB buffer to improve debugging.

CRs-Fixed: 1074315
Change-Id: I94fb0e5ae5e48c8932cf9e3540bd080e67d44988
Signed-off-by: default avatarMayank Rana <mrana@codeaurora.org>
parent c4e05e15
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment