dmaengine Archive on lore.kernel.org
 help / color / Atom feed
* Re: [PATCH v4] dmaengine: tegra210-adma: Fix runtime PM imbalance on error
@ 2020-06-21 10:50 Markus Elfring
  0 siblings, 0 replies; 5+ messages in thread
From: Markus Elfring @ 2020-06-21 10:50 UTC (permalink / raw)
  To: Dinghao Liu, dmaengine, linux-tegra
  Cc: linux-kernel, Dan Williams, Jonathan Hunter, Laxman Dewangan,
	Thierry Reding, Vinod Koul, Aditya Pakki, Kangjie Lu,
	Navid Emamdoost, Qiushi Wu

I propose to combine two tags in the previous patch subject.


> pm_runtime_get_sync() increments the runtime PM usage counter even
> when it returns an error code. Thus a pairing decrement is needed on
> the error handling path to keep the counter balanced.

* Can an imperative wording be nicer for the change description?
  https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id=64677779e8962c20b580b471790fe42367750599#n151

* Would you like to add the tag “Fixes” to the commit message?


> ---
> drivers/dma/tegra210-adma.c | 5 ++++-

I find it nicer to replace the triple dashes before this diffstat
by a blank line.

Regards,
Markus

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

* Re: [PATCH] [v4] dmaengine: tegra210-adma: Fix runtime PM imbalance on error
  2020-06-23 12:08   ` Geert Uytterhoeven
@ 2020-06-23 12:25     ` Jon Hunter
  0 siblings, 0 replies; 5+ messages in thread
From: Jon Hunter @ 2020-06-23 12:25 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Dinghao Liu, Kangjie Lu, Laxman Dewangan, Vinod Koul,
	Dan Williams, Thierry Reding, dmaengine, linux-tegra,
	Linux Kernel Mailing List

Hi Geert,

On 23/06/2020 13:08, Geert Uytterhoeven wrote:
> Hi Jon,
> 
> More stirring in the cesspool ;-)

Ha! Indeed.

> On Tue, Jun 23, 2020 at 12:13 PM Jon Hunter <jonathanh@nvidia.com> wrote:
>> On 21/06/2020 06:47, Dinghao Liu wrote:
>>> pm_runtime_get_sync() increments the runtime PM usage counter even
>>> when it returns an error code. Thus a pairing decrement is needed on
>>> the error handling path to keep the counter balanced.
>>
>> So you have not mentioned here why you are using _noidle and not _put.
>> Furthermore, in this patch [0] you are not using _noidle to fix the same
>> problem in another driver. We should fix this in a consistent manner
>> across all drivers, otherwise it leads to more confusion.
>>
>> Finally, Rafael mentions we should just use _put [0] and so I think we
>> should follow his recommendation.
>>
>> Jon
>>
>> [0] https://lkml.org/lkml/2020/5/21/601
> 
> "_noidle() is the simplest one and it is sufficient."
> https://lore.kernel.org/linux-i2c/CAJZ5v0i87NGcy9+kxubScdPDyByr8ypQWcGgBFn+V-wDd69BHQ@mail.gmail.com/

Good to know. This detail should be spelled out in the changelog so that
it is clear why we are using _noidle and not _put. I did take a look and
it did seem to handle the usage_count OK, but I was concerned if there
could be something else in the _put path that may get missed.

Anyway, I am fine with the change, but with an updated changelog on why
_noidle is being used.

> You never know what additional things the other put* variants
> will start doing in the future...

Hopefully not, as that would be a breakage of the API itself. From what
Rafael said that all _put calls should work and if at some point in the
future they don't, then that seems like a regression.

Jon

-- 
nvpublic

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

* Re: [PATCH] [v4] dmaengine: tegra210-adma: Fix runtime PM imbalance on error
  2020-06-23 10:13 ` Jon Hunter
@ 2020-06-23 12:08   ` Geert Uytterhoeven
  2020-06-23 12:25     ` Jon Hunter
  0 siblings, 1 reply; 5+ messages in thread
From: Geert Uytterhoeven @ 2020-06-23 12:08 UTC (permalink / raw)
  To: Jon Hunter
  Cc: Dinghao Liu, Kangjie Lu, Laxman Dewangan, Vinod Koul,
	Dan Williams, Thierry Reding, dmaengine, linux-tegra,
	Linux Kernel Mailing List

Hi Jon,

More stirring in the cesspool ;-)

On Tue, Jun 23, 2020 at 12:13 PM Jon Hunter <jonathanh@nvidia.com> wrote:
> On 21/06/2020 06:47, Dinghao Liu wrote:
> > pm_runtime_get_sync() increments the runtime PM usage counter even
> > when it returns an error code. Thus a pairing decrement is needed on
> > the error handling path to keep the counter balanced.
>
> So you have not mentioned here why you are using _noidle and not _put.
> Furthermore, in this patch [0] you are not using _noidle to fix the same
> problem in another driver. We should fix this in a consistent manner
> across all drivers, otherwise it leads to more confusion.
>
> Finally, Rafael mentions we should just use _put [0] and so I think we
> should follow his recommendation.
>
> Jon
>
> [0] https://lkml.org/lkml/2020/5/21/601

"_noidle() is the simplest one and it is sufficient."
https://lore.kernel.org/linux-i2c/CAJZ5v0i87NGcy9+kxubScdPDyByr8ypQWcGgBFn+V-wDd69BHQ@mail.gmail.com/

You never know what additional things the other put* variants
will start doing in the future...

Gr{oetje,eeting}s,

                        Geert


--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH] [v4] dmaengine: tegra210-adma: Fix runtime PM imbalance on error
  2020-06-21  5:47 [PATCH] [v4] " Dinghao Liu
@ 2020-06-23 10:13 ` Jon Hunter
  2020-06-23 12:08   ` Geert Uytterhoeven
  0 siblings, 1 reply; 5+ messages in thread
From: Jon Hunter @ 2020-06-23 10:13 UTC (permalink / raw)
  To: Dinghao Liu, kjlu
  Cc: Laxman Dewangan, Vinod Koul, Dan Williams, Thierry Reding,
	dmaengine, linux-tegra, linux-kernel


On 21/06/2020 06:47, Dinghao Liu wrote:
> pm_runtime_get_sync() increments the runtime PM usage counter even
> when it returns an error code. Thus a pairing decrement is needed on
> the error handling path to keep the counter balanced.

So you have not mentioned here why you are using _noidle and not _put.
Furthermore, in this patch [0] you are not using _noidle to fix the same
problem in another driver. We should fix this in a consistent manner
across all drivers, otherwise it leads to more confusion.

Finally, Rafael mentions we should just use _put [0] and so I think we
should follow his recommendation.

Jon

[0] https://lkml.org/lkml/2020/5/21/601
-- 
nvpublic

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

* [PATCH] [v4] dmaengine: tegra210-adma: Fix runtime PM imbalance on error
@ 2020-06-21  5:47 Dinghao Liu
  2020-06-23 10:13 ` Jon Hunter
  0 siblings, 1 reply; 5+ messages in thread
From: Dinghao Liu @ 2020-06-21  5:47 UTC (permalink / raw)
  To: dinghao.liu, kjlu
  Cc: Laxman Dewangan, Jon Hunter, Vinod Koul, Dan Williams,
	Thierry Reding, dmaengine, linux-tegra, linux-kernel

pm_runtime_get_sync() increments the runtime PM usage counter even
when it returns an error code. Thus a pairing decrement is needed on
the error handling path to keep the counter balanced.

Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---

v2: - Merge two patches that fix runtime PM imbalance in
      tegra_adma_probe() and tegra_adma_alloc_chan_resources()
      respectively.

v3: - Use pm_runtime_put_noidle() instead of pm_runtime_put_sync()
      in tegra_adma_alloc_chan_resources().

v4: - Use pm_runtime_put_noidle() instead of pm_runtime_put_sync()
      in tegra_adma_probe().
---
 drivers/dma/tegra210-adma.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/tegra210-adma.c b/drivers/dma/tegra210-adma.c
index db58d7e4f9fe..c5fa2ef74abc 100644
--- a/drivers/dma/tegra210-adma.c
+++ b/drivers/dma/tegra210-adma.c
@@ -658,6 +658,7 @@ static int tegra_adma_alloc_chan_resources(struct dma_chan *dc)
 
 	ret = pm_runtime_get_sync(tdc2dev(tdc));
 	if (ret < 0) {
+		pm_runtime_put_noidle(tdc2dev(tdc));
 		free_irq(tdc->irq, tdc);
 		return ret;
 	}
@@ -869,8 +870,10 @@ static int tegra_adma_probe(struct platform_device *pdev)
 	pm_runtime_enable(&pdev->dev);
 
 	ret = pm_runtime_get_sync(&pdev->dev);
-	if (ret < 0)
+	if (ret < 0) {
+		pm_runtime_put_noidle(&pdev->dev);
 		goto rpm_disable;
+	}
 
 	ret = tegra_adma_init(tdma);
 	if (ret)
-- 
2.17.1


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

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-21 10:50 [PATCH v4] dmaengine: tegra210-adma: Fix runtime PM imbalance on error Markus Elfring
  -- strict thread matches above, loose matches on Subject: below --
2020-06-21  5:47 [PATCH] [v4] " Dinghao Liu
2020-06-23 10:13 ` Jon Hunter
2020-06-23 12:08   ` Geert Uytterhoeven
2020-06-23 12:25     ` Jon Hunter

dmaengine Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/dmaengine/0 dmaengine/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dmaengine dmaengine/ https://lore.kernel.org/dmaengine \
		dmaengine@vger.kernel.org
	public-inbox-index dmaengine

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.dmaengine


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git