linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: spi-nor: Fix runtime PM imbalance in cqspi_probe
@ 2020-05-22 10:05 Dinghao Liu
  2020-07-01  7:58 ` Tudor.Ambarus
  0 siblings, 1 reply; 2+ messages in thread
From: Dinghao Liu @ 2020-05-22 10:05 UTC (permalink / raw)
  To: dinghao.liu, kjlu
  Cc: Tudor Ambarus, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Philipp Zabel, Boris Brezillon,
	Michael Walle, Thomas Gleixner, Thor Thayer, Stephen Boyd,
	linux-mtd, linux-kernel

When devm_reset_control_get_optional_exclusive() returns
an error code, a pairing runtime PM usage counter
decrement is needed to keep the counter balanced.

Also, call pm_runtime_disable() when pm_runtime_get_sync()
and devm_reset_control_get_optional_exclusive() return an
error code.

Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---
 drivers/mtd/spi-nor/controllers/cadence-quadspi.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/mtd/spi-nor/controllers/cadence-quadspi.c b/drivers/mtd/spi-nor/controllers/cadence-quadspi.c
index 494dcab4aaaa..eabdf01e0d08 100644
--- a/drivers/mtd/spi-nor/controllers/cadence-quadspi.c
+++ b/drivers/mtd/spi-nor/controllers/cadence-quadspi.c
@@ -1377,6 +1377,7 @@ static int cqspi_probe(struct platform_device *pdev)
 	ret = pm_runtime_get_sync(dev);
 	if (ret < 0) {
 		pm_runtime_put_noidle(dev);
+		pm_runtime_disable(dev);
 		return ret;
 	}
 
@@ -1390,12 +1391,16 @@ static int cqspi_probe(struct platform_device *pdev)
 	rstc = devm_reset_control_get_optional_exclusive(dev, "qspi");
 	if (IS_ERR(rstc)) {
 		dev_err(dev, "Cannot get QSPI reset.\n");
+		pm_runtime_put_sync(dev);
+		pm_runtime_disable(dev);
 		return PTR_ERR(rstc);
 	}
 
 	rstc_ocp = devm_reset_control_get_optional_exclusive(dev, "qspi-ocp");
 	if (IS_ERR(rstc_ocp)) {
 		dev_err(dev, "Cannot get QSPI OCP reset.\n");
+		pm_runtime_put_sync(dev);
+		pm_runtime_disable(dev);
 		return PTR_ERR(rstc_ocp);
 	}
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mtd: spi-nor: Fix runtime PM imbalance in cqspi_probe
  2020-05-22 10:05 [PATCH] mtd: spi-nor: Fix runtime PM imbalance in cqspi_probe Dinghao Liu
@ 2020-07-01  7:58 ` Tudor.Ambarus
  0 siblings, 0 replies; 2+ messages in thread
From: Tudor.Ambarus @ 2020-07-01  7:58 UTC (permalink / raw)
  To: dinghao.liu, kjlu
  Cc: thor.thayer, vigneshr, bbrezillon, richard, linux-kernel, swboyd,
	michael, linux-mtd, p.zabel, miquel.raynal, tglx

On 5/22/20 1:05 PM, Dinghao Liu wrote:
> When devm_reset_control_get_optional_exclusive() returns
> an error code, a pairing runtime PM usage counter
> decrement is needed to keep the counter balanced.
> 
> Also, call pm_runtime_disable() when pm_runtime_get_sync()
> and devm_reset_control_get_optional_exclusive() return an
> error code.
> 

I see that this is now fixed with the move to drivers/spi/spi-cadence-quadspi.c

Thanks,
ta

> Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> ---
>  drivers/mtd/spi-nor/controllers/cadence-quadspi.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/mtd/spi-nor/controllers/cadence-quadspi.c b/drivers/mtd/spi-nor/controllers/cadence-quadspi.c
> index 494dcab4aaaa..eabdf01e0d08 100644
> --- a/drivers/mtd/spi-nor/controllers/cadence-quadspi.c
> +++ b/drivers/mtd/spi-nor/controllers/cadence-quadspi.c
> @@ -1377,6 +1377,7 @@ static int cqspi_probe(struct platform_device *pdev)
>  	ret = pm_runtime_get_sync(dev);
>  	if (ret < 0) {
>  		pm_runtime_put_noidle(dev);
> +		pm_runtime_disable(dev);
>  		return ret;
>  	}
>  
> @@ -1390,12 +1391,16 @@ static int cqspi_probe(struct platform_device *pdev)
>  	rstc = devm_reset_control_get_optional_exclusive(dev, "qspi");
>  	if (IS_ERR(rstc)) {
>  		dev_err(dev, "Cannot get QSPI reset.\n");
> +		pm_runtime_put_sync(dev);
> +		pm_runtime_disable(dev);
>  		return PTR_ERR(rstc);
>  	}
>  
>  	rstc_ocp = devm_reset_control_get_optional_exclusive(dev, "qspi-ocp");
>  	if (IS_ERR(rstc_ocp)) {
>  		dev_err(dev, "Cannot get QSPI OCP reset.\n");
> +		pm_runtime_put_sync(dev);
> +		pm_runtime_disable(dev);
>  		return PTR_ERR(rstc_ocp);
>  	}
>  

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-07-01  7:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-22 10:05 [PATCH] mtd: spi-nor: Fix runtime PM imbalance in cqspi_probe Dinghao Liu
2020-07-01  7:58 ` Tudor.Ambarus

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).