Skip to contentSkip to conversation

remap non-modular uses of module_init properly

PATCH In review Paul Gortmaker 2 participants 6 messages Jan 13, 2014 – Jan 14, 2014

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

cover remap non-modular uses of module_init properly

The goal is to move module_init/module_exit from init.h and into module.h -- however in doing so, we uncover several instances in powerpc code where module_init is used somewhat incorrectly by non modular code, and a file that needs module.h but isn't sourcing it. We need to make these fixups 1st before changing the headers so that we don't cause build failures.

The changes are largely inert, however we do cause a largely trivial change in the initcall ordering -- that happens because module_init is really device_initcall; and yet we shouldn't be using device_initcall where clearly arch_initcall or subsys_initcall are more appropriate.

Boot tested on sbc8548 on powerpc next branch of today.

Paul Gortmaker (4):
powerpc: use device_initcall for registering rtc devices
powerpc: book3s kvm can be modular so it should use module.h
powerpc: use subsys_initcall for Freescale Local Bus
powerpc: don't use module_init for non-modular core hugetlb code

 arch/powerpc/kernel/time.c        | 2 +-
 arch/powerpc/kvm/book3s.c         | 2 +-
 arch/powerpc/mm/hugetlbpage.c     | 2 +-
 arch/powerpc/platforms/ps3/time.c | 3 +--
 arch/powerpc/sysdev/fsl_lbc.c     | 2 +-
 5 files changed, 5 insertions(+), 6 deletions(-)
Signature · 1 line
1.8.5.2
#1 lore raw

PATCH 1/4 powerpc: use device_initcall for registering rtc devices

Currently these two RTC devices are in core platform code where it is not possible for them to be modular. It will never be modular, so using module_init as an alias for __initcall can be somewhat misleading.

Fix this up now, so that we can relocate module_init from init.h into module.h in the future. If we don't do this, we'd have to add module.h to obviously non-modular code, and that would be a worse thing.

Note that direct use of __initcall is discouraged, vs. one of the priority categorized subgroups. As __initcall gets mapped onto device_initcall, our use of device_initcall directly in this change means that the runtime impact is zero -- they will remain at level 6 in initcall ordering.

---
 arch/powerpc/kernel/time.c        | 2 +-
 arch/powerpc/platforms/ps3/time.c | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)
arch/powerpc/kernel/time.c +1 -1
index afb1b56ef4fa..bee2bb2bbc75 100644
@@ -1053,4 +1053,4 @@ static int __init rtc_init(void)
 	return PTR_ERR_OR_ZERO(pdev);
 }
 
-module_init(rtc_init);
+device_initcall(rtc_init);
arch/powerpc/platforms/ps3/time.c +1 -2
index ce73ce865613..791c6142c4a7 100644
@@ -92,5 +92,4 @@ static int __init ps3_rtc_init(void)
 
 	return PTR_ERR_OR_ZERO(pdev);
 }
-
-module_init(ps3_rtc_init);
+device_initcall(ps3_rtc_init);
Signature · 1 line
1.8.5.2
#5 lore raw

PATCH 4/4 powerpc: don't use module_init for non-modular core hugetlb code

In reply to Paul Gortmaker

The hugetlbpage.o is obj-y (always built in). It will never be modular, so using module_init as an alias for __initcall is somewhat misleading.

Fix this up now, so that we can relocate module_init from init.h into module.h in the future. If we don't do this, we'd have to add module.h to obviously non-modular code, and that would be a worse thing.

Note that direct use of __initcall is discouraged, vs. one of the priority categorized subgroups. As __initcall gets mapped onto device_initcall, our use of arch_initcall (which makes sense for arch code) will thus change this registration from level 6-device to level 3-arch (i.e. slightly earlier). However no observable impact of that small difference has been observed during testing, or is expected.

---
 arch/powerpc/mm/hugetlbpage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/mm/hugetlbpage.c +1 -1
