Skip to contentSkip to conversation

clocksource/drivers: Prevent clockevent driver unbind

PATCH Applied Johan Hovold 4 participants 13 messages Nov 11, 2025 – Nov 26, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover clocksource/drivers: Prevent clockevent driver unbind

Clockevents cannot be deregistered so suppress driver bind attributes to prevent drivers from being unbound and, for example, releasing underlying resources after registration.

Note that the NXP STM patch depends on the recently submitted section mismatch fix. [1]

Johan

[1] https://lore.kernel.org/lkml/[email protected]/

Johan Hovold (3):
clocksource/drivers/arm_arch_timer_mmio: Prevent driver unbind clocksource/drivers/nxp-pit: Prevent driver unbind clocksource/drivers/nxp-stm: Prevent driver unbind

 drivers/clocksource/arm_arch_timer_mmio.c | 2 ++
 drivers/clocksource/timer-nxp-pit.c       | 3 ++-
 drivers/clocksource/timer-nxp-stm.c       | 3 ++-
 3 files changed, 6 insertions(+), 2 deletions(-)
Signature · 1 line
2.51.0
#1 lore raw

PATCH 1/3 clocksource/drivers/arm_arch_timer_mmio: Prevent driver unbind

Clockevents cannot be deregistered so suppress the bind attributes to prevent the driver from being unbound and releasing the underlying resources after registration.

Fixes 4891f01527bb ("clocksource/drivers/arm_arch_timer: Add standalone MMIO driver")
---
 drivers/clocksource/arm_arch_timer_mmio.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/clocksource/arm_arch_timer_mmio.c +2 -0
index ebe1987d651e..d10362692fdd 100644
@@ -426,6 +426,7 @@ static struct platform_driver arch_timer_mmio_drv = {
 	.driver	= {
 		.name = "arch-timer-mmio",
 		.of_match_table	= arch_timer_mmio_of_table,
+		.suppress_bind_attrs = true,
 	},
 	.probe	= arch_timer_mmio_probe,
 };
@@ -434,6 +435,7 @@ builtin_platform_driver(arch_timer_mmio_drv);
 static struct platform_driver arch_timer_mmio_acpi_drv = {
 	.driver	= {
 		.name = "gtdt-arm-mmio-timer",
+		.suppress_bind_attrs = true,
 	},
 	.probe	= arch_timer_mmio_probe,
 };
Signature · 1 line
2.51.0
maintainer Acked-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] clocksource/drivers/arm_arch_timer_mmio: Prevent driver unbind

Quoted 24 lines · Johan Hovold

Clockevents cannot be deregistered so suppress the bind attributes to prevent the driver from being unbound and releasing the underlying resources after registration.

Fixes 4891f01527bb ("clocksource/drivers/arm_arch_timer: Add standalone MMIO driver")
---
 drivers/clocksource/arm_arch_timer_mmio.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/clocksource/arm_arch_timer_mmio.c +1 -0
index ebe1987d651e..d10362692fdd 100644
@@ -426,6 +426,7 @@ static struct platform_driver arch_timer_mmio_drv = {
 	.driver	= {
 		.name = "arch-timer-mmio",
 		.of_match_table	= arch_timer_mmio_of_table,
+		.suppress_bind_attrs = true,
 	},
 	.probe	= arch_timer_mmio_probe,
 };

drivers/clocksource/arm_arch_timer_mmio.c builtin_platform_driver(arch_timer_mmio_drv); · line 441

Quoted 7 lines
drivers/clocksource/arm_arch_timer_mmio.c +1 -0
@@ -434,6 +435,7 @@ builtin_platform_driver(arch_timer_mmio_drv);
 static struct platform_driver arch_timer_mmio_acpi_drv = {
 	.driver	= {
 		.name = "gtdt-arm-mmio-timer",
+		.suppress_bind_attrs = true,
 	},
 	.probe	= arch_timer_mmio_probe,
 };
	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
merge bot Applied
#3 lore raw

[tip: timers/clocksource] clocksource/drivers/arm_arch_timer_mmio: Prevent driver unbind

In reply to Johan Hovold
The following commit has been merged into the timers/clocksource branch of tip:

The following commit has been merged into the timers/clocksource branch of tip:

Commit-ID:     6aa10f0e2ef9eba1955be6a9d0a8eaecf6bdb7ae
Gitweb:        https://git.kernel.org/tip/6aa10f0e2ef9eba1955be6a9d0a8eaecf6bdb7ae
Author:        Johan Hovold <[email protected]>
AuthorDate:    Tue, 11 Nov 2025 16:32:24 +01:00
Committer:     Daniel Lezcano <[email protected]>
CommitterDate: Wed, 26 Nov 2025 11:24:47 +01:00

