From patchwork Fri Feb 13 12:48:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Fuzzey X-Patchwork-Id: 5825011 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D9F1A9F39D for ; Fri, 13 Feb 2015 12:51:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 05BD920256 for ; Fri, 13 Feb 2015 12:51:26 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DE02920148 for ; Fri, 13 Feb 2015 12:51:24 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YMFgL-0005ZJ-I2; Fri, 13 Feb 2015 12:49:17 +0000 Received: from ip83.parkeon.com ([213.152.31.83] helo=mta2.parkeon.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YMFgH-0005Vo-Nq for linux-arm-kernel@lists.infradead.org; Fri, 13 Feb 2015 12:49:14 +0000 Received: from time001.besancon.parkeon.com ([10.32.16.23] helo=mail.besancon.parkeon.com) by mta2.parkeon.com with esmtp (Exim 4.82) (envelope-from ) id 1YMFfs-0004W4-0I for linux-arm-kernel@lists.infradead.org; Fri, 13 Feb 2015 13:48:48 +0100 Received: from [10.32.51.181] (port=60522 helo=[127.0.0.1]) by mail.besancon.parkeon.com with esmtp (Exim 4.71) (envelope-from ) id 1YMFft-0008Vy-UO for linux-arm-kernel@lists.infradead.org; Fri, 13 Feb 2015 13:48:49 +0100 Subject: [RFC PATCH] ARM: LL_DEBUG: Fix hang on i.MX53 when wrong port selected. To: linux-arm-kernel@lists.infradead.org From: Martin Fuzzey Date: Fri, 13 Feb 2015 13:48:49 +0100 Message-ID: <20150213124849.22919.14204.stgit@localhost> User-Agent: StGit/0.16 MIME-Version: 1.0 X-Spam-Score: -2.0 (--) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150213_044913_962401_9B4863AF X-CRM114-Status: UNSURE ( 8.38 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.0 (/) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Attempts to access the i.MX53 UART data registers while the UART is not enabled cause the processor to hang. This can occur when CONFIG_LL_DEBUG is selected but CONFIG_DEBUG_IMX_UART_PORT does not correspond to the port enabled by the bootloader. So, do not attempt to send any data if the port is not enabled. Checking the enabled bit requires an extra scratch register. For the moment I have only added this to the imx version. Obviously, if this solution is acceptable, the register would have to be added to all the other implementations too in order to avoid breaking the build. Hence RFC status for the moment to see if there are any better ideas. Signed-off-by: Martin Fuzzey --- arch/arm/boot/compressed/debug.S | 2 +- arch/arm/boot/compressed/head.S | 16 ++++++++-------- arch/arm/include/debug/imx.S | 10 ++++++++-- arch/arm/kernel/debug.S | 2 +- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/arch/arm/boot/compressed/debug.S b/arch/arm/boot/compressed/debug.S index 5392ee6..1f83297 100644 --- a/arch/arm/boot/compressed/debug.S +++ b/arch/arm/boot/compressed/debug.S @@ -8,7 +8,7 @@ ENTRY(putc) addruart r1, r2, r3 waituart r3, r1 - senduart r0, r1 + senduart r0, r1, r3 busyuart r3, r1 mov pc, lr ENDPROC(putc) diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S index 132c70e..0a02301 100644 --- a/arch/arm/boot/compressed/head.S +++ b/arch/arm/boot/compressed/head.S @@ -26,19 +26,19 @@ #if defined(CONFIG_CPU_V6) || defined(CONFIG_CPU_V6K) || defined(CONFIG_CPU_V7) .macro loadsp, rb, tmp .endm - .macro writeb, ch, rb + .macro writeb, ch, rb, tmp mcr p14, 0, \ch, c0, c5, 0 .endm #elif defined(CONFIG_CPU_XSCALE) .macro loadsp, rb, tmp .endm - .macro writeb, ch, rb + .macro writeb, ch, rb, tmp mcr p14, 0, \ch, c8, c0, 0 .endm #else .macro loadsp, rb, tmp .endm - .macro writeb, ch, rb + .macro writeb, ch, rb, tmp mcr p14, 0, \ch, c1, c0, 0 .endm #endif @@ -47,8 +47,8 @@ #include CONFIG_DEBUG_LL_INCLUDE - .macro writeb, ch, rb - senduart \ch, \rb + .macro writeb, ch, rb, tmp + senduart \ch, \rb, \tmp .endm #if defined(CONFIG_ARCH_SA1100) @@ -870,7 +870,7 @@ proc_types: W(b) __armv3_mpu_cache_on W(b) __armv3_mpu_cache_off W(b) __armv3_mpu_cache_flush - + .word 0x41009400 @ ARM94x .word 0xff00ff00 W(b) __armv4_mpu_cache_on @@ -1084,7 +1084,7 @@ __armv4_mpu_cache_flush: mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache mcr p15, 0, ip, c7, c10, 4 @ drain WB mov pc, lr - + __fa526_cache_flush: tst r4, #1 movne pc, lr @@ -1246,7 +1246,7 @@ puts: loadsp r3, r1 1: ldrb r2, [r0], #1 teq r2, #0 moveq pc, lr -2: writeb r2, r3 +2: writeb r2, r3, r1 mov r1, #0x00020000 3: subs r1, r1, #1 bne 3b diff --git a/arch/arm/include/debug/imx.S b/arch/arm/include/debug/imx.S index 619d8cc..a04821c 100644 --- a/arch/arm/include/debug/imx.S +++ b/arch/arm/include/debug/imx.S @@ -33,8 +33,14 @@ ldr \rv, =UART_VADDR @ virtual .endm - .macro senduart,rd,rx - str \rd, [\rx, #0x40] @ TXDATA + .macro senduart,rd,rx, tmp +/* + * Data registers only accessible if uart enabled. + * Check to prevent hangs if bootloader config does not match + */ + ldr \tmp, [\rx, #0x80] @ CR1 + tst \tmp, #1 + strne \rd, [\rx, #0x40] @ TXDATA .endm .macro waituart,rd,rx diff --git a/arch/arm/kernel/debug.S b/arch/arm/kernel/debug.S index 78c91b5..5a360ab 100644 --- a/arch/arm/kernel/debug.S +++ b/arch/arm/kernel/debug.S @@ -81,7 +81,7 @@ ENTRY(printascii) addruart_current r3, r1, r2 b 2f 1: waituart r2, r3 - senduart r1, r3 + senduart r1, r3, r2 busyuart r2, r3 teq r1, #'\n' moveq r1, #'\r'