mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH V3] watchdog: of_xilinx_wdt: Remove unnecessary clock disable call in the remove path
@ 2023-08-28  9:50 Srinivas Neeli
  2023-08-28 10:08 ` Guenter Roeck
  0 siblings, 1 reply; 3+ messages in thread
From: Srinivas Neeli @ 2023-08-28  9:50 UTC (permalink / raw)
  To: shubhrajyoti.datta, michal.simek, wim, linux, christophe.jaillet
  Cc: linux-watchdog, linux-arm-kernel, linux-kernel, git,
	neelisrinivas18, Srinivas Neeli

There is a mismatch in axi clock enable and disable calls.
The axi clock is enabled and disabled by the probe function,
then it is again disabled in the remove path.
So observed the call trace while removing the module.
Use the clk_enable() and devm_clk_get_prepared() functions
instead of devm_clk_get_enable() to avoid an extra clock disable
call from the remove path.

 Call trace:
  clk_core_disable+0xb0/0xc0
  clk_disable+0x30/0x4c
  clk_disable_unprepare+0x18/0x30
  devm_clk_release+0x24/0x40
  devres_release_all+0xc8/0x190
  device_unbind_cleanup+0x18/0x6c
  device_release_driver_internal+0x20c/0x250
  device_release_driver+0x18/0x24
  bus_remove_device+0x124/0x130
  device_del+0x174/0x440

Fixes: 4de0224c6fbe ("watchdog: of_xilinx_wdt: Use devm_clk_get_enabled() helper")
Signed-off-by: Srinivas Neeli <srinivas.neeli@amd.com>
---
Changes in V3:
-> Added "clk_disable() in xwdt_selftest() error path.
Changes in V2:
-> Fixed typo in "To" list(linux@roeck-us.net).
---
 drivers/watchdog/of_xilinx_wdt.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/watchdog/of_xilinx_wdt.c b/drivers/watchdog/of_xilinx_wdt.c
index 05657dc1d36a..352853e6fe71 100644
--- a/drivers/watchdog/of_xilinx_wdt.c
+++ b/drivers/watchdog/of_xilinx_wdt.c
@@ -187,7 +187,7 @@ static int xwdt_probe(struct platform_device *pdev)
 
 	watchdog_set_nowayout(xilinx_wdt_wdd, enable_once);
 
-	xdev->clk = devm_clk_get_enabled(dev, NULL);
+	xdev->clk = devm_clk_get_prepared(dev, NULL);
 	if (IS_ERR(xdev->clk)) {
 		if (PTR_ERR(xdev->clk) != -ENOENT)
 			return PTR_ERR(xdev->clk);
@@ -218,18 +218,25 @@ static int xwdt_probe(struct platform_device *pdev)
 	spin_lock_init(&xdev->spinlock);
 	watchdog_set_drvdata(xilinx_wdt_wdd, xdev);
 
+	rc = clk_enable(xdev->clk);
+	if (rc) {
+		dev_err(dev, "unable to enable clock\n");
+		return rc;
+	}
+
 	rc = xwdt_selftest(xdev);
 	if (rc == XWT_TIMER_FAILED) {
 		dev_err(dev, "SelfTest routine error\n");
+		clk_disable(xdev->clk);
 		return rc;
 	}
 
+	clk_disable(xdev->clk);
+
 	rc = devm_watchdog_register_device(dev, xilinx_wdt_wdd);
 	if (rc)
 		return rc;
 
-	clk_disable(xdev->clk);
-
 	dev_info(dev, "Xilinx Watchdog Timer with timeout %ds\n",
 		 xilinx_wdt_wdd->timeout);
 
-- 
2.25.1


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

* Re: [PATCH V3] watchdog: of_xilinx_wdt: Remove unnecessary clock disable call in the remove path
  2023-08-28  9:50 [PATCH V3] watchdog: of_xilinx_wdt: Remove unnecessary clock disable call in the remove path Srinivas Neeli
@ 2023-08-28 10:08 ` Guenter Roeck
  2023-08-28 18:05   ` Marion & Christophe JAILLET
  0 siblings, 1 reply; 3+ messages in thread
From: Guenter Roeck @ 2023-08-28 10:08 UTC (permalink / raw)
  To: Srinivas Neeli, shubhrajyoti.datta, michal.simek, wim,
	christophe.jaillet
  Cc: linux-watchdog, linux-arm-kernel, linux-kernel, git, neelisrinivas18

On 8/28/23 02:50, Srinivas Neeli wrote:
> There is a mismatch in axi clock enable and disable calls.
> The axi clock is enabled and disabled by the probe function,
> then it is again disabled in the remove path.
> So observed the call trace while removing the module.
> Use the clk_enable() and devm_clk_get_prepared() functions
> instead of devm_clk_get_enable() to avoid an extra clock disable
> call from the remove path.
> 
>   Call trace:
>    clk_core_disable+0xb0/0xc0
>    clk_disable+0x30/0x4c
>    clk_disable_unprepare+0x18/0x30
>    devm_clk_release+0x24/0x40
>    devres_release_all+0xc8/0x190
>    device_unbind_cleanup+0x18/0x6c
>    device_release_driver_internal+0x20c/0x250
>    device_release_driver+0x18/0x24
>    bus_remove_device+0x124/0x130
>    device_del+0x174/0x440
> 
> Fixes: 4de0224c6fbe ("watchdog: of_xilinx_wdt: Use devm_clk_get_enabled() helper")
> Signed-off-by: Srinivas Neeli <srinivas.neeli@amd.com>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
> Changes in V3:
> -> Added "clk_disable() in xwdt_selftest() error path.
> Changes in V2:
> -> Fixed typo in "To" list(linux@roeck-us.net).
> ---
>   drivers/watchdog/of_xilinx_wdt.c | 13 ++++++++++---
>   1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/watchdog/of_xilinx_wdt.c b/drivers/watchdog/of_xilinx_wdt.c
> index 05657dc1d36a..352853e6fe71 100644
> --- a/drivers/watchdog/of_xilinx_wdt.c
> +++ b/drivers/watchdog/of_xilinx_wdt.c
> @@ -187,7 +187,7 @@ static int xwdt_probe(struct platform_device *pdev)
>   
>   	watchdog_set_nowayout(xilinx_wdt_wdd, enable_once);
>   
> -	xdev->clk = devm_clk_get_enabled(dev, NULL);
> +	xdev->clk = devm_clk_get_prepared(dev, NULL);
>   	if (IS_ERR(xdev->clk)) {
>   		if (PTR_ERR(xdev->clk) != -ENOENT)
>   			return PTR_ERR(xdev->clk);
> @@ -218,18 +218,25 @@ static int xwdt_probe(struct platform_device *pdev)
>   	spin_lock_init(&xdev->spinlock);
>   	watchdog_set_drvdata(xilinx_wdt_wdd, xdev);
>   
> +	rc = clk_enable(xdev->clk);
> +	if (rc) {
> +		dev_err(dev, "unable to enable clock\n");
> +		return rc;
> +	}
> +
>   	rc = xwdt_selftest(xdev);
>   	if (rc == XWT_TIMER_FAILED) {
>   		dev_err(dev, "SelfTest routine error\n");
> +		clk_disable(xdev->clk);
>   		return rc;
>   	}
>   
> +	clk_disable(xdev->clk);
> +
>   	rc = devm_watchdog_register_device(dev, xilinx_wdt_wdd);
>   	if (rc)
>   		return rc;
>   
> -	clk_disable(xdev->clk);
> -
>   	dev_info(dev, "Xilinx Watchdog Timer with timeout %ds\n",
>   		 xilinx_wdt_wdd->timeout);
>   


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

* Re: [PATCH V3] watchdog: of_xilinx_wdt: Remove unnecessary clock disable call in the remove path
  2023-08-28 10:08 ` Guenter Roeck
@ 2023-08-28 18:05   ` Marion & Christophe JAILLET
  0 siblings, 0 replies; 3+ messages in thread
From: Marion & Christophe JAILLET @ 2023-08-28 18:05 UTC (permalink / raw)
  To: Guenter Roeck, Srinivas Neeli, shubhrajyoti.datta, michal.simek, wim
  Cc: linux-watchdog, linux-arm-kernel, linux-kernel, git, neelisrinivas18


Le 28/08/2023 à 12:08, Guenter Roeck a écrit :
> On 8/28/23 02:50, Srinivas Neeli wrote:
>> There is a mismatch in axi clock enable and disable calls.
>> The axi clock is enabled and disabled by the probe function,
>> then it is again disabled in the remove path.
>> So observed the call trace while removing the module.
>> Use the clk_enable() and devm_clk_get_prepared() functions
>> instead of devm_clk_get_enable() to avoid an extra clock disable
>> call from the remove path.
>>
>>   Call trace:
>>    clk_core_disable+0xb0/0xc0
>>    clk_disable+0x30/0x4c
>>    clk_disable_unprepare+0x18/0x30
>>    devm_clk_release+0x24/0x40
>>    devres_release_all+0xc8/0x190
>>    device_unbind_cleanup+0x18/0x6c
>>    device_release_driver_internal+0x20c/0x250
>>    device_release_driver+0x18/0x24
>>    bus_remove_device+0x124/0x130
>>    device_del+0x174/0x440
>>
>> Fixes: 4de0224c6fbe ("watchdog: of_xilinx_wdt: Use 
>> devm_clk_get_enabled() helper")
>> Signed-off-by: Srinivas Neeli <srinivas.neeli@amd.com>
>
> Reviewed-by: Guenter Roeck <linux@roeck-us.net>
>

Hi, I'm not sure the Fixes tag is correct.

This issue was there before it.
Commit 4de0224c6fbe is just a clean-up and shouldn't change the behavior 
of the code.

I think that the issue was introduced in 2017 in b6bc41645547. (should 
the bellow patch be backported in older stable kernels)

CJ


>> ---
>> Changes in V3:
>> -> Added "clk_disable() in xwdt_selftest() error path.
>> Changes in V2:
>> -> Fixed typo in "To" list(linux@roeck-us.net).
>> ---
>>   drivers/watchdog/of_xilinx_wdt.c | 13 ++++++++++---
>>   1 file changed, 10 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/watchdog/of_xilinx_wdt.c 
>> b/drivers/watchdog/of_xilinx_wdt.c
>> index 05657dc1d36a..352853e6fe71 100644
>> --- a/drivers/watchdog/of_xilinx_wdt.c
>> +++ b/drivers/watchdog/of_xilinx_wdt.c
>> @@ -187,7 +187,7 @@ static int xwdt_probe(struct platform_device *pdev)
>>         watchdog_set_nowayout(xilinx_wdt_wdd, enable_once);
>>   -    xdev->clk = devm_clk_get_enabled(dev, NULL);
>> +    xdev->clk = devm_clk_get_prepared(dev, NULL);
>>       if (IS_ERR(xdev->clk)) {
>>           if (PTR_ERR(xdev->clk) != -ENOENT)
>>               return PTR_ERR(xdev->clk);
>> @@ -218,18 +218,25 @@ static int xwdt_probe(struct platform_device 
>> *pdev)
>>       spin_lock_init(&xdev->spinlock);
>>       watchdog_set_drvdata(xilinx_wdt_wdd, xdev);
>>   +    rc = clk_enable(xdev->clk);
>> +    if (rc) {
>> +        dev_err(dev, "unable to enable clock\n");
>> +        return rc;
>> +    }
>> +
>>       rc = xwdt_selftest(xdev);
>>       if (rc == XWT_TIMER_FAILED) {
>>           dev_err(dev, "SelfTest routine error\n");
>> +        clk_disable(xdev->clk);
>>           return rc;
>>       }
>>   +    clk_disable(xdev->clk);
>> +
>>       rc = devm_watchdog_register_device(dev, xilinx_wdt_wdd);
>>       if (rc)
>>           return rc;
>>   -    clk_disable(xdev->clk);
>> -
>>       dev_info(dev, "Xilinx Watchdog Timer with timeout %ds\n",
>>            xilinx_wdt_wdd->timeout);
>

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

end of thread, other threads:[~2023-08-28 18:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-28  9:50 [PATCH V3] watchdog: of_xilinx_wdt: Remove unnecessary clock disable call in the remove path Srinivas Neeli
2023-08-28 10:08 ` Guenter Roeck
2023-08-28 18:05   ` Marion & Christophe JAILLET

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®