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

Commit 23590203 authored by Sujeev Dias's avatar Sujeev Dias Committed by Gerrit - the friendly Code Review server
Browse files

mhi: core: synchronize fast resume and state change event thread



It's possible during fast resume transition device could be sending a state
change event. It's important these two thread processed in a synchronous
order to avoid out of sync issues between host and device.

CRs-Fixed: 24956804
Change-Id: I94724cd70bdc728cb5757422c33a51912dfa3cc7
Signed-off-by: default avatarSujeev Dias <sdias@codeaurora.org>
parent 4b2e2cdd
Loading
Loading
Loading
Loading
+8 −10
Original line number Diff line number Diff line
@@ -1273,6 +1273,9 @@ int mhi_pm_fast_resume(struct mhi_controller *mhi_cntrl, bool notify_client)
		}
	}

	/* do not process control events */
	tasklet_disable(&mhi_cntrl->mhi_event->task);

	write_lock_irq(&mhi_cntrl->pm_lock);
	/* restore the states */
	mhi_cntrl->pm_state = mhi_cntrl->saved_pm_state;
@@ -1284,19 +1287,14 @@ int mhi_pm_fast_resume(struct mhi_controller *mhi_cntrl, bool notify_client)
		mhi_pm_m0_transition(mhi_cntrl);
	case MHI_PM_M2:
		read_lock_bh(&mhi_cntrl->pm_lock);
		/*
		 * we're doing a double check of pm_state because by the time we
		 * grab the pm_lock, device may have already initiate a M0 on
		 * its own. If that's the case we should not be toggling device
		 * wake.
		 */
		if (mhi_cntrl->pm_state == MHI_PM_M2) {
		mhi_cntrl->wake_get(mhi_cntrl, true);
		mhi_cntrl->wake_put(mhi_cntrl, true);
		}
		read_unlock_bh(&mhi_cntrl->pm_lock);
	}

	/* now it's safe to process ctrl events */
	tasklet_enable(&mhi_cntrl->mhi_event->task);

	/*
	 * In fast suspend/resume case device is not aware host transition
	 * to suspend state. So, device could be triggering a interrupt while