Skip to content

Commit e92643d

Browse files
Stanley Chumartinkpetersen
authored andcommitted
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, 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/[email protected] Fixes: 57d104c ("ufs: add UFS power management support") Reviewed-by: Can Guo <[email protected]> Signed-off-by: Stanley Chu <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 73cc291 commit e92643d

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

drivers/scsi/ufs/ufshcd.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8913,11 +8913,7 @@ int ufshcd_shutdown(struct ufs_hba *hba)
89138913
if (ufshcd_is_ufs_dev_poweroff(hba) && ufshcd_is_link_off(hba))
89148914
goto out;
89158915

8916-
if (pm_runtime_suspended(hba->dev)) {
8917-
ret = ufshcd_runtime_resume(hba);
8918-
if (ret)
8919-
goto out;
8920-
}
8916+
pm_runtime_get_sync(hba->dev);
89218917

89228918
ret = ufshcd_suspend(hba, UFS_SHUTDOWN_PM);
89238919
out:

0 commit comments

Comments
 (0)