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

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

mhi: core: ensure MHI is active while processing mission mode



It is possible for MHI host to be in suspended state before
processing mission mode and block register access. Ensure MHI is
in active state before processing mission mode transition and
allow boot sequence completion.

CRs-Fixed: 2334309
Change-Id: I62ec8779894451b32f38a7f9129a7121ecfb8bd1
Acked-by: default avatarBhaumik Vasav Bhatt <bbhatt@qti.qualcomm.com>
Signed-off-by: default avatarSujeev Dias <sdias@codeaurora.org>
parent 93449487
Loading
Loading
Loading
Loading
+22 −9
Original line number Original line Diff line number Diff line
@@ -422,27 +422,32 @@ int mhi_pm_m3_transition(struct mhi_controller *mhi_cntrl)


static int mhi_pm_mission_mode_transition(struct mhi_controller *mhi_cntrl)
static int mhi_pm_mission_mode_transition(struct mhi_controller *mhi_cntrl)
{
{
	int i;
	int i, ret;
	struct mhi_event *mhi_event;
	struct mhi_event *mhi_event;


	MHI_LOG("Processing Mission Mode Transition\n");
	MHI_LOG("Processing Mission Mode Transition\n");


	/* force MHI to be in M0 state before continuing */
	ret = __mhi_device_get_sync(mhi_cntrl);
	if (ret)
		return ret;

	ret = -EIO;

	write_lock_irq(&mhi_cntrl->pm_lock);
	write_lock_irq(&mhi_cntrl->pm_lock);
	if (MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state))
	if (MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state))
		mhi_cntrl->ee = mhi_get_exec_env(mhi_cntrl);
		mhi_cntrl->ee = mhi_get_exec_env(mhi_cntrl);
	write_unlock_irq(&mhi_cntrl->pm_lock);
	write_unlock_irq(&mhi_cntrl->pm_lock);


	read_lock_bh(&mhi_cntrl->pm_lock);
	if (!MHI_IN_MISSION_MODE(mhi_cntrl->ee))
	if (!MHI_IN_MISSION_MODE(mhi_cntrl->ee))
		return -EIO;
		goto error_mission_mode;


	wake_up_all(&mhi_cntrl->state_event);
	wake_up_all(&mhi_cntrl->state_event);


	/* add elements to all HW event rings */
	/* add elements to all HW event rings */
	read_lock_bh(&mhi_cntrl->pm_lock);
	if (MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state))
	if (MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) {
		goto error_mission_mode;
		read_unlock_bh(&mhi_cntrl->pm_lock);
		return -EIO;
	}


	mhi_event = mhi_cntrl->mhi_event;
	mhi_event = mhi_cntrl->mhi_event;
	for (i = 0; i < mhi_cntrl->total_ev_rings; i++, mhi_event++) {
	for (i = 0; i < mhi_cntrl->total_ev_rings; i++, mhi_event++) {
@@ -474,9 +479,17 @@ static int mhi_pm_mission_mode_transition(struct mhi_controller *mhi_cntrl)
	/* add supported devices */
	/* add supported devices */
	mhi_create_devices(mhi_cntrl);
	mhi_create_devices(mhi_cntrl);


	MHI_LOG("Exited\n");
	ret = 0;


	return 0;
	read_lock_bh(&mhi_cntrl->pm_lock);

error_mission_mode:
	mhi_cntrl->wake_put(mhi_cntrl, false);
	read_unlock_bh(&mhi_cntrl->pm_lock);

	MHI_LOG("Exit with ret:%d\n", ret);

	return ret;
}
}


/* handles both sys_err and shutdown transitions */
/* handles both sys_err and shutdown transitions */