* [PATCH] spi: tegra114: missing put on pm_runtime_get_sync failure
@ 2020-06-02 4:55 Navid Emamdoost
[not found] ` <20200602045506.40574-1-navid.emamdoost-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Navid Emamdoost @ 2020-06-02 4:55 UTC (permalink / raw)
To: Laxman Dewangan, Mark Brown, Thierry Reding, Jonathan Hunter,
linux-spi-u79uwXL29TY76Z2rM5mHXA,
linux-tegra-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
Cc: emamd001-OJFnDUYgAso, wu000273-OJFnDUYgAso, kjlu-OJFnDUYgAso,
mccamant-k0Ej6N9cQa43uPMLIKxrzw, Navid Emamdoost
the call to pm_runtime_get_sync increments the counter even
in case of failure leading to incorrect ref count.
Call pm_runtime_put if pm_runtime_get_sync fails.
Signed-off-by: Navid Emamdoost <navid.emamdoost-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
drivers/spi/spi-tegra114.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/spi/spi-tegra114.c b/drivers/spi/spi-tegra114.c
index 83edabdb41ad..dccd2ac1a975 100644
--- a/drivers/spi/spi-tegra114.c
+++ b/drivers/spi/spi-tegra114.c
@@ -974,6 +974,7 @@ static int tegra_spi_setup(struct spi_device *spi)
dev_err(tspi->dev, "pm runtime failed, e = %d\n", ret);
if (cdata)
tegra_spi_cleanup(spi);
+ pm_runtime_put(tspi->dev);
return ret;
}
@@ -1398,6 +1399,7 @@ static int tegra_spi_probe(struct platform_device *pdev)
ret = pm_runtime_get_sync(&pdev->dev);
if (ret < 0) {
dev_err(&pdev->dev, "pm runtime get failed, e = %d\n", ret);
+ pm_runtime_put(&pdev->dev);
goto exit_pm_disable;
}
@@ -1479,6 +1481,7 @@ static int tegra_spi_resume(struct device *dev)
ret = pm_runtime_get_sync(dev);
if (ret < 0) {
dev_err(dev, "pm runtime failed, e = %d\n", ret);
+ pm_runtime_put(dev);
return ret;
}
tegra_spi_writel(tspi, tspi->command1_reg, SPI_COMMAND1);
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread[parent not found: <20200602045506.40574-1-navid.emamdoost-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH] spi: tegra114: missing put on pm_runtime_get_sync failure [not found] ` <20200602045506.40574-1-navid.emamdoost-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2020-06-05 6:09 ` Jon Hunter [not found] ` <f928fb02-47d7-b6f9-6198-bd549d6ac6b5-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> 0 siblings, 1 reply; 3+ messages in thread From: Jon Hunter @ 2020-06-05 6:09 UTC (permalink / raw) To: Navid Emamdoost, Laxman Dewangan, Mark Brown, Thierry Reding, linux-spi-u79uwXL29TY76Z2rM5mHXA, linux-tegra-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA Cc: emamd001-OJFnDUYgAso, wu000273-OJFnDUYgAso, kjlu-OJFnDUYgAso, mccamant-k0Ej6N9cQa43uPMLIKxrzw On 02/06/2020 05:55, Navid Emamdoost wrote: > the call to pm_runtime_get_sync increments the counter even > in case of failure leading to incorrect ref count. > Call pm_runtime_put if pm_runtime_get_sync fails. > > Signed-off-by: Navid Emamdoost <navid.emamdoost-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > --- > drivers/spi/spi-tegra114.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/spi/spi-tegra114.c b/drivers/spi/spi-tegra114.c > index 83edabdb41ad..dccd2ac1a975 100644 > --- a/drivers/spi/spi-tegra114.c > +++ b/drivers/spi/spi-tegra114.c > @@ -974,6 +974,7 @@ static int tegra_spi_setup(struct spi_device *spi) > dev_err(tspi->dev, "pm runtime failed, e = %d\n", ret); > if (cdata) > tegra_spi_cleanup(spi); > + pm_runtime_put(tspi->dev); > return ret; > } > > @@ -1398,6 +1399,7 @@ static int tegra_spi_probe(struct platform_device *pdev) > ret = pm_runtime_get_sync(&pdev->dev); > if (ret < 0) { > dev_err(&pdev->dev, "pm runtime get failed, e = %d\n", ret); > + pm_runtime_put(&pdev->dev); > goto exit_pm_disable; > } I am wondering if it is better we use put_sync() here to ensure that this happens before we exit the probe. Jon -- nvpublic ^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <f928fb02-47d7-b6f9-6198-bd549d6ac6b5-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH] spi: tegra114: missing put on pm_runtime_get_sync failure [not found] ` <f928fb02-47d7-b6f9-6198-bd549d6ac6b5-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> @ 2020-06-05 6:13 ` Navid Emamdoost 0 siblings, 0 replies; 3+ messages in thread From: Navid Emamdoost @ 2020-06-05 6:13 UTC (permalink / raw) To: Jon Hunter Cc: Laxman Dewangan, Mark Brown, Thierry Reding, linux-spi-u79uwXL29TY76Z2rM5mHXA, linux-tegra-u79uwXL29TY76Z2rM5mHXA, LKML, Navid Emamdoost, Qiushi Wu, Kangjie Lu, mccamant-k0Ej6N9cQa43uPMLIKxrzw On Fri, Jun 5, 2020 at 1:09 AM Jon Hunter <jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> wrote: > > > On 02/06/2020 05:55, Navid Emamdoost wrote: > > the call to pm_runtime_get_sync increments the counter even > > in case of failure leading to incorrect ref count. > > Call pm_runtime_put if pm_runtime_get_sync fails. > > > > Signed-off-by: Navid Emamdoost <navid.emamdoost-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > --- > > drivers/spi/spi-tegra114.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/drivers/spi/spi-tegra114.c b/drivers/spi/spi-tegra114.c > > index 83edabdb41ad..dccd2ac1a975 100644 > > --- a/drivers/spi/spi-tegra114.c > > +++ b/drivers/spi/spi-tegra114.c > > @@ -974,6 +974,7 @@ static int tegra_spi_setup(struct spi_device *spi) > > dev_err(tspi->dev, "pm runtime failed, e = %d\n", ret); > > if (cdata) > > tegra_spi_cleanup(spi); > > + pm_runtime_put(tspi->dev); > > return ret; > > } > > > > @@ -1398,6 +1399,7 @@ static int tegra_spi_probe(struct platform_device *pdev) > > ret = pm_runtime_get_sync(&pdev->dev); > > if (ret < 0) { > > dev_err(&pdev->dev, "pm runtime get failed, e = %d\n", ret); > > + pm_runtime_put(&pdev->dev); > > goto exit_pm_disable; > > } > > I am wondering if it is better we use put_sync() here to ensure that > this happens before we exit the probe. To be honest I am not sure when to use different flavors of pm_runtime_put (like pm_runtime_put_noidle, pm_runtime_put_autosuspend, pm_runtime_put_sync, pm_runtime_put, pm_runtime_put_sync_suspend). I'd appreciate it if you could give me a pointer on how to decide on this. > > Jon > > -- > nvpublic -- Navid. ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-06-05 6:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-02 4:55 [PATCH] spi: tegra114: missing put on pm_runtime_get_sync failure Navid Emamdoost
[not found] ` <20200602045506.40574-1-navid.emamdoost-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2020-06-05 6:09 ` Jon Hunter
[not found] ` <f928fb02-47d7-b6f9-6198-bd549d6ac6b5-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2020-06-05 6:13 ` Navid Emamdoost
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox