diff mbox series

[v2] hwrng: exynos - Fix runtime PM imbalance on error

Message ID 20210422104141.17668-1-l.stelmach@samsung.com (mailing list archive)
State New, archived
Headers show
Series [v2] hwrng: exynos - Fix runtime PM imbalance on error | expand

Commit Message

Łukasz Stelmach April 22, 2021, 10:41 a.m. UTC
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(-)

Comments

Krzysztof Kozlowski April 22, 2021, 10:46 a.m. UTC | #1
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
Marek Szyprowski April 22, 2021, 11:19 a.m. UTC | #2
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
Łukasz Stelmach April 22, 2021, 11:22 a.m. UTC | #3
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/
Krzysztof Kozlowski April 22, 2021, 4:31 p.m. UTC | #4
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
diff mbox series

Patch

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;