aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Travis <travis@sgi.com>2008-06-09 19:22:23 -0400
committerAndi Kleen <andi@basil.nowhere.org>2008-07-16 17:27:01 -0400
commit706546d02384b64e083bd9130c56eaa599c66038 (patch)
treef660fa259f7c8f93a1427cdef529a6ffe8331cab
parent5411552c707f4b7387ad63141ef3a559e7488091 (diff)
ACPI: change processors from array to per_cpu variable
Change processors from an array sized by NR_CPUS to a per_cpu variable. Signed-off-by: Mike Travis <travis@sgi.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Len Brown <len.brown@intel.com> Signed-off-by: Andi Kleen <ak@linux.intel.com>
-rw-r--r--drivers/acpi/processor_core.c20
-rw-r--r--drivers/acpi/processor_idle.c8
-rw-r--r--drivers/acpi/processor_perflib.c18
-rw-r--r--drivers/acpi/processor_throttling.c14
-rw-r--r--include/acpi/processor.h2
5 files changed, 30 insertions, 32 deletions
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index feddc8ed870a..9a803f85ccfe 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -118,7 +118,7 @@ static const struct file_operations acpi_processor_info_fops = {
118 .release = single_release, 118 .release = single_release,
119}; 119};
120 120
121struct acpi_processor *processors[NR_CPUS]; 121DEFINE_PER_CPU(struct acpi_processor *, processors);
122struct acpi_processor_errata errata __read_mostly; 122struct acpi_processor_errata errata __read_mostly;
123 123
124/* -------------------------------------------------------------------------- 124/* --------------------------------------------------------------------------
@@ -614,7 +614,7 @@ static int acpi_processor_get_info(struct acpi_processor *pr, unsigned has_uid)
614 return 0; 614 return 0;
615} 615}
616 616
617static void *processor_device_array[NR_CPUS]; 617static DEFINE_PER_CPU(void *, processor_device_array);
618 618
619static int __cpuinit acpi_processor_start(struct acpi_device *device) 619static int __cpuinit acpi_processor_start(struct acpi_device *device)
620{ 620{
@@ -638,15 +638,15 @@ static int __cpuinit acpi_processor_start(struct acpi_device *device)
638 * ACPI id of processors can be reported wrongly by the BIOS. 638 * ACPI id of processors can be reported wrongly by the BIOS.
639 * Don't trust it blindly 639 * Don't trust it blindly
640 */ 640 */
641 if (processor_device_array[pr->id] != NULL && 641 if (per_cpu(processor_device_array, pr->id) != NULL &&
642 processor_device_array[pr->id] != device) { 642 per_cpu(processor_device_array, pr->id) != device) {
643 printk(KERN_WARNING "BIOS reported wrong ACPI id " 643 printk(KERN_WARNING "BIOS reported wrong ACPI id "
644 "for the processor\n"); 644 "for the processor\n");
645 return -ENODEV; 645 return -ENODEV;
646 } 646 }
647 processor_device_array[pr->id] = device; 647 per_cpu(processor_device_array, pr->id) = device;
648 648
649 processors[pr->id] = pr; 649 per_cpu(processors, pr->id) = pr;
650 650
651 result = acpi_processor_add_fs(device); 651 result = acpi_processor_add_fs(device);
652 if (result) 652 if (result)
@@ -753,7 +753,7 @@ static int acpi_cpu_soft_notify(struct notifier_block *nfb,
753 unsigned long action, void *hcpu) 753 unsigned long action, void *hcpu)
754{ 754{
755 unsigned int cpu = (unsigned long)hcpu; 755 unsigned int cpu = (unsigned long)hcpu;
756 struct acpi_processor *pr = processors[cpu]; 756 struct acpi_processor *pr = per_cpu(processors, cpu);
757 757
758 if (action == CPU_ONLINE && pr) { 758 if (action == CPU_ONLINE && pr) {
759 acpi_processor_ppc_has_changed(pr); 759 acpi_processor_ppc_has_changed(pr);
@@ -825,8 +825,8 @@ static int acpi_processor_remove(struct acpi_device *device, int type)
825 pr->cdev = NULL; 825 pr->cdev = NULL;
826 } 826 }
827 827
828 processors[pr->id] = NULL; 828 per_cpu(processors, pr->id) = NULL;
829 processor_device_array[pr->id] = NULL; 829 per_cpu(processor_device_array, pr->id) = NULL;
830 kfree(pr); 830 kfree(pr);
831 831
832 return 0; 832 return 0;
@@ -1074,8 +1074,6 @@ static int __init acpi_processor_init(void)
1074{ 1074{
1075 int result = 0; 1075 int result = 0;
1076 1076
1077
1078 memset(&processors, 0, sizeof(processors));
1079 memset(&errata, 0, sizeof(errata)); 1077 memset(&errata, 0, sizeof(errata));
1080 1078
1081#ifdef CONFIG_SMP 1079#ifdef CONFIG_SMP
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 4976e5db2b3f..0fc310e7dfd6 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -401,7 +401,7 @@ static void acpi_processor_idle(void)
401 */ 401 */
402 local_irq_disable(); 402 local_irq_disable();
403 403
404 pr = processors[smp_processor_id()]; 404 pr = __get_cpu_var(processors);
405 if (!pr) { 405 if (!pr) {
406 local_irq_enable(); 406 local_irq_enable();
407 return; 407 return;
@@ -1431,7 +1431,7 @@ static int acpi_idle_enter_c1(struct cpuidle_device *dev,
1431 struct acpi_processor *pr; 1431 struct acpi_processor *pr;
1432 struct acpi_processor_cx *cx = cpuidle_get_statedata(state); 1432 struct acpi_processor_cx *cx = cpuidle_get_statedata(state);
1433 1433
1434 pr = processors[smp_processor_id()]; 1434 pr = __get_cpu_var(processors);
1435 1435
1436 if (unlikely(!pr)) 1436 if (unlikely(!pr))
1437 return 0; 1437 return 0;
@@ -1471,7 +1471,7 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
1471 u32 t1, t2; 1471 u32 t1, t2;
1472 int sleep_ticks = 0; 1472 int sleep_ticks = 0;
1473 1473
1474 pr = processors[smp_processor_id()]; 1474 pr = __get_cpu_var(processors);
1475 1475
1476 if (unlikely(!pr)) 1476 if (unlikely(!pr))
1477 return 0; 1477 return 0;
@@ -1549,7 +1549,7 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
1549 u32 t1, t2; 1549 u32 t1, t2;
1550 int sleep_ticks = 0; 1550 int sleep_ticks = 0;
1551 1551
1552 pr = processors[smp_processor_id()]; 1552 pr = __get_cpu_var(processors);
1553 1553
1554 if (unlikely(!pr)) 1554 if (unlikely(!pr))
1555 return 0; 1555 return 0;
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index d80b2d1441af..b4749969c6b4 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -89,7 +89,7 @@ static int acpi_processor_ppc_notifier(struct notifier_block *nb,
89 if (event != CPUFREQ_INCOMPATIBLE) 89 if (event != CPUFREQ_INCOMPATIBLE)
90 goto out; 90 goto out;
91 91
92 pr = processors[policy->cpu]; 92 pr = per_cpu(processors, policy->cpu);
93 if (!pr || !pr->performance) 93 if (!pr || !pr->performance)
94 goto out; 94 goto out;
95 95
@@ -572,7 +572,7 @@ int acpi_processor_preregister_performance(
572 572
573 /* Call _PSD for all CPUs */ 573 /* Call _PSD for all CPUs */
574 for_each_possible_cpu(i) { 574 for_each_possible_cpu(i) {
575 pr = processors[i]; 575 pr = per_cpu(processors, i);
576 if (!pr) { 576 if (!pr) {
577 /* Look only at processors in ACPI namespace */ 577 /* Look only at processors in ACPI namespace */
578 continue; 578 continue;
@@ -603,7 +603,7 @@ int acpi_processor_preregister_performance(
603 * domain info. 603 * domain info.
604 */ 604 */
605 for_each_possible_cpu(i) { 605 for_each_possible_cpu(i) {
606 pr = processors[i]; 606 pr = per_cpu(processors, i);
607 if (!pr) 607 if (!pr)
608 continue; 608 continue;
609 609
@@ -624,7 +624,7 @@ int acpi_processor_preregister_performance(
624 624
625 cpus_clear(covered_cpus); 625 cpus_clear(covered_cpus);
626 for_each_possible_cpu(i) { 626 for_each_possible_cpu(i) {
627 pr = processors[i]; 627 pr = per_cpu(processors, i);
628 if (!pr) 628 if (!pr)
629 continue; 629 continue;
630 630
@@ -651,7 +651,7 @@ int acpi_processor_preregister_performance(
651 if (i == j) 651 if (i == j)
652 continue; 652 continue;
653 653
654 match_pr = processors[j]; 654 match_pr = per_cpu(processors, j);
655 if (!match_pr) 655 if (!match_pr)
656 continue; 656 continue;
657 657
@@ -680,7 +680,7 @@ int acpi_processor_preregister_performance(
680 if (i == j) 680 if (i == j)
681 continue; 681 continue;
682 682
683 match_pr = processors[j]; 683 match_pr = per_cpu(processors, j);
684 if (!match_pr) 684 if (!match_pr)
685 continue; 685 continue;
686 686
@@ -697,7 +697,7 @@ int acpi_processor_preregister_performance(
697 697
698err_ret: 698err_ret:
699 for_each_possible_cpu(i) { 699 for_each_possible_cpu(i) {
700 pr = processors[i]; 700 pr = per_cpu(processors, i);
701 if (!pr || !pr->performance) 701 if (!pr || !pr->performance)
702 continue; 702 continue;
703 703
@@ -728,7 +728,7 @@ acpi_processor_register_performance(struct acpi_processor_performance
728 728
729 mutex_lock(&performance_mutex); 729 mutex_lock(&performance_mutex);
730 730
731 pr = processors[cpu]; 731 pr = per_cpu(processors, cpu);
732 if (!pr) { 732 if (!pr) {
733 mutex_unlock(&performance_mutex); 733 mutex_unlock(&performance_mutex);
734 return -ENODEV; 734 return -ENODEV;
@@ -766,7 +766,7 @@ acpi_processor_unregister_performance(struct acpi_processor_performance
766 766
767 mutex_lock(&performance_mutex); 767 mutex_lock(&performance_mutex);
768 768
769 pr = processors[cpu]; 769 pr = per_cpu(processors, cpu);
770 if (!pr) { 770 if (!pr) {
771 mutex_unlock(&performance_mutex); 771 mutex_unlock(&performance_mutex);
772 return; 772 return;
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index bb06738860c4..8728782aad3b 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -71,7 +71,7 @@ static int acpi_processor_update_tsd_coord(void)
71 * coordination between all CPUs. 71 * coordination between all CPUs.
72 */ 72 */
73 for_each_possible_cpu(i) { 73 for_each_possible_cpu(i) {
74 pr = processors[i]; 74 pr = per_cpu(processors, i);
75 if (!pr) 75 if (!pr)
76 continue; 76 continue;
77 77
@@ -93,7 +93,7 @@ static int acpi_processor_update_tsd_coord(void)
93 93
94 cpus_clear(covered_cpus); 94 cpus_clear(covered_cpus);
95 for_each_possible_cpu(i) { 95 for_each_possible_cpu(i) {
96 pr = processors[i]; 96 pr = per_cpu(processors, i);
97 if (!pr) 97 if (!pr)
98 continue; 98 continue;
99 99
@@ -119,7 +119,7 @@ static int acpi_processor_update_tsd_coord(void)
119 if (i == j) 119 if (i == j)
120 continue; 120 continue;
121 121
122 match_pr = processors[j]; 122 match_pr = per_cpu(processors, j);
123 if (!match_pr) 123 if (!match_pr)
124 continue; 124 continue;
125 125
@@ -152,7 +152,7 @@ static int acpi_processor_update_tsd_coord(void)
152 if (i == j) 152 if (i == j)
153 continue; 153 continue;
154 154
155 match_pr = processors[j]; 155 match_pr = per_cpu(processors, j);
156 if (!match_pr) 156 if (!match_pr)
157 continue; 157 continue;
158 158
@@ -172,7 +172,7 @@ static int acpi_processor_update_tsd_coord(void)
172 172
173err_ret: 173err_ret:
174 for_each_possible_cpu(i) { 174 for_each_possible_cpu(i) {
175 pr = processors[i]; 175 pr = per_cpu(processors, i);
176 if (!pr) 176 if (!pr)
177 continue; 177 continue;
178 178
@@ -214,7 +214,7 @@ static int acpi_processor_throttling_notifier(unsigned long event, void *data)
214 struct acpi_processor_throttling *p_throttling; 214 struct acpi_processor_throttling *p_throttling;
215 215
216 cpu = p_tstate->cpu; 216 cpu = p_tstate->cpu;
217 pr = processors[cpu]; 217 pr = per_cpu(processors, cpu);
218 if (!pr) { 218 if (!pr) {
219 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Invalid pr pointer\n")); 219 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Invalid pr pointer\n"));
220 return 0; 220 return 0;
@@ -1035,7 +1035,7 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
1035 * cpus. 1035 * cpus.
1036 */ 1036 */
1037 for_each_cpu_mask(i, online_throttling_cpus) { 1037 for_each_cpu_mask(i, online_throttling_cpus) {
1038 match_pr = processors[i]; 1038 match_pr = per_cpu(processors, i);
1039 /* 1039 /*
1040 * If the pointer is invalid, we will report the 1040 * If the pointer is invalid, we will report the
1041 * error message and continue. 1041 * error message and continue.
diff --git a/include/acpi/processor.h b/include/acpi/processor.h
index 06ebb6ef72aa..3795590e152a 100644
--- a/include/acpi/processor.h
+++ b/include/acpi/processor.h
@@ -255,7 +255,7 @@ extern void acpi_processor_unregister_performance(struct
255int acpi_processor_notify_smm(struct module *calling_module); 255int acpi_processor_notify_smm(struct module *calling_module);
256 256
257/* for communication between multiple parts of the processor kernel module */ 257/* for communication between multiple parts of the processor kernel module */
258extern struct acpi_processor *processors[NR_CPUS]; 258DECLARE_PER_CPU(struct acpi_processor *, processors);
259extern struct acpi_processor_errata errata; 259extern struct acpi_processor_errata errata;
260 260
261void arch_acpi_processor_init_pdc(struct acpi_processor *pr); 261void arch_acpi_processor_init_pdc(struct acpi_processor *pr);