notify SMM of cpufreq/pstate support
Subsystems (2)
RFC PATCH 1/1 notify SMM of cpufreq/pstate support
[Follow-up to
http://marc.theaimsgroup.com/?l=acpi4linux&m=108725302512746&w=2 and
http://marc.theaimsgroup.com/?l=acpi4linux&m=107684287525298&w=2
which were the last tries of getting this right last February and June]
Notify SMM of cpufreq
Often, the BIOS changes the CPU frequency if a notebook is (dis)connected from its AC adapter. This interferes with a) an user setting the CPU frequency and b) kernel timing code which needs to know loops_per_jiffy, cpu_khz etc.
So, ACPI 2.0 offers a method to disable such BIOS changes -- writing a value contained in the FADT (pstate_cnt) to the smi_cmd port. This patch utilizes this method by doing this write in processor.c.
However, most current notebooks only offer 1.0 ACPI tables, where the pstate_cnt entry is marked as "reserved". Unless ACPI is in strict mode, the value in this "reserved" field is used as well, but a warning is printed.
So, when is the BIOS notified? When should it be notified? The ACPI specification doesn't say much about it. This patch does it if either of the following cpufreq drivers is pretty much done with a successful registration:
- acpi
- powernow-k7 [if either the system is blacklisted or acpi_force is used]
- powernow-k8 [if the preferred DSDT method is used -- normally, it is...]
- speedstep-centrino [if the preferred DSDT method is used -- normally, it is...]
There's a small problem with the whole pstate_cnt approach: if there is a physical[*] platform limit, it might be necessary to adjust the CPU frequency to avoid serious problems. Unless the BIOS is notified that the kernel is aware of _PPC, the BIOS will likely do such adjustments on its own. As it will be notified now that the OS can properly handle P-States, it might happen that the BIOS won't handle such serious limits -- but if the cpufreq driver is "rmmod'ed" in between, it won't be handled by the OS, either.
This is a serious error, but it will _also_ happen on _any_ OS if:
a) the pstate_cnt had been written to BIOS
b) the system locks up hard so that even IRQs are not handled any more
c) the physical platform limit event occurs
So, both the cpufreq driver and the acpi processor module are "locked" (i.e. rmmod won't work any more) if the BIOS contains a _PPC entry, and acpi_processor_notify_smm() is called.
[*] not the "we-want-to-have-X-hours-of-battery-time-in-that-test" type of platform limits...
arch/i386/kernel/cpu/cpufreq/acpi.c | 4 - arch/i386/kernel/cpu/cpufreq/powernow-k7.c | 3 arch/i386/kernel/cpu/cpufreq/powernow-k8.c | 4 + arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c | 3 drivers/acpi/processor.c | 87 +++++++++++++++++++--- drivers/acpi/tables/tbconvrt.c | 10 ++ include/acpi/actbl.h | 2 include/acpi/processor.h | 4 + 8 files changed, 106 insertions(+), 11 deletions(-)
arch/i386/kernel/cpu/cpufreq/acpi.c +3 -1
@@ -428,7 +428,9 @@if (result) { goto err_freqfree; } - + +/* notify BIOS that we exist */ +acpi_processor_notify_smm (THIS_MODULE );printk (KERN_INFO "cpufreq: CPU%u - ACPI performance management activated.\n" , cpu);
arch/i386/kernel/cpu/cpufreq/powernow-k7.c +3 -0
@@ -400,6 +400,9 @@ powernow_table[i].frequency =CPUFREQ_TABLE_END ; powernow_table[i].index =0 ; +/* notify BIOS that we exist */ +acpi_processor_notify_smm (THIS_MODULE ); +return 0 ; err2:
arch/i386/kernel/cpu/cpufreq/powernow-k8.c +4 -0
@@ -768,6 +768,10 @@ data->numps = data->acpi_data.state_count;print_basics (data);powernow_k8_acpi_pst_values (data,0 ); + +/* notify BIOS that we exist */ +acpi_processor_notify_smm (THIS_MODULE ); +return 0 ; err_out_mem:
arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c +3 -0
@@ -428,6 +428,9 @@ centrino_model->op_points[i].frequency =CPUFREQ_ENTRY_INVALID ; } +/* notify BIOS that we exist */ +acpi_processor_notify_smm (THIS_MODULE ); +return 0 ; err_kfree_all:
drivers/acpi/processor.c +79 -8
131 lines not on this page · raw message
drivers/acpi/tables/tbconvrt.c +8 -2
@@ -50,6 +50,8 @@ ACPI_MODULE_NAME ("tbconvrt") +u8 acpi_fadt_is_v1; +/******************************************************************************* * * FUNCTION: acpi_tb_get_table_count
@@ -212,6 +214,7 @@/* ACPI 1.0 FACS */ /* The BIOS stored FADT should agree with Revision 1.0 */ + acpi_fadt_is_v1 =1 ;/* * Copy the table header and the common part of the tables.
@@ -240,9 +243,12 @@/* * Processor Performance State Control. This is the value OSPM writes to * the SMI_CMD register to assume processor performance state control -* responsibility. There isn't any equivalence in 1.0, leave it zeroed. +* responsibility. There isn't any equivalence in 1.0, but as many 1.x +* ACPI tables contain _PCT and _PSS we also keep this value, unless +* acpi_strict is set. */ - local_fadt->pstate_cnt =0 ; +if (acpi_strict) + local_fadt->pstate_cnt =0 ;/* * Support for the _CST object and C States change notification.
include/acpi/actbl.h +2 -0
@@ -330,6 +330,8 @@#include "actbl1.h" /* Acpi 1.0 table definitions */ #include "actbl2.h" /* Acpi 2.0 table definitions */ +extern u8 acpi_fadt_is_v1;/* is set to 1 if FADT is revision 1, +* needed for certain workarounds */ #pragma pack(1)/*
include/acpi/processor.h +4 -0
@@ -140,4 +140,8 @@struct acpi_processor_performance * performance, unsigned int cpu); +/* note: this locks both the calling module and the processor module +if a _PPC object exists, rmmod is disallowed then */ +int acpi_processor_notify_smm (struct module *calling_module); +#endif