* [PATCH v2] scsi: ufs: Avoid runtime suspend possibly being blocked forever
@ 2019-06-12 15:19 Stanley Chu
2019-06-13 8:09 ` Avri Altman
[not found] ` <1560352745-24681-1-git-send-email-stanley.chu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
0 siblings, 2 replies; 4+ messages in thread
From: Stanley Chu @ 2019-06-12 15:19 UTC (permalink / raw)
To: linux-scsi, martin.petersen, avri.altman, alim.akhtar,
pedrom.sousa
Cc: linux-mediatek, linux-arm-kernel, matthias.bgg, evgreen, beanhuo,
marc.w.gonzalez, ygardi, subhashj, sthumma, kuohong.wang,
peter.wang, chun-hung.wu, andy.teng, Stanley Chu, stable
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>
---
drivers/scsi/ufs/ufshcd-pltfrm.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c
index 8a74ec30c3d2..d7d521b394c3 100644
--- a/drivers/scsi/ufs/ufshcd-pltfrm.c
+++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
@@ -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:
--
2.18.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [PATCH v2] scsi: ufs: Avoid runtime suspend possibly being blocked forever
2019-06-12 15:19 [PATCH v2] scsi: ufs: Avoid runtime suspend possibly being blocked forever Stanley Chu
@ 2019-06-13 8:09 ` Avri Altman
[not found] ` <1560352745-24681-1-git-send-email-stanley.chu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
1 sibling, 0 replies; 4+ messages in thread
From: Avri Altman @ 2019-06-13 8:09 UTC (permalink / raw)
To: Stanley Chu, linux-scsi@vger.kernel.org,
martin.petersen@oracle.com, alim.akhtar@samsung.com,
pedrom.sousa@synopsys.com
Cc: sthumma@codeaurora.org, marc.w.gonzalez@free.fr,
andy.teng@mediatek.com, chun-hung.wu@mediatek.com,
kuohong.wang@mediatek.com, peter.wang@mediatek.com,
evgreen@chromium.org, subhashj@codeaurora.org,
linux-mediatek@lists.infradead.org, ygardi@codeaurora.org,
matthias.bgg@gmail.com, stable@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, beanhuo@micron.com
>
> 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>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] scsi: ufs: Avoid runtime suspend possibly being blocked forever
[not found] ` <1560352745-24681-1-git-send-email-stanley.chu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
@ 2019-06-15 22:16 ` Sasha Levin
2019-06-19 2:51 ` Martin K. Petersen
1 sibling, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2019-06-15 22:16 UTC (permalink / raw)
To: Sasha Levin, Stanley Chu, linux-scsi-u79uwXL29TY76Z2rM5mHXA,
martin.petersen-QHcLZuEGTsvQT0dZR+AlfA
Cc: linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
stable-u79uwXL29TY76Z2rM5mHXA
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] scsi: ufs: Avoid runtime suspend possibly being blocked forever
[not found] ` <1560352745-24681-1-git-send-email-stanley.chu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2019-06-15 22:16 ` Sasha Levin
@ 2019-06-19 2:51 ` Martin K. Petersen
1 sibling, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2019-06-19 2:51 UTC (permalink / raw)
To: Stanley Chu
Cc: sthumma-sgV2jX0FEOL9JmXXK+q4OQ, linux-scsi-u79uwXL29TY76Z2rM5mHXA,
martin.petersen-QHcLZuEGTsvQT0dZR+AlfA,
marc.w.gonzalez-GANU6spQydw, subhashj-sgV2jX0FEOL9JmXXK+q4OQ,
chun-hung.wu-NuS5LvNUpcJWk0Htik3J/w,
kuohong.wang-NuS5LvNUpcJWk0Htik3J/w,
peter.wang-NuS5LvNUpcJWk0Htik3J/w, evgreen-F7+t8E8rja9g9hUCZPvPmw,
avri.altman-Sjgp3cTcYWE,
linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
ygardi-sgV2jX0FEOL9JmXXK+q4OQ, alim.akhtar-Sze3O3UU22JBDgjK7y7TUQ,
andy.teng-NuS5LvNUpcJWk0Htik3J/w,
matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w,
stable-u79uwXL29TY76Z2rM5mHXA,
pedrom.sousa-HKixBCOQz3hWk0Htik3J/w,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
beanhuo-AL4WhLSQfzjQT0dZR+AlfA
Stanley,
> 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.
Applied to 5.2/scsi-fixes. Thanks!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-06-19 2:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-12 15:19 [PATCH v2] scsi: ufs: Avoid runtime suspend possibly being blocked forever Stanley Chu
2019-06-13 8:09 ` Avri Altman
[not found] ` <1560352745-24681-1-git-send-email-stanley.chu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2019-06-15 22:16 ` Sasha Levin
2019-06-19 2:51 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).