From patchwork Mon Jan 14 07:52:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hiroshi Doyu X-Patchwork-Id: 211722 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id D704D2C00E8 for ; Mon, 14 Jan 2013 18:53:12 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755726Ab3ANHxM (ORCPT ); Mon, 14 Jan 2013 02:53:12 -0500 Received: from hqemgate03.nvidia.com ([216.228.121.140]:1425 "EHLO hqemgate03.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755704Ab3ANHxL (ORCPT ); Mon, 14 Jan 2013 02:53:11 -0500 Received: from hqnvupgp07.nvidia.com (Not Verified[216.228.121.13]) by hqemgate03.nvidia.com id ; Sun, 13 Jan 2013 23:57:06 -0800 Received: from hqemhub02.nvidia.com ([172.17.108.22]) by hqnvupgp07.nvidia.com (PGP Universal service); Sun, 13 Jan 2013 23:52:56 -0800 X-PGP-Universal: processed; by hqnvupgp07.nvidia.com on Sun, 13 Jan 2013 23:52:56 -0800 Received: from hqnvemgw01.nvidia.com (172.20.150.20) by hqemhub02.nvidia.com (172.20.150.31) with Microsoft SMTP Server id 8.3.279.1; Sun, 13 Jan 2013 23:53:00 -0800 Received: from daphne.nvidia.com (Not Verified[172.16.212.96]) by hqnvemgw01.nvidia.com with MailMarshal (v6,7,2,8378) id ; Sun, 13 Jan 2013 23:53:49 -0800 Received: from oreo.Nvidia.com (dhcp-10-21-25-186.nvidia.com [10.21.25.186]) by daphne.nvidia.com (8.13.8+Sun/8.8.8) with ESMTP id r0E7qvKp022996; Sun, 13 Jan 2013 23:52:57 -0800 (PST) From: Hiroshi Doyu To: , , CC: , Subject: [PATCH 1/2] ARM: kernel: DT cpu map validity check helper function Date: Mon, 14 Jan 2013 09:52:49 +0200 Message-ID: <1358149970-28156-1-git-send-email-hdoyu@nvidia.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org From: Lorenzo Pieralisi 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 helper function that platforms 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 | 6 ++++++ 2 files changed, 16 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..4d8d1ec 100644 --- a/arch/arm/kernel/devtree.c +++ b/arch/arm/kernel/devtree.c @@ -64,6 +64,11 @@ void __init arm_dt_memblock_reserve(void) } /* + * 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 * and builds the cpu logical map array containing MPIDR values related to * logical cpus @@ -158,6 +163,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];