Skip to content

Commit

Permalink
powercap: intel_rapl: Allow probing without CPUID match
Browse files Browse the repository at this point in the history
Currently, CPU model checks is used to
1. get proper rapl_defaults callbacks for RAPL MSR/MMIO Interface.
2. create a platform device node for the intel_rapl_msr driver to probe.

Both of these are only mandatory for the RAPL MSR/MMIO Interface.

Make the CPUID match optional.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Tested-by: Wang Wendy <wendy.wang@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
zhang-rui authored and rafaeljw committed May 24, 2023
1 parent 31cb130 commit 1488ac9
Showing 1 changed file with 14 additions and 21 deletions.
35 changes: 14 additions & 21 deletions drivers/powercap/intel_rapl_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1528,32 +1528,25 @@ static int __init rapl_init(void)
int ret;

id = x86_match_cpu(rapl_ids);
if (!id) {
pr_err("driver does not support CPU family %d model %d\n",
boot_cpu_data.x86, boot_cpu_data.x86_model);
if (id) {
rapl_defaults = (struct rapl_defaults *)id->driver_data;

return -ENODEV;
}

rapl_defaults = (struct rapl_defaults *)id->driver_data;

ret = register_pm_notifier(&rapl_pm_notifier);
if (ret)
return ret;
rapl_msr_platdev = platform_device_alloc("intel_rapl_msr", 0);
if (!rapl_msr_platdev)
return -ENOMEM;

rapl_msr_platdev = platform_device_alloc("intel_rapl_msr", 0);
if (!rapl_msr_platdev) {
ret = -ENOMEM;
goto end;
ret = platform_device_add(rapl_msr_platdev);
if (ret) {
platform_device_put(rapl_msr_platdev);
return ret;
}
}

ret = platform_device_add(rapl_msr_platdev);
if (ret)
ret = register_pm_notifier(&rapl_pm_notifier);
if (ret && rapl_msr_platdev) {
platform_device_del(rapl_msr_platdev);
platform_device_put(rapl_msr_platdev);

end:
if (ret)
unregister_pm_notifier(&rapl_pm_notifier);
}

return ret;
}
Expand Down

0 comments on commit 1488ac9

Please sign in to comment.