From patchwork Wed Oct 29 18:14:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 5190901 Return-Path: X-Original-To: patchwork-linux-arm-msm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BBF0EC11AC for ; Wed, 29 Oct 2014 18:16:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D651620225 for ; Wed, 29 Oct 2014 18:16:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DCBCE200D4 for ; Wed, 29 Oct 2014 18:16:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755629AbaJ2SQ3 (ORCPT ); Wed, 29 Oct 2014 14:16:29 -0400 Received: from smtp.codeaurora.org ([198.145.11.231]:34168 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755214AbaJ2SOl (ORCPT ); Wed, 29 Oct 2014 14:14:41 -0400 Received: from smtp.codeaurora.org (localhost [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 2CD6014045B; Wed, 29 Oct 2014 18:14:41 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 486) id 1EB0D140460; Wed, 29 Oct 2014 18:14:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from sboyd-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: sboyd@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 7988614045B; Wed, 29 Oct 2014 18:14:40 +0000 (UTC) From: Stephen Boyd To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-serial@vger.kernel.org, Frank Rowand , Daniel Thompson Subject: [PATCH 1/2] tty: serial: msm: Fix sysrq spinlock recursion on non-DM Date: Wed, 29 Oct 2014 11:14:37 -0700 Message-Id: <1414606478-13709-2-git-send-email-sboyd@codeaurora.org> X-Mailer: git-send-email 2.1.0.61.ge50deb1 In-Reply-To: <1414606478-13709-1-git-send-email-sboyd@codeaurora.org> References: <1414606478-13709-1-git-send-email-sboyd@codeaurora.org> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The handle_rx() path calls uart_handle_sysrq_char() with the port lock held. This causes a spinlock recursion. Release and reacquire the lock here to avoid this. BUG: spinlock recursion on CPU#0, swapper/0 lock: msm_uart_ports+0x1e0/0x2d0, .magic: dead4ead, .owner: swapper/0, .owner_cpu: 0 CPU: 0 PID: 0 Comm: swapper Not tainted 3.17.0-rc7-00012-gb38ee8265941 #69 [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [] (show_stack) from [] (do_raw_spin_lock+0x11c/0x13c) [] (do_raw_spin_lock) from [] (msm_console_write+0x78/0x188) [] (msm_console_write) from [] (call_console_drivers.constprop.22+0xb4/0x144) [] (call_console_drivers.constprop.22) from [] (console_unlock+0x27c/0x4ac) [] (console_unlock) from [] (vprintk_emit+0x1f4/0x5a8) [] (vprintk_emit) from [] (printk+0x30/0x40) [] (printk) from [] (__handle_sysrq+0x58/0x1b8) [] (__handle_sysrq) from [] (msm_irq+0x694/0x6f8) [] (msm_irq) from [] (handle_irq_event_percpu+0x58/0x270) [] (handle_irq_event_percpu) from [] (handle_irq_event+0x3c/0x5c) [] (handle_irq_event) from [] (handle_level_irq+0x9c/0x138) [] (handle_level_irq) from [] (generic_handle_irq+0x24/0x38) [] (generic_handle_irq) from [] (handle_IRQ+0x44/0xb0) [] (handle_IRQ) from [] (msm_vic_handle_irq+0x44/0x64) [] (msm_vic_handle_irq) from [] (__irq_svc+0x44/0x7c) Exception stack(0xc0719f68 to 0xc0719fb0) 9f60: 00000001 00000001 00000000 c0722938 c0718000 c0769acc 9f80: 00000000 c0720098 c0769305 4117b362 c0769acc 00000000 01000000 c0719fb0 9fa0: c004cab0 c000f880 20000013 ffffffff [] (__irq_svc) from [] (arch_cpu_idle+0x20/0x30) [] (arch_cpu_idle) from [] (cpu_startup_entry+0xf4/0x23c) [] (cpu_startup_entry) from [] (start_kernel+0x32c/0x394) Cc: Frank Rowand Cc: Daniel Thompson Signed-off-by: Stephen Boyd --- drivers/tty/serial/msm_serial.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c index 4b6c78331a64..cedcc36762a2 100644 --- a/drivers/tty/serial/msm_serial.c +++ b/drivers/tty/serial/msm_serial.c @@ -174,6 +174,7 @@ static void handle_rx(struct uart_port *port) while ((sr = msm_read(port, UART_SR)) & UART_SR_RX_READY) { unsigned int c; char flag = TTY_NORMAL; + int sysrq; c = msm_read(port, UART_RF); @@ -195,7 +196,10 @@ static void handle_rx(struct uart_port *port) else if (sr & UART_SR_PAR_FRAME_ERR) flag = TTY_FRAME; - if (!uart_handle_sysrq_char(port, c)) + spin_unlock(&port->lock); + sysrq = uart_handle_sysrq_char(port, c); + spin_lock(&port->lock); + if (!sysrq) tty_insert_flip_char(tport, c, flag); }