clocksource/drivers/arm_arch_timer_mmio: Prevent driver unbind

Clockevents cannot be deregistered so suppress the bind attributes to prevent the driver from being unbound and releasing the underlying resources after registration.

Fixes 4891f01527bb ("clocksource/drivers/arm_arch_timer: Add standalone MMIO driver")
---
 drivers/clocksource/arm_arch_timer_mmio.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/clocksource/arm_arch_timer_mmio.c +2 -0
index ebe1987..d103626 100644
@@ -426,6 +426,7 @@ static struct platform_driver arch_timer_mmio_drv = {
 	.driver	= {
 		.name = "arch-timer-mmio",
 		.of_match_table	= arch_timer_mmio_of_table,
+		.suppress_bind_attrs = true,
 	},
 	.probe	= arch_timer_mmio_probe,
 };
@@ -434,6 +435,7 @@ builtin_platform_driver(arch_timer_mmio_drv);
 static struct platform_driver arch_timer_mmio_acpi_drv = {
 	.driver	= {
 		.name = "gtdt-arm-mmio-timer",
+		.suppress_bind_attrs = true,
 	},
 	.probe	= arch_timer_mmio_probe,
 };
#4 lore raw

PATCH 2/3 clocksource/drivers/nxp-pit: Prevent driver unbind

In reply to Johan Hovold

The driver does not support unbinding (e.g. as clockevents cannot be deregistered) so suppress the bind attributes to prevent the driver from being unbound and rebound after registration (and disabling the timer when reprobing fails).

Even if the driver can currently only be built-in, also switch to builtin_platform_driver() to prevent it from being unloaded should modular builds ever be enabled.

Fixes bee33f22d7c3 ("clocksource/drivers/nxp-pit: Add NXP Automotive s32g2 / s32g3 support")
---
 drivers/clocksource/timer-nxp-pit.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/clocksource/timer-nxp-pit.c +2 -1
index 2d0a3554b6bf..d1740f18f718 100644
@@ -374,9 +374,10 @@ static struct platform_driver nxp_pit_driver = {
 	.driver = {
 		.name = "nxp-pit",
 		.of_match_table = pit_timer_of_match,
+		.suppress_bind_attrs = true,
 	},
 	.probe = pit_timer_probe,
 };
-module_platform_driver(nxp_pit_driver);
+builtin_platform_driver(nxp_pit_driver);
 
 TIMER_OF_DECLARE(vf610, "fsl,vf610-pit", pit_timer_init);
Signature · 1 line
2.51.0
#5 lore raw

Re: [PATCH 2/3] clocksource/drivers/nxp-pit: Prevent driver unbind

Quoted 20 lines · Johan Hovold

The driver does not support unbinding (e.g. as clockevents cannot be deregistered) so suppress the bind attributes to prevent the driver from being unbound and rebound after registration (and disabling the timer when reprobing fails).

Even if the driver can currently only be built-in, also switch to builtin_platform_driver() to prevent it from being unloaded should modular builds ever be enabled.

Fixes bee33f22d7c3 ("clocksource/drivers/nxp-pit: Add NXP Automotive s32g2 / s32g3 support")
---
  drivers/clocksource/timer-nxp-pit.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/clocksource/timer-nxp-pit.c +0 -0
index 2d0a3554b6bf..d1740f18f718 100644

