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

Commit 3ad23061 authored by Saket Saurabh's avatar Saket Saurabh
Browse files

phy-msm-usb: Set pm_done to true only when usb is in lpm



As part of USB disconnect event, msm_otg_suspend() executes and USB
enters into low power mode and pm_done flag is set to true. In the
scenario in which before the msm_otg_suspend() finished executing,
then USB connect event came in, in this case msm_otg_suspend() returns
-EBUSY. And later USB connect event is processed. As device is already
in resumed state, hence pm_done flag is never set to false. So on
next USB connect pm usage counter gets incremented in msm_otg_sm_work()
and device cannot enter into sleep state.

Fix the issue by setting pm_done flag to true as part of USB disconnect
event only when USB finished executing msm_otg_suspend() and is able to
enter low power mode.

CRs-fixed: 649434
Change-Id: Icd8d612ce6280300d0d97656f3dcf1921b45126f
Signed-off-by: default avatarSaket Saurabh <ssaurabh@codeaurora.org>
parent 9946a704
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -2814,6 +2814,11 @@ static void msm_otg_sm_work(struct work_struct *w)
			 */
			pm_runtime_mark_last_busy(otg->phy->dev);
			pm_runtime_autosuspend(otg->phy->dev);
			/*
			 * Set pm_done to true as part of USB disconnect
			 * only when USB is in low power mode.
			 */
			if (atomic_read(&motg->in_lpm))
				motg->pm_done = 1;
		}
		break;
+4 −1
Original line number Diff line number Diff line
@@ -370,7 +370,10 @@ struct msm_otg_platform_data {
 * @chg_check_timer: The timer used to implement the workaround to detect
 *               very slow plug in of wall charger.
 * @ui_enabled: USB Intterupt is enabled or disabled.
 * @pm_done: Indicates whether USB is PM resumed
 * @pm_done: It is used to increment the pm counter using pm_runtime_get_sync.
	     This handles the race case when PM resume thread returns before
	     the charger detection starts. When USB is disconnected and in lpm
	     pm_done is set to true.
 * @ext_id_irq: IRQ for ID interrupt.
 */
struct msm_otg {