summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStanley Chu <stanley.chu@mediatek.com>2020-11-19 09:29:16 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-12-02 10:31:27 +0300
commit9745eeb6450e5b91cb8868209a450e7c769a9724 (patch)
treef38086f583f88a6b4025d2dcb07b238cca7ba198
parentd46ca6dc4f9a0f7fb5a3fcbb47a6aec6e4c837bf (diff)
downloadlinux-9745eeb6450e5b91cb8868209a450e7c769a9724.tar.xz
scsi: ufs: Fix race between shutdown and runtime resume flow
[ Upstream commit e92643db514803c2c87d72caf5950b4c0a8faf4a ] If UFS host device is in runtime-suspended state while UFS shutdown callback is invoked, UFS device shall be resumed for register accesses. Currently only UFS local runtime resume function will be invoked to wake up the host. This is not enough because if someone triggers runtime resume from block layer, then race may happen between shutdown and runtime resume flow, and finally lead to unlocked register access. To fix this, in ufshcd_shutdown(), use pm_runtime_get_sync() instead of resuming UFS device by ufshcd_runtime_resume() "internally" to let runtime PM framework manage the whole resume flow. Link: https://lore.kernel.org/r/20201119062916.12931-1-stanley.chu@mediatek.com Fixes: 57d104c153d3 ("ufs: add UFS power management support") Reviewed-by: Can Guo <cang@codeaurora.org> Signed-off-by: Stanley Chu <stanley.chu@mediatek.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/scsi/ufs/ufshcd.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index ad5f2e2b4cba..ad80e4223c2d 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -6521,11 +6521,7 @@ int ufshcd_shutdown(struct ufs_hba *hba)
if (ufshcd_is_ufs_dev_poweroff(hba) && ufshcd_is_link_off(hba))
goto out;
- if (pm_runtime_suspended(hba->dev)) {
- ret = ufshcd_runtime_resume(hba);
- if (ret)
- goto out;
- }
+ pm_runtime_get_sync(hba->dev);
ret = ufshcd_suspend(hba, UFS_SHUTDOWN_PM);
out: