linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [v2] hwrng: exynos - Fix runtime PM imbalance on error
@ 2020-05-22  1:16 Dinghao Liu
       [not found] ` <CGME20200522090736eucas1p1ad308b9b37d50d9243f0fbeeeb3eab0a@eucas1p1.samsung.com>
  0 siblings, 1 reply; 7+ messages in thread
From: Dinghao Liu @ 2020-05-22  1:16 UTC (permalink / raw)
  To: dinghao.liu, kjlu
  Cc: Łukasz Stelmach, Matt Mackall, Herbert Xu, Arnd Bergmann,
	Greg Kroah-Hartman, Kukjin Kim, Krzysztof Kozlowski,
	linux-samsung-soc, linux-crypto, linux-arm-kernel, 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>
---

Changelog:

v2: -- Remove unnecessary 'err_clock' label
---
 drivers/char/hw_random/exynos-trng.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/char/hw_random/exynos-trng.c b/drivers/char/hw_random/exynos-trng.c
index 8e1fe3f8dd2d..8393b898a50e 100644
--- a/drivers/char/hw_random/exynos-trng.c
+++ b/drivers/char/hw_random/exynos-trng.c
@@ -142,13 +142,13 @@ static int exynos_trng_probe(struct platform_device *pdev)
 	if (IS_ERR(trng->clk)) {
 		ret = PTR_ERR(trng->clk);
 		dev_err(&pdev->dev, "Could not get clock.\n");
-		goto err_clock;
+		goto err_pm_get;
 	}
 
 	ret = clk_prepare_enable(trng->clk);
 	if (ret) {
 		dev_err(&pdev->dev, "Could not enable the clk.\n");
-		goto err_clock;
+		goto err_pm_get;
 	}
 
 	ret = devm_hwrng_register(&pdev->dev, &trng->rng);
@@ -164,10 +164,8 @@ static int exynos_trng_probe(struct platform_device *pdev)
 err_register:
 	clk_disable_unprepare(trng->clk);
 
-err_clock:
-	pm_runtime_put_sync(&pdev->dev);
-
 err_pm_get:
+	pm_runtime_put_sync(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 
 	return ret;
-- 
2.17.1


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

* Re: [PATCH] [v2] hwrng: exynos - Fix runtime PM imbalance on error
       [not found] ` <CGME20200522090736eucas1p1ad308b9b37d50d9243f0fbeeeb3eab0a@eucas1p1.samsung.com>
@ 2020-05-22  9:07   ` Lukasz Stelmach
  0 siblings, 0 replies; 7+ messages in thread
From: Lukasz Stelmach @ 2020-05-22  9:07 UTC (permalink / raw)
  To: Dinghao Liu
  Cc: kjlu, Matt Mackall, Herbert Xu, Arnd Bergmann,
	Greg Kroah-Hartman, Kukjin Kim, Krzysztof Kozlowski,
	linux-samsung-soc, linux-crypto, linux-arm-kernel, linux-kernel,
	Bartlomiej Zolnierkiewicz

[-- Attachment #1: Type: text/plain, Size: 1683 bytes --]

It was <2020-05-22 pią 09:16>, when 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.
>
> Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> ---
>
> Changelog:
>
> v2: -- Remove unnecessary 'err_clock' label
> ---
>  drivers/char/hw_random/exynos-trng.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
>

Reviewed-by: Lukasz Stelmach <l.stelmach@samsung.com>


Thank you.

> diff --git a/drivers/char/hw_random/exynos-trng.c b/drivers/char/hw_random/exynos-trng.c
> index 8e1fe3f8dd2d..8393b898a50e 100644
> --- a/drivers/char/hw_random/exynos-trng.c
> +++ b/drivers/char/hw_random/exynos-trng.c
> @@ -142,13 +142,13 @@ static int exynos_trng_probe(struct platform_device *pdev)
>  	if (IS_ERR(trng->clk)) {
>  		ret = PTR_ERR(trng->clk);
>  		dev_err(&pdev->dev, "Could not get clock.\n");
> -		goto err_clock;
> +		goto err_pm_get;
>  	}
>  
>  	ret = clk_prepare_enable(trng->clk);
>  	if (ret) {
>  		dev_err(&pdev->dev, "Could not enable the clk.\n");
> -		goto err_clock;
> +		goto err_pm_get;
>  	}
>  
>  	ret = devm_hwrng_register(&pdev->dev, &trng->rng);
> @@ -164,10 +164,8 @@ static int exynos_trng_probe(struct platform_device *pdev)
>  err_register:
>  	clk_disable_unprepare(trng->clk);
>  
> -err_clock:
> -	pm_runtime_put_sync(&pdev->dev);
> -
>  err_pm_get:
> +	pm_runtime_put_sync(&pdev->dev);
>  	pm_runtime_disable(&pdev->dev);
>  
>  	return ret;

-- 
Łukasz Stelmach
Samsung R&D Institute Poland
Samsung Electronics

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

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

* Re: [PATCH v2] hwrng: exynos - Fix runtime PM imbalance on error
  2021-04-22 11:22       ` Łukasz Stelmach
@ 2021-04-22 16:31         ` Krzysztof Kozlowski
  0 siblings, 0 replies; 7+ messages in thread
From: Krzysztof Kozlowski @ 2021-04-22 16:31 UTC (permalink / raw)
  To: Łukasz Stelmach
  Cc: Matt Mackall, Herbert Xu, linux-samsung-soc, linux-crypto,
	linux-arm-kernel, linux-kernel,
	Bartłomiej Żolnierkiewicz, Marek Szyprowski

On 22/04/2021 13:22, Łukasz Stelmach wrote:
> It was <2021-04-22 czw 12:46>, when Krzysztof Kozlowski wrote:
>> On 22/04/2021 12:41, Łukasz Stelmach wrote:
>>> pm_runtime_get_sync() increments the runtime PM usage counter even
>>> the call returns an error code. Thus a pairing decrement is needed
>>> on the error handling path to keep the counter balanced.
>>
>> It's exactly the same as Dinghao's patch:
>> https://lore.kernel.org/linux-samsung-soc/20200522011659.26727-1-dinghao.liu@zju.edu.cn/
>> which you reviewed. It has even the same commit msg
>> (although it's difficult to be creative here).
>>
>> I think it's better to resend his patch instead.
> 
> It isn't the same because it uses pm_runtime_put_noidle() as discussed
> here[1], applied here[2] and advised here[2]. Dinghao didn't prepare
> v3[4] for exynos.

Thanks, makes sense but then I would prefer Marek's approach of
pm_runtime_resume_and_get().

Best regards,
Krzysztof

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

* Re: [PATCH v2] hwrng: exynos - Fix runtime PM imbalance on error
       [not found]     ` <CGME20210422112224eucas1p283ca7aeaa25ab514b9743a11e63a76e0@eucas1p2.samsung.com>
@ 2021-04-22 11:22       ` Łukasz Stelmach
  2021-04-22 16:31         ` Krzysztof Kozlowski
  0 siblings, 1 reply; 7+ messages in thread
From: Łukasz Stelmach @ 2021-04-22 11:22 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Matt Mackall, Herbert Xu, linux-samsung-soc, linux-crypto,
	linux-arm-kernel, linux-kernel,
	Bartłomiej Żolnierkiewicz, Marek Szyprowski

[-- Attachment #1: Type: text/plain, Size: 1171 bytes --]

It was <2021-04-22 czw 12:46>, when Krzysztof Kozlowski wrote:
> On 22/04/2021 12:41, Łukasz Stelmach wrote:
>> pm_runtime_get_sync() increments the runtime PM usage counter even
>> the call returns an error code. Thus a pairing decrement is needed
>> on the error handling path to keep the counter balanced.
>
> It's exactly the same as Dinghao's patch:
> https://lore.kernel.org/linux-samsung-soc/20200522011659.26727-1-dinghao.liu@zju.edu.cn/
> which you reviewed. It has even the same commit msg
> (although it's difficult to be creative here).
>
> I think it's better to resend his patch instead.

It isn't the same because it uses pm_runtime_put_noidle() as discussed
here[1], applied here[2] and advised here[2]. Dinghao didn't prepare
v3[4] for exynos.

[1] https://lore.kernel.org/lkml/20200528065519.GA26960@gondor.apana.org.au/
[2] https://lore.kernel.org/lkml/20200528072106.5191-1-dinghao.liu@zju.edu.cn/
[3] https://lore.kernel.org/lkml/20200616073142.GA30519@gondor.apana.org.au/
[4] https://lore.kernel.org/lkml/20200522011659.26727-1-dinghao.liu@zju.edu.cn/
-- 
Łukasz Stelmach
Samsung R&D Institute Poland
Samsung Electronics

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

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

* Re: [PATCH v2] hwrng: exynos - Fix runtime PM imbalance on error
  2021-04-22 10:46   ` Krzysztof Kozlowski
@ 2021-04-22 11:19     ` Marek Szyprowski
       [not found]     ` <CGME20210422112224eucas1p283ca7aeaa25ab514b9743a11e63a76e0@eucas1p2.samsung.com>
  1 sibling, 0 replies; 7+ messages in thread
From: Marek Szyprowski @ 2021-04-22 11:19 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Łukasz Stelmach, Matt Mackall,
	Herbert Xu, linux-samsung-soc, linux-crypto, linux-arm-kernel,
	linux-kernel
  Cc: Bartłomiej Żolnierkiewicz

On 22.04.2021 12:46, Krzysztof Kozlowski wrote:
> On 22/04/2021 12:41, Łukasz Stelmach wrote:
>> pm_runtime_get_sync() increments the runtime PM usage counter even
>> the call returns an error code. Thus a pairing decrement is needed
>> on the error handling path to keep the counter balanced.
> It's exactly the same as Dinghao's patch:
> https://lore.kernel.org/linux-samsung-soc/20200522011659.26727-1-dinghao.liu@zju.edu.cn/
> which you reviewed. It has even the same commit msg
> (although it's difficult to be creative here).
>
> I think it's better to resend his patch instead.

Frankly speaking I would get rid of the pm_runtime_get_sync() calls in 
the drivers and replace them with pm_runtime_resume_and_get() to finish 
that never ending pm_runtime get/put misunderstanding soap opea...

Best regards

-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland


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

* Re: [PATCH v2] hwrng: exynos - Fix runtime PM imbalance on error
  2021-04-22 10:41 ` [PATCH v2] " Łukasz Stelmach
@ 2021-04-22 10:46   ` Krzysztof Kozlowski
  2021-04-22 11:19     ` Marek Szyprowski
       [not found]     ` <CGME20210422112224eucas1p283ca7aeaa25ab514b9743a11e63a76e0@eucas1p2.samsung.com>
  0 siblings, 2 replies; 7+ messages in thread
From: Krzysztof Kozlowski @ 2021-04-22 10:46 UTC (permalink / raw)
  To: Łukasz Stelmach, Matt Mackall, Herbert Xu,
	linux-samsung-soc, linux-crypto, linux-arm-kernel, linux-kernel
  Cc: Bartłomiej Żolnierkiewicz, Marek Szyprowski

On 22/04/2021 12:41, Łukasz Stelmach wrote:
> pm_runtime_get_sync() increments the runtime PM usage counter even
> the call returns an error code. Thus a pairing decrement is needed
> on the error handling path to keep the counter balanced.

It's exactly the same as Dinghao's patch:
https://lore.kernel.org/linux-samsung-soc/20200522011659.26727-1-dinghao.liu@zju.edu.cn/
which you reviewed. It has even the same commit msg
(although it's difficult to be creative here).

I think it's better to resend his patch instead.



Best regards,
Krzysztof

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

* [PATCH v2] hwrng: exynos - Fix runtime PM imbalance on error
       [not found] <CGME20210422104145eucas1p17f46c95b72f3568761a9f7911bf072e1@eucas1p1.samsung.com>
@ 2021-04-22 10:41 ` Łukasz Stelmach
  2021-04-22 10:46   ` Krzysztof Kozlowski
  0 siblings, 1 reply; 7+ messages in thread
From: Łukasz Stelmach @ 2021-04-22 10:41 UTC (permalink / raw)
  To: Matt Mackall, Herbert Xu, Krzysztof Kozlowski, linux-samsung-soc,
	linux-crypto, linux-arm-kernel, linux-kernel
  Cc: Bartłomiej Żolnierkiewicz, Marek Szyprowski,
	Łukasz Stelmach

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

Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
---
Changes in v2:
  - removed Change-Id from the commit message

 drivers/char/hw_random/exynos-trng.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/char/hw_random/exynos-trng.c b/drivers/char/hw_random/exynos-trng.c
index 8e1fe3f8dd2d..9f455d952e87 100644
--- a/drivers/char/hw_random/exynos-trng.c
+++ b/drivers/char/hw_random/exynos-trng.c
@@ -142,13 +142,13 @@ static int exynos_trng_probe(struct platform_device *pdev)
 	if (IS_ERR(trng->clk)) {
 		ret = PTR_ERR(trng->clk);
 		dev_err(&pdev->dev, "Could not get clock.\n");
-		goto err_clock;
+		goto err_pm_get;
 	}
 
 	ret = clk_prepare_enable(trng->clk);
 	if (ret) {
 		dev_err(&pdev->dev, "Could not enable the clk.\n");
-		goto err_clock;
+		goto err_pm_get;
 	}
 
 	ret = devm_hwrng_register(&pdev->dev, &trng->rng);
@@ -164,10 +164,8 @@ static int exynos_trng_probe(struct platform_device *pdev)
 err_register:
 	clk_disable_unprepare(trng->clk);
 
-err_clock:
-	pm_runtime_put_sync(&pdev->dev);
-
 err_pm_get:
+	pm_runtime_put_noidle(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 
 	return ret;
-- 
2.26.2


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

end of thread, other threads:[~2021-04-22 16:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-22  1:16 [PATCH] [v2] hwrng: exynos - Fix runtime PM imbalance on error Dinghao Liu
     [not found] ` <CGME20200522090736eucas1p1ad308b9b37d50d9243f0fbeeeb3eab0a@eucas1p1.samsung.com>
2020-05-22  9:07   ` Lukasz Stelmach
     [not found] <CGME20210422104145eucas1p17f46c95b72f3568761a9f7911bf072e1@eucas1p1.samsung.com>
2021-04-22 10:41 ` [PATCH v2] " Łukasz Stelmach
2021-04-22 10:46   ` Krzysztof Kozlowski
2021-04-22 11:19     ` Marek Szyprowski
     [not found]     ` <CGME20210422112224eucas1p283ca7aeaa25ab514b9743a11e63a76e0@eucas1p2.samsung.com>
2021-04-22 11:22       ` Łukasz Stelmach
2021-04-22 16:31         ` Krzysztof Kozlowski

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