From patchwork Wed Jun 5 01:58:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 2664221 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork2.kernel.org (Postfix) with ESMTP id 065D2DF2A1 for ; Wed, 5 Jun 2013 02:00:08 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Uk318-00057E-P0; Wed, 05 Jun 2013 02:00:03 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Uk316-0003Cs-5G; Wed, 05 Jun 2013 02:00:00 +0000 Received: from mail-vb0-x249.google.com ([2607:f8b0:400c:c02::249]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Uk313-0003CL-4t for linux-arm-kernel@lists.infradead.org; Wed, 05 Jun 2013 01:59:58 +0000 Received: by mail-vb0-f73.google.com with SMTP id p14so101946vbm.4 for ; Tue, 04 Jun 2013 18:59:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=4Xgg9sr4jepFY/EmrDD1oU6TlIdMkHxvGy9sfoLtQ38=; b=F9Ld/O3u6bc/1i8qc3RD/Rmbaku4hDwabisENEIUT3w5QGDickI6E8RviNRvoUIjvV u/V38fMRK0VUz152V7CkoHq6zm7Z2dX2icYfFPn9GjYyUndLrWcyizsRQxUsXjAl/S4q fCP0JxMwEhrDtUBOUDf53mNnRfHaSOG74MksIH3gCfS6dBvZ4Fb7VFBzgKDunfxbTCxc QoLQRB7MRPPwibXbt5MnDhHb1kQniIUsMv494qxzNIGQaCTyM8KDOF7qWFKogmDSr92I UrNU64MzqJXop1pzNcka/wxuQSpvXA2f+bABrwCEu+BHKK1ao8QCVIdiAFWqyV0RxvJo xKrA== X-Received: by 10.236.134.14 with SMTP id r14mr15830642yhi.39.1370397572179; Tue, 04 Jun 2013 18:59:32 -0700 (PDT) Received: from corp2gmr1-2.hot.corp.google.com (corp2gmr1-2.hot.corp.google.com [172.24.189.93]) by gmr-mx.google.com with ESMTPS id o42si6533246yhe.5.2013.06.04.18.59.32 for (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Tue, 04 Jun 2013 18:59:32 -0700 (PDT) Received: from tictac.mtv.corp.google.com (tictac.mtv.corp.google.com [172.22.162.34]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id 081B75A41AE; Tue, 4 Jun 2013 18:59:32 -0700 (PDT) Received: by tictac.mtv.corp.google.com (Postfix, from userid 121310) id A4FD180DED; Tue, 4 Jun 2013 18:59:31 -0700 (PDT) From: Doug Anderson To: Kukjin Kim , Olof Johansson Subject: [PATCH] ARM: samsung: avoid racy early printk at bootup Date: Tue, 4 Jun 2013 18:58:59 -0700 Message-Id: <1370397539-21653-1-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 1.8.3 X-Gm-Message-State: ALoCoQn8TRpHnESafgrBreWJVauwpJX4jW2d0ttZfAJocw4wBgwbaBUaQO0LMGJB/jwetboTyd8kEtD9V+GCCjnJBsYVi3Z1TPG826pK5Ci+uARmfDejVjF61ftjmfU8Fytwc8fuIuWCn/UzW44UoRwc9SRill9xFjr2csWWFHNG92xee6MsmJTiwfVGrxRonQRaedasybm/fH9/mx/ldztjHb3+YNp10Q== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130604_215957_270737_08870C35 X-CRM114-Status: GOOD ( 13.92 ) X-Spam-Score: -2.4 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.5 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: linux-samsung-soc@vger.kernel.org, Russell King , linux-kernel@vger.kernel.org, Simon Glass , Tomasz Figa , Doug Anderson , Thomas Abraham , Ben Dooks , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org At boot, we've got a stack trace that looks something like this (exynos5 as example) * exynos5_map_io * s3c_init_cpu * exynos_init_io * exynos5_dt_map_io * paging_init * setup_arch When paging_init() runs we'll lose any early MMU mappings that we might have had to allow us access to S3C_VA_UART. We won't add those mappings back in until after the SoC-specific map_io() function is called. However, we print the CPU ID _right before_ we call the SoC-specific function. Oops. Things happen to work all right most of the time because the mapping is sticking around in our TLB. ...but if we get really unlucky (like me!) or we put an explicit flush_tlb_all() at the start of exynos_init_io(), then things go boom. This patch moves the problematic printk() till after the cpu->map_io() call. It also switches it over to pr_info(). This patch _doesn't_ remove the questionable printks in the panic case, since we might get lucky and the TLB might still let us print. This patch also adds a few warnings to help others avoid similar headaches. Signed-off-by: Doug Anderson --- arch/arm/mach-exynos/common.c | 7 +++++++ arch/arm/plat-samsung/init.c | 8 +++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-exynos/common.c b/arch/arm/mach-exynos/common.c index 027c9e7..8b51b0d 100644 --- a/arch/arm/mach-exynos/common.c +++ b/arch/arm/mach-exynos/common.c @@ -386,6 +386,13 @@ int __init exynos_fdt_map_chipid(unsigned long node, const char *uname, void __init exynos_init_io(struct map_desc *mach_desc, int size) { + /* + * WARNING: use of printk in this function or its children can be + * deadly. We've switched over to new page tables but haven't yet + * added S3C_VA_UART into the mapping. You might get lucky and see a + * printout work, but if you call flush_tlb_all() it will fail reliably. + */ + #ifdef CONFIG_OF if (initial_boot_params) of_scan_flat_dt(exynos_fdt_map_chipid, NULL); diff --git a/arch/arm/plat-samsung/init.c b/arch/arm/plat-samsung/init.c index 79d10fc..494cfbb 100644 --- a/arch/arm/plat-samsung/init.c +++ b/arch/arm/plat-samsung/init.c @@ -49,18 +49,20 @@ void __init s3c_init_cpu(unsigned long idcode, cpu = s3c_lookup_cpu(idcode, cputab, cputab_size); if (cpu == NULL) { + /* Questionable printk; S3C_VA_UART not mapped yet! */ printk(KERN_ERR "Unknown CPU type 0x%08lx\n", idcode); panic("Unknown S3C24XX CPU"); } - - printk("CPU %s (id 0x%08lx)\n", cpu->name, idcode); - if (cpu->map_io == NULL || cpu->init == NULL) { + /* Questionable printk; S3C_VA_UART not mapped yet! */ printk(KERN_ERR "CPU %s support not enabled\n", cpu->name); panic("Unsupported Samsung CPU"); } cpu->map_io(); + + /* IMPORTANT: call this after cpu->map_io() so we can print reliably */ + pr_info("CPU %s (id 0x%08lx)\n", cpu->name, idcode); } /* s3c24xx_init_clocks