index 90bb6d9409bf..d25c202420da 100644
@@ -911,7 +911,7 @@ static int __init hugetlbpage_init(void)
 	return 0;
 }
 #endif
-module_init(hugetlbpage_init);
+arch_initcall(hugetlbpage_init);
 
 void flush_dcache_icache_hugepage(struct page *page)
 {
Signature · 1 line
1.8.5.2
#3 lore raw

PATCH 3/4 powerpc: use subsys_initcall for Freescale Local Bus

In reply to Paul Gortmaker

The FSL_SOC option is bool, and hence this code is either present or absent. It will never be modular, so using module_init as an alias for __initcall is rather misleading.

Fix this up now, so that we can relocate module_init from init.h into module.h in the future. If we don't do this, we'd have to add module.h to obviously non-modular code, and that would be a worse thing.

Note that direct use of __initcall is discouraged, vs. one of the priority categorized subgroups. As __initcall gets mapped onto device_initcall, our use of subsys_initcall (which makes sense for bus code) will thus change this registration from level 6-device to level 4-subsys (i.e. slightly earlier). However no observable impact of that small difference has been observed during testing, or is expected.

---
 arch/powerpc/sysdev/fsl_lbc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/sysdev/fsl_lbc.c +1 -1
index 6bc5a546d49f..9f00e5f84abe 100644
@@ -388,4 +388,4 @@ static int __init fsl_lbc_init(void)
 {
 	return platform_driver_register(&fsl_lbc_ctrl_driver);
 }
-module_init(fsl_lbc_init);
+subsys_initcall(fsl_lbc_init);
Signature · 1 line
1.8.5.2
#2 lore raw

PATCH 2/4 powerpc: book3s kvm can be modular so it should use module.h

In reply to Paul Gortmaker

KVM support is tristate, so this file should be including module.h instead of export.h -- it only works currently because module_init is currently (mis)placed in init.h -- but we are intending to clean that up and relocate it to module.h

---
 arch/powerpc/kvm/book3s.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kvm/book3s.c +1 -1
index 8912608b7e1b..279459e8a072 100644
@@ -16,7 +16,7 @@
 
 #include <linux/kvm_host.h>
 #include <linux/err.h>
-#include <linux/export.h>
+#include <linux/module.h>
 #include <linux/slab.h>
 
 #include <asm/reg.h>
Signature · 1 line
1.8.5.2
Acked-by on v1 3/4
#4 lore raw

Re: [PATCH 3/4] powerpc: use subsys_initcall for Freescale Local Bus

In reply to Paul Gortmaker
Quoted 27 lines · Paul Gortmaker

The FSL_SOC option is bool, and hence this code is either present or absent. It will never be modular, so using module_init as an alias for __initcall is rather misleading.

Fix this up now, so that we can relocate module_init from init.h into module.h in the future. If we don't do this, we'd have to add module.h to obviously non-modular code, and that would be a worse thing.

Note that direct use of __initcall is discouraged, vs. one of the priority categorized subgroups. As __initcall gets mapped onto device_initcall, our use of subsys_initcall (which makes sense for bus code) will thus change this registration from level 6-device to level 4-subsys (i.e. slightly earlier). However no observable impact of that small difference has been observed during testing, or is expected.

---
 arch/powerpc/sysdev/fsl_lbc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/sysdev/fsl_lbc.c +0 -0
index 6bc5a546d49f..9f00e5f84abe 100644

arch/powerpc/sysdev/fsl_lbc.c static int __init fsl_lbc_init(void) · line 391

Quoted 5 lines
arch/powerpc/sysdev/fsl_lbc.c +1 -1
@@ -388,4 +388,4 @@ static int __init fsl_lbc_init(void)
 {
 	return platform_driver_register(&fsl_lbc_ctrl_driver);
 }
-module_init(fsl_lbc_init);
+subsys_initcall(fsl_lbc_init);

-Scott