scsi: ufs: Avoid runtime suspend possibly being blocked forever
Subsystems (3)
PATCH v2 1/1 scsi: ufs: Avoid runtime suspend possibly being blocked forever
UFS runtime suspend can be triggered after pm_runtime_enable() is invoked in ufshcd_pltfrm_init(). However if the first runtime suspend is triggered before binding ufs_hba structure to ufs device structure via platform_set_drvdata(), then UFS runtime suspend will be no longer triggered in the future because its dev->power.runtime_error was set in the first triggering and does not have any chance to be cleared.
To be more clear, dev->power.runtime_error is set if hba is NULL in ufshcd_runtime_suspend() which returns -EINVAL to rpm_callback() where dev->power.runtime_error is set as -EINVAL. In this case, any future rpm_suspend() for UFS device fails because rpm_check_suspend_allowed() fails due to non-zero dev->power.runtime_error.
To resolve this issue, make sure the first UFS runtime suspend get valid "hba" in ufshcd_runtime_suspend(): Enable UFS runtime PM only after hba is successfully bound to UFS device structure.
--- drivers/scsi/ufs/ufshcd-pltfrm.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/scsi/ufs/ufshcd-pltfrm.c +4 -7
@@ -430,24 +430,21 @@ int ufshcd_pltfrm_init(struct platform_device *pdev, goto dealloc_host; } -pm_runtime_set_active (&pdev->dev); -pm_runtime_enable (&pdev->dev); -ufshcd_init_lanes_per_dir (hba); err =ufshcd_init (hba, mmio_base, irq);if (err) {dev_err (dev,"Initialization failed\n" ); - goto out_disable_rpm; + goto dealloc_host; }platform_set_drvdata (pdev, hba); +pm_runtime_set_active (&pdev->dev); +pm_runtime_enable (&pdev->dev); +return 0 ; -out_disable_rpm: -pm_runtime_disable (&pdev->dev); -pm_runtime_set_suspended (&pdev->dev); dealloc_host:ufshcd_dealloc_host (hba); out:
Signature · 1 line
2.18.0
Quoted 16 lines
UFS runtime suspend can be triggered after
pm_runtime_enable()is invoked inufshcd_pltfrm_init(). However if the first runtime suspend is triggered before bindingufs_hbastructure to ufs device structure viaplatform_set_drvdata(), then UFS runtime suspend will be no longer triggered in the future because itsdev->power.runtime_errorwas set in the first triggering and does not have any chance to be cleared.To be more clear,
dev->power.runtime_erroris set if hba is NULL inufshcd_runtime_suspend()which returns-EINVALtorpm_callback()wheredev->power.runtime_erroris set as-EINVAL. In this case, any futurerpm_suspend()for UFS device fails becauserpm_check_suspend_allowed()fails due to non-zerodev->power.runtime_error.
Quoted 8 lines
To resolve this issue, make sure the first UFS runtime suspend get valid "hba" in
ufshcd_runtime_suspend(): Enable UFS runtime PM only after hba is successfully bound to UFS device structure.Fixes 62694735ca95 ([SCSI] ufs: Add runtime PM support for UFS hostcontroller driver)
Signed-off-by Stanley Chu <[email protected]>
Hi,
[This is an automated email]
This commit has been processed because it contains a "Fixes:" tag,
fixing commit: 62694735ca95 [SCSI] ufs: Add runtime PM support for UFS host controller driver.
The bot has tested the following trees: v5.1.9, v4.19.50, v4.14.125, v4.9.181, v4.4.181.
v5.1.9: Build OK!
v4.19.50: Build OK!
v4.14.125: Build OK!
v4.9.181: Build OK!
v4.4.181: Failed to apply! Possible dependencies:
54b879b76ea2 ("scsi: ufs-qcom: add number of lanes per direction") bad9764cfaaa ("scsi: ufs: fix spelling mistake in error message")
How should we proceed with this patch?
--
Thanks,
Sasha
Martin K. Petersen
AppliedStanley,
Quoted 7 lines
UFS runtime suspend can be triggered after
pm_runtime_enable()is invoked inufshcd_pltfrm_init(). However if the first runtime suspend is triggered before bindingufs_hbastructure to ufs device structure viaplatform_set_drvdata(), then UFS runtime suspend will be no longer triggered in the future because itsdev->power.runtime_errorwas set in the first triggering and does not have any chance to be cleared.
Applied to 5.2/scsi-fixes. Thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering