mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] rtc: rtc-cadence: fix clock cleanup ordering
@ 2026-08-18 12:41 Jiawen Liu
  2026-08-18 20:24 ` Christophe JAILLET
  0 siblings, 1 reply; 3+ messages in thread
From: Jiawen Liu @ 2026-08-18 12:41 UTC (permalink / raw)
  To: linux-kernel; +Cc: jiawen

From: jiawen <1298662399@qq.com>

The probe function enables the peripheral clock (pclk) before the
reference clock (ref_clk), and its error path disables ref_clk before
pclk. However, the remove function disables pclk before ref_clk, which
is the reverse order. This asymmetric teardown can leave the clock
framework in an inconsistent state and violates the expected lifecycle
balance. Fix the remove function to disable ref_clk first, then pclk,
matching the probe enable order and the error path cleanup order.

Signed-off-by: jiawen <1298662399@qq.com>
---
diff --git a/drivers/rtc/rtc-cadence.c b/drivers/rtc/rtc-cadence.c
--- a/drivers/rtc/rtc-cadence.c
+++ b/drivers/rtc/rtc-cadence.c
@@ -361,8 +361,8 @@
 	cdns_rtc_alarm_irq_enable(&pdev->dev, 0);
 	device_init_wakeup(&pdev->dev, false);
 
+	clk_disable_unprepare(crtc->ref_clk);
 	clk_disable_unprepare(crtc->pclk);
-	clk_disable_unprepare(crtc->ref_clk);
 }
 
 #ifdef CONFIG_PM_SLEEP


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

* Re: [PATCH] rtc: rtc-cadence: fix clock cleanup ordering
  2026-08-18 12:41 [PATCH] rtc: rtc-cadence: fix clock cleanup ordering Jiawen Liu
@ 2026-08-18 20:24 ` Christophe JAILLET
  2026-11-08 17:22   ` Jiawen Liu
  0 siblings, 1 reply; 3+ messages in thread
From: Christophe JAILLET @ 2026-08-18 20:24 UTC (permalink / raw)
  To: Jiawen Liu, linux-kernel; +Cc: alexandre.belloni

Le 18/08/2026 à 14:41, Jiawen Liu a écrit :
> From: jiawen <1298662399@qq.com>
> 
> The probe function enables the peripheral clock (pclk) before the
> reference clock (ref_clk), and its error path disables ref_clk before
> pclk. However, the remove function disables pclk before ref_clk, which
> is the reverse order. This asymmetric teardown can leave the clock
> framework in an inconsistent state and violates the expected lifecycle
> balance. Fix the remove function to disable ref_clk first, then pclk,
> matching the probe enable order and the error path cleanup order.
> 
> Signed-off-by: jiawen <1298662399@qq.com>
> ---
> diff --git a/drivers/rtc/rtc-cadence.c b/drivers/rtc/rtc-cadence.c
> --- a/drivers/rtc/rtc-cadence.c
> +++ b/drivers/rtc/rtc-cadence.c
> @@ -361,8 +361,8 @@
>   	cdns_rtc_alarm_irq_enable(&pdev->dev, 0);
>   	device_init_wakeup(&pdev->dev, false);
>   
> +	clk_disable_unprepare(crtc->ref_clk);
>   	clk_disable_unprepare(crtc->pclk);
> -	clk_disable_unprepare(crtc->ref_clk);
>   }
>   
>   #ifdef CONFIG_PM_SLEEP
> 

Hi,
you should use ./scripts/get_maintainer.pl to identify to who the patch 
should be sent. A pmatch only sent to linux-kernel@... will be taken by 
no-one.

Personally, I use "./scripts/get_maintainer.pl --nogit --nogit-fallback 
--norolestats" to fileter even more the output.

So adding Alexandre Belloni to my reply.



Also, are you using "git format-patch" to prepare the patch to be sent? 
In my case, some more context is added after "@@ -361,8 +361,8 @@". This 
help when reviewing patches.



Concerning your patch, I think that using devm_clk_get_enabled() instead 
of devm_clk_get() in the probe would be a better option. It changes the 
same order as you do and simplify the error handling path of the probe 
and the remove function.

CJ


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

* Re: [PATCH] rtc: rtc-cadence: fix clock cleanup ordering
  2026-08-18 20:24 ` Christophe JAILLET
@ 2026-11-08 17:22   ` Jiawen Liu
  0 siblings, 0 replies; 3+ messages in thread
From: Jiawen Liu @ 2026-11-08 17:22 UTC (permalink / raw)
  To: Christophe JAILLET, Alexandre Belloni; +Cc: linux-kernel

Hi Christophe,

Thanks for the review and for adding Alexandre.

My description did not establish that the existing clock-disable order
causes a failure, so I should not have claimed that it leaves the clock
framework inconsistent.

I'll check the clock dependencies and the managed-clock option before
deciding whether a revised change is warranted. For any update, I'll use
get_maintainer.pl and prepare the patch with git format-patch.

Thanks,
Jiawen


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

end of thread, other threads:[~2026-11-08 17:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-18 12:41 [PATCH] rtc: rtc-cadence: fix clock cleanup ordering Jiawen Liu
2026-08-18 20:24 ` Christophe JAILLET
2026-11-08 17:22   ` Jiawen Liu

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®