aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.osdl.org>2007-01-03 20:34:12 -0500
committerLinus Torvalds <torvalds@woody.osdl.org>2007-01-03 20:34:12 -0500
commitde9e957f12d09793aac7d44ee0f7987dc8019b94 (patch)
tree216081044a7df1ce3e8ae6482148fedb7d1f1b73
parent9c5b0ce43d0e4e4799c6cdc77c5ed7a95b763035 (diff)
parent43c8f12f9f4a7cb4140693fc9baed35a02165898 (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/davej/cpufreq
* master.kernel.org:/pub/scm/linux/kernel/git/davej/cpufreq: [CPUFREQ] longhaul: Kill off warnings introduced by recent changes. [CPUFREQ] Uninitialized use of cmd.val in arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c:acpi_cpufreq_target() [CPUFREQ] Longhaul - Always guess FSB [CPUFREQ] Longhaul - Fix up powersaver assumptions. [CPUFREQ] longhaul: Fix up unreachable code. [CPUFREQ] speedstep-centrino: missing space and bracket [CPUFREQ] Bug fix for acpi-cpufreq and cpufreq_stats oops on frequency change notification [CPUFREQ] select consistently
-rw-r--r--arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c10
-rw-r--r--arch/i386/kernel/cpu/cpufreq/longhaul.c120
-rw-r--r--arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c6
-rw-r--r--arch/x86_64/kernel/cpufreq/Kconfig1
-rw-r--r--drivers/cpufreq/cpufreq_stats.c4
5 files changed, 67 insertions, 74 deletions
diff --git a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
index b735458c6e3a..10baa3501ed3 100644
--- a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
+++ b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
@@ -373,8 +373,8 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy,
373 cpumask_t online_policy_cpus; 373 cpumask_t online_policy_cpus;
374 struct drv_cmd cmd; 374 struct drv_cmd cmd;
375 unsigned int msr; 375 unsigned int msr;
376 unsigned int next_state = 0; 376 unsigned int next_state = 0; /* Index into freq_table */
377 unsigned int next_perf_state = 0; 377 unsigned int next_perf_state = 0; /* Index into perf table */
378 unsigned int i; 378 unsigned int i;
379 int result = 0; 379 int result = 0;
380 380
@@ -420,6 +420,7 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy,
420 msr = 420 msr =
421 (u32) perf->states[next_perf_state]. 421 (u32) perf->states[next_perf_state].
422 control & INTEL_MSR_RANGE; 422 control & INTEL_MSR_RANGE;
423 cmd.val = get_cur_val(online_policy_cpus);
423 cmd.val = (cmd.val & ~INTEL_MSR_RANGE) | msr; 424 cmd.val = (cmd.val & ~INTEL_MSR_RANGE) | msr;
424 break; 425 break;
425 case SYSTEM_IO_CAPABLE: 426 case SYSTEM_IO_CAPABLE:
@@ -439,8 +440,8 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy,
439 else 440 else
440 cpu_set(policy->cpu, cmd.mask); 441 cpu_set(policy->cpu, cmd.mask);
441 442
442 freqs.old = data->freq_table[perf->state].frequency; 443 freqs.old = perf->states[perf->state].core_frequency * 1000;
443 freqs.new = data->freq_table[next_perf_state].frequency; 444 freqs.new = data->freq_table[next_state].frequency;
444 for_each_cpu_mask(i, cmd.mask) { 445 for_each_cpu_mask(i, cmd.mask) {
445 freqs.cpu = i; 446 freqs.cpu = i;
446 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 447 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
@@ -677,6 +678,7 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
677 valid_states++; 678 valid_states++;
678 } 679 }
679 data->freq_table[valid_states].frequency = CPUFREQ_TABLE_END; 680 data->freq_table[valid_states].frequency = CPUFREQ_TABLE_END;
681 perf->state = 0;
680 682
681 result = cpufreq_frequency_table_cpuinfo(policy, data->freq_table); 683 result = cpufreq_frequency_table_cpuinfo(policy, data->freq_table);
682 if (result) 684 if (result)
diff --git a/arch/i386/kernel/cpu/cpufreq/longhaul.c b/arch/i386/kernel/cpu/cpufreq/longhaul.c
index 6d9c97a690fd..e940e00b96c9 100644
--- a/arch/i386/kernel/cpu/cpufreq/longhaul.c
+++ b/arch/i386/kernel/cpu/cpufreq/longhaul.c
@@ -52,6 +52,10 @@
52#define CPU_EZRA_T 4 52#define CPU_EZRA_T 4
53#define CPU_NEHEMIAH 5 53#define CPU_NEHEMIAH 5
54 54
55/* Flags */
56#define USE_ACPI_C3 (1 << 1)
57#define USE_NORTHBRIDGE (1 << 2)
58
55static int cpu_model; 59static int cpu_model;
56static unsigned int numscales=16; 60static unsigned int numscales=16;
57static unsigned int fsb; 61static unsigned int fsb;
@@ -68,7 +72,7 @@ static unsigned int minmult, maxmult;
68static int can_scale_voltage; 72static int can_scale_voltage;
69static struct acpi_processor *pr = NULL; 73static struct acpi_processor *pr = NULL;
70static struct acpi_processor_cx *cx = NULL; 74static struct acpi_processor_cx *cx = NULL;
71static int port22_en; 75static u8 longhaul_flags;
72 76
73/* Module parameters */ 77/* Module parameters */
74static int scale_voltage; 78static int scale_voltage;
@@ -80,7 +84,6 @@ static int ignore_latency;
80/* Clock ratios multiplied by 10 */ 84/* Clock ratios multiplied by 10 */
81static int clock_ratio[32]; 85static int clock_ratio[32];
82static int eblcr_table[32]; 86static int eblcr_table[32];
83static unsigned int highest_speed, lowest_speed; /* kHz */
84static int longhaul_version; 87static int longhaul_version;
85static struct cpufreq_frequency_table *longhaul_table; 88static struct cpufreq_frequency_table *longhaul_table;
86 89
@@ -178,7 +181,7 @@ static void do_powersaver(int cx_address, unsigned int clock_ratio_index)
178 safe_halt(); 181 safe_halt();
179 /* Change frequency on next halt or sleep */ 182 /* Change frequency on next halt or sleep */
180 wrmsrl(MSR_VIA_LONGHAUL, longhaul.val); 183 wrmsrl(MSR_VIA_LONGHAUL, longhaul.val);
181 if (port22_en) { 184 if (!cx_address) {
182 ACPI_FLUSH_CPU_CACHE(); 185 ACPI_FLUSH_CPU_CACHE();
183 /* Invoke C1 */ 186 /* Invoke C1 */
184 halt(); 187 halt();
@@ -189,7 +192,6 @@ static void do_powersaver(int cx_address, unsigned int clock_ratio_index)
189 /* Dummy op - must do something useless after P_LVL3 read */ 192 /* Dummy op - must do something useless after P_LVL3 read */
190 t = inl(acpi_fadt.xpm_tmr_blk.address); 193 t = inl(acpi_fadt.xpm_tmr_blk.address);
191 } 194 }
192
193 /* Disable bus ratio bit */ 195 /* Disable bus ratio bit */
194 local_irq_disable(); 196 local_irq_disable();
195 longhaul.bits.RevisionKey = longhaul.bits.RevisionID; 197 longhaul.bits.RevisionKey = longhaul.bits.RevisionID;
@@ -243,15 +245,14 @@ static void longhaul_setstate(unsigned int clock_ratio_index)
243 outb(0xFF,0xA1); /* Overkill */ 245 outb(0xFF,0xA1); /* Overkill */
244 outb(0xFE,0x21); /* TMR0 only */ 246 outb(0xFE,0x21); /* TMR0 only */
245 247
246 if (pr->flags.bm_control) { 248 if (longhaul_flags & USE_NORTHBRIDGE) {
249 /* Disable AGP and PCI arbiters */
250 outb(3, 0x22);
251 } else if ((pr != NULL) && pr->flags.bm_control) {
247 /* Disable bus master arbitration */ 252 /* Disable bus master arbitration */
248 acpi_set_register(ACPI_BITREG_ARB_DISABLE, 1, 253 acpi_set_register(ACPI_BITREG_ARB_DISABLE, 1,
249 ACPI_MTX_DO_NOT_LOCK); 254 ACPI_MTX_DO_NOT_LOCK);
250 } else if (port22_en) {
251 /* Disable AGP and PCI arbiters */
252 outb(3, 0x22);
253 } 255 }
254
255 switch (longhaul_version) { 256 switch (longhaul_version) {
256 257
257 /* 258 /*
@@ -278,22 +279,25 @@ static void longhaul_setstate(unsigned int clock_ratio_index)
278 * to work in practice. 279 * to work in practice.
279 */ 280 */
280 case TYPE_POWERSAVER: 281 case TYPE_POWERSAVER:
281 /* Don't allow wakeup */ 282 if (longhaul_flags & USE_ACPI_C3) {
282 acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 0, 283 /* Don't allow wakeup */
283 ACPI_MTX_DO_NOT_LOCK); 284 acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 0,
284 do_powersaver(cx->address, clock_ratio_index); 285 ACPI_MTX_DO_NOT_LOCK);
286 do_powersaver(cx->address, clock_ratio_index);
287 } else {
288 do_powersaver(0, clock_ratio_index);
289 }
285 break; 290 break;
286 } 291 }
287 292
288 if (pr->flags.bm_control) { 293 if (longhaul_flags & USE_NORTHBRIDGE) {
294 /* Enable arbiters */
295 outb(0, 0x22);
296 } else if ((pr != NULL) && pr->flags.bm_control) {
289 /* Enable bus master arbitration */ 297 /* Enable bus master arbitration */
290 acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0, 298 acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0,
291 ACPI_MTX_DO_NOT_LOCK); 299 ACPI_MTX_DO_NOT_LOCK);
292 } else if (port22_en) {
293 /* Enable arbiters */
294 outb(0, 0x22);
295 } 300 }
296
297 outb(pic2_mask,0xA1); /* restore mask */ 301 outb(pic2_mask,0xA1); /* restore mask */
298 outb(pic1_mask,0x21); 302 outb(pic1_mask,0x21);
299 303
@@ -314,12 +318,12 @@ static void longhaul_setstate(unsigned int clock_ratio_index)
314 318
315#define ROUNDING 0xf 319#define ROUNDING 0xf
316 320
317static int _guess(int guess) 321static int _guess(int guess, int mult)
318{ 322{
319 int target; 323 int target;
320 324
321 target = ((maxmult/10)*guess); 325 target = ((mult/10)*guess);
322 if (maxmult%10 != 0) 326 if (mult%10 != 0)
323 target += (guess/2); 327 target += (guess/2);
324 target += ROUNDING/2; 328 target += ROUNDING/2;
325 target &= ~ROUNDING; 329 target &= ~ROUNDING;
@@ -327,17 +331,17 @@ static int _guess(int guess)
327} 331}
328 332
329 333
330static int guess_fsb(void) 334static int guess_fsb(int mult)
331{ 335{
332 int speed = (cpu_khz/1000); 336 int speed = (cpu_khz/1000);
333 int i; 337 int i;
334 int speeds[3] = { 66, 100, 133 }; 338 int speeds[] = { 66, 100, 133, 200 };
335 339
336 speed += ROUNDING/2; 340 speed += ROUNDING/2;
337 speed &= ~ROUNDING; 341 speed &= ~ROUNDING;
338 342
339 for (i=0; i<3; i++) { 343 for (i=0; i<4; i++) {
340 if (_guess(speeds[i]) == speed) 344 if (_guess(speeds[i], mult) == speed)
341 return speeds[i]; 345 return speeds[i];
342 } 346 }
343 return 0; 347 return 0;
@@ -354,9 +358,7 @@ static int __init longhaul_get_ranges(void)
354 130, 150, 160, 140, -1, 155, -1, 145 }; 358 130, 150, 160, 140, -1, 155, -1, 145 };
355 unsigned int j, k = 0; 359 unsigned int j, k = 0;
356 union msr_longhaul longhaul; 360 union msr_longhaul longhaul;
357 unsigned long lo, hi; 361 int mult = 0;
358 unsigned int eblcr_fsb_table_v1[] = { 66, 133, 100, -1 };
359 unsigned int eblcr_fsb_table_v2[] = { 133, 100, -1, 66 };
360 362
361 switch (longhaul_version) { 363 switch (longhaul_version) {
362 case TYPE_LONGHAUL_V1: 364 case TYPE_LONGHAUL_V1:
@@ -364,30 +366,18 @@ static int __init longhaul_get_ranges(void)
364 /* Ugh, Longhaul v1 didn't have the min/max MSRs. 366 /* Ugh, Longhaul v1 didn't have the min/max MSRs.
365 Assume min=3.0x & max = whatever we booted at. */ 367 Assume min=3.0x & max = whatever we booted at. */
366 minmult = 30; 368 minmult = 30;
367 maxmult = longhaul_get_cpu_mult(); 369 maxmult = mult = longhaul_get_cpu_mult();
368 rdmsr (MSR_IA32_EBL_CR_POWERON, lo, hi);
369 invalue = (lo & (1<<18|1<<19)) >>18;
370 if (cpu_model==CPU_SAMUEL || cpu_model==CPU_SAMUEL2)
371 fsb = eblcr_fsb_table_v1[invalue];
372 else
373 fsb = guess_fsb();
374 break; 370 break;
375 371
376 case TYPE_POWERSAVER: 372 case TYPE_POWERSAVER:
377 /* Ezra-T */ 373 /* Ezra-T */
378 if (cpu_model==CPU_EZRA_T) { 374 if (cpu_model==CPU_EZRA_T) {
375 minmult = 30;
379 rdmsrl (MSR_VIA_LONGHAUL, longhaul.val); 376 rdmsrl (MSR_VIA_LONGHAUL, longhaul.val);
380 invalue = longhaul.bits.MaxMHzBR; 377 invalue = longhaul.bits.MaxMHzBR;
381 if (longhaul.bits.MaxMHzBR4) 378 if (longhaul.bits.MaxMHzBR4)
382 invalue += 16; 379 invalue += 16;
383 maxmult=ezra_t_multipliers[invalue]; 380 maxmult = mult = ezra_t_multipliers[invalue];
384
385 invalue = longhaul.bits.MinMHzBR;
386 if (longhaul.bits.MinMHzBR4 == 1)
387 minmult = 30;
388 else
389 minmult = ezra_t_multipliers[invalue];
390 fsb = eblcr_fsb_table_v2[longhaul.bits.MaxMHzFSB];
391 break; 381 break;
392 } 382 }
393 383
@@ -407,21 +397,16 @@ static int __init longhaul_get_ranges(void)
407 * But it works, so we don't grumble. 397 * But it works, so we don't grumble.
408 */ 398 */
409 minmult=40; 399 minmult=40;
410 maxmult=longhaul_get_cpu_mult(); 400 maxmult = mult = longhaul_get_cpu_mult();
411
412 /* Starting with the 1.2GHz parts, theres a 200MHz bus. */
413 if ((cpu_khz/maxmult) > 13400)
414 fsb = 200;
415 else
416 fsb = eblcr_fsb_table_v2[longhaul.bits.MaxMHzFSB];
417 break; 401 break;
418 } 402 }
419 } 403 }
404 fsb = guess_fsb(mult);
420 405
421 dprintk ("MinMult:%d.%dx MaxMult:%d.%dx\n", 406 dprintk ("MinMult:%d.%dx MaxMult:%d.%dx\n",
422 minmult/10, minmult%10, maxmult/10, maxmult%10); 407 minmult/10, minmult%10, maxmult/10, maxmult%10);
423 408
424 if (fsb == -1) { 409 if (fsb == 0) {
425 printk (KERN_INFO PFX "Invalid (reserved) FSB!\n"); 410 printk (KERN_INFO PFX "Invalid (reserved) FSB!\n");
426 return -EINVAL; 411 return -EINVAL;
427 } 412 }
@@ -691,27 +676,32 @@ static int __init longhaul_cpu_init(struct cpufreq_policy *policy)
691 /* Find ACPI data for processor */ 676 /* Find ACPI data for processor */
692 acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, 677 acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
693 &longhaul_walk_callback, NULL, (void *)&pr); 678 &longhaul_walk_callback, NULL, (void *)&pr);
694 if (pr == NULL)
695 goto err_acpi;
696 679
697 if (longhaul_version == TYPE_POWERSAVER) { 680 /* Check ACPI support for C3 state */
698 /* Check ACPI support for C3 state */ 681 if ((pr != NULL) && (longhaul_version == TYPE_POWERSAVER)) {
699 cx = &pr->power.states[ACPI_STATE_C3]; 682 cx = &pr->power.states[ACPI_STATE_C3];
700 if (cx->address > 0 && 683 if (cx->address > 0 &&
701 (cx->latency <= 1000 || ignore_latency != 0) ) { 684 (cx->latency <= 1000 || ignore_latency != 0) ) {
685 longhaul_flags |= USE_ACPI_C3;
702 goto print_support_type; 686 goto print_support_type;
703 } 687 }
704 } 688 }
689 /* Check if northbridge is friendly */
690 if (enable_arbiter_disable()) {
691 longhaul_flags |= USE_NORTHBRIDGE;
692 goto print_support_type;
693 }
694
695 /* No ACPI C3 or we can't use it */
705 /* Check ACPI support for bus master arbiter disable */ 696 /* Check ACPI support for bus master arbiter disable */
706 if (!pr->flags.bm_control) { 697 if ((pr == NULL) || !(pr->flags.bm_control)) {
707 if (enable_arbiter_disable()) { 698 printk(KERN_ERR PFX
708 port22_en = 1; 699 "No ACPI support. Unsupported northbridge.\n");
709 } else { 700 return -ENODEV;
710 goto err_acpi;
711 }
712 } 701 }
702
713print_support_type: 703print_support_type:
714 if (!port22_en) { 704 if (!(longhaul_flags & USE_NORTHBRIDGE)) {
715 printk (KERN_INFO PFX "Using ACPI support.\n"); 705 printk (KERN_INFO PFX "Using ACPI support.\n");
716 } else { 706 } else {
717 printk (KERN_INFO PFX "Using northbridge support.\n"); 707 printk (KERN_INFO PFX "Using northbridge support.\n");
@@ -736,10 +726,6 @@ print_support_type:
736 cpufreq_frequency_table_get_attr(longhaul_table, policy->cpu); 726 cpufreq_frequency_table_get_attr(longhaul_table, policy->cpu);
737 727
738 return 0; 728 return 0;
739
740err_acpi:
741 printk(KERN_ERR PFX "No ACPI support. Unsupported northbridge. Aborting.\n");
742 return -ENODEV;
743} 729}
744 730
745static int __devexit longhaul_cpu_exit(struct cpufreq_policy *policy) 731static int __devexit longhaul_cpu_exit(struct cpufreq_policy *policy)
@@ -774,8 +760,8 @@ static int __init longhaul_init(void)
774 760
775#ifdef CONFIG_SMP 761#ifdef CONFIG_SMP
776 if (num_online_cpus() > 1) { 762 if (num_online_cpus() > 1) {
777 return -ENODEV;
778 printk(KERN_ERR PFX "More than 1 CPU detected, longhaul disabled.\n"); 763 printk(KERN_ERR PFX "More than 1 CPU detected, longhaul disabled.\n");
764 return -ENODEV;
779 } 765 }
780#endif 766#endif
781#ifdef CONFIG_X86_IO_APIC 767#ifdef CONFIG_X86_IO_APIC
diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
index 5113e9231634..f43b987f952b 100644
--- a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
+++ b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
@@ -533,9 +533,9 @@ static int centrino_cpu_init_acpi(struct cpufreq_policy *policy)
533 533
534 /* notify BIOS that we exist */ 534 /* notify BIOS that we exist */
535 acpi_processor_notify_smm(THIS_MODULE); 535 acpi_processor_notify_smm(THIS_MODULE);
536 printk("speedstep-centrino with X86_SPEEDSTEP_CENTRINO_ACPI" 536 printk("speedstep-centrino with X86_SPEEDSTEP_CENTRINO_ACPI "
537 "config is deprecated.\n " 537 "config is deprecated.\n "
538 "Use X86_ACPI_CPUFREQ (acpi-cpufreq instead.\n" ); 538 "Use X86_ACPI_CPUFREQ (acpi-cpufreq) instead.\n" );
539 539
540 return 0; 540 return 0;
541 541
diff --git a/arch/x86_64/kernel/cpufreq/Kconfig b/arch/x86_64/kernel/cpufreq/Kconfig
index 3abcfa3e1ed7..45a6a1fd14ac 100644
--- a/arch/x86_64/kernel/cpufreq/Kconfig
+++ b/arch/x86_64/kernel/cpufreq/Kconfig
@@ -49,6 +49,7 @@ config X86_SPEEDSTEP_CENTRINO_ACPI
49 49
50config X86_ACPI_CPUFREQ 50config X86_ACPI_CPUFREQ
51 tristate "ACPI Processor P-States driver" 51 tristate "ACPI Processor P-States driver"
52 select CPU_FREQ_TABLE
52 depends on ACPI_PROCESSOR 53 depends on ACPI_PROCESSOR
53 help 54 help
54 This driver adds a CPUFreq driver which utilizes the ACPI 55 This driver adds a CPUFreq driver which utilizes the ACPI
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index 6742b1adf2c8..91ad342a6051 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -285,6 +285,7 @@ cpufreq_stat_notifier_trans (struct notifier_block *nb, unsigned long val,
285 stat = cpufreq_stats_table[freq->cpu]; 285 stat = cpufreq_stats_table[freq->cpu];
286 if (!stat) 286 if (!stat)
287 return 0; 287 return 0;
288
288 old_index = freq_table_get_index(stat, freq->old); 289 old_index = freq_table_get_index(stat, freq->old);
289 new_index = freq_table_get_index(stat, freq->new); 290 new_index = freq_table_get_index(stat, freq->new);
290 291
@@ -292,6 +293,9 @@ cpufreq_stat_notifier_trans (struct notifier_block *nb, unsigned long val,
292 if (old_index == new_index) 293 if (old_index == new_index)
293 return 0; 294 return 0;
294 295
296 if (old_index == -1 || new_index == -1)
297 return 0;
298
295 spin_lock(&cpufreq_stats_lock); 299 spin_lock(&cpufreq_stats_lock);
296 stat->last_index = new_index; 300 stat->last_index = new_index;
297#ifdef CONFIG_CPU_FREQ_STAT_DETAILS 301#ifdef CONFIG_CPU_FREQ_STAT_DETAILS