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); From patchwork Mon Oct 29 18:07:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 10659973 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 9A8C43CF1 for ; Mon, 29 Oct 2018 18:09:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 855DC29C8C for ; Mon, 29 Oct 2018 18:09:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 77CF929C8E; Mon, 29 Oct 2018 18:09:41 +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 1EE2229C8C for ; Mon, 29 Oct 2018 18:09:41 +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=yzaxM9EJeMuSXius4hwsap4J/6AexqoS04dZaiIx2PM=; b=eBhROJdbkMaYuC t3DbTu1vojAt6DwdCXrmuLIW4D188F2vj/reIMkSU2iLnJv2nfZc8cN40IsOdF5w3qZ45gGDhLaPK s/BzCRXXfHAxid7vWWTWYq9k01vAOXXp8wSGUV2AgM5jPPcirf7k9VbuGDeLtS0Vv7D8HqPwPNT2D Qq3kOOMP8IHrdJ/BKJ/eajQhYpl+XQBUuoQLcMKdS37g86LQsLJbETmGyqJd2YzUDDQj92nEDfqwD k3DVl5iYFxJjyUOK5pIw/20FHJuHSC+YN/UrKXicPupPQeNavCZ3gJLgJ5FeGjx3ftL8QDDWyB/LA 9mw7ToaW2l+TBEBiK/Sw==; 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 1gHByq-0008Qh-Lx; Mon, 29 Oct 2018 18:09:36 +0000 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gHBy0-00081J-U8 for linux-arm-kernel@lists.infradead.org; Mon, 29 Oct 2018 18:08:47 +0000 Received: by mail-pg1-x544.google.com with SMTP id s3-v6so4277261pga.12 for ; Mon, 29 Oct 2018 11:08:34 -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=5KlK5EoYecHiEwx2KYOj1AK3WWuK24K/BTuRZp/Hgn0=; b=ViKF3X5QZz1G04Kuc+UrpCLOIvvtASddvUpgEhbE2NwCsDxuq6JsW/AfF3MtdzfNcH x4aFvJIFkNdrS8l2CQjvpOEnAdP+LsFKZAoe9CdyAH5M9odaITFSuzPbsiwDohBeU3UQ YDDibS0wr7JOOkRxMW/g3gib7jVbkYmN9FZJo= 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=5KlK5EoYecHiEwx2KYOj1AK3WWuK24K/BTuRZp/Hgn0=; b=HzFggfkuhzGFKK2w5t2W8u26I6k/bO1Wdy+vm/pXqB8PvIlpz6fD7eIWmK8AbEhH7z 1UhwJ0QEk8z06Goyh/10a2AGQEf8/Q44JintEy4eeH5vRhIezO1BglLRxb9hFqx48YWh kNFf+uLCKAXuAker9noYK9/wfThalawJvwq2+X351j4RoW1kEuqkAABT83SzgPGXCpIr xz8UoiI18DYfUZTi3lwq4qE1qvB5EtqJr34WxOjqkF1sW3gh6OyQ5N1PqmaZa0ht3oUW 5csjmuNLT/i47BkkIOQz3OLwHmPH10W3VyKYrL0X/lBJASDLzQO9ocWNWMA9CLRL3wrw Z08A== X-Gm-Message-State: AGRZ1gI9MBZzUK0BB8RsDDIGJjO5/463uOnUxPZwIM4biqA+6QCsxWyE wF5Q37H0VwzG/dKWPKVafH5k3Q== X-Google-Smtp-Source: AJdET5dnes+lqSdsKf+M8kej513uIWGXuNg0nbxyLNaYWMhztTpOmHr2lEByvMdxDcC5rsUHz1VWbw== X-Received: by 2002:a62:7a92:: with SMTP id v140-v6mr9434788pfc.46.1540836514355; Mon, 29 Oct 2018 11:08:34 -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.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Oct 2018 11:08:33 -0700 (PDT) From: Douglas Anderson To: Jason Wessel , Daniel Thompson , tglx@linutronix.de, mingo@kernel.org, gregkh@linuxfoundation.org Subject: [PATCH 6/7] smp: Don't yell about IRQs disabled in kgdb_roundup_cpus() Date: Mon, 29 Oct 2018 11:07:06 -0700 Message-Id: <20181029180707.207546-7-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_110844_993606_FCD817C5 X-CRM114-Status: GOOD ( 13.87 ) 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: linux-mips@linux-mips.org, linux-sh@vger.kernel.org, peterz@infradead.org, linux-arm-msm@vger.kernel.org, frederic@kernel.org, riel@surriel.com, Douglas Anderson , linux-kernel@vger.kernel.org, luto@kernel.org, kgdb-bugreport@lists.sourceforge.net, sparclinux@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-snps-arc@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org 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 In kgdb_roundup_cpus() we've got code that looks like: local_irq_enable(); smp_call_function(kgdb_call_nmi_hook, NULL, 0); local_irq_disable(); In certain cases when we drop into kgdb (like with sysrq-g on a serial console) we'll get a big yell that looks like: sysrq: SysRq : DEBUG ------------[ cut here ]------------ DEBUG_LOCKS_WARN_ON(current->hardirq_context) WARNING: CPU: 0 PID: 0 at .../kernel/locking/lockdep.c:2875 lockdep_hardirqs_on+0xf0/0x160 CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.19.0 #27 pstate: 604003c9 (nZCv DAIF +PAN -UAO) pc : lockdep_hardirqs_on+0xf0/0x160 ... Call trace: lockdep_hardirqs_on+0xf0/0x160 trace_hardirqs_on+0x188/0x1ac kgdb_roundup_cpus+0x14/0x3c kgdb_cpu_enter+0x53c/0x5cc kgdb_handle_exception+0x180/0x1d4 kgdb_compiled_brk_fn+0x30/0x3c brk_handler+0x134/0x178 do_debug_exception+0xfc/0x178 el1_dbg+0x18/0x78 kgdb_breakpoint+0x34/0x58 sysrq_handle_dbg+0x54/0x5c __handle_sysrq+0x114/0x21c handle_sysrq+0x30/0x3c qcom_geni_serial_isr+0x2dc/0x30c ... ... irq event stamp: ...45 hardirqs last enabled at (...44): [...] __do_softirq+0xd8/0x4e4 hardirqs last disabled at (...45): [...] el1_irq+0x74/0x130 softirqs last enabled at (...42): [...] _local_bh_enable+0x2c/0x34 softirqs last disabled at (...43): [...] irq_exit+0xa8/0x100 ---[ end trace adf21f830c46e638 ]--- Let's add kgdb to the list of reasons not to warn in smp_call_function_many(). That will allow us (in a future patch) to stop calling local_irq_enable() which will get rid of the original splat. NOTE: with this change comes the obvious question: will we start deadlocking more often now when we drop into the debugger. I can't say that for sure one way or the other, but the fact that we do the same logic for "oops_in_progress" makes me feel like it shouldn't happen too often. Also note that the old logic of turning on interrupts temporarily wasn't exactly safe since (I presume) that could have violated spin_lock_irqsave() semantics and ended up with a deadlock of its own. Signed-off-by: Douglas Anderson --- kernel/smp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/smp.c b/kernel/smp.c index 163c451af42e..bb581e58c8dc 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "smpboot.h" @@ -413,7 +414,8 @@ void smp_call_function_many(const struct cpumask *mask, * can't happen. */ WARN_ON_ONCE(cpu_online(this_cpu) && irqs_disabled() - && !oops_in_progress && !early_boot_irqs_disabled); + && !oops_in_progress && !early_boot_irqs_disabled + && !in_dbg_master()); /* Try to fastpath. So, what's a CPU they want? Ignoring this one. */ cpu = cpumask_first_and(mask, cpu_online_mask); From patchwork Mon Oct 29 18:07:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 10659983 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 DFB6814BD for ; Mon, 29 Oct 2018 18:14:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C5711292FA for ; Mon, 29 Oct 2018 18:14:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B919629665; Mon, 29 Oct 2018 18:14:05 +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 168EE292FA for ; Mon, 29 Oct 2018 18:14:04 +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=7ZNL5I5G6c+mINw9rSH9mp6zDR4g9QE6hnxq7IslodY=; b=QX4Hht/pYGgeqe wgfohpOp9lT2J77sjzFKM8TCL8zSLHvwHKnT0b9q7ui61NuxegOPiM3TI8FmpOkGbqjJvZEMnx4iH e0Bm4SLP0pXmPNQadqRZzI9ZfeVgMl6hloXi3urRK6IbMxx3nmHtaQ9D0CW3bcLKVmB5GrEjdZ8P9 LEAwhqZH242TZZvstmRLv6uR+3hW1dK7TT79Zywv6L1iQd2VtyT227uUyEV9Ryffwje6MJV0pgRrU hcOx9NX47njirvBUhF8MMAhqjtQfMJTydqfETxCD/juPES8TevCLQ44DnMeS4p0xMUGE27bU5yc1W wCvTc9pbpUArPnx7I2Pg==; 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 1gHC32-0002fh-3f; Mon, 29 Oct 2018 18:13:56 +0000 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gHBy0-00081y-UC for linux-arm-kernel@lists.infradead.org; Mon, 29 Oct 2018 18:08:47 +0000 Received: by mail-pg1-x544.google.com with SMTP id n10-v6so4276269pgv.10 for ; Mon, 29 Oct 2018 11:08:37 -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=CroHCjy2cXyW18SnvnT99u56hhAhS32VgKvRG9qriMk=; b=Adw2RJawkgnaC/jpDoSz7kz4ztVYqXNmBSnL2SvigdwN21Qq4qG0Pe+1/1PrUPKs9S bDz7ozuAXF3qkF3GBazKl/rEQgxQHcyekO1KrYK9RL32KkbqUTGP8wOmE1NGu3DekUXx VI2tl0dPwLK1ovDongsGFEfW+cu+jec5xtADY= 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=CroHCjy2cXyW18SnvnT99u56hhAhS32VgKvRG9qriMk=; b=WQUuSMw57e+e+XFpcTJLlQThnCWuUiK5Gv0nxZ2nylV5BIOdO7oV8BUmJmodij4ZPZ oMof2hrTxf5YANdWRbjrT8Bio25NvnQBzgfIf29USjq5IV3MdGEBssKbscDG7sBOEsCL irZPx63sz42Yipd0eE6fsyU367mdbDCxlLosfFyITCoAwpCVGzKMsBSF3G4IjzaZ+IFu 3MA5ErxH9oMyJs5IT4N9sh5yRhSQ6wtYNpLE0tBbZR+p+pJPeZ4t5DMCEWoP2aHmAIYi BjS4XPfXBe821pRZ6oA/F4iO2fu3i/pC436N88F9W3VN+GoEin3+clr/ozp3DKiLmIpJ MFyA== X-Gm-Message-State: AGRZ1gJCHuwiHiGPt9tgDxMe6FNubjiPWviRJ5lohjyV4YI6D0nefcma 09AL1RUgZH+rJpimNhObd/BX+Q== X-Google-Smtp-Source: AJdET5d1BEiS9eVnpREP9GcY6nBDc+TgRpo6cR3NLiALJXXRpfCKZMOIAtRRC3z9kZ0u7UVM6sOi9A== X-Received: by 2002:a62:a50d:: with SMTP id v13-v6mr16095653pfm.18.1540836517190; Mon, 29 Oct 2018 11:08:37 -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.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Oct 2018 11:08:35 -0700 (PDT) From: Douglas Anderson To: Jason Wessel , Daniel Thompson , tglx@linutronix.de, mingo@kernel.org, gregkh@linuxfoundation.org Subject: [PATCH 7/7] kgdb: Remove irq flags and local_irq_enable/disable from roundup Date: Mon, 29 Oct 2018 11:07:07 -0700 Message-Id: <20181029180707.207546-8-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_110845_029896_0F207D6A X-CRM114-Status: GOOD ( 17.96 ) 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: kstewart@linuxfoundation.org, linux-mips@linux-mips.org, dalias@libc.org, catalin.marinas@arm.com, linux-sh@vger.kernel.org, benh@kernel.crashing.org, will.deacon@arm.com, linux-kernel@vger.kernel.org, mhocko@suse.com, paulus@samba.org, hpa@zytor.com, sparclinux@vger.kernel.org, sfr@canb.auug.org.au, ysato@users.sourceforge.jp, mpe@ellerman.id.au, x86@kernel.org, linux@armlinux.org.uk, mingo@redhat.com, kgdb-bugreport@lists.sourceforge.net, jhogan@kernel.org, linux-snps-arc@lists.infradead.org, linux-arm-msm@vger.kernel.org, ying.huang@intel.com, rppt@linux.vnet.ibm.com, bp@alien8.de, linux-arm-kernel@lists.infradead.org, christophe.leroy@c-s.fr, pombredanne@nexb.com, vgupta@synopsys.com, Douglas Anderson , ralf@linux-mips.org, rkuo@codeaurora.org, paul.burton@mips.com, linux-hexagon@vger.kernel.org, akpm@linux-foundation.org, linuxppc-dev@lists.ozlabs.org, davem@davemloft.net 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 The function kgdb_roundup_cpus() was passed a parameter that was documented as: > the flags that will be used when restoring the interrupts. There is > local_irq_save() call before kgdb_roundup_cpus(). Nobody used those flags. Anyone who wanted to temporarily turn on interrupts just did local_irq_enable() and local_irq_disable() without looking at them. So we can definitely remove the flags. Speaking of calling local_irq_enable(), it seems like a bad idea and it caused a nice splat on my system with lockdep turned on. Specifically it hit: DEBUG_LOCKS_WARN_ON(current->hardirq_context) See the previous patch in this series ("smp: Don't yell about IRQs disabled in kgdb_roundup_cpus()") for more details, but the last few things on the stack were this on my arm64 board: lockdep_hardirqs_on+0xf0/0x160 trace_hardirqs_on+0x188/0x1ac kgdb_roundup_cpus+0x14/0x3c As agrued in the the commit text of ("smp: Don't yell about IRQs disabled in kgdb_roundup_cpus()"), it seems better to make smp_call_function() lenient about kgdb than to locally turn on IRQs here. Thus let's totally remove all the local_irq_enable() and local_irq_disable() calls from all of the kgdb_roundup_cpus() calls. Signed-off-by: Douglas Anderson --- arch/arc/kernel/kgdb.c | 4 +--- arch/arm/kernel/kgdb.c | 4 +--- arch/arm64/kernel/kgdb.c | 4 +--- arch/hexagon/kernel/kgdb.c | 11 ++--------- arch/mips/kernel/kgdb.c | 4 +--- arch/powerpc/kernel/kgdb.c | 2 +- arch/sh/kernel/kgdb.c | 4 +--- arch/sparc/kernel/smp_64.c | 2 +- arch/x86/kernel/kgdb.c | 9 ++------- include/linux/kgdb.h | 9 ++------- kernel/debug/debug_core.c | 2 +- 11 files changed, 14 insertions(+), 41 deletions(-) diff --git a/arch/arc/kernel/kgdb.c b/arch/arc/kernel/kgdb.c index 9a3c34af2ae8..d94d3cb7f9e8 100644 --- a/arch/arc/kernel/kgdb.c +++ b/arch/arc/kernel/kgdb.c @@ -197,11 +197,9 @@ static void kgdb_call_nmi_hook(void *ignored) kgdb_nmicallback(raw_smp_processor_id(), NULL); } -void kgdb_roundup_cpus(unsigned long flags) +void kgdb_roundup_cpus(void) { - local_irq_enable(); smp_call_function(kgdb_call_nmi_hook, NULL, 0); - local_irq_disable(); } struct kgdb_arch arch_kgdb_ops = { diff --git a/arch/arm/kernel/kgdb.c b/arch/arm/kernel/kgdb.c index caa0dbe3dc61..a80e9259f7e9 100644 --- a/arch/arm/kernel/kgdb.c +++ b/arch/arm/kernel/kgdb.c @@ -175,11 +175,9 @@ static void kgdb_call_nmi_hook(void *ignored) kgdb_nmicallback(raw_smp_processor_id(), get_irq_regs()); } -void kgdb_roundup_cpus(unsigned long flags) +void kgdb_roundup_cpus(void) { - local_irq_enable(); smp_call_function(kgdb_call_nmi_hook, NULL, 0); - local_irq_disable(); } static int __kgdb_notify(struct die_args *args, unsigned long cmd) diff --git a/arch/arm64/kernel/kgdb.c b/arch/arm64/kernel/kgdb.c index a20de58061a8..5d171c26788f 100644 --- a/arch/arm64/kernel/kgdb.c +++ b/arch/arm64/kernel/kgdb.c @@ -289,11 +289,9 @@ static void kgdb_call_nmi_hook(void *ignored) kgdb_nmicallback(raw_smp_processor_id(), get_irq_regs()); } -void kgdb_roundup_cpus(unsigned long flags) +void kgdb_roundup_cpus(void) { - local_irq_enable(); smp_call_function(kgdb_call_nmi_hook, NULL, 0); - local_irq_disable(); } static int __kgdb_notify(struct die_args *args, unsigned long cmd) diff --git a/arch/hexagon/kernel/kgdb.c b/arch/hexagon/kernel/kgdb.c index 16c24b22d0b2..30fbc491cf45 100644 --- a/arch/hexagon/kernel/kgdb.c +++ b/arch/hexagon/kernel/kgdb.c @@ -119,17 +119,12 @@ void kgdb_arch_set_pc(struct pt_regs *regs, unsigned long pc) /** * kgdb_roundup_cpus - Get other CPUs into a holding pattern - * @flags: Current IRQ state * * On SMP systems, we need to get the attention of the other CPUs * and get them be in a known state. This should do what is needed * to get the other CPUs to call kgdb_wait(). Note that on some arches, * the NMI approach is not used for rounding up all the CPUs. For example, - * in case of MIPS, smp_call_function() is used to roundup CPUs. In - * this case, we have to make sure that interrupts are enabled before - * calling smp_call_function(). The argument to this function is - * the flags that will be used when restoring the interrupts. There is - * local_irq_save() call before kgdb_roundup_cpus(). + * in case of MIPS, smp_call_function() is used to roundup CPUs. * * On non-SMP systems, this is not called. */ @@ -139,11 +134,9 @@ static void hexagon_kgdb_nmi_hook(void *ignored) kgdb_nmicallback(raw_smp_processor_id(), get_irq_regs()); } -void kgdb_roundup_cpus(unsigned long flags) +void kgdb_roundup_cpus(void) { - local_irq_enable(); smp_call_function(hexagon_kgdb_nmi_hook, NULL, 0); - local_irq_disable(); } #endif diff --git a/arch/mips/kernel/kgdb.c b/arch/mips/kernel/kgdb.c index eb6c0d582626..6671a279966f 100644 --- a/arch/mips/kernel/kgdb.c +++ b/arch/mips/kernel/kgdb.c @@ -219,11 +219,9 @@ static void kgdb_call_nmi_hook(void *ignored) set_fs(old_fs); } -void kgdb_roundup_cpus(unsigned long flags) +void kgdb_roundup_cpus(void) { - local_irq_enable(); smp_call_function(kgdb_call_nmi_hook, NULL, 0); - local_irq_disable(); } static int compute_signal(int tt) diff --git a/arch/powerpc/kernel/kgdb.c b/arch/powerpc/kernel/kgdb.c index 59c578f865aa..b0e804844be0 100644 --- a/arch/powerpc/kernel/kgdb.c +++ b/arch/powerpc/kernel/kgdb.c @@ -124,7 +124,7 @@ static int kgdb_call_nmi_hook(struct pt_regs *regs) } #ifdef CONFIG_SMP -void kgdb_roundup_cpus(unsigned long flags) +void kgdb_roundup_cpus(void) { smp_send_debugger_break(); } diff --git a/arch/sh/kernel/kgdb.c b/arch/sh/kernel/kgdb.c index 4f04c6638a4d..86b3ea927e42 100644 --- a/arch/sh/kernel/kgdb.c +++ b/arch/sh/kernel/kgdb.c @@ -319,11 +319,9 @@ static void kgdb_call_nmi_hook(void *ignored) kgdb_nmicallback(raw_smp_processor_id(), get_irq_regs()); } -void kgdb_roundup_cpus(unsigned long flags) +void kgdb_roundup_cpus(void) { - local_irq_enable(); smp_call_function(kgdb_call_nmi_hook, NULL, 0); - local_irq_disable(); } static int __kgdb_notify(struct die_args *args, unsigned long cmd) diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c index 4792e08ad36b..f45d876983f1 100644 --- a/arch/sparc/kernel/smp_64.c +++ b/arch/sparc/kernel/smp_64.c @@ -1014,7 +1014,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page) } #ifdef CONFIG_KGDB -void kgdb_roundup_cpus(unsigned long flags) +void kgdb_roundup_cpus(void) { smp_cross_call(&xcall_kgdb_capture, 0, 0, 0); } diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c index 8e36f249646e..ac6291a4178d 100644 --- a/arch/x86/kernel/kgdb.c +++ b/arch/x86/kernel/kgdb.c @@ -422,21 +422,16 @@ static void kgdb_disable_hw_debug(struct pt_regs *regs) #ifdef CONFIG_SMP /** * kgdb_roundup_cpus - Get other CPUs into a holding pattern - * @flags: Current IRQ state * * On SMP systems, we need to get the attention of the other CPUs * and get them be in a known state. This should do what is needed * to get the other CPUs to call kgdb_wait(). Note that on some arches, * the NMI approach is not used for rounding up all the CPUs. For example, - * in case of MIPS, smp_call_function() is used to roundup CPUs. In - * this case, we have to make sure that interrupts are enabled before - * calling smp_call_function(). The argument to this function is - * the flags that will be used when restoring the interrupts. There is - * local_irq_save() call before kgdb_roundup_cpus(). + * in case of MIPS, smp_call_function() is used to roundup CPUs. * * On non-SMP systems, this is not called. */ -void kgdb_roundup_cpus(unsigned long flags) +void kgdb_roundup_cpus(void) { apic->send_IPI_allbutself(APIC_DM_NMI); } diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h index e465bb15912d..05e5b2eb0d32 100644 --- a/include/linux/kgdb.h +++ b/include/linux/kgdb.h @@ -178,21 +178,16 @@ kgdb_arch_handle_exception(int vector, int signo, int err_code, /** * kgdb_roundup_cpus - Get other CPUs into a holding pattern - * @flags: Current IRQ state * * On SMP systems, we need to get the attention of the other CPUs * and get them into a known state. This should do what is needed * to get the other CPUs to call kgdb_wait(). Note that on some arches, * the NMI approach is not used for rounding up all the CPUs. For example, - * in case of MIPS, smp_call_function() is used to roundup CPUs. In - * this case, we have to make sure that interrupts are enabled before - * calling smp_call_function(). The argument to this function is - * the flags that will be used when restoring the interrupts. There is - * local_irq_save() call before kgdb_roundup_cpus(). + * in case of MIPS, smp_call_function() is used to roundup CPUs. * * On non-SMP systems, this is not called. */ -extern void kgdb_roundup_cpus(unsigned long flags); +extern void kgdb_roundup_cpus(void); /** * kgdb_arch_set_pc - Generic call back to the program counter diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c index 65c0f1363788..f3cadda45f07 100644 --- a/kernel/debug/debug_core.c +++ b/kernel/debug/debug_core.c @@ -593,7 +593,7 @@ static int kgdb_cpu_enter(struct kgdb_state *ks, struct pt_regs *regs, /* Signal the other CPUs to enter kgdb_wait() */ else if ((!kgdb_single_step) && kgdb_do_roundup) - kgdb_roundup_cpus(flags); + kgdb_roundup_cpus(); #endif /*