Timer driver module support
Status from this message: The following commit has been merged into the timers/clocksource branch of tip:
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v1 Latest posting 2/27 patches 3 repliesApplied
- v1 posting 1/27 patches 1 replySuperseded
Patches in v1 posting 2/2 Applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/7 | clocksource/drivers/timer-probe: Create a platform_device before the framework is initializeddrivers/ include/ include/ | +93 | 0 replies | |
| 2/7 | clocksource/drivers/mmio: Make the code compatible with modulesdrivers/ | +8 | 1 reply | |
| 3/7 | clocksource/drivers/timer-of: Make the code compatible with modulesdrivers/ drivers/ | +15 | 0 replies | |
| 4/7 | clocksource/drivers/timer-probe: Add the module support for the TIMER_PDEV_DECLARE() macrodrivers/ drivers/ include/ | +20 | 0 replies | |
| 5/7 | clocksource/drivers/rockchip: Use the TIMER_PDEV_DECLARE() macrodrivers/ | +34 | 0 replies | |
| 6/7 | clocksource/drivers/rockchip: Add rockchip timer module supportdrivers/ | +2 | 0 replies | |
| 7/7 | clocksource/drivers/mediatek: Convert to module supportdrivers/ | +23 | 0 replies |
Reviews trailers per patch
1 of 7 patches has a Reviewed-by or Acked-by.
| Patch | John Stultz |
|---|---|
| 1/7 | |
| 2/7 | A-b |
| 3/7 | |
| 4/7 | |
| 5/7 | |
| 6/7 | |
| 7/7 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v1 resend 0/7] Timer driver module support
Converting the timer driver modules requires a particular care because, depending on the platform, that may be not supported.
A previous study showed we are safe regarding how the module refcount is held and if THIS_MODULE is set for the clockevent and the clocksource when they are registered.
It won't be possible to unload a module if a clockevent is registered.
It will be possible to unload a module if only a clocksource is registered and it is not the current one.
However platforms without architected timers may need the timer driver to be initialized very early and others can be initialized later. The former can not be a module and the init function receives a device_node pointer, there is no device associated and devres is not used. That results in a lot of rollbacking code where usually it is where we find bug and resource leaks. The latter can be converted to a module and uses a module_platform_driver(), thus the init function is a probe function receiving a struct platform_device pointer parameter.
We end up with two approaches and duplicate code for the init functions. This is not optimal.
Finally, we have the driver having to be initialized very early on some platforms and be built as a module on other platforms, resulting on having two init functions co-existing in the same driver.
This series provides what is needed to move to the same probe function for early init, builtin and module timers.
A new macro is introduced: TIMER_PDEV_DECLARE() and a new Kconfig option is added CONFIG_EARLY_TIMER. TIMER_PDEV_DECLARE() will have different behavior depending on the context:
- The driver is a module and CONFIG_EARLY_TIMER=no --> the driver is a module
- The driver is builtin and CONFIG_EARLY_TIMER=no --> the driver is loaded later
- The driver is builtin or a module but CONFIG_EARLY_TIMER=yes --> the driver is initialized through the timer-probe function
The different timer driver framework functions have their __init sections removed and the symbols exported in order to be compatible with the drivers converted into modules.
The series provides a couple of drivers changed. The Mediatek as a recent requested target which is only compiled-tested. The Rockchip timer which was tested on a rk3588 in the three different configurations.
Daniel Lezcano (7):
clocksource/drivers/timer-probe: Create a platform_device before the
framework is initialized
drivers/clocksource/rockchip: Use the TIMER_PDEV_DECLARE() macro clocksource/drivers/mmio: Make the code compatible with modules clocksource/drivers/timer-of: Make the code compatible with modules clocksource/drivers/timer-probe: Add the module support for the
TIMER_PDEV_DECLARE() macro
clocksource/drivers/rockchip: Add rockchip timer module support clocksource/drivers/mediatek: Convert to module support
drivers/clocksource/Kconfig | 7 +- drivers/clocksource/mmio.c | 11 ++- drivers/clocksource/timer-mediatek.c | 29 ++++++-- drivers/clocksource/timer-of.c | 24 ++++--- drivers/clocksource/timer-of.h | 5 +- drivers/clocksource/timer-probe.c | 69 ++++++++++++++++-- drivers/clocksource/timer-rockchip.c | 101 ++++++++++----------------- include/asm-generic/vmlinux.lds.h | 10 +++ include/linux/clocksource.h | 31 ++++++++ 9 files changed, 194 insertions(+), 93 deletions(-)
Signature · 1 line
2.43.0