diff mbox

[1/2] arm64: adding cpu lookup functionality

Message ID 1422658466-23984-2-git-send-email-mathieu.poirier@linaro.org
State New
Headers show

Commit Message

Mathieu Poirier Jan. 30, 2015, 10:54 p.m. UTC
From: Mathieu Poirier <mathieu.poirier@linaro.org>

Adding a lookup function allowing for quick and easy mapping
between processor HWID (as found, for example) in DT specifications
and the CPU index known to the kernel.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
 arch/arm64/include/asm/smp_plat.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Mathieu Poirier Feb. 2, 2015, 9:20 p.m. UTC | #1
On 2 February 2015 at 06:50, Will Deacon <will.deacon@arm.com> wrote:
> On Fri, Jan 30, 2015 at 10:54:25PM +0000, mathieu.poirier@linaro.org wrote:
>> From: Mathieu Poirier <mathieu.poirier@linaro.org>
>>
>> Adding a lookup function allowing for quick and easy mapping
>> between processor HWID (as found, for example) in DT specifications
>> and the CPU index known to the kernel.
>>
>> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
>> ---
>>  arch/arm64/include/asm/smp_plat.h | 12 ++++++++++++
>>  1 file changed, 12 insertions(+)
>>
>> diff --git a/arch/arm64/include/asm/smp_plat.h b/arch/arm64/include/asm/smp_plat.h
>> index 59e282311b58..8e4b011303b1 100644
>> --- a/arch/arm64/include/asm/smp_plat.h
>> +++ b/arch/arm64/include/asm/smp_plat.h
>> @@ -19,6 +19,7 @@
>>  #ifndef __ASM_SMP_PLAT_H
>>  #define __ASM_SMP_PLAT_H
>>
>> +#include <linux/cpumask.h>
>>  #include <asm/types.h>
>>
>>  struct mpidr_hash {
>> @@ -40,4 +41,15 @@ static inline u32 mpidr_hash_size(void)
>>  extern u64 __cpu_logical_map[NR_CPUS];
>>  #define cpu_logical_map(cpu)    __cpu_logical_map[cpu]
>>
>> +static inline int get_logical_index(u64 mpidr)
>> +{
>> +     int cpu;
>> +
>> +     for (cpu = 0; cpu < nr_cpu_ids; cpu++)
>> +             if (cpu_logical_map(cpu) == mpidr)
>> +                     return cpu;
>> +     return -EINVAL;
>> +}
>
> Can you not achieve the same thing using arch_find_n_match_cpu_physical_id
> in the coresight code?
>
> Will

I ended up using "of_get_cpu_node()", which uses
"arch_find_n_match_cpu_physical_id()".  Thanks for pointing this out.

Mathieu
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
diff mbox

Patch

diff --git a/arch/arm64/include/asm/smp_plat.h b/arch/arm64/include/asm/smp_plat.h
index 59e282311b58..8e4b011303b1 100644
--- a/arch/arm64/include/asm/smp_plat.h
+++ b/arch/arm64/include/asm/smp_plat.h
@@ -19,6 +19,7 @@ 
 #ifndef __ASM_SMP_PLAT_H
 #define __ASM_SMP_PLAT_H
 
+#include <linux/cpumask.h>
 #include <asm/types.h>
 
 struct mpidr_hash {
@@ -40,4 +41,15 @@  static inline u32 mpidr_hash_size(void)
 extern u64 __cpu_logical_map[NR_CPUS];
 #define cpu_logical_map(cpu)    __cpu_logical_map[cpu]
 
+static inline int get_logical_index(u64 mpidr)
+{
+	int cpu;
+
+	for (cpu = 0; cpu < nr_cpu_ids; cpu++)
+		if (cpu_logical_map(cpu) == mpidr)
+			return cpu;
+	return -EINVAL;
+}
+
+
 #endif /* __ASM_SMP_PLAT_H */