From patchwork Mon Oct 29 18:07:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 10659969 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EADE317DF for ; Mon, 29 Oct 2018 18:09:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D806C29C8A for ; Mon, 29 Oct 2018 18:09:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CBF6729C8D; Mon, 29 Oct 2018 18:09:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4B1CF29C8A for ; Mon, 29 Oct 2018 18:09:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WP1qDWqEBu7Gvzrnz+jEMdNhfBPvZTnDOgKH4X74HXI=; b=mkg/uVxWulbGY9 uPFs5QBNks3sfGWkRKIgLFOcrgPDMpVvcLERX3LWgRz/gcIBTMeTwAeCYchSyVZn5nwti7O8+jbp8 NrL1ZWtSSSmDcnoKcgIcyHtVN4hdWyKNTnala8Q5SaXbxod3wZRNL1wa11Rz7VzP69Ne1uDyNV07d DNe/9YFl1ESC1aRZNIcz80v7UjORsVtClO1a+5NFpKl/amNLCGMZiARmDVuVBIfAln7MBlvnX2I2r ICOfl0tclLQCMEWhI2HektRnXuLgazBtMNcm1WgK/flPb1GMFhU8ANchZlbU6/8McPx4qfiwRShL5 4qohqPW8MsPZ+73qkGug==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gHBy4-00085L-B7; Mon, 29 Oct 2018 18:08:48 +0000 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gHBxy-0007zn-QF for linux-arm-kernel@lists.infradead.org; Mon, 29 Oct 2018 18:08:45 +0000 Received: by mail-pf1-x441.google.com with SMTP id f26-v6so4419713pfn.9 for ; Mon, 29 Oct 2018 11:08:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CSaQp289WlwooI6biqRK70zJEg/8W1x/ZX+9kCIc7Ts=; b=mxvoiQpswweCkHANP3Cexu88qUDHEHcm1IUx/gx6U9O+2agCOQbySNl981YrQPO/NE ZINFMOGENJEp2Aht7gk4zKayGjMO6w8n2HAseulpfg1OphhcjUqBwzvJ/cbdumj+QMlg uZMhsBdcbNKonkRq7C2sIofM1Jw1d0iaZAIQs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CSaQp289WlwooI6biqRK70zJEg/8W1x/ZX+9kCIc7Ts=; b=BbMCxGwNsao58JB+EAJVI9Gy0yT+lQOQ3gpdRzXfry0pd4eXNPenwtgBMwgaYrzDkY tUHydVKXzWEU8RGP7JGc7WR+NLqTMZzd7TVKQ/ESPi65WRAFhpWsbTDZlTjqXXQ/42HT xiDwPPuYkPkOoEO0JMf0DgObLo/kBBxHfL6oQ9GjzzyMe/6TnjSmmOKIM5O5xXDOLF/y 1/4jqwMncufeKwfy8eLY1n2s3joyo36kmSHDW57tMMqvJCJU3WdK97wiOJZ1YnUtQd77 LJrYZIa4EHf7l6fYql7oHIaagqnzc/RLBbOjVmUgv8bjdrWk+VnZk33OYpGfdSw+hsso yiKA== X-Gm-Message-State: AGRZ1gJbThF8qLVBDr9FW82Ti3Jc6OXwLYY20yjt6Rn+yORnczO0gvki D/msv/nW6nVBBEknceslicTbyw== X-Google-Smtp-Source: AJdET5d/8hGlxDxAlpCXY3ZegXVIPGXLSUdUXAvdHRmyPp8wrYLT7hr04+3LnVhCwvDG/Kn1hLlsVw== X-Received: by 2002:a62:425b:: with SMTP id p88-v6mr16258227pfa.96.1540836512254; Mon, 29 Oct 2018 11:08:32 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:c8e0:70d7:4be7:a36]) by smtp.gmail.com with ESMTPSA id u13-v6sm20537765pgp.18.2018.10.29.11.08.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Oct 2018 11:08:31 -0700 (PDT) From: Douglas Anderson To: Jason Wessel , Daniel Thompson , tglx@linutronix.de, mingo@kernel.org, gregkh@linuxfoundation.org Subject: [PATCH 5/7] serial: 8250: Process sysrq at port unlock time Date: Mon, 29 Oct 2018 11:07:05 -0700 Message-Id: <20181029180707.207546-6-dianders@chromium.org> X-Mailer: git-send-email 2.19.1.568.g152ad8e336-goog In-Reply-To: <20181029180707.207546-1-dianders@chromium.org> References: <20181029180707.207546-1-dianders@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181029_110842_875750_634245F5 X-CRM114-Status: GOOD ( 13.00 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nm@ti.com, marex@denx.de, linux-arm-kernel@lists.infradead.org, vigneshr@ti.com, linux-aspeed@lists.ozlabs.org, andrew@aj.id.au, linux-arm-msm@vger.kernel.org, rolf.evers.fischer@aptiv.com, Douglas Anderson , linux-kernel@vger.kernel.org, tony@atomide.com, Jisheng.Zhang@synaptics.com, jk@ozlabs.org, linux-serial@vger.kernel.org, kgdb-bugreport@lists.sourceforge.net, jslaby@suse.com, asierra@xes-inc.com, andriy.shevchenko@linux.intel.com, dan.carpenter@oracle.com, joel@jms.id.au Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Let's take advantage of the new ("serial: core: Allow processing sysrq at port unlock time") to handle sysrqs more cleanly. Signed-off-by: Douglas Anderson --- I don't have a great way to test all 8250 variants, but I've at least tested rk3288 / rk3399 and they seem to work. Hopefully I got the aspeed_vuart / fsl / omap variants right (I only compile tested those). drivers/tty/serial/8250/8250_aspeed_vuart.c | 6 +++++- drivers/tty/serial/8250/8250_fsl.c | 6 +++++- drivers/tty/serial/8250/8250_omap.c | 6 +++++- drivers/tty/serial/8250/8250_port.c | 8 +++----- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/tty/serial/8250/8250_aspeed_vuart.c b/drivers/tty/serial/8250/8250_aspeed_vuart.c index 435bec40dee6..0438d9a905ce 100644 --- a/drivers/tty/serial/8250/8250_aspeed_vuart.c +++ b/drivers/tty/serial/8250/8250_aspeed_vuart.c @@ -5,6 +5,10 @@ * Copyright (C) 2016 Jeremy Kerr , IBM Corp. * Copyright (C) 2006 Arnd Bergmann , IBM Corp. */ +#if defined(CONFIG_SERIAL_8250_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) +#define SUPPORT_SYSRQ +#endif + #include #include #include @@ -293,7 +297,7 @@ static int aspeed_vuart_handle_irq(struct uart_port *port) if (lsr & UART_LSR_THRE) serial8250_tx_chars(up); - spin_unlock_irqrestore(&port->lock, flags); + uart_unlock_and_check_sysrq(port, flags); return 1; } diff --git a/drivers/tty/serial/8250/8250_fsl.c b/drivers/tty/serial/8250/8250_fsl.c index 6640a4c7ddd1..ff3dcaea5d93 100644 --- a/drivers/tty/serial/8250/8250_fsl.c +++ b/drivers/tty/serial/8250/8250_fsl.c @@ -1,4 +1,8 @@ // SPDX-License-Identifier: GPL-2.0 +#if defined(CONFIG_SERIAL_8250_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) +#define SUPPORT_SYSRQ +#endif + #include #include @@ -54,7 +58,7 @@ int fsl8250_handle_irq(struct uart_port *port) serial8250_tx_chars(up); up->lsr_saved_flags = orig_lsr; - spin_unlock_irqrestore(&up->port.lock, flags); + uart_unlock_and_check_sysrq(&up->port, flags); return 1; } EXPORT_SYMBOL_GPL(fsl8250_handle_irq); diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c index a019286f8bb6..ad7ba7d0f28d 100644 --- a/drivers/tty/serial/8250/8250_omap.c +++ b/drivers/tty/serial/8250/8250_omap.c @@ -8,6 +8,10 @@ * */ +#if defined(CONFIG_SERIAL_8250_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) +#define SUPPORT_SYSRQ +#endif + #include #include #include @@ -1085,7 +1089,7 @@ static int omap_8250_dma_handle_irq(struct uart_port *port) } } - spin_unlock_irqrestore(&port->lock, flags); + uart_unlock_and_check_sysrq(port, flags); serial8250_rpm_put(up); return 1; } diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c index f776b3eafb96..c39482b96111 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -1755,7 +1755,7 @@ void serial8250_read_char(struct uart_8250_port *up, unsigned char lsr) else if (lsr & UART_LSR_FE) flag = TTY_FRAME; } - if (uart_handle_sysrq_char(port, ch)) + if (uart_prepare_sysrq_char(port, ch)) return; uart_insert_char(port, lsr, UART_LSR_OE, ch, flag); @@ -1897,7 +1897,7 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir) if ((!up->dma || up->dma->tx_err) && (status & UART_LSR_THRE)) serial8250_tx_chars(up); - spin_unlock_irqrestore(&port->lock, flags); + uart_unlock_and_check_sysrq(port, flags); return 1; } EXPORT_SYMBOL_GPL(serial8250_handle_irq); @@ -3258,9 +3258,7 @@ void serial8250_console_write(struct uart_8250_port *up, const char *s, serial8250_rpm_get(up); - if (port->sysrq) - locked = 0; - else if (oops_in_progress) + if (oops_in_progress) locked = spin_trylock_irqsave(&port->lock, flags); else spin_lock_irqsave(&port->lock, flags);