aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiang Liu <jiang.liu@huawei.com>2013-09-01 23:57:35 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-09-23 19:39:39 -0400
commitd536bf3dc97417471e2c5098837a1cddd7fbb3c7 (patch)
tree215b3309564b76adb0b9dc92b51de9730bd73526
parentca9f62ac783bf88c54143f8065adc0fc8df859c1 (diff)
ACPI / processor: use apic_id and remove duplicated _MAT evaluation
Since APIC id is saved in processor struct, just use it and remove the duplicated _MAT evaluation. Signed-off-by: Jiang Liu <jiang.liu@huawei.com> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--arch/ia64/kernel/acpi.c38
-rw-r--r--arch/x86/kernel/acpi/boot.c38
-rw-r--r--drivers/acpi/acpi_processor.c2
-rw-r--r--include/linux/acpi.h2
4 files changed, 9 insertions, 71 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/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 40c76604199f..f6dbb2f5e39f 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -614,44 +614,12 @@ static void acpi_map_cpu2node(acpi_handle handle, int cpu, int physid)
614#endif 614#endif
615} 615}
616 616
617static int _acpi_map_lsapic(acpi_handle handle, int *pcpu) 617static int _acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)
618{ 618{
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; 619 cpumask_var_t tmp_map, new_map;
623 u8 physid;
624 int cpu; 620 int cpu;
625 int retval = -ENOMEM; 621 int retval = -ENOMEM;
626 622
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
640 lapic = (struct acpi_madt_local_apic *)obj->buffer.pointer;
641
642 if (lapic->header.type != ACPI_MADT_TYPE_LOCAL_APIC ||
643 !(lapic->lapic_flags & ACPI_MADT_ENABLED)) {
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)) 623 if (!alloc_cpumask_var(&tmp_map, GFP_KERNEL))
656 goto out; 624 goto out;
657 625
@@ -689,9 +657,9 @@ out:
689} 657}
690 658
691/* wrapper to silence section mismatch warning */ 659/* wrapper to silence section mismatch warning */
692int __ref acpi_map_lsapic(acpi_handle handle, int *pcpu) 660int __ref acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)
693{ 661{
694 return _acpi_map_lsapic(handle, pcpu); 662 return _acpi_map_lsapic(handle, physid, pcpu);
695} 663}
696EXPORT_SYMBOL(acpi_map_lsapic); 664EXPORT_SYMBOL(acpi_map_lsapic);
697 665
diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index f89f914cb97e..66c9b702894b 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -181,7 +181,7 @@ static int acpi_processor_hotadd_init(struct acpi_processor *pr)
181 cpu_maps_update_begin(); 181 cpu_maps_update_begin();
182 cpu_hotplug_begin(); 182 cpu_hotplug_begin();
183 183
184 ret = acpi_map_lsapic(pr->handle, &pr->id); 184 ret = acpi_map_lsapic(pr->handle, pr->apic_id, &pr->id);
185 if (ret) 185 if (ret)
186 goto out; 186 goto out;
187 187
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