aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorZhao Yakui <yakui.zhao@intel.com>2007-11-15 04:02:03 -0500
committerLen Brown <len.brown@intel.com>2007-11-16 21:39:21 -0500
commit22cc50199d0616f7b002563a0e9117ba479356e1 (patch)
treef04b7fa8396e3d449572b80e626fc752baa62edb /drivers/acpi
parent49fbabf56dc715bbb51e59742e82ba762790aac0 (diff)
ACPI: If _TSS exists, do not access FADT.duty_width
Factor out legacy FADT.duty_width code and run it only in the non _TSS case. Signed-off-by: Zhao Yakui <yakui.zhao@intel.com> Signed-off-by: Li Shaohua <shaohua.li@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/processor_throttling.c66
1 files changed, 36 insertions, 30 deletions
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index 5fa8ac1c0c84..20d82f55ce5f 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -478,6 +478,40 @@ static int acpi_processor_get_throttling(struct acpi_processor *pr)
478 return pr->throttling.acpi_processor_get_throttling(pr); 478 return pr->throttling.acpi_processor_get_throttling(pr);
479} 479}
480 480
481static int acpi_processor_get_fadt_info(struct acpi_processor *pr)
482{
483 int i, step;
484
485 if (!pr->throttling.address) {
486 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n"));
487 return -EINVAL;
488 } else if (!pr->throttling.duty_width) {
489 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling states\n"));
490 return -EINVAL;
491 }
492 /* TBD: Support duty_cycle values that span bit 4. */
493 else if ((pr->throttling.duty_offset + pr->throttling.duty_width) > 4) {
494 printk(KERN_WARNING PREFIX "duty_cycle spans bit 4\n");
495 return -EINVAL;
496 }
497
498 pr->throttling.state_count = 1 << acpi_gbl_FADT.duty_width;
499
500 /*
501 * Compute state values. Note that throttling displays a linear power
502 * performance relationship (at 50% performance the CPU will consume
503 * 50% power). Values are in 1/10th of a percent to preserve accuracy.
504 */
505
506 step = (1000 / pr->throttling.state_count);
507
508 for (i = 0; i < pr->throttling.state_count; i++) {
509 pr->throttling.states[i].performance = 1000 - step * i;
510 pr->throttling.states[i].power = 1000 - step * i;
511 }
512 return 0;
513}
514
481static int acpi_processor_set_throttling_fadt(struct acpi_processor *pr, 515static int acpi_processor_set_throttling_fadt(struct acpi_processor *pr,
482 int state) 516 int state)
483{ 517{
@@ -591,8 +625,6 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
591int acpi_processor_get_throttling_info(struct acpi_processor *pr) 625int acpi_processor_get_throttling_info(struct acpi_processor *pr)
592{ 626{
593 int result = 0; 627 int result = 0;
594 int step = 0;
595 int i = 0;
596 628
597 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 629 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
598 "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n", 630 "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n",
@@ -611,6 +643,8 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
611 acpi_processor_get_throttling_states(pr) || 643 acpi_processor_get_throttling_states(pr) ||
612 acpi_processor_get_platform_limit(pr)) 644 acpi_processor_get_platform_limit(pr))
613 { 645 {
646 if (acpi_processor_get_fadt_info(pr))
647 return 0;
614 pr->throttling.acpi_processor_get_throttling = 648 pr->throttling.acpi_processor_get_throttling =
615 &acpi_processor_get_throttling_fadt; 649 &acpi_processor_get_throttling_fadt;
616 pr->throttling.acpi_processor_set_throttling = 650 pr->throttling.acpi_processor_set_throttling =
@@ -624,19 +658,6 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
624 658
625 acpi_processor_get_tsd(pr); 659 acpi_processor_get_tsd(pr);
626 660
627 if (!pr->throttling.address) {
628 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n"));
629 return 0;
630 } else if (!pr->throttling.duty_width) {
631 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling states\n"));
632 return 0;
633 }
634 /* TBD: Support duty_cycle values that span bit 4. */
635 else if ((pr->throttling.duty_offset + pr->throttling.duty_width) > 4) {
636 printk(KERN_WARNING PREFIX "duty_cycle spans bit 4\n");
637 return 0;
638 }
639
640 /* 661 /*
641 * PIIX4 Errata: We don't support throttling on the original PIIX4. 662 * PIIX4 Errata: We don't support throttling on the original PIIX4.
642 * This shouldn't be an issue as few (if any) mobile systems ever 663 * This shouldn't be an issue as few (if any) mobile systems ever
@@ -648,21 +669,6 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
648 return 0; 669 return 0;
649 } 670 }
650 671
651 pr->throttling.state_count = 1 << acpi_gbl_FADT.duty_width;
652
653 /*
654 * Compute state values. Note that throttling displays a linear power/
655 * performance relationship (at 50% performance the CPU will consume
656 * 50% power). Values are in 1/10th of a percent to preserve accuracy.
657 */
658
659 step = (1000 / pr->throttling.state_count);
660
661 for (i = 0; i < pr->throttling.state_count; i++) {
662 pr->throttling.states[i].performance = step * i;
663 pr->throttling.states[i].power = step * i;
664 }
665
666 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d throttling states\n", 672 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d throttling states\n",
667 pr->throttling.state_count)); 673 pr->throttling.state_count));
668 674