bk://linux-dj.bkbits.net/cpufreq davej@redhat.com|ChangeSet|20040708130847|18898 davej # This is a BitKeeper generated diff -Nru style patch. # # ChangeSet # 2004/07/08 14:19:23-07:00 akpm@bix.(none) # Merge bk://linux-dj.bkbits.net/cpufreq # into bix.(none):/usr/src/bk-cpufreq # # arch/i386/kernel/cpu/cpufreq/powernow-k7.c # 2004/07/08 14:19:19-07:00 akpm@bix.(none) +0 -0 # Auto merged # # ChangeSet # 2004/07/08 14:08:47+01:00 davej@redhat.com # [CPUFREQ] fix whitespace after merge. # # Signed-off-by: Dave Jones # # arch/i386/kernel/cpu/cpufreq/powernow-k7.c # 2004/07/08 14:07:31+01:00 davej@redhat.com +1 -1 # [CPUFREQ] fix whitespace after merge. # # Signed-off-by: Dave Jones # # ChangeSet # 2004/07/08 13:59:21+01:00 davej@delerium.codemonkey.org.uk # Merge delerium.codemonkey.org.uk:/mnt/data/src/bk/bk-linus # into delerium.codemonkey.org.uk:/mnt/data/src/bk/cpufreq # # arch/i386/kernel/cpu/cpufreq/powernow-k7.c # 2004/07/08 13:59:14+01:00 davej@delerium.codemonkey.org.uk +0 -0 # Auto merged # # ChangeSet # 2004/07/04 22:43:06-07:00 akpm@bix.(none) # Merge bk://linux-dj.bkbits.net/cpufreq # into bix.(none):/usr/src/bk-cpufreq # # arch/i386/kernel/cpu/cpufreq/powernow-k7.c # 2004/07/04 22:43:03-07:00 akpm@bix.(none) +0 -0 # Auto merged # # ChangeSet # 2004/07/05 01:36:09+01:00 davej@redhat.com # [CPUFREQ] Remove out of date comment from powernow-k7 # This has had significant amount of testing since it got merged, and # nothing nasty has actually ever happened. # # Signed-off-by: Dave Jones # # arch/i386/kernel/cpu/cpufreq/powernow-k7.c # 2004/07/05 01:36:00+01:00 davej@redhat.com +0 -2 # [CPUFREQ] Remove out of date comment from powernow-k7 # This has had significant amount of testing since it got merged, and # nothing nasty has actually ever happened. # # Signed-off-by: Dave Jones # # ChangeSet # 2004/07/05 01:34:47+01:00 davej@redhat.com # [CPUFREQ] REmove more trailing whitespace # # Signed-off-by: Dave Jones # # arch/i386/kernel/cpu/cpufreq/powernow-k7.c # 2004/07/05 01:34:40+01:00 davej@redhat.com +9 -9 # [CPUFREQ] REmove more trailing whitespace # # Signed-off-by: Dave Jones # # ChangeSet # 2004/07/05 01:20:53+01:00 davej@redhat.com # [CPUFREQ] Make powernow-k7 debug printk a runtime option. # Signed-off-by: Dave Jones # # arch/i386/kernel/cpu/cpufreq/powernow-k7.c # 2004/07/05 01:20:44+01:00 davej@redhat.com +19 -9 # [CPUFREQ] Make powernow-k7 debug printk a runtime option. # Signed-off-by: Dave Jones # # ChangeSet # 2004/07/04 01:18:17+01:00 davej@redhat.com # [CPUFREQ] fix userspace resume support. # # Fix resume support in the userspace cpufreq governor: we need to set the # CPU to the frequency last echo'ed by userspace into this governor's files. # # Signed-off-by: Dominik Brodowski # Signed-off-by: Dave Jones # # drivers/cpufreq/cpufreq_userspace.c # 2004/07/04 01:18:10+01:00 davej@redhat.com +10 -0 # [CPUFREQ] fix userspace resume support. # # Fix resume support in the userspace cpufreq governor: we need to set the # CPU to the frequency last echo'ed by userspace into this governor's files. # # Signed-off-by: Dominik Brodowski # Signed-off-by: Dave Jones # # ChangeSet # 2004/07/04 01:16:06+01:00 davej@redhat.com # [CPUFREQ] fix double "out-of-sync" warning on resume. # # - Rephrase "out-of-sync" warning (partly) based upon Gerald Britton's suggestion # - Also update cpufreq's opinion of current cpu frequency upon resume, else the # "out-of-sync" warning will appear twice. Thanks to Gerald Britton for noting this. # # Signed-off-by: Dominik Brodowski # Signed-off-by: Dave Jones # # drivers/cpufreq/cpufreq.c # 2004/07/04 01:15:58+01:00 davej@redhat.com +6 -5 # [CPUFREQ] fix double "out-of-sync" warning on resume. # # - Rephrase "out-of-sync" warning (partly) based upon Gerald Britton's suggestion # - Also update cpufreq's opinion of current cpu frequency upon resume, else the # "out-of-sync" warning will appear twice. Thanks to Gerald Britton for noting this. # # Signed-off-by: Dominik Brodowski # Signed-off-by: Dave Jones # # ChangeSet # 2004/07/03 18:05:50+01:00 davej@redhat.com # [CPUFREQ] Fix FSB calculation in powernow-k7 # # use the maximum fid instead of the current fid. # # From: Bruno Ducrot # Signed-off-by: Dave Jones # # arch/i386/kernel/cpu/cpufreq/powernow-k7.c # 2004/07/03 18:05:42+01:00 davej@redhat.com +1 -1 # [CPUFREQ] Fix FSB calculation in powernow-k7 # # use the maximum fid instead of the current fid. # # From: Bruno Ducrot # Signed-off-by: Dave Jones # # ChangeSet # 2004/07/03 17:17:16+01:00 davej@redhat.com # [CPUFREQ] Trailing whitespace removal in longrun driver. # # Signed-off-by: Dave Jones # # arch/i386/kernel/cpu/cpufreq/longrun.c # 2004/07/03 17:17:09+01:00 davej@redhat.com +21 -21 # [CPUFREQ] Trailing whitespace removal in longrun driver. # # Signed-off-by: Dave Jones # # ChangeSet # 2004/06/29 23:43:48+01:00 davej@redhat.com # [CPUFREQ] Fix sparse NULL ptr warning. # # Signed-off-by: Dave Jones # # arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c # 2004/06/29 23:43:41+01:00 davej@redhat.com +1 -1 # [CPUFREQ] Fix sparse NULL ptr warning. # # Signed-off-by: Dave Jones # # ChangeSet # 2004/06/27 16:53:42-07:00 akpm@bix.(none) # Merge bix.(none):/usr/src/bk25 into bix.(none):/usr/src/bk-cpufreq # # arch/i386/kernel/cpu/cpufreq/powernow-k7.c # 2004/06/27 16:53:38-07:00 akpm@bix.(none) +0 -0 # Auto merged # # ChangeSet # 2004/06/20 00:04:48+01:00 davej@redhat.com # [CPUFREQ] Stop powernow-k7 printk'ing tab characters. # # Signed-off-by: Dave Jones # # arch/i386/kernel/cpu/cpufreq/powernow-k7.c # 2004/06/20 00:04:29+01:00 davej@redhat.com +5 -5 # [CPUFREQ] Stop powernow-k7 printk'ing tab characters. # # Signed-off-by: Dave Jones # # ChangeSet # 2004/06/16 17:58:22+01:00 davej@redhat.com # [CPUFREQ] new Dothan variant for speedstep-centrino # # Add support for new Dothan variant (CPUID 0x6d6) to speedstep-centrino. # Noted to be missing and tested by Athul Acharya. # # Signed-off-by: Dominik Brodowski # Signed-off-by: Dave Jones # # arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c # 2004/06/16 17:58:14+01:00 davej@redhat.com +9 -1 # [CPUFREQ] new Dothan variant for speedstep-centrino # # Add support for new Dothan variant (CPUID 0x6d6) to speedstep-centrino. # Noted to be missing and tested by Athul Acharya. # # Signed-off-by: Dominik Brodowski # Signed-off-by: Dave Jones # diff -Nru a/arch/i386/kernel/cpu/cpufreq/longrun.c b/arch/i386/kernel/cpu/cpufreq/longrun.c --- a/arch/i386/kernel/cpu/cpufreq/longrun.c 2004-07-08 18:11:41 -07:00 +++ b/arch/i386/kernel/cpu/cpufreq/longrun.c 2004-07-08 18:11:41 -07:00 @@ -7,7 +7,7 @@ */ #include -#include +#include #include #include #include @@ -19,7 +19,7 @@ static struct cpufreq_driver longrun_driver; /** - * longrun_{low,high}_freq is needed for the conversion of cpufreq kHz + * longrun_{low,high}_freq is needed for the conversion of cpufreq kHz * values into per cent values. In TMTA microcode, the following is valid: * performance_pctg = (current_freq - low_freq)/(high_freq - low_freq) */ @@ -42,18 +42,18 @@ policy->policy = CPUFREQ_POLICY_PERFORMANCE; else policy->policy = CPUFREQ_POLICY_POWERSAVE; - + rdmsr(MSR_TMTA_LONGRUN_CTRL, msr_lo, msr_hi); msr_lo &= 0x0000007F; msr_hi &= 0x0000007F; - + if ( longrun_high_freq <= longrun_low_freq ) { /* Assume degenerate Longrun table */ policy->min = policy->max = longrun_high_freq; } else { - policy->min = longrun_low_freq + msr_lo * + policy->min = longrun_low_freq + msr_lo * ((longrun_high_freq - longrun_low_freq) / 100); - policy->max = longrun_low_freq + msr_hi * + policy->max = longrun_low_freq + msr_hi * ((longrun_high_freq - longrun_low_freq) / 100); } policy->cpu = 0; @@ -79,9 +79,9 @@ /* Assume degenerate Longrun table */ pctg_lo = pctg_hi = 100; } else { - pctg_lo = (policy->min - longrun_low_freq) / + pctg_lo = (policy->min - longrun_low_freq) / ((longrun_high_freq - longrun_low_freq) / 100); - pctg_hi = (policy->max - longrun_low_freq) / + pctg_hi = (policy->max - longrun_low_freq) / ((longrun_high_freq - longrun_low_freq) / 100); } @@ -118,7 +118,7 @@ * longrun_verify_poliy - verifies a new CPUFreq policy * @policy: the policy to verify * - * Validates a new CPUFreq policy. This function has to be called with + * Validates a new CPUFreq policy. This function has to be called with * cpufreq_driver locked. */ static int longrun_verify_policy(struct cpufreq_policy *policy) @@ -127,8 +127,8 @@ return -EINVAL; policy->cpu = 0; - cpufreq_verify_within_limits(policy, - policy->cpuinfo.min_freq, + cpufreq_verify_within_limits(policy, + policy->cpuinfo.min_freq, policy->cpuinfo.max_freq); if ((policy->policy != CPUFREQ_POLICY_POWERSAVE) && @@ -160,7 +160,7 @@ * TMTA rules: * performance_pctg = (target_freq - low_freq)/(high_freq - low_freq) */ -static unsigned int __init longrun_determine_freqs(unsigned int *low_freq, +static unsigned int __init longrun_determine_freqs(unsigned int *low_freq, unsigned int *high_freq) { u32 msr_lo, msr_hi; @@ -174,9 +174,9 @@ if (cpu_has(c, X86_FEATURE_LRTI)) { /* if the LongRun Table Interface is present, the - * detection is a bit easier: + * detection is a bit easier: * For minimum frequency, read out the maximum - * level (msr_hi), write that into "currently + * level (msr_hi), write that into "currently * selected level", and read out the frequency. * For maximum frequency, read out level zero. */ @@ -223,7 +223,7 @@ cpuid(0x80860007, &eax, &ebx, &ecx, &edx); /* restore values */ - wrmsr(MSR_TMTA_LONGRUN_CTRL, save_lo, save_hi); + wrmsr(MSR_TMTA_LONGRUN_CTRL, save_lo, save_hi); } /* performance_pctg = (current_freq - low_freq)/(high_freq - low_freq) @@ -237,7 +237,7 @@ if ((ecx > 95) || (ecx == 0) || (eax < ebx)) return -EIO; - edx = (eax - ebx) / (100 - ecx); + edx = (eax - ebx) / (100 - ecx); *low_freq = edx * 1000; /* back to kHz */ if (*low_freq > *high_freq) @@ -249,7 +249,7 @@ static int __init longrun_cpu_init(struct cpufreq_policy *policy) { - int result = 0; + int result = 0; /* capability check */ if (policy->cpu != 0) @@ -265,15 +265,15 @@ policy->cpuinfo.max_freq = longrun_high_freq; policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; longrun_get_policy(policy); - + return 0; } static struct cpufreq_driver longrun_driver = { .flags = CPUFREQ_CONST_LOOPS, - .verify = longrun_verify_policy, - .setpolicy = longrun_set_policy, + .verify = longrun_verify_policy, + .setpolicy = longrun_set_policy, .get = longrun_get, .init = longrun_cpu_init, .name = "longrun", @@ -290,7 +290,7 @@ { struct cpuinfo_x86 *c = cpu_data; - if (c->x86_vendor != X86_VENDOR_TRANSMETA || + if (c->x86_vendor != X86_VENDOR_TRANSMETA || !cpu_has(c, X86_FEATURE_LONGRUN)) return -ENODEV; diff -Nru a/arch/i386/kernel/cpu/cpufreq/powernow-k7.c b/arch/i386/kernel/cpu/cpufreq/powernow-k7.c --- a/arch/i386/kernel/cpu/cpufreq/powernow-k7.c 2004-07-08 18:11:41 -07:00 +++ b/arch/i386/kernel/cpu/cpufreq/powernow-k7.c 2004-07-08 18:11:41 -07:00 @@ -6,8 +6,6 @@ * Licensed under the terms of the GNU GPL License version 2. * Based upon datasheets & sample CPUs kindly provided by AMD. * - * BIG FAT DISCLAIMER: Work in progress code. Possibly *dangerous* - * * Errata 5: Processor may fail to execute a FID/VID change in presence of interrupt. * - We cli/sti on stepping A0 CPUs around the FID/VID transition. * Errata 15: Processors with half frequency multipliers may hang upon wakeup from disconnect. @@ -36,14 +34,6 @@ #include "powernow-k7.h" -#define DEBUG - -#ifdef DEBUG -#define dprintk(msg...) printk(msg) -#else -#define dprintk(msg...) do { } while(0) -#endif - #define PFX "powernow: " @@ -97,6 +87,7 @@ */ static int acpi_force; +static int debug; static struct cpufreq_frequency_table *powernow_table; @@ -109,6 +100,21 @@ static unsigned int latency; static char have_a0; +static void dprintk(const char *fmt, ...) +{ + char s[256]; + va_list args; + + if (debug==0) + return; + + va_start(args,fmt); + vsprintf(s, fmt, args); + printk(s); + va_end(args); +} + + static int check_fsb(unsigned int fsbspeed) { int delta; @@ -196,7 +202,7 @@ #endif } - dprintk (KERN_INFO PFX " FID: 0x%x (%d.%dx [%dMHz])\t", fid, + dprintk (KERN_INFO PFX " FID: 0x%x (%d.%dx [%dMHz]) ", fid, fid_codes[fid] / 10, fid_codes[fid] % 10, speed/1000); if (speed < minimum_speed) @@ -285,7 +291,7 @@ change_VID(vid); change_FID(fid); } - + if (have_a0 == 1) local_irq_enable(); @@ -377,7 +383,7 @@ powernow_table[i].frequency = CPUFREQ_ENTRY_INVALID; } - dprintk (KERN_INFO PFX " FID: 0x%x (%d.%dx [%dMHz])\t", fid, + dprintk (KERN_INFO PFX " FID: 0x%x (%d.%dx [%dMHz]) ", fid, fid_codes[fid] / 10, fid_codes[fid] % 10, speed/1000); dprintk ("VID: 0x%x (%d.%03dV)\n", vid, mobile_vid_table[vid]/1000, mobile_vid_table[vid]%1000); @@ -467,9 +473,9 @@ (maxfid==pst->maxfid) && (startvid==pst->startvid)) { dprintk (KERN_INFO PFX "PST:%d (@%p)\n", i, pst); - dprintk (KERN_INFO PFX " cpuid: 0x%x\t", pst->cpuid); - dprintk ("fsb: %d\t", pst->fsbspeed); - dprintk ("maxFID: 0x%x\t", pst->maxfid); + dprintk (KERN_INFO PFX " cpuid: 0x%x ", pst->cpuid); + dprintk ("fsb: %d ", pst->fsbspeed); + dprintk ("maxFID: 0x%x ", pst->maxfid); dprintk ("startvid: 0x%x\n", pst->startvid); ret = get_ranges ((char *) pst + sizeof (struct pst_s)); @@ -591,14 +597,14 @@ rdmsrl (MSR_K7_FID_VID_STATUS, fidvidstatus.val); /* A K7 with powernow technology is set to max frequency by BIOS */ - fsb = (10 * cpu_khz) / fid_codes[fidvidstatus.bits.CFID]; + fsb = (10 * cpu_khz) / fid_codes[fidvidstatus.bits.MFID]; if (!fsb) { printk(KERN_WARNING PFX "can not determine bus frequency\n"); return -EINVAL; } dprintk(KERN_INFO PFX "FSB: %3d.%03d MHz\n", fsb/1000, fsb%1000); - if (dmi_check_system(powernow_dmi_table) || acpi_force) { + if (dmi_check_system(powernow_dmi_table) || acpi_force) { printk (KERN_INFO PFX "PSB/PST known to be broken. Trying ACPI instead\n"); result = powernow_acpi_init(); } else { @@ -648,14 +654,14 @@ }; static struct cpufreq_driver powernow_driver = { - .verify = powernow_verify, - .target = powernow_target, - .get = powernow_get, - .init = powernow_cpu_init, - .exit = powernow_cpu_exit, - .name = "powernow-k7", - .owner = THIS_MODULE, - .attr = powernow_table_attr, + .verify = powernow_verify, + .target = powernow_target, + .get = powernow_get, + .init = powernow_cpu_init, + .exit = powernow_cpu_exit, + .name = "powernow-k7", + .owner = THIS_MODULE, + .attr = powernow_table_attr, }; static int __init powernow_init (void) @@ -679,8 +685,10 @@ kfree(powernow_table); } +module_param(debug, int, 0444); +MODULE_PARM_DESC(debug, "enable debug output."); module_param(acpi_force, int, 0444); -MODULE_PARM_DESC(acpi_force, "Force ACPI to be used"); +MODULE_PARM_DESC(acpi_force, "Force ACPI to be used."); MODULE_AUTHOR ("Dave Jones "); MODULE_DESCRIPTION ("Powernow driver for AMD K7 processors."); diff -Nru a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c --- a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c 2004-07-08 18:11:41 -07:00 +++ b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c 2004-07-08 18:11:41 -07:00 @@ -60,6 +60,13 @@ .x86_mask = 1, }; +static const struct cpu_id cpu_id_dothan_b0 = { + .x86_vendor = X86_VENDOR_INTEL, + .x86 = 6, + .x86_model = 13, + .x86_mask = 6, +}; + struct cpu_model { const struct cpu_id *cpu_id; @@ -214,7 +221,7 @@ BANIAS(1500), BANIAS(1600), BANIAS(1700), - { 0, } + { NULL, } }; #undef _BANIAS #undef BANIAS @@ -400,7 +407,8 @@ return -ENODEV; if ((centrino_verify_cpu_id(cpu, &cpu_id_banias)) && - (centrino_verify_cpu_id(cpu, &cpu_id_dothan_a1))) { + (centrino_verify_cpu_id(cpu, &cpu_id_dothan_a1)) && + (centrino_verify_cpu_id(cpu, &cpu_id_dothan_b0))) { printk(KERN_INFO PFX "found unsupported CPU with Enhanced SpeedStep: " "send /proc/cpuinfo to " MAINTAINER "\n"); return -ENODEV; diff -Nru a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c --- a/drivers/cpufreq/cpufreq.c 2004-07-08 18:11:41 -07:00 +++ b/drivers/cpufreq/cpufreq.c 2004-07-08 18:11:41 -07:00 @@ -617,8 +617,8 @@ if (cpufreq_driver->flags & CPUFREQ_PANIC_RESUME_OUTOFSYNC) panic("CPU Frequency is out of sync."); - printk(KERN_WARNING "Warning: CPU frequency out of sync: cpufreq and timing" - "core thinks of %u, is %u kHz.\n", cpu_policy->cur, cur_freq); + printk(KERN_WARNING "Warning: CPU frequency is %u, " + "cpufreq assumed %u kHz.\n", cur_freq, cpu_policy->cur); freqs.cpu = cpu; freqs.old = cpu_policy->cur; @@ -626,6 +626,8 @@ notifier_call_chain(&cpufreq_transition_notifier_list, CPUFREQ_RESUMECHANGE, &freqs); adjust_jiffies(CPUFREQ_RESUMECHANGE, &freqs); + + cpu_policy->cur = cur_freq; } } @@ -1065,9 +1067,8 @@ if (cpufreq_driver->flags & CPUFREQ_PANIC_OUTOFSYNC) panic("CPU Frequency is out of sync."); - printk(KERN_WARNING "Warning: CPU frequency out of sync: " - "cpufreq and timing core thinks of %u, is %u kHz.\n", - cpufreq_cpu_data[freqs->cpu]->cur, freqs->old); + printk(KERN_WARNING "Warning: CPU frequency is %u, " + "cpufreq assumed %u kHz.\n", freqs->old, cpufreq_cpu_data[freqs->cpu]->cur); freqs->old = cpufreq_cpu_data[freqs->cpu]->cur; } } diff -Nru a/drivers/cpufreq/cpufreq_userspace.c b/drivers/cpufreq/cpufreq_userspace.c --- a/drivers/cpufreq/cpufreq_userspace.c 2004-07-08 18:11:41 -07:00 +++ b/drivers/cpufreq/cpufreq_userspace.c 2004-07-08 18:11:41 -07:00 @@ -82,6 +82,13 @@ { struct cpufreq_freqs *freq = data; + /* Don't update cur_freq if CPU is managed and we're + * waking up: else we won't remember what frequency + * we need to set the CPU to. + */ + if (cpu_is_managed[freq->cpu] && (val == CPUFREQ_RESUMECHANGE)) + return 0; + cpu_cur_freq[freq->cpu] = freq->new; return 0; @@ -521,6 +528,9 @@ CPUFREQ_RELATION_H); else if (policy->min > cpu_cur_freq[cpu]) __cpufreq_driver_target(¤t_policy[cpu], policy->min, + CPUFREQ_RELATION_L); + else + __cpufreq_driver_target(¤t_policy[cpu], cpu_cur_freq[cpu], CPUFREQ_RELATION_L); memcpy (¤t_policy[cpu], policy, sizeof(struct cpufreq_policy)); up(&userspace_sem);