drivers/clocksource/timer-nxp-pit.c static struct platform_driver nxp_pit_driver = { · line 381

Quoted 9 lines
drivers/clocksource/timer-nxp-pit.c +2 -1
@@ -374,9 +374,10 @@ static struct platform_driver nxp_pit_driver = {
  	.driver = {
  		.name = "nxp-pit",
  		.of_match_table = pit_timer_of_match,
+		.suppress_bind_attrs = true,
  	},
  	.probe = pit_timer_probe,
  };
-module_platform_driver(nxp_pit_driver);
+builtin_platform_driver(nxp_pit_driver);

Do not use builtin_platform here. You can add the tristate Kconfig option for this driver, I tested it.

Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
#6 lore raw

Re: [PATCH 2/3] clocksource/drivers/nxp-pit: Prevent driver unbind

Quoted 25 lines · Daniel Lezcano
Quoted 24 lines · Johan Hovold

The driver does not support unbinding (e.g. as clockevents cannot be deregistered) so suppress the bind attributes to prevent the driver from being unbound and rebound after registration (and disabling the timer when reprobing fails).

Even if the driver can currently only be built-in, also switch to builtin_platform_driver() to prevent it from being unloaded should modular builds ever be enabled.

Fixes bee33f22d7c3 ("clocksource/drivers/nxp-pit: Add NXP Automotive s32g2 / s32g3 support")
---
  drivers/clocksource/timer-nxp-pit.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/clocksource/timer-nxp-pit.c +1 -0
index 2d0a3554b6bf..d1740f18f718 100644
@@ -374,9 +374,10 @@ static struct platform_driver nxp_pit_driver = {
  	.driver = {
  		.name = "nxp-pit",
  		.of_match_table = pit_timer_of_match,
+		.suppress_bind_attrs = true,
Quoted 8 lines

drivers/clocksource/timer-nxp-pit.c static struct platform_driver nxp_pit_driver = { · line 381

Quoted 5 lines
drivers/clocksource/timer-nxp-pit.c +1 -1
  	},
  	.probe = pit_timer_probe,
  };
-module_platform_driver(nxp_pit_driver);
+builtin_platform_driver(nxp_pit_driver);

Do not use builtin_platform here. You can add the tristate Kconfig option for this driver, I tested it.

As I just commented on the cover letter, that's not relevant here; builtin_platform_driver() only prevents unloading a driver built as a module (which is something we want to prevent for these drivers).

Johan

#7 lore raw

Re: [PATCH 2/3] clocksource/drivers/nxp-pit: Prevent driver unbind

Quoted 35 lines · Johan Hovold
Quoted 25 lines · Daniel Lezcano
Quoted 24 lines · Johan Hovold

The driver does not support unbinding (e.g. as clockevents cannot be deregistered) so suppress the bind attributes to prevent the driver from being unbound and rebound after registration (and disabling the timer when reprobing fails).

Even if the driver can currently only be built-in, also switch to builtin_platform_driver() to prevent it from being unloaded should modular builds ever be enabled.

Fixes bee33f22d7c3 ("clocksource/drivers/nxp-pit: Add NXP Automotive s32g2 / s32g3 support")
---
   drivers/clocksource/timer-nxp-pit.c | 3 ++-
   1 file changed, 2 insertions(+), 1 deletion(-)
drivers/clocksource/timer-nxp-pit.c +1 -0
index 2d0a3554b6bf..d1740f18f718 100644
@@ -374,9 +374,10 @@ static struct platform_driver nxp_pit_driver = {
   	.driver = {
   		.name = "nxp-pit",
   		.of_match_table = pit_timer_of_match,
+		.suppress_bind_attrs = true,
Quoted 8 lines

drivers/clocksource/timer-nxp-pit.c static struct platform_driver nxp_pit_driver = { · line 381

Quoted 5 lines
drivers/clocksource/timer-nxp-pit.c +1 -1
   	},
   	.probe = pit_timer_probe,
   };
-module_platform_driver(nxp_pit_driver);
+builtin_platform_driver(nxp_pit_driver);

Do not use builtin_platform here. You can add the tristate Kconfig option for this driver, I tested it.

Quoted 3 lines

As I just commented on the cover letter, that's not relevant here; builtin_platform_driver() only prevents unloading a driver built as a module (which is something we want to prevent for these drivers).

I see your point, I agree. That is something we want to prevent for drivers having a clockevent.

Even if the core framework will prevent the module to be unloaded, we can consider these changes an additional guard.

Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
merge bot Applied
#8 lore raw

[tip: timers/clocksource] clocksource/drivers/nxp-pit: Prevent driver unbind

In reply to Johan Hovold
The following commit has been merged into the timers/clocksource branch of tip:

The following commit has been merged into the timers/clocksource branch of tip:

Commit-ID:     e25f964cf414dafa6bee5c9c2c0b1d1fb041dc92
Gitweb:        https://git.kernel.org/tip/e25f964cf414dafa6bee5c9c2c0b1d1fb041dc92
Author:        Johan Hovold <[email protected]>
AuthorDate:    Tue, 11 Nov 2025 16:32:25 +01:00
Committer:     Daniel Lezcano <[email protected]>
CommitterDate: Wed, 26 Nov 2025 11:24:57 +01:00

clocksource/drivers/nxp-pit: Prevent driver unbind

The driver does not support unbinding (e.g. as clockevents cannot be deregistered) so suppress the bind attributes to prevent the driver from being unbound and rebound after registration (and disabling the timer when reprobing fails).

Even if the driver can currently only be built-in, also switch to builtin_platform_driver() to prevent it from being unloaded should modular builds ever be enabled.

Fixes bee33f22d7c3 ("clocksource/drivers/nxp-pit: Add NXP Automotive s32g2 / s32g3 support")
---
 drivers/clocksource/timer-nxp-pit.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/clocksource/timer-nxp-pit.c +2 -1
index 2d0a355..d1740f1 100644
@@ -374,9 +374,10 @@ static struct platform_driver nxp_pit_driver = {
 	.driver = {
 		.name = "nxp-pit",
 		.of_match_table = pit_timer_of_match,
+		.suppress_bind_attrs = true,
 	},
 	.probe = pit_timer_probe,
 };
-module_platform_driver(nxp_pit_driver);
+builtin_platform_driver(nxp_pit_driver);
 
 TIMER_OF_DECLARE(vf610, "fsl,vf610-pit", pit_timer_init);
#9 lore raw

PATCH 3/3 clocksource/drivers/nxp-stm: Prevent driver unbind

In reply to Johan Hovold

Clockevents cannot be deregistered so suppress the bind attributes to prevent the driver from being unbound and releasing the underlying resources after registration.

Even if the driver can currently only be built-in, also switch to builtin_platform_driver() to prevent it from being unloaded should modular builds ever be enabled.

Fixes cec32ac75827 ("clocksource/drivers/nxp-timer: Add the System Timer Module for the s32gx platforms")
---
 drivers/clocksource/timer-nxp-stm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/clocksource/timer-nxp-stm.c +2 -1
index c320d764b12e..1ab907233f48 100644
@@ -487,9 +487,10 @@ static struct platform_driver nxp_stm_driver = {
 	.driver	= {
 		.name		= "nxp-stm",
 		.of_match_table	= nxp_stm_of_match,
+		.suppress_bind_attrs = true,
 	},
 };
-module_platform_driver(nxp_stm_driver);
+builtin_platform_driver(nxp_stm_driver);
 
 MODULE_DESCRIPTION("NXP System Timer Module driver");
 MODULE_LICENSE("GPL");
Signature · 1 line
2.51.0
merge bot Applied
#10 lore raw

[tip: timers/clocksource] clocksource/drivers/nxp-stm: Prevent driver unbind

The following commit has been merged into the timers/clocksource branch of tip:

The following commit has been merged into the timers/clocksource branch of tip:

Commit-ID:     6a2416892e8942f5e2bfe9b85c0164f410a53a2d
Gitweb:        https://git.kernel.org/tip/6a2416892e8942f5e2bfe9b85c0164f410a53a2d
Author:        Johan Hovold <[email protected]>
AuthorDate:    Tue, 11 Nov 2025 16:32:26 +01:00
Committer:     Daniel Lezcano <[email protected]>
CommitterDate: Wed, 26 Nov 2025 11:25:03 +01:00

clocksource/drivers/nxp-stm: Prevent driver unbind

Clockevents cannot be deregistered so suppress the bind attributes to prevent the driver from being unbound and releasing the underlying resources after registration.

Even if the driver can currently only be built-in, also switch to builtin_platform_driver() to prevent it from being unloaded should modular builds ever be enabled.

Fixes cec32ac75827 ("clocksource/drivers/nxp-timer: Add the System Timer Module for the s32gx platforms")
---
 drivers/clocksource/timer-nxp-stm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/clocksource/timer-nxp-stm.c +2 -1
index c320d76..1ab9072 100644
@@ -487,9 +487,10 @@ static struct platform_driver nxp_stm_driver = {
 	.driver	= {
 		.name		= "nxp-stm",
 		.of_match_table	= nxp_stm_of_match,
+		.suppress_bind_attrs = true,
 	},
 };
-module_platform_driver(nxp_stm_driver);
+builtin_platform_driver(nxp_stm_driver);
 
 MODULE_DESCRIPTION("NXP System Timer Module driver");
 MODULE_LICENSE("GPL");
#11 lore raw
In reply to Johan Hovold

Hi Johan,

Quoted 3 lines · Johan Hovold

Clockevents cannot be deregistered so suppress driver bind attributes to prevent drivers from being unbound and, for example, releasing underlying resources after registration.

For non architected timers, we want to be able to convert the timers as modules.

That's an on-going work [1].

Your series assumes we won't convert that into modules, so you do the conversion to builtin. But actually, there is a slow move to module conversion.

However, given a clockevent can not be unregistered, the 'suppress_bind_attrs' flag makes sense for those registering one.

-- Daniel

[1] https://lore.kernel.org/all/[email protected]/

Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
#12 lore raw
Quoted 5 lines · Daniel Lezcano
Quoted 3 lines · Johan Hovold

Clockevents cannot be deregistered so suppress driver bind attributes to prevent drivers from being unbound and, for example, releasing underlying resources after registration.

Quoted 8 lines

For non architected timers, we want to be able to convert the timers as modules.

That's an on-going work [1].

Your series assumes we won't convert that into modules, so you do the conversion to builtin. But actually, there is a slow move to module conversion.

No, that's not the case. The builtin_platform_driver macro still allows building drivers as modules, it just prevents unloading them.

Johan