platform/surface: aggregator: Fix initialization order when compiling as builtin module
Subsystems (3)
Maximilian Luz
maintainerPATCH 1/1 platform/surface: aggregator: Fix initialization order when compiling as builtin module
When building the Surface Aggregator Module (SAM) core, registry, and other SAM client drivers as builtin modules (=y), proper initialization order is not guaranteed. Due to this, client driver registration (triggered by device registration in the registry) races against bus initialization in the core.
If any attempt is made at registering the device driver before the bus has been initialized (i.e. if bus initialization fails this race) driver registration will fail with a message similar to:
Driver surface_battery was unable to register with bus_type surface_aggregator because the bus was not initialized
Switch from module_init() to subsys_initcall() to resolve this issue. Note that the serdev subsystem uses postcore_initcall() so we are still able to safely register the serdev device driver for the core.
--- drivers/platform/surface/aggregator/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/surface/aggregator/core.c +1 -1
@@ -817,7 +817,7 @@ static int __init ssam_core_init(void) err_bus:return status; } -module_init (ssam_core_init); +subsys_initcall (ssam_core_init); static void __exit ssam_core_exit(void) {
Signature · 1 line
2.36.0
Hi,
Quoted 12 lines · Maximilian Luz
When building the Surface Aggregator Module (SAM) core, registry, and other SAM client drivers as builtin modules (=y), proper initialization order is not guaranteed. Due to this, client driver registration (triggered by device registration in the registry) races against bus initialization in the core.
If any attempt is made at registering the device driver before the bus has been initialized (i.e. if bus initialization fails this race) driver registration will fail with a message similar to:
Driver
surface_batterywas unable to register withbus_typesurface_aggregatorbecause the bus was not initialized
Quoted 7 lines
Switch from
module_init()tosubsys_initcall()to resolve this issue. Note that the serdev subsystem usespostcore_initcall()so we are still able to safely register the serdev device driver for the core.Fixes c167b9c7e3d6 ("platform/surface: Add Surface Aggregator subsystem")Reported-by Blaž Hrastnik <[email protected]>Signed-off-by Maximilian Luz <[email protected]>
Thank you for your patch, I've applied this patch to my review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans
Note it will show up in my review-hans branch once I've pushed my local branch there, which might take a while.
Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window.
Regards,
Hans
Quoted 17 lines
--- drivers/platform/surface/aggregator/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/platform/surface/aggregator/core.c +1
-1@@ -817,7 +817,7 @@ static int __init ssam_core_init(void) err_bus:return status; } -module_init (ssam_core_init); +subsys_initcall (ssam_core_init); static void __exit ssam_core_exit(void) {