clocksource/drivers: Prevent clockevent driver unbind
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
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.
--- drivers/clocksource/arm_arch_timer_mmio.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/clocksource/arm_arch_timer_mmio.c +2 -0
@@ -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
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")Signed-off-by Johan Hovold <[email protected]>--- drivers/clocksource/arm_arch_timer_mmio.c | 2 ++ 1 file changed, 2 insertions(+)drivers/clocksource/arm_arch_timer_mmio.c +1
-0@@ -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.
[tip: timers/clocksource] clocksource/drivers/arm_arch_timer_mmio: Prevent driver unbind
In reply to Johan HovoldThe 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.
--- drivers/clocksource/arm_arch_timer_mmio.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/clocksource/arm_arch_timer_mmio.c +2 -0
@@ -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, };
PATCH 2/3 clocksource/drivers/nxp-pit: Prevent driver unbind
In reply to Johan HovoldThe 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.
--- drivers/clocksource/timer-nxp-pit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
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);TIMER_OF_DECLARE (vf610,"fsl,vf610-pit" , pit_timer_init);
Signature · 1 line
2.51.0
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")Signed-off-by Johan Hovold <[email protected]>--- drivers/clocksource/timer-nxp-pit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/clocksource/timer-nxp-pit.c +0
-0
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
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")Signed-off-by Johan Hovold <[email protected]>--- drivers/clocksource/timer-nxp-pit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/clocksource/timer-nxp-pit.c +1
-0@@ -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_platformhere. You can add the tristateKconfigoption 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
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")Signed-off-by Johan Hovold <[email protected]>--- drivers/clocksource/timer-nxp-pit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/clocksource/timer-nxp-pit.c +1
-0@@ -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_platformhere. You can add the tristateKconfigoption 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
[tip: timers/clocksource] clocksource/drivers/nxp-pit: Prevent driver unbind
In reply to Johan HovoldThe 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.
--- drivers/clocksource/timer-nxp-pit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
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);TIMER_OF_DECLARE (vf610,"fsl,vf610-pit" , pit_timer_init);
PATCH 3/3 clocksource/drivers/nxp-stm: Prevent driver unbind
In reply to Johan HovoldClockevents 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.
--- drivers/clocksource/timer-nxp-stm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/clocksource/timer-nxp-stm.c +2 -1
@@ -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
[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.
--- drivers/clocksource/timer-nxp-stm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/clocksource/timer-nxp-stm.c +2 -1
@@ -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" );
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
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