aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-10-27 20:11:24 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-10-27 20:11:24 -0400
commit3fbc4d63744b21ed6814ce768672531500bd3f14 (patch)
tree661663d6d5e577e0a4462e89ee8d693298c7eb44
parent8e32e47dbb98fd24e4c541753427a576e6ab5bb3 (diff)
parent764d022133979f9d9a179152cd89717e9752c61a (diff)
Merge branch 'acpi-processor'
* acpi-processor: ACPI / processor: fixed a brace coding style issue ACPI / processor: Remove outdated comments ACPI / processor: remove unnecessary if (!pr) check ACPI / processor: remove some dead code in acpi_processor_get_info() x86 / ACPI: simplify _acpi_map_lsapic() ACPI / processor: use apic_id and remove duplicated _MAT evaluation ACPI / processor: Introduce apic_id in struct processor to save parsed APIC id
-rw-r--r--arch/ia64/kernel/acpi.c38
-rw-r--r--arch/x86/include/asm/mpspec.h2
-rw-r--r--arch/x86/kernel/acpi/boot.c88
-rw-r--r--arch/x86/kernel/apic/apic.c8
-rw-r--r--drivers/acpi/acpi_processor.c22
-rw-r--r--drivers/acpi/processor_core.c26
-rw-r--r--drivers/acpi/processor_driver.c3
-rw-r--r--include/acpi/processor.h3
-rw-r--r--include/linux/acpi.h2
9 files changed, 61 insertions, 131 deletions
diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
index 5eb71d22c3d5..59d52e3aef12 100644
--- a/arch/ia64/kernel/acpi.c
+++ b/arch/ia64/kernel/acpi.c
@@ -882,40 +882,10 @@ __init void prefill_possible_map(void)
882 set_cpu_possible(i, true); 882 set_cpu_possible(i, true);
883} 883}
884 884
885static int _acpi_map_lsapic(acpi_handle handle, int *pcpu) 885static int _acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)
886{ 886{
887 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
888 union acpi_object *obj;
889 struct acpi_madt_local_sapic *lsapic;
890 cpumask_t tmp_map; 887 cpumask_t tmp_map;
891 int cpu, physid; 888 int cpu;
892
893 if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))
894 return -EINVAL;
895
896 if (!buffer.length || !buffer.pointer)
897 return -EINVAL;
898
899 obj = buffer.pointer;
900 if (obj->type != ACPI_TYPE_BUFFER)
901 {
902 kfree(buffer.pointer);
903 return -EINVAL;
904 }
905
906 lsapic = (struct acpi_madt_local_sapic *)obj->buffer.pointer;
907
908 if ((lsapic->header.type != ACPI_MADT_TYPE_LOCAL_SAPIC) ||
909 (!(lsapic->lapic_flags & ACPI_MADT_ENABLED))) {
910 kfree(buffer.pointer);
911 return -EINVAL;
912 }
913
914 physid = ((lsapic->id << 8) | (lsapic->eid));
915
916 kfree(buffer.pointer);
917 buffer.length = ACPI_ALLOCATE_BUFFER;
918 buffer.pointer = NULL;
919 889
920 cpumask_complement(&tmp_map, cpu_present_mask); 890 cpumask_complement(&tmp_map, cpu_present_mask);
921 cpu = cpumask_first(&tmp_map); 891 cpu = cpumask_first(&tmp_map);
@@ -934,9 +904,9 @@ static int _acpi_map_lsapic(acpi_handle handle, int *pcpu)
934} 904}
935 905
936/* wrapper to silence section mismatch warning */ 906/* wrapper to silence section mismatch warning */
937int __ref acpi_map_lsapic(acpi_handle handle, int *pcpu) 907int __ref acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)
938{ 908{
939 return _acpi_map_lsapic(handle, pcpu); 909 return _acpi_map_lsapic(handle, physid, pcpu);
940} 910}
941EXPORT_SYMBOL(acpi_map_lsapic); 911EXPORT_SYMBOL(acpi_map_lsapic);
942 912
diff --git a/arch/x86/include/asm/mpspec.h b/arch/x86/include/asm/mpspec.h
index 626cf70082d7..3142a94c7b4b 100644
--- a/arch/x86/include/asm/mpspec.h
+++ b/arch/x86/include/asm/mpspec.h
@@ -94,7 +94,7 @@ static inline void early_reserve_e820_mpc_new(void) { }
94#define default_get_smp_config x86_init_uint_noop 94#define default_get_smp_config x86_init_uint_noop
95#endif 95#endif
96 96
97void generic_processor_info(int apicid, int version); 97int generic_processor_info(int apicid, int version);
98#ifdef CONFIG_ACPI 98#ifdef CONFIG_ACPI
99extern void mp_register_ioapic(int id, u32 address, u32 gsi_base); 99extern void mp_register_ioapic(int id, u32 address, u32 gsi_base);
100extern void mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, 100extern void mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger,
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 40c76604199f..1f7c0746611f 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -189,24 +189,31 @@ static int __init acpi_parse_madt(struct acpi_table_header *table)
189 return 0; 189 return 0;
190} 190}
191 191
192static void acpi_register_lapic(int id, u8 enabled) 192/**
193 * acpi_register_lapic - register a local apic and generates a logic cpu number
194 * @id: local apic id to register
195 * @enabled: this cpu is enabled or not
196 *
197 * Returns the logic cpu number which maps to the local apic
198 */
199static int acpi_register_lapic(int id, u8 enabled)
193{ 200{
194 unsigned int ver = 0; 201 unsigned int ver = 0;
195 202
196 if (id >= MAX_LOCAL_APIC) { 203 if (id >= MAX_LOCAL_APIC) {
197 printk(KERN_INFO PREFIX "skipped apicid that is too big\n"); 204 printk(KERN_INFO PREFIX "skipped apicid that is too big\n");
198 return; 205 return -EINVAL;
199 } 206 }
200 207
201 if (!enabled) { 208 if (!enabled) {
202 ++disabled_cpus; 209 ++disabled_cpus;
203 return; 210 return -EINVAL;
204 } 211 }
205 212
206 if (boot_cpu_physical_apicid != -1U) 213 if (boot_cpu_physical_apicid != -1U)
207 ver = apic_version[boot_cpu_physical_apicid]; 214 ver = apic_version[boot_cpu_physical_apicid];
208 215
209 generic_processor_info(id, ver); 216 return generic_processor_info(id, ver);
210} 217}
211 218
212static int __init 219static int __init
@@ -614,84 +621,27 @@ static void acpi_map_cpu2node(acpi_handle handle, int cpu, int physid)
614#endif 621#endif
615} 622}
616 623
617static int _acpi_map_lsapic(acpi_handle handle, int *pcpu) 624static int _acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)
618{ 625{
619 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
620 union acpi_object *obj;
621 struct acpi_madt_local_apic *lapic;
622 cpumask_var_t tmp_map, new_map;
623 u8 physid;
624 int cpu; 626 int cpu;
625 int retval = -ENOMEM;
626
627 if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))
628 return -EINVAL;
629
630 if (!buffer.length || !buffer.pointer)
631 return -EINVAL;
632
633 obj = buffer.pointer;
634 if (obj->type != ACPI_TYPE_BUFFER ||
635 obj->buffer.length < sizeof(*lapic)) {
636 kfree(buffer.pointer);
637 return -EINVAL;
638 }
639 627
640 lapic = (struct acpi_madt_local_apic *)obj->buffer.pointer; 628 cpu = acpi_register_lapic(physid, ACPI_MADT_ENABLED);
641 629 if (cpu < 0) {
642 if (lapic->header.type != ACPI_MADT_TYPE_LOCAL_APIC || 630 pr_info(PREFIX "Unable to map lapic to logical cpu number\n");
643 !(lapic->lapic_flags & ACPI_MADT_ENABLED)) { 631 return cpu;
644 kfree(buffer.pointer);
645 return -EINVAL;
646 }
647
648 physid = lapic->id;
649
650 kfree(buffer.pointer);
651 buffer.length = ACPI_ALLOCATE_BUFFER;
652 buffer.pointer = NULL;
653 lapic = NULL;
654
655 if (!alloc_cpumask_var(&tmp_map, GFP_KERNEL))
656 goto out;
657
658 if (!alloc_cpumask_var(&new_map, GFP_KERNEL))
659 goto free_tmp_map;
660
661 cpumask_copy(tmp_map, cpu_present_mask);
662 acpi_register_lapic(physid, ACPI_MADT_ENABLED);
663
664 /*
665 * If acpi_register_lapic successfully generates a new logical cpu
666 * number, then the following will get us exactly what was mapped
667 */
668 cpumask_andnot(new_map, cpu_present_mask, tmp_map);
669 if (cpumask_empty(new_map)) {
670 printk ("Unable to map lapic to logical cpu number\n");
671 retval = -EINVAL;
672 goto free_new_map;
673 } 632 }
674 633
675 acpi_processor_set_pdc(handle); 634 acpi_processor_set_pdc(handle);
676
677 cpu = cpumask_first(new_map);
678 acpi_map_cpu2node(handle, cpu, physid); 635 acpi_map_cpu2node(handle, cpu, physid);
679 636
680 *pcpu = cpu; 637 *pcpu = cpu;
681 retval = 0; 638 return 0;
682
683free_new_map:
684 free_cpumask_var(new_map);
685free_tmp_map:
686 free_cpumask_var(tmp_map);
687out:
688 return retval;
689} 639}
690 640
691/* wrapper to silence section mismatch warning */ 641/* wrapper to silence section mismatch warning */
692int __ref acpi_map_lsapic(acpi_handle handle, int *pcpu) 642int __ref acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)
693{ 643{
694 return _acpi_map_lsapic(handle, pcpu); 644 return _acpi_map_lsapic(handle, physid, pcpu);
695} 645}
696EXPORT_SYMBOL(acpi_map_lsapic); 646EXPORT_SYMBOL(acpi_map_lsapic);
697 647
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index a7eb82d9b012..ed165d657380 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -2107,7 +2107,7 @@ void disconnect_bsp_APIC(int virt_wire_setup)
2107 apic_write(APIC_LVT1, value); 2107 apic_write(APIC_LVT1, value);
2108} 2108}
2109 2109
2110void generic_processor_info(int apicid, int version) 2110int generic_processor_info(int apicid, int version)
2111{ 2111{
2112 int cpu, max = nr_cpu_ids; 2112 int cpu, max = nr_cpu_ids;
2113 bool boot_cpu_detected = physid_isset(boot_cpu_physical_apicid, 2113 bool boot_cpu_detected = physid_isset(boot_cpu_physical_apicid,
@@ -2127,7 +2127,7 @@ void generic_processor_info(int apicid, int version)
2127 " Processor %d/0x%x ignored.\n", max, thiscpu, apicid); 2127 " Processor %d/0x%x ignored.\n", max, thiscpu, apicid);
2128 2128
2129 disabled_cpus++; 2129 disabled_cpus++;
2130 return; 2130 return -ENODEV;
2131 } 2131 }
2132 2132
2133 if (num_processors >= nr_cpu_ids) { 2133 if (num_processors >= nr_cpu_ids) {
@@ -2138,7 +2138,7 @@ void generic_processor_info(int apicid, int version)
2138 " Processor %d/0x%x ignored.\n", max, thiscpu, apicid); 2138 " Processor %d/0x%x ignored.\n", max, thiscpu, apicid);
2139 2139
2140 disabled_cpus++; 2140 disabled_cpus++;
2141 return; 2141 return -EINVAL;
2142 } 2142 }
2143 2143
2144 num_processors++; 2144 num_processors++;
@@ -2183,6 +2183,8 @@ void generic_processor_info(int apicid, int version)
2183#endif 2183#endif
2184 set_cpu_possible(cpu, true); 2184 set_cpu_possible(cpu, true);
2185 set_cpu_present(cpu, true); 2185 set_cpu_present(cpu, true);
2186
2187 return cpu;
2186} 2188}
2187 2189
2188int hard_smp_processor_id(void) 2190int hard_smp_processor_id(void)
diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index 357abdc1406a..3c1d6b0c09a4 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -140,15 +140,11 @@ static int acpi_processor_errata_piix4(struct pci_dev *dev)
140 return 0; 140 return 0;
141} 141}
142 142
143static int acpi_processor_errata(struct acpi_processor *pr) 143static int acpi_processor_errata(void)
144{ 144{
145 int result = 0; 145 int result = 0;
146 struct pci_dev *dev = NULL; 146 struct pci_dev *dev = NULL;
147 147
148
149 if (!pr)
150 return -EINVAL;
151
152 /* 148 /*
153 * PIIX4 149 * PIIX4
154 */ 150 */
@@ -181,7 +177,7 @@ static int acpi_processor_hotadd_init(struct acpi_processor *pr)
181 cpu_maps_update_begin(); 177 cpu_maps_update_begin();
182 cpu_hotplug_begin(); 178 cpu_hotplug_begin();
183 179
184 ret = acpi_map_lsapic(pr->handle, &pr->id); 180 ret = acpi_map_lsapic(pr->handle, pr->apic_id, &pr->id);
185 if (ret) 181 if (ret)
186 goto out; 182 goto out;
187 183
@@ -221,10 +217,7 @@ static int acpi_processor_get_info(struct acpi_device *device)
221 static int cpu0_initialized; 217 static int cpu0_initialized;
222 unsigned long long value; 218 unsigned long long value;
223 219
224 if (num_online_cpus() > 1) 220 acpi_processor_errata();
225 errata.smp = TRUE;
226
227 acpi_processor_errata(pr);
228 221
229 /* 222 /*
230 * Check to see if we have bus mastering arbitration control. This 223 * Check to see if we have bus mastering arbitration control. This
@@ -248,11 +241,6 @@ static int acpi_processor_get_info(struct acpi_device *device)
248 return -ENODEV; 241 return -ENODEV;
249 } 242 }
250 243
251 /*
252 * TBD: Synch processor ID (via LAPIC/LSAPIC structures) on SMP.
253 * >>> 'acpi_get_processor_id(acpi_id, &id)' in
254 * arch/xxx/acpi.c
255 */
256 pr->acpi_id = object.processor.proc_id; 244 pr->acpi_id = object.processor.proc_id;
257 } else { 245 } else {
258 /* 246 /*
@@ -270,7 +258,9 @@ static int acpi_processor_get_info(struct acpi_device *device)
270 device_declaration = 1; 258 device_declaration = 1;
271 pr->acpi_id = value; 259 pr->acpi_id = value;
272 } 260 }
273 cpu_index = acpi_get_cpuid(pr->handle, device_declaration, pr->acpi_id); 261 pr->apic_id = acpi_get_apicid(pr->handle, device_declaration,
262 pr->acpi_id);
263 cpu_index = acpi_map_cpuid(pr->apic_id, pr->acpi_id);
274 264
275 /* Handle UP system running SMP kernel, with no LAPIC in MADT */ 265 /* Handle UP system running SMP kernel, with no LAPIC in MADT */
276 if (!cpu0_initialized && (cpu_index == -1) && 266 if (!cpu0_initialized && (cpu_index == -1) &&
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index cf34d903f4fb..b3171f30b319 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -162,16 +162,23 @@ exit:
162 return apic_id; 162 return apic_id;
163} 163}
164 164
165int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id) 165int acpi_get_apicid(acpi_handle handle, int type, u32 acpi_id)
166{ 166{
167#ifdef CONFIG_SMP 167 int apic_id;
168 int i;
169#endif
170 int apic_id = -1;
171 168
172 apic_id = map_mat_entry(handle, type, acpi_id); 169 apic_id = map_mat_entry(handle, type, acpi_id);
173 if (apic_id == -1) 170 if (apic_id == -1)
174 apic_id = map_madt_entry(type, acpi_id); 171 apic_id = map_madt_entry(type, acpi_id);
172
173 return apic_id;
174}
175
176int acpi_map_cpuid(int apic_id, u32 acpi_id)
177{
178#ifdef CONFIG_SMP
179 int i;
180#endif
181
175 if (apic_id == -1) { 182 if (apic_id == -1) {
176 /* 183 /*
177 * On UP processor, there is no _MAT or MADT table. 184 * On UP processor, there is no _MAT or MADT table.
@@ -211,6 +218,15 @@ int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id)
211#endif 218#endif
212 return -1; 219 return -1;
213} 220}
221
222int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id)
223{
224 int apic_id;
225
226 apic_id = acpi_get_apicid(handle, type, acpi_id);
227
228 return acpi_map_cpuid(apic_id, acpi_id);
229}
214EXPORT_SYMBOL_GPL(acpi_get_cpuid); 230EXPORT_SYMBOL_GPL(acpi_get_cpuid);
215 231
216static bool __init processor_physically_present(acpi_handle handle) 232static bool __init processor_physically_present(acpi_handle handle)
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
index e534ba66d5b8..40fc773ab6e0 100644
--- a/drivers/acpi/processor_driver.c
+++ b/drivers/acpi/processor_driver.c
@@ -153,8 +153,7 @@ static int acpi_cpu_soft_notify(struct notifier_block *nfb,
153 return NOTIFY_OK; 153 return NOTIFY_OK;
154} 154}
155 155
156static struct notifier_block __refdata acpi_cpu_notifier = 156static struct notifier_block __refdata acpi_cpu_notifier = {
157{
158 .notifier_call = acpi_cpu_soft_notify, 157 .notifier_call = acpi_cpu_soft_notify,
159}; 158};
160 159
diff --git a/include/acpi/processor.h b/include/acpi/processor.h
index 66096d06925e..7816e45f5d5a 100644
--- a/include/acpi/processor.h
+++ b/include/acpi/processor.h
@@ -199,6 +199,7 @@ struct acpi_processor_flags {
199struct acpi_processor { 199struct acpi_processor {
200 acpi_handle handle; 200 acpi_handle handle;
201 u32 acpi_id; 201 u32 acpi_id;
202 u32 apic_id;
202 u32 id; 203 u32 id;
203 u32 pblk; 204 u32 pblk;
204 int performance_platform_limit; 205 int performance_platform_limit;
@@ -314,6 +315,8 @@ static inline int acpi_processor_get_bios_limit(int cpu, unsigned int *limit)
314 315
315/* in processor_core.c */ 316/* in processor_core.c */
316void acpi_processor_set_pdc(acpi_handle handle); 317void acpi_processor_set_pdc(acpi_handle handle);
318int acpi_get_apicid(acpi_handle, int type, u32 acpi_id);
319int acpi_map_cpuid(int apic_id, u32 acpi_id);
317int acpi_get_cpuid(acpi_handle, int type, u32 acpi_id); 320int acpi_get_cpuid(acpi_handle, int type, u32 acpi_id);
318 321
319/* in processor_throttling.c */ 322/* in processor_throttling.c */
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index a5db4aeefa36..3bc74141453f 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -116,7 +116,7 @@ void acpi_numa_arch_fixup(void);
116 116
117#ifdef CONFIG_ACPI_HOTPLUG_CPU 117#ifdef CONFIG_ACPI_HOTPLUG_CPU
118/* Arch dependent functions for cpu hotplug support */ 118/* Arch dependent functions for cpu hotplug support */
119int acpi_map_lsapic(acpi_handle handle, int *pcpu); 119int acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu);
120int acpi_unmap_lsapic(int cpu); 120int acpi_unmap_lsapic(int cpu);
121#endif /* CONFIG_ACPI_HOTPLUG_CPU */ 121#endif /* CONFIG_ACPI_HOTPLUG_CPU */
122 122