Skip to contentSkip to conversation

powercap: adjust init order

PATCH In review Zhang Rui 2 participants 2 messages Jul 21, 2019 – Jul 22, 2019 Power management core

lore
Share & tools
lore

Zhang Rui

author
#0 lore raw

PATCH 1/1 powercap: adjust init order

The MMIO RAPL interface driver depends on both powercap subsystem and the intel_rapl_common code.
But when all of them are built in, the MMIO RAPL interface driver is loaded before the later two and this breaks the system during boot. This is because the powercap sysfs class is not registered and the rapl_defaults ops is not set when built-in MMIO RAPL interface driver gets loaded.

Fix this by adjusting the init order of powercap subsystem and the intel_rapl_common code, so that their init functions are executed before MMIO RAPL interface driver in any case.

Fixes 555c45fe0d04 ("int340X/processor_thermal_device: add support for MMIO RAPL")
---
 drivers/powercap/intel_rapl_common.c | 2 +-
 drivers/powercap/powercap_sys.c      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/powercap/intel_rapl_common.c +1 -1
index 9fd6dd3..6df4818 100644
@@ -1454,7 +1454,7 @@ static void __exit rapl_exit(void)
 	unregister_pm_notifier(&rapl_pm_notifier);
 }
 
-module_init(rapl_init);
+fs_initcall(rapl_init);
 module_exit(rapl_exit);
 
 MODULE_DESCRIPTION("Intel Runtime Average Power Limit (RAPL) common code");
drivers/powercap/powercap_sys.c +1 -1
index 540e8aa..f808c5f 100644
@@ -671,7 +671,7 @@ static int __init powercap_init(void)
 	return class_register(&powercap_class);
 }
 
-device_initcall(powercap_init);
+fs_initcall(powercap_init);
 
 MODULE_DESCRIPTION("PowerCap sysfs Driver");
 MODULE_AUTHOR("Srinivas Pandruvada <[email protected]>");
Signature · 1 line
2.7.4
#1 lore raw
Quoted 39 lines · CEST Zhang Rui

The MMIO RAPL interface driver depends on both powercap subsystem and the intel_rapl_common code.
But when all of them are built in, the MMIO RAPL interface driver is loaded before the later two and this breaks the system during boot. This is because the powercap sysfs class is not registered and the rapl_defaults ops is not set when built-in MMIO RAPL interface driver gets loaded.

Fix this by adjusting the init order of powercap subsystem and the intel_rapl_common code, so that their init functions are executed before MMIO RAPL interface driver in any case.

Fixes 555c45fe0d04 ("int340X/processor_thermal_device: add support for MMIO RAPL")
---
 drivers/powercap/intel_rapl_common.c | 2 +-
 drivers/powercap/powercap_sys.c      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/powercap/intel_rapl_common.c +1 -1
index 9fd6dd3..6df4818 100644
@@ -1454,7 +1454,7 @@ static void __exit rapl_exit(void)
 	unregister_pm_notifier(&rapl_pm_notifier);
 }
 
-module_init(rapl_init);
+fs_initcall(rapl_init);
 module_exit(rapl_exit);
 
 MODULE_DESCRIPTION("Intel Runtime Average Power Limit (RAPL) common code");
drivers/powercap/powercap_sys.c +0 -0
index 540e8aa..f808c5f 100644

drivers/powercap/powercap_sys.c static int __init powercap_init(void) · line 677

Quoted 8 lines
drivers/powercap/powercap_sys.c +1 -1
@@ -671,7 +671,7 @@ static int __init powercap_init(void)
 	return class_register(&powercap_class);
 }
 
-device_initcall(powercap_init);
+fs_initcall(powercap_init);
 
 MODULE_DESCRIPTION("PowerCap sysfs Driver");
 MODULE_AUTHOR("Srinivas Pandruvada <[email protected]>");

Applied (with some subject and changelog tweaks), thanks!