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

Commit 71413311 authored by Subhash Jadavani's avatar Subhash Jadavani
Browse files

scsi: ufs: fix deadlock when attempting hibern8 during clock gating



If UFSHCD_CAP_HIBERN8_WITH_CLK_GATING capability is enabled then UFS
driver should put the link in hibern8 along with gating of UFS related
clocks but we are hitting the deadlock in this case. UFS gating work
calls the ufshcd_uic_hibern8_enter() which would call the helper function
ufshcd_uic_pwr_ctrl(). ufshcd_uic_pwr_ctrl() calls ufshcd_hold() to make
sure that clocks are ungated which means clock ungate work would end up
waiting for the gate work to finish which causes the deadlock (as gate
work is waiting for ufshcd_uic_pwer_ctrl() to finish).

Fix this issue by letting the callers of ufshcd_uic_pwr_ctrl() to decide
if they really need to vote for the UFS clocks or not.

Change-Id: I5b9d1a1c75bbc5a7097e6cc71cd9ec6885cd271a
Signed-off-by: default avatarSubhash Jadavani <subhashj@codeaurora.org>
parent a206d164
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -2645,7 +2645,6 @@ int ufshcd_uic_pwr_ctrl(struct ufs_hba *hba, struct uic_command *cmd)
	bool uic_ready;
	int retries = POWER_MODE_RETRIES;

	ufshcd_hold(hba, false);
	mutex_lock(&hba->uic_cmd_mutex);
	init_completion(&uic_async_done);

@@ -2714,7 +2713,6 @@ out:
	hba->uic_async_done = NULL;
	spin_unlock_irqrestore(hba->host->host_lock, flags);
	mutex_unlock(&hba->uic_cmd_mutex);
	ufshcd_release(hba);
	return ret;
}

@@ -2744,7 +2742,9 @@ static int ufshcd_uic_change_pwr_mode(struct ufs_hba *hba, u8 mode)
	uic_cmd.command = UIC_CMD_DME_SET;
	uic_cmd.argument1 = UIC_ARG_MIB(PA_PWRMODE);
	uic_cmd.argument3 = mode;
	ufshcd_hold(hba, false);
	ret = ufshcd_uic_pwr_ctrl(hba, &uic_cmd);
	ufshcd_release(hba);
out:
	return ret;
}