提交 4cde2252 编写于 作者: J James Morse 提交者: Yang Yingliang

ACPI / processor: Add helper to convert acpi_id to a phys_cpuid

hulk inclusion
category: feature
bugzilla: 28055
CVE: NA

------------------------------

The PPTT parsing code only has access to an acpi_id, we need a hardware
property, preferably the corresponding phys_cpuid_t.

acpi_get_cpuid() requires us to have the acpi_handle, which would imply
we already have the acpi_device or acpi_processor structure. This call
is useful when the CPU may not have been mapped, e.g. when walking the
namespace.

The PPTT is parsed after CPUs have been discovered and mapped, add a
helper to walk the possible CPUs and test whether the acpi_processor
matches our acpi_id.
Signed-off-by: NJames Morse <james.morse@arm.com>
Signed-off-by: NWang ShaoBo <bobo.shaobowang@huawei.com>
Reviewed-By: NXie XiuQi <xiexiuqi@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 6636f443
...@@ -9,7 +9,9 @@ ...@@ -9,7 +9,9 @@
* Yinghai Lu <yinghai@kernel.org> * Yinghai Lu <yinghai@kernel.org>
* Jiang Liu <jiang.liu@intel.com> * Jiang Liu <jiang.liu@intel.com>
*/ */
#include <linux/percpu.h>
#include <linux/export.h> #include <linux/export.h>
#include <linux/cpumask.h>
#include <linux/acpi.h> #include <linux/acpi.h>
#include <acpi/processor.h> #include <acpi/processor.h>
...@@ -263,6 +265,20 @@ int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id) ...@@ -263,6 +265,20 @@ int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id)
} }
EXPORT_SYMBOL_GPL(acpi_get_cpuid); EXPORT_SYMBOL_GPL(acpi_get_cpuid);
phys_cpuid_t acpi_id_to_phys_cpuid(u32 acpi_id)
{
int cpu;
struct acpi_processor *pr;
for_each_possible_cpu(cpu) {
pr = per_cpu(processors, cpu);
if (pr && pr->acpi_id == acpi_id)
return pr->phys_id;
}
return PHYS_CPUID_INVALID;
}
#ifdef CONFIG_ACPI_HOTPLUG_IOAPIC #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
static int get_ioapic_id(struct acpi_subtable_header *entry, u32 gsi_base, static int get_ioapic_id(struct acpi_subtable_header *entry, u32 gsi_base,
u64 *phys_addr, int *ioapic_id) u64 *phys_addr, int *ioapic_id)
......
...@@ -333,6 +333,7 @@ phys_cpuid_t acpi_get_phys_id(acpi_handle, int type, u32 acpi_id); ...@@ -333,6 +333,7 @@ phys_cpuid_t acpi_get_phys_id(acpi_handle, int type, u32 acpi_id);
phys_cpuid_t acpi_map_madt_entry(u32 acpi_id); phys_cpuid_t acpi_map_madt_entry(u32 acpi_id);
int acpi_map_cpuid(phys_cpuid_t phys_id, u32 acpi_id); int acpi_map_cpuid(phys_cpuid_t phys_id, u32 acpi_id);
int acpi_get_cpuid(acpi_handle, int type, u32 acpi_id); int acpi_get_cpuid(acpi_handle, int type, u32 acpi_id);
phys_cpuid_t acpi_id_to_phys_cpuid(u32 acpi_id);
#ifdef CONFIG_ACPI_CPPC_LIB #ifdef CONFIG_ACPI_CPPC_LIB
extern int acpi_cppc_processor_probe(struct acpi_processor *pr); extern int acpi_cppc_processor_probe(struct acpi_processor *pr);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册