scsi: ufs: Fix race between shutdown and runtime resume flow
authorStanley Chu <stanley.chu@mediatek.com>
Thu, 19 Nov 2020 06:29:16 +0000 (14:29 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Fri, 20 Nov 2020 03:18:36 +0000 (22:18 -0500)
commite92643db514803c2c87d72caf5950b4c0a8faf4a
treea9874702b7f0cb6e6d1b5a8a6165a3b385c499be
parent73cc291c270248567245f084dcdf5078069af6b5
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/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>
drivers/scsi/ufs/ufshcd.c