If pm_runtime_resume_and_get() fails then it returns w/o the RPM usage
counter being incremented. In this case call pm_runtime_put() in
remove() will result in a usage counter imbalance. Therefore check the
return code of pm_runtime_resume_and_get() and bail out in case of error.
Fixes: bee08559701f ("reset: renesas: Add RZ/G2L usbphy control driver")
Signed-off-by: Heiner Kallweit <[email protected]>
---
v2:
- bail out in case of error instead of switching to pm_runtime_get_sync()
v3:
- add dev_err_probe() in case of error
---
drivers/reset/reset-rzg2l-usbphy-ctrl.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/reset/reset-rzg2l-usbphy-ctrl.c b/drivers/reset/reset-rzg2l-usbphy-ctrl.c
index e0704fd2b..46fcd2218 100644
--- a/drivers/reset/reset-rzg2l-usbphy-ctrl.c
+++ b/drivers/reset/reset-rzg2l-usbphy-ctrl.c
@@ -137,7 +137,12 @@ static int rzg2l_usbphy_ctrl_probe(struct platform_device *pdev)
dev_set_drvdata(dev, priv);
pm_runtime_enable(&pdev->dev);
- pm_runtime_resume_and_get(&pdev->dev);
+ error = pm_runtime_resume_and_get(&pdev->dev);
+ if (error < 0) {
+ pm_runtime_disable(&pdev->dev);
+ reset_control_assert(priv->rstc);
+ return dev_err_probe(&pdev->dev, error, "pm_runtime_resume_and_get failed");
+ }
/* put pll and phy into reset state */
spin_lock_irqsave(&priv->lock, flags);
--
2.34.1
Hi Heiner,
Thanks for the patch.
> Subject: [PATCH resend v3] reset: renesas: Fix Runtime PM usage
>
> If pm_runtime_resume_and_get() fails then it returns w/o the RPM usage
> counter being incremented. In this case call pm_runtime_put() in
> remove() will result in a usage counter imbalance. Therefore check the
> return code of pm_runtime_resume_and_get() and bail out in case of error.
>
> Fixes: bee08559701f ("reset: renesas: Add RZ/G2L usbphy control driver")
> Signed-off-by: Heiner Kallweit <[email protected]>
Reviewed-by: Biju Das <[email protected]>
Cheers,
Biju
> ---
> v2:
> - bail out in case of error instead of switching to pm_runtime_get_sync()
> v3:
> - add dev_err_probe() in case of error
> ---
> drivers/reset/reset-rzg2l-usbphy-ctrl.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/reset/reset-rzg2l-usbphy-ctrl.c
> b/drivers/reset/reset-rzg2l-usbphy-ctrl.c
> index e0704fd2b..46fcd2218 100644
> --- a/drivers/reset/reset-rzg2l-usbphy-ctrl.c
> +++ b/drivers/reset/reset-rzg2l-usbphy-ctrl.c
> @@ -137,7 +137,12 @@ static int rzg2l_usbphy_ctrl_probe(struct
> platform_device *pdev)
> dev_set_drvdata(dev, priv);
>
> pm_runtime_enable(&pdev->dev);
> - pm_runtime_resume_and_get(&pdev->dev);
> + error = pm_runtime_resume_and_get(&pdev->dev);
> + if (error < 0) {
> + pm_runtime_disable(&pdev->dev);
> + reset_control_assert(priv->rstc);
> + return dev_err_probe(&pdev->dev, error,
> "pm_runtime_resume_and_get failed");
> + }
>
> /* put pll and phy into reset state */
> spin_lock_irqsave(&priv->lock, flags);
> --
> 2.34.1
On Wed, 2021-12-15 at 10:18 +0000, Biju Das wrote:
> Hi Heiner,
>
> Thanks for the patch.
>
> > Subject: [PATCH resend v3] reset: renesas: Fix Runtime PM usage
> >
> > If pm_runtime_resume_and_get() fails then it returns w/o the RPM usage
> > counter being incremented. In this case call pm_runtime_put() in
> > remove() will result in a usage counter imbalance. Therefore check the
> > return code of pm_runtime_resume_and_get() and bail out in case of error.
> >
> > Fixes: bee08559701f ("reset: renesas: Add RZ/G2L usbphy control driver")
> > Signed-off-by: Heiner Kallweit <[email protected]>
>
> Reviewed-by: Biju Das <[email protected]>
Thank you both, applied to reset/fixes.
regards
Philipp