fix up CPU detection in p4-clockmod
PATCH 1/1 fix up CPU detection in p4-clockmod
Too many users use the p4-clockmod cpufreq driver instead of the more advanced speedstep-centrino, speedstep-ich or even acpi drivers. All of the latter (usually) provide voltage scaling, while the p4-clockmod driver only offers a variant of frequency scaling. So, warn users if they try out this driver instead.
Also, instead of using a local copy, use the speedstep_lib infrastructure for detecting the processor speed. Adding the Pentium-M get_frequency function to that module only costs about 200 bytes in object size.
arch/i386/kernel/cpu/cpufreq/Kconfig | 10 ++-- arch/i386/kernel/cpu/cpufreq/p4-clockmod.c | 55 ++++++++------------------- arch/i386/kernel/cpu/cpufreq/speedstep-lib.c | 23 +++++++++++ arch/i386/kernel/cpu/cpufreq/speedstep-lib.h | 6 ++ 4 files changed, 52 insertions(+), 42 deletions(-)
arch/i386/kernel/cpu/cpufreq/Kconfig +5 -5
@@ -145,11 +145,6 @@ If in doubt, say N. -config X86_SPEEDSTEP_LIB - tristate - depends on (X86_SPEEDSTEP_ICH || X86_SPEEDSTEP_SMI) - default (X86_SPEEDSTEP_ICH || X86_SPEEDSTEP_SMI) - config X86_P4_CLOCKMOD tristate "Intel Pentium 4 clock modulation" depends on CPU_FREQ_TABLE
@@ -161,6 +156,11 @@ If in doubt, say N. +config X86_SPEEDSTEP_LIB + tristate + depends on (X86_SPEEDSTEP_ICH || X86_SPEEDSTEP_SMI || X86_P4_CLOCKMOD) + default (X86_SPEEDSTEP_ICH || X86_SPEEDSTEP_SMI || X86_P4_CLOCKMOD) + config X86_LONGRUN tristate "Transmeta LongRun" depends on CPU_FREQ
arch/i386/kernel/cpu/cpufreq/p4-clockmod.c +18 -37
81 lines not on this page · raw message
arch/i386/kernel/cpu/cpufreq/speedstep-lib.c +23 -0
@@ -104,6 +104,26 @@ } +static unsigned int pentiumM_get_frequency (void ) +{ +u32 msr_lo, msr_tmp; + +rdmsr (MSR_IA32_EBL_CR_POWERON , msr_lo, msr_tmp); +dprintk (KERN_DEBUG "speedstep-lib: PM - MSR_IA32_EBL_CR_POWERON: 0x%x 0x%x\n" , msr_lo, msr_tmp); + +/* see table B-2 of 24547212.pdf */ +if (msr_lo &0x00040000 ) { +printk (KERN_DEBUG "speedstep-lib: PM - invalid FSB: 0x%x 0x%x\n" , msr_lo, msr_tmp); +return 0 ; + } + + msr_tmp = (msr_lo >>22 ) &0x1f ; +dprintk (KERN_DEBUG "speedstep-lib: bits 22-26 are 0x%x\n" , msr_tmp); + +return (msr_tmp *100 *10000 ); +} + +static unsigned int pentium4_get_frequency (void ) {struct cpuinfo_x86 *c = &boot_cpu_data;
@@ -151,6 +171,9 @@unsigned int speedstep_get_processor_frequency (unsigned int processor) {switch (processor) { +case SPEEDSTEP_PROCESSOR_PM : +return pentiumM_get_frequency (); +case SPEEDSTEP_PROCESSOR_P4D :case SPEEDSTEP_PROCESSOR_P4M :return pentium4_get_frequency ();case SPEEDSTEP_PROCESSOR_PIII_T :
arch/i386/kernel/cpu/cpufreq/speedstep-lib.h +6 -0
@@ -17,6 +17,12 @@#define SPEEDSTEP_PROCESSOR_PIII_T 0x00000003/* Tualatin core */ #define SPEEDSTEP_PROCESSOR_P4M 0x00000004/* P4-M */ +/* the following processors are not speedstep-capable and are not auto-detected +* in speedstep_detect_processor(). However, their speed can be detected using +* the speedstep_get_processor_frequency() call. */ +#define SPEEDSTEP_PROCESSOR_PM 0xFFFFFF03/* Pentium M */ +#define SPEEDSTEP_PROCESSOR_P4D 0xFFFFFF04/* desktop P4 */ +/* speedstep states -- only two of them */ #define SPEEDSTEP_HIGH 0x00000000
Quoted 9 lines · Dominik Brodowski
Too many users use the p4-clockmod cpufreq driver instead of the more advanced speedstep-centrino, speedstep-ich or even acpi drivers. All of the latter (usually) provide voltage scaling, while the p4-clockmod driver only offers a variant of frequency scaling. So, warn users if they try out this driver instead.
Also, instead of using a local copy, use the
speedstep_libinfrastructure for detecting the processor speed. Adding the Pentium-Mget_frequencyfunction to that module only costs about 200 bytes in object size.
another idea might be putting the cpu identify code into a speedstep.ko and have that request_module the right module
Dave.
Quoted 7 lines · Dave Jones
Quoted 6 lines · Dominik Brodowski
Too many users use the p4-clockmod cpufreq driver instead of the more advanced speedstep-centrino, speedstep-ich or even acpi drivers. All of the latter (usually) provide voltage scaling, while the p4-clockmod driver only offers a variant of frequency scaling. So, warn users if they try out this driver instead.
Quoted 6 lines
Quoted 3 lines
Also, instead of using a local copy, use the
speedstep_libinfrastructure for detecting the processor speed. Adding the Pentium-Mget_frequencyfunction to that module only costs about 200 bytes in object size.another idea might be putting the cpu identify code into a speedstep.ko and have that
request_modulethe right module
That's not a valid option as a replacement -- there _are_ different modules possible for the same CPU. However, it's a good idea if it is implemented as an "autoloader".
Dominik
_______________________________________________
Cpufreq mailing list
[email protected]
http://www.linux.org.uk/mailman/listinfo/cpufreq
Quoted 8 lines · Dave Jones
Quoted 6 lines · Dominik Brodowski
Too many users use the p4-clockmod cpufreq driver instead of the more advanced speedstep-centrino, speedstep-ich or even acpi drivers. All of the latter (usually) provide voltage scaling, while the p4-clockmod driver only offers a variant of frequency scaling. So, warn users if they try out this driver instead.
Quoted 7 lines
Quoted 3 lines
Also, instead of using a local copy, use the
speedstep_libinfrastructure for detecting the processor speed. Adding the Pentium-Mget_frequencyfunction to that module only costs about 200 bytes in object size.another idea might be putting the cpu identify code into a speedstep.ko and have that
request_modulethe right module
That seems like a more user-friendly approach to me.
I'll merge Dominik's patch while we think about it.
Quoted 13 lines · Andrew Morton
Quoted 12 lines · Dave Jones
Quoted 9 lines · Dominik Brodowski
Too many users use the p4-clockmod cpufreq driver instead of the more advanced speedstep-centrino, speedstep-ich or even acpi drivers. All of the latter (usually) provide voltage scaling, while the p4-clockmod driver only offers a variant of frequency scaling. So, warn users if they try out this driver instead.
Also, instead of using a local copy, use the
speedstep_libinfrastructure for detecting the processor speed. Adding the Pentium-Mget_frequencyfunction to that module only costs about 200 bytes in object size.
Quoted 7 lines
Quoted 3 lines
another idea might be putting the cpu identify code into a speedstep.ko and have that
request_modulethe right moduleThat seems like a more user-friendly approach to me.
I'll merge Dominik's patch while we think about it.
We still need cpu identification code in the various speedstep-* drivers as they need to do a few things differently on different CPUs...
The "request_modul"ing of the right module could be done more easily in userspace, IMHO. A small sample is attached.
Dominik
_______________________________________________
Cpufreq mailing list
[email protected]
http://www.linux.org.uk/mailman/listinfo/cpufreq