scsi: ufs: Fix race between shutdown and runtime resume flow
Subsystems (2)
PATCH 1/1 scsi: ufs: Fix race between shutdown and runtime resume flow
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 kind of issues, 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.
--- drivers/scsi/ufs/ufshcd.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/scsi/ufs/ufshcd.c +1 -5
@@ -8941,11 +8941,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:
Signature · 1 line
2.18.0
Quoted 9 lines · Stanley Chu
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.
Quoted 7 lines
To fix this kind of issues, in
ufshcd_shutdown(), usepm_runtime_get_sync()instead of resuming UFS device byufshcd_runtime_resume()"internally" to let runtime PM framework manage the whole resume flow.Fixes 57d104c153d3 ("ufs: add UFS power management support")Signed-off-by Stanley Chu <[email protected]>
Quoted 11 lines
--- drivers/scsi/ufs/ufshcd.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)drivers/scsi/ufs/ufshcd.c +0
-0@@ -8941,11 +8941,7 @@ int ufshcd_shutdown(struct ufs_hba *hba)if (ufshcd_is_ufs_dev_poweroff (hba) &&ufshcd_is_link_off (hba)) goto out;
drivers/scsi/ufs/ufshcd.c int ufshcd_shutdown(struct ufs_hba *hba) · line 8947
Quoted 10 lines
drivers/scsi/ufs/ufshcd.c +1
-5-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:
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
Martin K. Petersen
AppliedQuoted 10 lines · Stanley Chu
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.
[...]
Applied to 5.10/scsi-fixes, thanks!
[1/1] scsi: ufs: Fix race between shutdown and runtime resume flow
https://git.kernel.org/mkp/scsi/c/e92643db5148
Signature · 6 lines
Martin K. Petersen Oracle Linux Engineering _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek