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>
This commit is contained in:
Родитель
ca9f62ac78
Коммит
d536bf3dc9
|
@ -882,40 +882,10 @@ __init void prefill_possible_map(void)
|
|||
set_cpu_possible(i, true);
|
||||
}
|
||||
|
||||
static int _acpi_map_lsapic(acpi_handle handle, int *pcpu)
|
||||
static int _acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)
|
||||
{
|
||||
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
|
||||
union acpi_object *obj;
|
||||
struct acpi_madt_local_sapic *lsapic;
|
||||
cpumask_t tmp_map;
|
||||
int cpu, physid;
|
||||
|
||||
if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))
|
||||
return -EINVAL;
|
||||
|
||||
if (!buffer.length || !buffer.pointer)
|
||||
return -EINVAL;
|
||||
|
||||
obj = buffer.pointer;
|
||||
if (obj->type != ACPI_TYPE_BUFFER)
|
||||
{
|
||||
kfree(buffer.pointer);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
lsapic = (struct acpi_madt_local_sapic *)obj->buffer.pointer;
|
||||
|
||||
if ((lsapic->header.type != ACPI_MADT_TYPE_LOCAL_SAPIC) ||
|
||||
(!(lsapic->lapic_flags & ACPI_MADT_ENABLED))) {
|
||||
kfree(buffer.pointer);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
physid = ((lsapic->id << 8) | (lsapic->eid));
|
||||
|
||||
kfree(buffer.pointer);
|
||||
buffer.length = ACPI_ALLOCATE_BUFFER;
|
||||
buffer.pointer = NULL;
|
||||
int cpu;
|
||||
|
||||
cpumask_complement(&tmp_map, cpu_present_mask);
|
||||
cpu = cpumask_first(&tmp_map);
|
||||
|
@ -934,9 +904,9 @@ static int _acpi_map_lsapic(acpi_handle handle, int *pcpu)
|
|||
}
|
||||
|
||||
/* wrapper to silence section mismatch warning */
|
||||
int __ref acpi_map_lsapic(acpi_handle handle, int *pcpu)
|
||||
int __ref acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)
|
||||
{
|
||||
return _acpi_map_lsapic(handle, pcpu);
|
||||
return _acpi_map_lsapic(handle, physid, pcpu);
|
||||
}
|
||||
EXPORT_SYMBOL(acpi_map_lsapic);
|
||||
|
||||
|
|
|
@ -614,44 +614,12 @@ static void acpi_map_cpu2node(acpi_handle handle, int cpu, int physid)
|
|||
#endif
|
||||
}
|
||||
|
||||
static int _acpi_map_lsapic(acpi_handle handle, int *pcpu)
|
||||
static int _acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)
|
||||
{
|
||||
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
|
||||
union acpi_object *obj;
|
||||
struct acpi_madt_local_apic *lapic;
|
||||
cpumask_var_t tmp_map, new_map;
|
||||
u8 physid;
|
||||
int cpu;
|
||||
int retval = -ENOMEM;
|
||||
|
||||
if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))
|
||||
return -EINVAL;
|
||||
|
||||
if (!buffer.length || !buffer.pointer)
|
||||
return -EINVAL;
|
||||
|
||||
obj = buffer.pointer;
|
||||
if (obj->type != ACPI_TYPE_BUFFER ||
|
||||
obj->buffer.length < sizeof(*lapic)) {
|
||||
kfree(buffer.pointer);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
lapic = (struct acpi_madt_local_apic *)obj->buffer.pointer;
|
||||
|
||||
if (lapic->header.type != ACPI_MADT_TYPE_LOCAL_APIC ||
|
||||
!(lapic->lapic_flags & ACPI_MADT_ENABLED)) {
|
||||
kfree(buffer.pointer);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
physid = lapic->id;
|
||||
|
||||
kfree(buffer.pointer);
|
||||
buffer.length = ACPI_ALLOCATE_BUFFER;
|
||||
buffer.pointer = NULL;
|
||||
lapic = NULL;
|
||||
|
||||
if (!alloc_cpumask_var(&tmp_map, GFP_KERNEL))
|
||||
goto out;
|
||||
|
||||
|
@ -689,9 +657,9 @@ out:
|
|||
}
|
||||
|
||||
/* wrapper to silence section mismatch warning */
|
||||
int __ref acpi_map_lsapic(acpi_handle handle, int *pcpu)
|
||||
int __ref acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)
|
||||
{
|
||||
return _acpi_map_lsapic(handle, pcpu);
|
||||
return _acpi_map_lsapic(handle, physid, pcpu);
|
||||
}
|
||||
EXPORT_SYMBOL(acpi_map_lsapic);
|
||||
|
||||
|
|
|
@ -181,7 +181,7 @@ static int acpi_processor_hotadd_init(struct acpi_processor *pr)
|
|||
cpu_maps_update_begin();
|
||||
cpu_hotplug_begin();
|
||||
|
||||
ret = acpi_map_lsapic(pr->handle, &pr->id);
|
||||
ret = acpi_map_lsapic(pr->handle, pr->apic_id, &pr->id);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ void acpi_numa_arch_fixup(void);
|
|||
|
||||
#ifdef CONFIG_ACPI_HOTPLUG_CPU
|
||||
/* Arch dependent functions for cpu hotplug support */
|
||||
int acpi_map_lsapic(acpi_handle handle, int *pcpu);
|
||||
int acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu);
|
||||
int acpi_unmap_lsapic(int cpu);
|
||||
#endif /* CONFIG_ACPI_HOTPLUG_CPU */
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче