From patchwork Thu Jan 10 11:48:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Pieralisi X-Patchwork-Id: 1959651 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id C6CB2DF264 for ; Thu, 10 Jan 2013 11:52:32 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TtGdm-00080X-E6; Thu, 10 Jan 2013 11:49:46 +0000 Received: from service87.mimecast.com ([91.220.42.44]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TtGdj-00080C-1t for linux-arm-kernel@lists.infradead.org; Thu, 10 Jan 2013 11:49:43 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Thu, 10 Jan 2013 11:49:40 +0000 Received: from e102568-lin.cambridge.arm.com ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 10 Jan 2013 11:49:39 +0000 From: Lorenzo Pieralisi To: linux-arm-kernel@lists.infradead.org, devicetree-discuss@lists.ozlabs.org Subject: [PATCH] ARM: kernel: DT cpu map validity check helper function Date: Thu, 10 Jan 2013 11:48:27 +0000 Message-Id: <1357818507-8716-1-git-send-email-lorenzo.pieralisi@arm.com> X-Mailer: git-send-email 1.7.12 X-OriginalArrivalTime: 10 Jan 2013 11:49:39.0480 (UTC) FILETIME=[923CC980:01CDEF28] X-MC-Unique: 113011011494000201 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130110_064943_419808_19B29F9D X-CRM114-Status: GOOD ( 13.46 ) X-Spam-Score: 0.4 (/) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (0.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [91.220.42.44 listed in list.dnswl.org] 3.0 KHOP_BIG_TO_CC Sent to 10+ recipients instaed of Bcc or a list -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Mark Rutland , Nicolas Pitre , Lorenzo Pieralisi , Russell King , Pawel Moll , Stephen Warren , Tony Lindgren , Magnus Damm , Rob Herring , Grant Likely , Kukjin Kim , David Brown , Hiroshi Doyu X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Since the introduction of /cpu nodes bindings for ARM and the corresponding parse function arm_dt_init_cpu_maps(), the cpu_logical_map and the number of possible CPUs are set according to the DT /cpu nodes entries. Currently most of the existing ARM SMP platforms detect the number of cores through HW probing in their .smp_init_cpus functions and set the possible CPU mask accordingly. This method should be upgraded so that the CPU counting mechanism will be based on DT, keeping legacy HW probing mechanism as a fall back solution. In order to implement this fall back solution mechanism, the ARM DT code should provide a helper function to platforms to check if the cpu map has been properly initialized through DT. If the check fails the platform will resort to legacy HW based cores counting mechanism. This patch implements a trivial flag and a helper function that platform can call to check whether DT based cpu map initialization and cores count were completed successfully. Signed-off-by: Lorenzo Pieralisi --- arch/arm/include/asm/prom.h | 10 ++++++++++ arch/arm/kernel/devtree.c | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/arch/arm/include/asm/prom.h b/arch/arm/include/asm/prom.h index a219227..487614a 100644 --- a/arch/arm/include/asm/prom.h +++ b/arch/arm/include/asm/prom.h @@ -18,6 +18,15 @@ extern struct machine_desc *setup_machine_fdt(unsigned int dt_phys); extern void arm_dt_memblock_reserve(void); extern void __init arm_dt_init_cpu_maps(void); +/* + * Return true if cpu map initialization has been + * carried out correctly from DT + */ +static inline bool __init arm_dt_cpu_map_valid(void) +{ + extern bool valid_dt_cpu_map; + return valid_dt_cpu_map; +} #else /* CONFIG_OF */ @@ -28,6 +37,7 @@ static inline struct machine_desc *setup_machine_fdt(unsigned int dt_phys) static inline void arm_dt_memblock_reserve(void) { } static inline void arm_dt_init_cpu_maps(void) { } +static inline bool __init arm_dt_cpu_map_valid(void) { return false; } #endif /* CONFIG_OF */ #endif /* ASMARM_PROM_H */ diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c index 70f1bde..c82af3b 100644 --- a/arch/arm/kernel/devtree.c +++ b/arch/arm/kernel/devtree.c @@ -62,6 +62,10 @@ void __init arm_dt_memblock_reserve(void) memblock_reserve(base, size); } } +/* + * Export DT cpu map validity flag to platforms + */ +bool valid_dt_cpu_map __initdata; /* * arm_dt_init_cpu_maps - Function retrieves cpu nodes from the device tree @@ -158,6 +162,7 @@ void __init arm_dt_init_cpu_maps(void) * a reg property, the DT CPU list can be considered valid and the * logical map created in smp_setup_processor_id() can be overridden */ + valid_dt_cpu_map = true; for (i = 0; i < cpuidx; i++) { set_cpu_possible(i, true); cpu_logical_map(i) = tmp_map[i];