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

Commit d130e1b9 authored by Sujeev Dias's avatar Sujeev Dias
Browse files

mhi: cntrl: qcom: bring MHI out of suspend prior to MHI shutdown



During MHI shutdown, MHI host would issue an MHI reset to
controller. Therefore, if power-off occurs while MHI is in a
suspended state, MHI resume needs to occur first.

CRs-Fixed: 2446191
Change-Id: Iadd354cf51daabffad35555c43297e6ced4b177a
Acked-by: default avatarBhaumik Vasav Bhatt <bbhatt@qti.qualcomm.com>
Signed-off-by: default avatarSujeev Dias <sdias@codeaurora.org>
parent 955be850
Loading
Loading
Loading
Loading
+15 −8
Original line number Diff line number Diff line
@@ -202,26 +202,33 @@ void mhi_arch_esoc_ops_power_off(void *priv, bool mdm_state)
	struct mhi_controller *mhi_cntrl = priv;
	struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl);
	struct arch_info *arch_info = mhi_dev->arch_info;
	struct pci_dev *pci_dev = mhi_dev->pci_dev;

	MHI_LOG("Enter: mdm_crashed:%d\n", mdm_state);

	/*
	 * Abort system suspend if system is preparing to go to suspend
	 * by grabbing wake source.
	 * If system is suspended, wait for pm notifier callback to notify
	 * that resume has occurred with PM_POST_SUSPEND event.
	 */
	pm_stay_awake(&mhi_cntrl->mhi_dev->dev);
	wait_for_completion(&arch_info->pm_completion);

	/* if link is in drv suspend, wake it up */
	pm_runtime_get_sync(&pci_dev->dev);

	mutex_lock(&mhi_cntrl->pm_mutex);
	if (!mhi_dev->powered_on) {
		MHI_LOG("Not in active state\n");
		mutex_unlock(&mhi_cntrl->pm_mutex);
		pm_runtime_put_noidle(&pci_dev->dev);
		return;
	}
	mhi_dev->powered_on = false;
	mutex_unlock(&mhi_cntrl->pm_mutex);

	/*
	 * Abort system suspend if system is preparing to go to suspend
	 * by grabbing wake source.
	 * If system is suspended, wait for pm notifier callback to notify
	 * that resume has occurred with PM_POST_SUSPEND event.
	 */
	pm_stay_awake(&mhi_cntrl->mhi_dev->dev);
	wait_for_completion(&arch_info->pm_completion);
	pm_runtime_put_noidle(&pci_dev->dev);

	MHI_LOG("Triggering shutdown process\n");
	mhi_power_down(mhi_cntrl, !mdm_state);