aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorVenkatesh Pallipadi <venkatesh.pallipadi@intel.com>2005-04-15 15:07:10 -0400
committerLen Brown <len.brown@intel.com>2005-07-12 00:14:36 -0400
commit02df8b9385c21fdba165bd380f60eca1d3b0578b (patch)
tree988ad0e0ca73a40993fb1458d5cd19f90f922b31 /drivers/acpi
parent17e9c78a75ce9eacd61200f9e1f1924012e28846 (diff)
[ACPI] enable C2 and C3 idle power states on SMP
http://bugzilla.kernel.org/show_bug.cgi?id=4401 Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/processor_core.c37
-rw-r--r--drivers/acpi/processor_idle.c105
-rw-r--r--drivers/acpi/processor_perflib.c33
3 files changed, 109 insertions, 66 deletions
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index f4778747e889..e421842888b9 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -256,6 +256,43 @@ acpi_processor_errata (
256 256
257 257
258/* -------------------------------------------------------------------------- 258/* --------------------------------------------------------------------------
259 Common ACPI processor fucntions
260 -------------------------------------------------------------------------- */
261
262/*
263 * _PDC is required for a BIOS-OS handshake for most of the newer
264 * ACPI processor features.
265 */
266
267int acpi_processor_set_pdc(struct acpi_processor *pr,
268 struct acpi_object_list *pdc_in)
269{
270 acpi_status status = AE_OK;
271 u32 arg0_buf[3];
272 union acpi_object arg0 = {ACPI_TYPE_BUFFER};
273 struct acpi_object_list no_object = {1, &arg0};
274 struct acpi_object_list *pdc;
275
276 ACPI_FUNCTION_TRACE("acpi_processor_set_pdc");
277
278 arg0.buffer.length = 12;
279 arg0.buffer.pointer = (u8 *) arg0_buf;
280 arg0_buf[0] = ACPI_PDC_REVISION_ID;
281 arg0_buf[1] = 0;
282 arg0_buf[2] = 0;
283
284 pdc = (pdc_in) ? pdc_in : &no_object;
285
286 status = acpi_evaluate_object(pr->handle, "_PDC", pdc, NULL);
287
288 if ((ACPI_FAILURE(status)) && (pdc_in))
289 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Error evaluating _PDC, using legacy perf. control...\n"));
290
291 return_VALUE(status);
292}
293
294
295/* --------------------------------------------------------------------------
259 FS Interface (/proc) 296 FS Interface (/proc)
260 -------------------------------------------------------------------------- */ 297 -------------------------------------------------------------------------- */
261 298
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 /*
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index a9a1a8fe3199..1f0d6256302f 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -165,37 +165,6 @@ void acpi_processor_ppc_exit(void) {
165 acpi_processor_ppc_status &= ~PPC_REGISTERED; 165 acpi_processor_ppc_status &= ~PPC_REGISTERED;
166} 166}
167 167
168/*
169 * when registering a cpufreq driver with this ACPI processor driver, the
170 * _PCT and _PSS structures are read out and written into struct
171 * acpi_processor_performance.
172 */
173static int acpi_processor_set_pdc (struct acpi_processor *pr)
174{
175 acpi_status status = AE_OK;
176 u32 arg0_buf[3];
177 union acpi_object arg0 = {ACPI_TYPE_BUFFER};
178 struct acpi_object_list no_object = {1, &arg0};
179 struct acpi_object_list *pdc;
180
181 ACPI_FUNCTION_TRACE("acpi_processor_set_pdc");
182
183 arg0.buffer.length = 12;
184 arg0.buffer.pointer = (u8 *) arg0_buf;
185 arg0_buf[0] = ACPI_PDC_REVISION_ID;
186 arg0_buf[1] = 0;
187 arg0_buf[2] = 0;
188
189 pdc = (pr->performance->pdc) ? pr->performance->pdc : &no_object;
190
191 status = acpi_evaluate_object(pr->handle, "_PDC", pdc, NULL);
192
193 if ((ACPI_FAILURE(status)) && (pr->performance->pdc))
194 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Error evaluating _PDC, using legacy perf. control...\n"));
195
196 return_VALUE(status);
197}
198
199 168
200static int 169static int
201acpi_processor_get_performance_control ( 170acpi_processor_get_performance_control (
@@ -357,7 +326,7 @@ acpi_processor_get_performance_info (
357 if (!pr || !pr->performance || !pr->handle) 326 if (!pr || !pr->performance || !pr->handle)
358 return_VALUE(-EINVAL); 327 return_VALUE(-EINVAL);
359 328
360 acpi_processor_set_pdc(pr); 329 acpi_processor_set_pdc(pr, pr->performance->pdc);
361 330
362 status = acpi_get_handle(pr->handle, "_PCT", &handle); 331 status = acpi_get_handle(pr->handle, "_PCT", &handle);
363 if (ACPI_FAILURE(status)) { 332 if (ACPI_FAILURE(status)) {