From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932235AbbBBPhX (ORCPT ); Mon, 2 Feb 2015 10:37:23 -0500 Received: from foss-mx-na.foss.arm.com ([217.140.108.86]:40610 "EHLO foss-mx-na.foss.arm.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1753610AbbBBPhV (ORCPT ); Mon, 2 Feb 2015 10:37:21 -0500 Date: Mon, 2 Feb 2015 15:36:49 +0000 From: Mark Rutland To: "mathieu.poirier@linaro.org" Cc: Catalin Marinas , Will Deacon , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" Subject: Re: [PATCH 1/2] arm64: adding cpu lookup functionality Message-ID: <20150202153649.GC21175@leverpostej> References: <1422658466-23984-1-git-send-email-mathieu.poirier@linaro.org> <1422658466-23984-2-git-send-email-mathieu.poirier@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1422658466-23984-2-git-send-email-mathieu.poirier@linaro.org> Thread-Topic: [PATCH 1/2] arm64: adding cpu lookup functionality Accept-Language: en-GB, en-US Content-Language: en-US User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 30, 2015 at 10:54:25PM +0000, mathieu.poirier@linaro.org wrote: > From: Mathieu Poirier > > 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 > --- > 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 > #include > > 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; > +} Are there some pending updates for of_coresight.c that aren't in mainline yet? It looks like even with this the parsing would be broken if /cpus/#address-cells is greater than 1 (as with juno.dts), and it'll just assume CPU0 in that case. It would be nicer if we instead had a CPU node to logical ID mapping function in the core OF code. We already have the inverse with of_get_cpu_node, so I assume the necessary infrastructure is already there. Mark.