From patchwork Tue Aug 16 14:19:00 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot for Dave Martin X-Patchwork-Id: 1071792 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p7GEJSGl015652 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 16 Aug 2011 14:19:49 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QtKU8-0004V8-Kv; Tue, 16 Aug 2011 14:19:16 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QtKU8-0005LU-5T; Tue, 16 Aug 2011 14:19:16 +0000 Received: from mail-wy0-f177.google.com ([74.125.82.177]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QtKU5-0005LC-AJ for linux-arm-kernel@lists.infradead.org; Tue, 16 Aug 2011 14:19:13 +0000 Received: by wyh11 with SMTP id 11so131381wyh.36 for ; Tue, 16 Aug 2011 07:19:11 -0700 (PDT) Received: by 10.227.160.140 with SMTP id n12mr126147wbx.69.1313504351505; Tue, 16 Aug 2011 07:19:11 -0700 (PDT) Received: from e200948.peterhouse.linaro.org (fw-lnat.cambridge.arm.com [217.140.96.63]) by mx.google.com with ESMTPS id 8sm65077wbx.51.2011.08.16.07.19.09 (version=SSLv3 cipher=OTHER); Tue, 16 Aug 2011 07:19:10 -0700 (PDT) From: Dave Martin To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] ARM: Add safe diagnostic to indicate when __cpu_architecture isn't set up Date: Tue, 16 Aug 2011 15:19:00 +0100 Message-Id: <1313504340-28004-1-git-send-email-dave.martin@linaro.org> X-Mailer: git-send-email 1.7.4.1 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110816_101913_497183_A87488C4 X-CRM114-Status: GOOD ( 15.27 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.177 listed in list.dnswl.org] Cc: Nicolas Pitre , Jon Medhurst , patches@linaro.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 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 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 16 Aug 2011 14:19:49 +0000 (UTC) Although assing BUG() when __cpu_architecture is unexpectedly CPU_ARCH_UNKNOWN seems like a good idea, in practice the kernel may not be able to boot far enough even to write to the console in such cases, even with earlyprintk enabled. This patch adds a more useful diagnostic, and works out the cpu architecture from scratch in such cases, instead of just returning CPU_ARCH_UNKNOWN to the caller. This patch is useful for debugging, but I'm not convinced it should be merged. Signed-off-by: Dave Martin --- arch/arm/include/asm/system.h | 9 +++++++-- arch/arm/kernel/setup.c | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h index b0445f7..d679d2f 100644 --- a/arch/arm/include/asm/system.h +++ b/arch/arm/include/asm/system.h @@ -110,8 +110,13 @@ extern int __cpu_architecture; static inline int __pure cpu_architecture(void) { - BUG_ON(__cpu_architecture == CPU_ARCH_UNKNOWN); - return __cpu_architecture; + if (unlikely(__cpu_architecture == CPU_ARCH_UNKNOWN)) { + extern int __pure __get_cpu_architecture(void); + + WARN_ONCE(1, "__cpu_architecture not set yet!\n"); + return __get_cpu_architecture(); + } else + return __cpu_architecture; } extern void cpu_init(void); diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index 1e0c1b3..188aae5 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -212,7 +212,7 @@ static const char *proc_arch[] = { "?(17)", }; -static int __init __get_cpu_architecture(void) +int __get_cpu_architecture(void) { int cpu_arch;