29 #include <linux/kernel.h>
30 #include <linux/module.h>
33 #include <linux/slab.h>
36 #include <asm/cpufeature.h>
43 #define PREFIX "ACPI: "
45 #define ACPI_PROCESSOR_CLASS "processor"
46 #define ACPI_PROCESSOR_FILE_PERFORMANCE "performance"
47 #define _COMPONENT ACPI_PROCESSOR_COMPONENT
68 static int ignore_ppc = -1;
70 MODULE_PARM_DESC(ignore_ppc,
"If the frequency of your machine gets wrongly" \
71 "limited by BIOS, this should help");
73 #define PPC_REGISTERED 1
76 static int acpi_processor_ppc_status;
107 cpufreq_verify_within_limits(policy, 0,
109 core_frequency * 1000);
118 .notifier_call = acpi_processor_ppc_notifier,
124 unsigned long long ppc = 0;
144 pr_debug(
"CPU %d: _PPC is %d - frequency %s limited\n", pr->
id,
145 (
int)ppc, ppc ?
"" :
"not");
152 #define ACPI_PROCESSOR_NOTIFY_PERFORMANCE 0x80
190 acpi_processor_ppc_ost(pr->
handle, 1);
194 ret = acpi_processor_get_platform_limit(pr);
201 acpi_processor_ppc_ost(pr->
handle, 1);
203 acpi_processor_ppc_ost(pr->
handle, 0);
219 core_frequency * 1000;
231 "Warning: Processor Platform Limit not supported.\n");
240 acpi_processor_ppc_status &= ~PPC_REGISTERED;
250 static int requested;
254 if (!arch_has_acpi_pdc() || requested)
259 request_module_nowait(
"acpi_cpufreq");
265 static int acpi_processor_get_performance_control(
struct acpi_processor *pr)
282 || (pct->
package.count != 2)) {
292 obj = pct->
package.elements[0];
308 obj = pct->
package.elements[1];
355 static int acpi_processor_get_performance_states(
struct acpi_processor *pr)
364 int last_invalid = -1;
392 for (i = 0; i < pr->
performance->state_count; i++) {
410 amd_fixup_frequency(px, i);
413 "State [%d]: core_frequency[%d] power[%d] transition_latency[%d] bus_master_latency[%d] control[0x%x] status[0x%x]\n",
428 "Invalid BIOS _PSS frequency found for processor %d: 0x%llx MHz\n",
430 if (last_invalid == -1)
433 if (last_invalid != -1) {
444 if (last_invalid == 0) {
446 "No valid BIOS _PSS frequency found for processor %d\n", pr->
id);
452 if (last_invalid > 0)
461 static int acpi_processor_get_performance_info(
struct acpi_processor *pr)
473 "ACPI-based processor performance control unavailable\n"));
477 result = acpi_processor_get_performance_control(pr);
481 result = acpi_processor_get_performance_states(pr);
487 result = acpi_processor_get_platform_limit(pr);
500 "frequency support\n");
509 static int is_done = 0;
515 if (!try_module_get(calling_module))
524 module_put(calling_module);
526 }
else if (is_done < 0) {
527 module_put(calling_module);
536 module_put(calling_module);
541 "Writing pstate_control [0x%x] to smi_command [0x%x]\n",
548 "Failed to write pstate_control [0x%x] to "
551 module_put(calling_module);
559 if (!(acpi_processor_ppc_status &
PPC_IN_USE))
560 module_put(calling_module);
572 struct acpi_buffer format = {
sizeof(
"NNNNN"),
"NNNNN"};
635 int count, count_target;
644 if (!zalloc_cpumask_var(&covered_cpus,
GFP_KERNEL))
665 if (!performance || !
per_cpu_ptr(performance, i)) {
678 cpumask_set_cpu(i, pr->
performance->shared_cpu_map);
679 if (acpi_processor_get_psd(pr)) {
700 cpumask_set_cpu(i, pr->
performance->shared_cpu_map);
701 cpumask_set_cpu(i, covered_cpus);
719 match_pr =
per_cpu(processors, j);
723 match_pdomain = &(match_pr->
performance->domain_info);
739 cpumask_set_cpu(j, covered_cpus);
740 cpumask_set_cpu(j, pr->
performance->shared_cpu_map);
748 match_pr =
per_cpu(processors, j);
752 match_pdomain = &(match_pr->
performance->domain_info);
758 cpumask_copy(match_pr->
performance->shared_cpu_map,
772 cpumask_set_cpu(i, pr->
performance->shared_cpu_map);
780 free_cpumask_var(covered_cpus);
787 *performance,
unsigned int cpu)
811 if (acpi_processor_get_performance_info(pr)) {