]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
scsi: ufs: Avoid runtime suspend possibly being blocked forever
authorStanley Chu <stanley.chu@mediatek.com>
Wed, 12 Jun 2019 15:19:05 +0000 (23:19 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 19 Jun 2019 02:50:25 +0000 (22:50 -0400)
commit24e2e7a19f7e4b83d0d5189040d997bce3596473
tree1aaaa591431a95f715d3379762c53205152177dd
parent8cf4c5403aeb8d3921c174ad1c72c9753cfb5f5f
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.

Fixes: 62694735ca95 ([SCSI] ufs: Add runtime PM support for UFS host controller driver)
Cc: stable@vger.kernel.org
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/ufs/ufshcd-pltfrm.c