Linux-PM Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] powercap: adjust init order
@ 2019-07-21  2:49 Zhang Rui
  2019-07-22  9:33 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: Zhang Rui @ 2019-07-21  2:49 UTC (permalink / raw)
  To: rjw; +Cc: linux-pm, srinivas.pandruvada, rui.zhang, kenny

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")
Reported-and-tested-by: Kenneth R. Crudup <kenny@panix.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
 drivers/powercap/intel_rapl_common.c | 2 +-
 drivers/powercap/powercap_sys.c      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/powercap/intel_rapl_common.c b/drivers/powercap/intel_rapl_common.c
index 9fd6dd3..6df4818 100644
--- a/drivers/powercap/intel_rapl_common.c
+++ b/drivers/powercap/intel_rapl_common.c
@@ -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");
diff --git a/drivers/powercap/powercap_sys.c b/drivers/powercap/powercap_sys.c
index 540e8aa..f808c5f 100644
--- a/drivers/powercap/powercap_sys.c
+++ b/drivers/powercap/powercap_sys.c
@@ -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 <srinivas.pandruvada@linux.intel.com>");
-- 
2.7.4


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] powercap: adjust init order
  2019-07-21  2:49 [PATCH] powercap: adjust init order Zhang Rui
@ 2019-07-22  9:33 ` Rafael J. Wysocki
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2019-07-22  9:33 UTC (permalink / raw)
  To: Zhang Rui; +Cc: linux-pm, srinivas.pandruvada, kenny

On Sunday, July 21, 2019 4:49:44 AM CEST Zhang Rui wrote:
> 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")
> Reported-and-tested-by: Kenneth R. Crudup <kenny@panix.com>
> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
> ---
>  drivers/powercap/intel_rapl_common.c | 2 +-
>  drivers/powercap/powercap_sys.c      | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/powercap/intel_rapl_common.c b/drivers/powercap/intel_rapl_common.c
> index 9fd6dd3..6df4818 100644
> --- a/drivers/powercap/intel_rapl_common.c
> +++ b/drivers/powercap/intel_rapl_common.c
> @@ -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");
> diff --git a/drivers/powercap/powercap_sys.c b/drivers/powercap/powercap_sys.c
> index 540e8aa..f808c5f 100644
> --- a/drivers/powercap/powercap_sys.c
> +++ b/drivers/powercap/powercap_sys.c
> @@ -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 <srinivas.pandruvada@linux.intel.com>");
> 

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





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-21  2:49 [PATCH] powercap: adjust init order Zhang Rui
2019-07-22  9:33 ` Rafael J. Wysocki

Linux-PM Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-pm/0 linux-pm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-pm linux-pm/ https://lore.kernel.org/linux-pm \
		linux-pm@vger.kernel.org linux-pm@archiver.kernel.org
	public-inbox-index linux-pm


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-pm


AGPL code for this site: git clone https://public-inbox.org/ public-inbox