public inbox for linux-rtc@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] rtc: rzn1: clear interrupts on remove
@ 2025-03-12 10:00 Wolfram Sang
  2025-04-08 14:17 ` Alexandre Belloni
  2025-04-08 14:26 ` Alexandre Belloni
  0 siblings, 2 replies; 4+ messages in thread
From: Wolfram Sang @ 2025-03-12 10:00 UTC (permalink / raw)
  To: linux-renesas-soc
  Cc: Wolfram Sang, Miquel Raynal, Alexandre Belloni, linux-rtc

It is good practice to clear running interrupts before removing the
driver. This is not really a bugfix because on current systems RuntimePM
will disable the module clock, so interrupts won't be initiated. The
dependency on that behaviour is subtle, though. Better be self-contained
and clean up when removing.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---

Change since v1: fix build failure by adding the 'rtc' variable. Build
and tested on Renesas RZ/N1D.

 drivers/rtc/rtc-rzn1.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/rtc/rtc-rzn1.c b/drivers/rtc/rtc-rzn1.c
index eeb9612a666f..3c2861983ff1 100644
--- a/drivers/rtc/rtc-rzn1.c
+++ b/drivers/rtc/rtc-rzn1.c
@@ -444,6 +444,11 @@ static int rzn1_rtc_probe(struct platform_device *pdev)
 
 static void rzn1_rtc_remove(struct platform_device *pdev)
 {
+	struct rzn1_rtc *rtc = platform_get_drvdata(pdev);
+
+	/* Disable all interrupts */
+	writel(0, rtc->base + RZN1_RTC_CTL1);
+
 	pm_runtime_put(&pdev->dev);
 }
 
-- 
2.47.2


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

* Re: [PATCH v2] rtc: rzn1: clear interrupts on remove
  2025-03-12 10:00 [PATCH v2] rtc: rzn1: clear interrupts on remove Wolfram Sang
@ 2025-04-08 14:17 ` Alexandre Belloni
  2025-04-08 14:26 ` Alexandre Belloni
  1 sibling, 0 replies; 4+ messages in thread
From: Alexandre Belloni @ 2025-04-08 14:17 UTC (permalink / raw)
  To: linux-renesas-soc, Wolfram Sang; +Cc: Miquel Raynal, linux-rtc

On Wed, 12 Mar 2025 11:00:00 +0100, Wolfram Sang wrote:
> It is good practice to clear running interrupts before removing the
> driver. This is not really a bugfix because on current systems RuntimePM
> will disable the module clock, so interrupts won't be initiated. The
> dependency on that behaviour is subtle, though. Better be self-contained
> and clean up when removing.
> 
> 
> [...]

Applied, thanks!

[1/1] rtc: rzn1: clear interrupts on remove
      https://git.kernel.org/abelloni/c/0bddd060a6a3

Best regards,

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

* Re: [PATCH v2] rtc: rzn1: clear interrupts on remove
  2025-03-12 10:00 [PATCH v2] rtc: rzn1: clear interrupts on remove Wolfram Sang
  2025-04-08 14:17 ` Alexandre Belloni
@ 2025-04-08 14:26 ` Alexandre Belloni
  2025-04-08 15:00   ` Wolfram Sang
  1 sibling, 1 reply; 4+ messages in thread
From: Alexandre Belloni @ 2025-04-08 14:26 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-renesas-soc, Miquel Raynal, linux-rtc

On 12/03/2025 11:00:00+0100, Wolfram Sang wrote:
> It is good practice to clear running interrupts before removing the
> driver. This is not really a bugfix because on current systems RuntimePM

This is not completely true, most of the drivers would leave the
interrupt enabled after removing the driver because it can still
power on a device.

> will disable the module clock, so interrupts won't be initiated. The
> dependency on that behaviour is subtle, though. Better be self-contained
> and clean up when removing.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---
> 
> Change since v1: fix build failure by adding the 'rtc' variable. Build
> and tested on Renesas RZ/N1D.
> 
>  drivers/rtc/rtc-rzn1.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/rtc/rtc-rzn1.c b/drivers/rtc/rtc-rzn1.c
> index eeb9612a666f..3c2861983ff1 100644
> --- a/drivers/rtc/rtc-rzn1.c
> +++ b/drivers/rtc/rtc-rzn1.c
> @@ -444,6 +444,11 @@ static int rzn1_rtc_probe(struct platform_device *pdev)
>  
>  static void rzn1_rtc_remove(struct platform_device *pdev)
>  {
> +	struct rzn1_rtc *rtc = platform_get_drvdata(pdev);
> +
> +	/* Disable all interrupts */
> +	writel(0, rtc->base + RZN1_RTC_CTL1);
> +
>  	pm_runtime_put(&pdev->dev);
>  }
>  
> -- 
> 2.47.2
> 

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

* Re: [PATCH v2] rtc: rzn1: clear interrupts on remove
  2025-04-08 14:26 ` Alexandre Belloni
@ 2025-04-08 15:00   ` Wolfram Sang
  0 siblings, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2025-04-08 15:00 UTC (permalink / raw)
  To: Alexandre Belloni; +Cc: linux-renesas-soc, Miquel Raynal, linux-rtc

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

On Tue, Apr 08, 2025 at 04:26:36PM +0200, Alexandre Belloni wrote:
> On 12/03/2025 11:00:00+0100, Wolfram Sang wrote:
> > It is good practice to clear running interrupts before removing the
> > driver. This is not really a bugfix because on current systems RuntimePM
> 
> This is not completely true, most of the drivers would leave the
> interrupt enabled after removing the driver because it can still
> power on a device.

Ah, okay. Good to know that scenario as well. Thanks.


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

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

end of thread, other threads:[~2025-04-08 15:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-12 10:00 [PATCH v2] rtc: rzn1: clear interrupts on remove Wolfram Sang
2025-04-08 14:17 ` Alexandre Belloni
2025-04-08 14:26 ` Alexandre Belloni
2025-04-08 15:00   ` Wolfram Sang

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