aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/processor_idle.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/processor_idle.c')
-rw-r--r--drivers/acpi/processor_idle.c105
1 files changed, 71 insertions, 34 deletions
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 79d5ca3066c6..8f038cd29477 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -6,6 +6,8 @@
6 * Copyright (C) 2004 Dominik Brodowski <linux@brodo.de> 6 * Copyright (C) 2004 Dominik Brodowski <linux@brodo.de>
7 * Copyright (C) 2004 Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> 7 * Copyright (C) 2004 Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
8 * - Added processor hotplug support 8 * - Added processor hotplug support
9 * Copyright (C) 2005 Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
10 * - Added support for C3 on SMP
9 * 11 *
10 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 12 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11 * 13 *
@@ -142,7 +144,7 @@ acpi_processor_power_activate (
142 switch (old->type) { 144 switch (old->type) {
143 case ACPI_STATE_C3: 145 case ACPI_STATE_C3:
144 /* Disable bus master reload */ 146 /* Disable bus master reload */
145 if (new->type != ACPI_STATE_C3) 147 if (new->type != ACPI_STATE_C3 && pr->flags.bm_check)
146 acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 0, ACPI_MTX_DO_NOT_LOCK); 148 acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 0, ACPI_MTX_DO_NOT_LOCK);
147 break; 149 break;
148 } 150 }
@@ -152,7 +154,7 @@ acpi_processor_power_activate (
152 switch (new->type) { 154 switch (new->type) {
153 case ACPI_STATE_C3: 155 case ACPI_STATE_C3:
154 /* Enable bus master reload */ 156 /* Enable bus master reload */
155 if (old->type != ACPI_STATE_C3) 157 if (old->type != ACPI_STATE_C3 && pr->flags.bm_check)
156 acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 1, ACPI_MTX_DO_NOT_LOCK); 158 acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 1, ACPI_MTX_DO_NOT_LOCK);
157 break; 159 break;
158 } 160 }
@@ -163,6 +165,9 @@ acpi_processor_power_activate (
163} 165}
164 166
165 167
168static atomic_t c3_cpu_count;
169
170
166static void acpi_processor_idle (void) 171static void acpi_processor_idle (void)
167{ 172{
168 struct acpi_processor *pr = NULL; 173 struct acpi_processor *pr = NULL;
@@ -297,8 +302,22 @@ static void acpi_processor_idle (void)
297 break; 302 break;
298 303
299 case ACPI_STATE_C3: 304 case ACPI_STATE_C3:
300 /* Disable bus master arbitration */ 305
301 acpi_set_register(ACPI_BITREG_ARB_DISABLE, 1, ACPI_MTX_DO_NOT_LOCK); 306 if (pr->flags.bm_check) {
307 if (atomic_inc_return(&c3_cpu_count) ==
308 num_online_cpus()) {
309 /*
310 * All CPUs are trying to go to C3
311 * Disable bus master arbitration
312 */
313 acpi_set_register(ACPI_BITREG_ARB_DISABLE, 1,
314 ACPI_MTX_DO_NOT_LOCK);
315 }
316 } else {
317 /* SMP with no shared cache... Invalidate cache */
318 ACPI_FLUSH_CPU_CACHE();
319 }
320
302 /* Get start time (ticks) */ 321 /* Get start time (ticks) */
303 t1 = inl(acpi_fadt.xpm_tmr_blk.address); 322 t1 = inl(acpi_fadt.xpm_tmr_blk.address);
304 /* Invoke C3 */ 323 /* Invoke C3 */
@@ -307,8 +326,12 @@ static void acpi_processor_idle (void)
307 t2 = inl(acpi_fadt.xpm_tmr_blk.address); 326 t2 = inl(acpi_fadt.xpm_tmr_blk.address);
308 /* Get end time (ticks) */ 327 /* Get end time (ticks) */
309 t2 = inl(acpi_fadt.xpm_tmr_blk.address); 328 t2 = inl(acpi_fadt.xpm_tmr_blk.address);
310 /* Enable bus master arbitration */ 329 if (pr->flags.bm_check) {
311 acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0, ACPI_MTX_DO_NOT_LOCK); 330 /* Enable bus master arbitration */
331 atomic_dec(&c3_cpu_count);
332 acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0, ACPI_MTX_DO_NOT_LOCK);
333 }
334
312 /* Re-enable interrupts */ 335 /* Re-enable interrupts */
313 local_irq_enable(); 336 local_irq_enable();
314 /* Compute time (ticks) that we were actually asleep */ 337 /* Compute time (ticks) that we were actually asleep */
@@ -552,9 +575,6 @@ static int acpi_processor_get_power_info_cst (struct acpi_processor *pr)
552 575
553 ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_cst"); 576 ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_cst");
554 577
555 if (errata.smp)
556 return_VALUE(-ENODEV);
557
558 if (nocst) 578 if (nocst)
559 return_VALUE(-ENODEV); 579 return_VALUE(-ENODEV);
560 580
@@ -687,13 +707,6 @@ static void acpi_processor_power_verify_c2(struct acpi_processor_cx *cx)
687 return_VOID; 707 return_VOID;
688 } 708 }
689 709
690 /* We're (currently) only supporting C2 on UP */
691 else if (errata.smp) {
692 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
693 "C2 not supported in SMP mode\n"));
694 return_VOID;
695 }
696
697 /* 710 /*
698 * Otherwise we've met all of our C2 requirements. 711 * Otherwise we've met all of our C2 requirements.
699 * Normalize the C2 latency to expidite policy 712 * Normalize the C2 latency to expidite policy
@@ -709,6 +722,8 @@ static void acpi_processor_power_verify_c3(
709 struct acpi_processor *pr, 722 struct acpi_processor *pr,
710 struct acpi_processor_cx *cx) 723 struct acpi_processor_cx *cx)
711{ 724{
725 static int bm_check_flag;
726
712 ACPI_FUNCTION_TRACE("acpi_processor_get_power_verify_c3"); 727 ACPI_FUNCTION_TRACE("acpi_processor_get_power_verify_c3");
713 728
714 if (!cx->address) 729 if (!cx->address)
@@ -725,20 +740,6 @@ static void acpi_processor_power_verify_c3(
725 return_VOID; 740 return_VOID;
726 } 741 }
727 742
728 /* bus mastering control is necessary */
729 else if (!pr->flags.bm_control) {
730 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
731 "C3 support requires bus mastering control\n"));
732 return_VOID;
733 }
734
735 /* We're (currently) only supporting C2 on UP */
736 else if (errata.smp) {
737 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
738 "C3 not supported in SMP mode\n"));
739 return_VOID;
740 }
741
742 /* 743 /*
743 * PIIX4 Erratum #18: We don't support C3 when Type-F (fast) 744 * PIIX4 Erratum #18: We don't support C3 when Type-F (fast)
744 * DMA transfers are used by any ISA device to avoid livelock. 745 * DMA transfers are used by any ISA device to avoid livelock.
@@ -752,6 +753,39 @@ static void acpi_processor_power_verify_c3(
752 return_VOID; 753 return_VOID;
753 } 754 }
754 755
756 /* All the logic here assumes flags.bm_check is same across all CPUs */
757 if (!bm_check_flag) {
758 /* Determine whether bm_check is needed based on CPU */
759 acpi_processor_power_init_bm_check(&(pr->flags), pr->id);
760 bm_check_flag = pr->flags.bm_check;
761 } else {
762 pr->flags.bm_check = bm_check_flag;
763 }
764
765 if (pr->flags.bm_check) {
766 printk("Disabling BM access before entering C3\n");
767 /* bus mastering control is necessary */
768 if (!pr->flags.bm_control) {
769 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
770 "C3 support requires bus mastering control\n"));
771 return_VOID;
772 }
773 } else {
774 printk("Invalidating cache before entering C3\n");
775 /*
776 * WBINVD should be set in fadt, for C3 state to be
777 * supported on when bm_check is not required.
778 */
779 if (acpi_fadt.wb_invd != 1) {
780 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
781 "Cache invalidation should work properly"
782 " for C3 to be enabled on SMP systems\n"));
783 return_VOID;
784 }
785 acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD,
786 0, ACPI_MTX_DO_NOT_LOCK);
787 }
788
755 /* 789 /*
756 * Otherwise we've met all of our C3 requirements. 790 * Otherwise we've met all of our C3 requirements.
757 * Normalize the C3 latency to expidite policy. Enable 791 * Normalize the C3 latency to expidite policy. Enable
@@ -760,7 +794,6 @@ static void acpi_processor_power_verify_c3(
760 */ 794 */
761 cx->valid = 1; 795 cx->valid = 1;
762 cx->latency_ticks = US_TO_PM_TIMER_TICKS(cx->latency); 796 cx->latency_ticks = US_TO_PM_TIMER_TICKS(cx->latency);
763 pr->flags.bm_check = 1;
764 797
765 return_VOID; 798 return_VOID;
766} 799}
@@ -848,7 +881,7 @@ int acpi_processor_cst_has_changed (struct acpi_processor *pr)
848 if (!pr) 881 if (!pr)
849 return_VALUE(-EINVAL); 882 return_VALUE(-EINVAL);
850 883
851 if (errata.smp || nocst) { 884 if ( nocst) {
852 return_VALUE(-ENODEV); 885 return_VALUE(-ENODEV);
853 } 886 }
854 887
@@ -948,7 +981,6 @@ static struct file_operations acpi_processor_power_fops = {
948 .release = single_release, 981 .release = single_release,
949}; 982};
950 983
951
952int acpi_processor_power_init(struct acpi_processor *pr, struct acpi_device *device) 984int acpi_processor_power_init(struct acpi_processor *pr, struct acpi_device *device)
953{ 985{
954 acpi_status status = 0; 986 acpi_status status = 0;
@@ -965,7 +997,10 @@ int acpi_processor_power_init(struct acpi_processor *pr, struct acpi_device *dev
965 first_run++; 997 first_run++;
966 } 998 }
967 999
968 if (!errata.smp && (pr->id == 0) && acpi_fadt.cst_cnt && !nocst) { 1000 if (!pr)
1001 return_VALUE(-EINVAL);
1002
1003 if (acpi_fadt.cst_cnt && !nocst) {
969 status = acpi_os_write_port(acpi_fadt.smi_cmd, acpi_fadt.cst_cnt, 8); 1004 status = acpi_os_write_port(acpi_fadt.smi_cmd, acpi_fadt.cst_cnt, 8);
970 if (ACPI_FAILURE(status)) { 1005 if (ACPI_FAILURE(status)) {
971 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1006 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
@@ -973,6 +1008,8 @@ int acpi_processor_power_init(struct acpi_processor *pr, struct acpi_device *dev
973 } 1008 }
974 } 1009 }
975 1010
1011 acpi_processor_power_init_pdc(&(pr->power), pr->id);
1012 acpi_processor_set_pdc(pr, pr->power.pdc);
976 acpi_processor_get_power_info(pr); 1013 acpi_processor_get_power_info(pr);
977 1014
978 /* 1015 /*