diff options
author | Zhang Rui <rui.zhang@intel.com> | 2019-07-10 21:44:34 +0800 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2019-07-11 15:08:58 +0200 |
commit | abcfaeb3f5dc8bded4ba446eb2fb017a7a41d9bc (patch) | |
tree | e4bfec49a6ac1e2c66bda969d8fe940c8362b0a1 /drivers/powercap/intel_rapl_msr.c | |
parent | 555c45fe0d04bd817e245a125d242b6a86af4593 (diff) |
intel_rapl: Fix module autoloading issue
intel_rapl driver used to have a list of cpuids, which is used to
1. check if the processor support RAPL MSRs
2. do some cpu model specific setting
3. module autoloading
Now, the cpu model specific setting are moved to intel_rapl_common.c as
part of the common code, because the setup is also needed by RAPL MMIO
interface on those platforms.
But removing the cpuid list from intel_rapl MSR interface driver results
in that the driver can not be loaded automatically.
Maintaining another copy of the cpuid list in intel_rapl_msr.c does not make
sense because it increases the complexity when enabling RAPL support on a
new cpu model.
Fix the problem by creating an "intel_rapl_msr" platform device in the
common code, and make RAPL MSR interface driver (intel_rapl_msr.c) probe the
platform device directly.
Reviewed-by: Pandruvada, Srinivas <srinivas.pandruvada@intel.com>
Tested-by: Pandruvada, Srinivas <srinivas.pandruvada@intel.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/powercap/intel_rapl_msr.c')
-rw-r--r-- | drivers/powercap/intel_rapl_msr.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/drivers/powercap/intel_rapl_msr.c b/drivers/powercap/intel_rapl_msr.c index bc14a4579acb..d5487965bdfe 100644 --- a/drivers/powercap/intel_rapl_msr.c +++ b/drivers/powercap/intel_rapl_msr.c @@ -20,6 +20,7 @@ #include <linux/suspend.h> #include <linux/intel_rapl.h> #include <linux/processor.h> +#include <linux/platform_device.h> #include <asm/iosf_mbi.h> #include <asm/cpu_device_id.h> @@ -122,7 +123,7 @@ static int rapl_msr_write_raw(int cpu, struct reg_action *ra) return ra->err; } -static int __init rapl_msr_init(void) +static int rapl_msr_probe(struct platform_device *pdev) { int ret; @@ -152,15 +153,30 @@ out: return ret; } -static void __exit rapl_msr_exit(void) +static int rapl_msr_remove(struct platform_device *pdev) { cpuhp_remove_state(rapl_msr_priv.pcap_rapl_online); rapl_remove_platform_domain(&rapl_msr_priv); powercap_unregister_control_type(rapl_msr_priv.control_type); + return 0; } -module_init(rapl_msr_init); -module_exit(rapl_msr_exit); +static const struct platform_device_id rapl_msr_ids[] = { + { .name = "intel_rapl_msr", }, + {} +}; +MODULE_DEVICE_TABLE(platform, rapl_msr_ids); + +static struct platform_driver intel_rapl_msr_driver = { + .probe = rapl_msr_probe, + .remove = rapl_msr_remove, + .id_table = rapl_msr_ids, + .driver = { + .name = "intel_rapl_msr", + }, +}; + +module_platform_driver(intel_rapl_msr_driver); MODULE_DESCRIPTION("Driver for Intel RAPL (Running Average Power Limit) control via MSR interface"); MODULE_AUTHOR("Zhang Rui <rui.zhang@intel.com>"); |