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: Dave Martin X-Patchwork-Id: 3470 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 59A6D23F6B for ; Tue, 16 Aug 2011 14:19:14 +0000 (UTC) Received: from mail-ew0-f52.google.com (mail-ew0-f52.google.com [209.85.215.52]) by fiordland.canonical.com (Postfix) with ESMTP id 41F12A18007 for ; Tue, 16 Aug 2011 14:19:14 +0000 (UTC) Received: by ewy28 with SMTP id 28so3121266ewy.11 for ; Tue, 16 Aug 2011 07:19:14 -0700 (PDT) Received: by 10.213.29.147 with SMTP id q19mr837618ebc.132.1313504353804; Tue, 16 Aug 2011 07:19:13 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.213.102.5 with SMTP id e5cs155499ebo; Tue, 16 Aug 2011 07:19:13 -0700 (PDT) Received: from mr.google.com ([10.216.233.7]) by 10.216.233.7 with SMTP id o7mr6634689weq.7.1313504353644 (num_hops = 1); Tue, 16 Aug 2011 07:19:13 -0700 (PDT) Received: by 10.216.233.7 with SMTP id o7mr4666463weq.7.1313504353305; Tue, 16 Aug 2011 07:19:13 -0700 (PDT) Received: from mail-wy0-f178.google.com (mail-wy0-f178.google.com [74.125.82.178]) by mx.google.com with ESMTPS id l59si239322wed.113.2011.08.16.07.19.11 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 16 Aug 2011 07:19:12 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.178 is neither permitted nor denied by best guess record for domain of dave.martin@linaro.org) client-ip=74.125.82.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.178 is neither permitted nor denied by best guess record for domain of dave.martin@linaro.org) smtp.mail=dave.martin@linaro.org Received: by wyg19 with SMTP id 19so128345wyg.37 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 Cc: patches@linaro.org, Nicolas Pitre , Jon Medhurst 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 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;