From patchwork Mon Jun 22 14:26:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 191334 Delivered-To: patch@linaro.org Received: by 2002:a92:1f07:0:0:0:0:0 with SMTP id i7csp1092760ile; Mon, 22 Jun 2020 07:27:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6wFBUyEDHcJL34BHpdy2f+u4RV5OPdIb0BeaW5j0XhzRN502/Q6sgnuVFnSqAeoebxPme X-Received: by 2002:a17:906:88d:: with SMTP id n13mr2639552eje.349.1592836063374; Mon, 22 Jun 2020 07:27:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592836063; cv=none; d=google.com; s=arc-20160816; b=B3eTt4dKCVhjWekQyyLjiDL/ZbSY3w6VmACVszIb1oFar4S1UFx9nyu2g2kLlD6LXD xXYtIz3Gjbpsa0gHayNVyv5go30DhO4YUkjS0trR62w2RC5O/AUpascp0L8pWnQ3Vpun omFv7h/XAn/OuewJCs1/BCuVYo0eK6GbnDinoHpSlY+g1eEo2Mk14xkWSq5vmginB71p DOOICouAb1OkVq+aU95NMM+u7hSrp0U7NhjmG9gsu4jp8jCjx9fSjUPJ2HFBilV0/XRD by55vbgle0/+c2mjxmdAem5QkmVariLsFfcQeFrqNmp4sQ+rhomc4nCVHuR4MDLirG9w BVsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=8IF9E1gKHyjaeJfo2rxkpn7RVtFle/sJ4XKWmX86Q3Q=; b=JYGVVSdQasLJVCcxfHqw/4FiOUt7awgnMiRLWfE6j4IEKCWKmrWsfCAwuQDXPc6g5d fiyP57F60NoAhqZ/C2d/sz6CkueIK61zkSvJ6NrYBfPueVU9WcrKyYNSv3J78f6o9/Q5 x01tdUQLd+6Q7rj3HxbhF7FkE56H2tFitni66dMBbwnR9S3sksq5x6pDp0gWCtsHMne/ ZUC6h9v10wd3APrRtQU6HuBz3KP7vtkpLPaxtGAyKtuCCxV3ltCT1Cm8GZ6w3ABc5uKf eVlcErrcyz6yTIdW4VX7XZnIIpsZR6nCZ7cGw7P5y2pgZLCE1ACxWfyn1X40hwunJqTj YlLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vnopgcIu; spf=pass (google.com: domain of linux-serial-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w26si9077893edq.285.2020.06.22.07.27.43; Mon, 22 Jun 2020 07:27:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-serial-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vnopgcIu; spf=pass (google.com: domain of linux-serial-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729761AbgFVO13 (ORCPT + 1 other); Mon, 22 Jun 2020 10:27:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729759AbgFVO1Z (ORCPT ); Mon, 22 Jun 2020 10:27:25 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26BC8C061573 for ; Mon, 22 Jun 2020 07:27:25 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id j1so8501452pfe.4 for ; Mon, 22 Jun 2020 07:27:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8IF9E1gKHyjaeJfo2rxkpn7RVtFle/sJ4XKWmX86Q3Q=; b=vnopgcIuuGUomYyixYh3vmsH/ZEfcTlDpC9WbItwt2rL5Q/fAjVXnBvbwwOoml4Xop A4WCt4YiyvLALgP7spO6E9WpjRI5FqApFXfKm/XTeM4GWsztkl57XMdB59ib9gjLR7zk akE2I/kgqYJMQGP/cAXVUxx+4PC8BFLzoLMLkQIel8iaYCBE1KVlxO0ohMYj+qR5KTbP yhbnqOiI0guRk7dVDMuLikFBsjozadCgYhD4WJLJCy6/RaZjdIMFrniappbpl3733COV /XvsPO/au4Ik/ONpHzsmRCiDPYfMGMVlJL7MFHhfFFf4iSSPJwedCqKzyzuVDR8ocHV8 Dovw== 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; bh=8IF9E1gKHyjaeJfo2rxkpn7RVtFle/sJ4XKWmX86Q3Q=; b=lj7sdY6IY3N8q+7So7qiXHblZ897K1aarSrM7J1hngTp/7YxWhzzConOks/s5zDJGn g3W55WO2LpIpnfLrBiuNS4u5tBltOtS8Djov5blF+XW7lU7rKNTf9HPjBRlWEtn8cWm/ Gp8kZxxWgqvVXN7HEwcaW3HPu0XNi2lUvvbNeQCfUvcMaNELzk2I8nwn8c98cA9ma8Kn 05YxoCCr928Fe5GVwzKH5E4VLCYWBWGPoBvFA8s+5016YQ+pgAMKAG9tUUB3GcA2OBBb tk5hxncBK94wFLEohkVkt11YF4732L5B+ETpEOWGsMp7bGpWbAMub3lXycGV49MZt2PP oFMQ== X-Gm-Message-State: AOAM532vm5ph4sv6SG1MN7jr7t2dKuRodXzvwrT+yehu+pGOMvPClRYF RaNvreKjOrLTd3MkE88zfJBfPQ== X-Received: by 2002:aa7:9818:: with SMTP id e24mr21368063pfl.30.1592836044694; Mon, 22 Jun 2020 07:27:24 -0700 (PDT) Received: from localhost.localdomain ([117.252.67.186]) by smtp.gmail.com with ESMTPSA id d6sm14547939pjh.5.2020.06.22.07.27.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Jun 2020 07:27:23 -0700 (PDT) From: Sumit Garg To: kgdb-bugreport@lists.sourceforge.net, linux-serial@vger.kernel.org Cc: gregkh@linuxfoundation.org, daniel.thompson@linaro.org, jason.wessel@windriver.com, dianders@chromium.org, jslaby@suse.com, linux@armlinux.org.uk, linux-kernel@vger.kernel.org, Sumit Garg Subject: [PATCH 1/7] serial: kgdb_nmi: Allow NMI console to replace kgdb IO console Date: Mon, 22 Jun 2020 19:56:18 +0530 Message-Id: <1592835984-28613-2-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1592835984-28613-1-git-send-email-sumit.garg@linaro.org> References: <1592835984-28613-1-git-send-email-sumit.garg@linaro.org> Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Traditionally, kgdb NMI console relied on cmdline option "console=" to enable/disable consoles. But it didn't took into account DT/ACPI modes which can also provide default preferred console that can be enabled prior to kgdb NMI console. And if that default preferred console is used for debug IO operations as well then it will lead to duplicate consoles representing same physical serial device which in turn leads to duplicate printk messages. In order to avoid this duplication, we need to disable/unregister debug IO console in case the NMI console is enabled successfully. Also, we wouldn't like to see beginning boot messages twice, so we need to remove flag: CON_PRINTBUFFER prior to NMI console registration. Signed-off-by: Sumit Garg --- drivers/tty/serial/kgdb_nmi.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) -- 2.7.4 diff --git a/drivers/tty/serial/kgdb_nmi.c b/drivers/tty/serial/kgdb_nmi.c index 6004c0c..b32c6b1 100644 --- a/drivers/tty/serial/kgdb_nmi.c +++ b/drivers/tty/serial/kgdb_nmi.c @@ -40,6 +40,7 @@ module_param_named(magic, kgdb_nmi_magic, charp, 0600); MODULE_PARM_DESC(magic, "magic sequence to enter NMI debugger (default $3#33)"); static atomic_t kgdb_nmi_num_readers = ATOMIC_INIT(0); +static struct console *orig_dbg_cons; static int kgdb_nmi_console_setup(struct console *co, char *options) { @@ -352,8 +353,22 @@ int kgdb_register_nmi_console(void) goto err_drv_reg; } + /* + * If we already have an active debug IO console, and are switching + * to a NMI console, don't print everything out again, since debug IO + * console, and the NMI console are the same physical device, it's + * annoying to see the beginning boot messages twice. + */ + if (dbg_io_ops->cons && (dbg_io_ops->cons->flags & CON_ENABLED)) { + orig_dbg_cons = dbg_io_ops->cons; + kgdb_nmi_console.flags &= ~CON_PRINTBUFFER; + } + register_console(&kgdb_nmi_console); + if (orig_dbg_cons && (kgdb_nmi_console.flags & CON_ENABLED)) + unregister_console(orig_dbg_cons); + return 0; err_drv_reg: put_tty_driver(kgdb_nmi_tty_driver); @@ -373,6 +388,9 @@ int kgdb_unregister_nmi_console(void) if (ret) return ret; + if (orig_dbg_cons) + register_console(orig_dbg_cons); + ret = tty_unregister_driver(kgdb_nmi_tty_driver); if (ret) return ret; From patchwork Mon Jun 22 14:26:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 191332 Delivered-To: patch@linaro.org Received: by 2002:a92:1f07:0:0:0:0:0 with SMTP id i7csp1092585ile; Mon, 22 Jun 2020 07:27:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzimbhscLq8DLjUYmzKqObm8z4dAAw5m3/yUZjaYWbiAnBPp4/XEWavIVbNsT1EahlY/H03 X-Received: by 2002:a17:906:ce28:: with SMTP id sd8mr15658451ejb.280.1592836053598; Mon, 22 Jun 2020 07:27:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592836053; cv=none; d=google.com; s=arc-20160816; b=YCgTGxc/fbkiUMvXaYRwfnlib4YunUz+IuO/MkxLWVXvpyXRadbY1qH0fL6/WoNZl6 9wDa2Wz3g/wjWnxxDV51iGgmeXgpIXgXyQl04WiBZnxRKW1xO5Bn3oAfcIP8P7oTeFrx P9QgnsENqc442ag74YVP9nPXT04OUCQe+HATt1f09A4PGIXYDj3SXvXVzWvCujr3ODC8 Am46raPURfVLh62poz0ye5vu8RUiIOX7MJNHHYz7hYw0Ednfc7pNnShdDLp7l/g+kQ0d dmgo2nCHJkOPgV97GRaKO8xmU8wsBmSoVAHFXva/zKNwn9YKQX/f17cRBSgWBml7sXQy qcww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=vwFsGBHaAVO/O+/Qurpo2lVEh+kEhysHr8M/+K/fxoc=; b=kJ5NCk8aQlatu8w1GF0blPA/WSjjiZkF4Dzf/HKeG4qx6YLmOjdTpkoUoay8FRx6IG OYEhWWbdoK/8xJKU5sJFm9fn2mJ5HdFc4qHklA0qydFs2wKfKAgbhKnqp6EDGKLIYotk wZO1sWSbKj0CEliQlv7LVRSQ3cnnhYgv4MaH/W5PL/cnR0wvEM2l1gUubRvoUowN6RH+ oZjc3gKBbkmrFk4wc6kbLR52MLmSLOGQ1Cz1bLAumn7p4T9n1096xHz1mw8NhF4UCOJ9 oo2LO0V2a5u6B+mG6MOxvb5Lm5/7f59LUBGsSwEQ8mffPBAmf0eWiNaMaj3nCmZoVsXE ZlGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A0H4lXeS; spf=pass (google.com: domain of linux-serial-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w26si9077893edq.285.2020.06.22.07.27.33; Mon, 22 Jun 2020 07:27:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-serial-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A0H4lXeS; spf=pass (google.com: domain of linux-serial-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729753AbgFVO1b (ORCPT + 1 other); Mon, 22 Jun 2020 10:27:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729771AbgFVO1a (ORCPT ); Mon, 22 Jun 2020 10:27:30 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7177DC061795 for ; Mon, 22 Jun 2020 07:27:30 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id z63so8501224pfb.1 for ; Mon, 22 Jun 2020 07:27:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vwFsGBHaAVO/O+/Qurpo2lVEh+kEhysHr8M/+K/fxoc=; b=A0H4lXeSqd1TcxTG4LkROpY5Ka7b89dAFnokSllDR68dqft5Eb3Sn+vycp/qtrhYPY Zg19eLNhtlN0dlmyu1JXx/lZTscE50s/df/wBFUmF5h0/CYagKoI7JXYmu8c/LiH9aWW c51dblKL90Tzo4xj50Bfq6fyy9fWKaJKxiwUejKcV6chfaeKNl6slT2CtykiK81hqv4d 2yLtdAYPMo8a6blB1QahexeTWQd6h0+I/PgnWrAhNe34KueKPg9k3NcquzAXJeYN77gJ MO2fh80EBgSVbP51lQ9PRKP9SD5h4V1Varsf+rDfhLRjJwdFtwfECRh2Xk9zwBi2IGHW azbQ== 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; bh=vwFsGBHaAVO/O+/Qurpo2lVEh+kEhysHr8M/+K/fxoc=; b=hHhxLWS9UIKUJGFUmwHfSXNM2zNtqY8gbuo5x5idWlBAyrBocQ0qP2fWX/uP47YsJM vAU32z9G720fHSR0Toae6u2/HnHQaRkvpfm6Du8j39KKG+KzOMJWFKovyqU+J8tsmWJK 52dY7zAmimslazOmPsTI593/Ndvhe1wN0ARlQXwXIX6T4G8taCDstoFUjICTpc5UpmAo 0lZGFOUu4HYA5ylbB7NLZOf7vUVKmOOkWFOiC93guZFD4MGhNjRmZth/Fj9HUPfKb3dE W7R9511pB5r7NBBflxyQftSInzOt6v23z36K8d3dsqwXPfZoXBuurmj9EQGg7a9DDPPl Gz3w== X-Gm-Message-State: AOAM533OjEroOMWiiwENmNRSA/KM9bOnA+IqFRV8Ejqf011wIluggdgX xzqPI8dhvQdumL8YVNkzV5/e0A== X-Received: by 2002:a63:d318:: with SMTP id b24mr12063898pgg.403.1592836050027; Mon, 22 Jun 2020 07:27:30 -0700 (PDT) Received: from localhost.localdomain ([117.252.67.186]) by smtp.gmail.com with ESMTPSA id d6sm14547939pjh.5.2020.06.22.07.27.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Jun 2020 07:27:29 -0700 (PDT) From: Sumit Garg To: kgdb-bugreport@lists.sourceforge.net, linux-serial@vger.kernel.org Cc: gregkh@linuxfoundation.org, daniel.thompson@linaro.org, jason.wessel@windriver.com, dianders@chromium.org, jslaby@suse.com, linux@armlinux.org.uk, linux-kernel@vger.kernel.org, Sumit Garg Subject: [PATCH 2/7] tty: serial: Add poll_get_irq() to the polling interface Date: Mon, 22 Jun 2020 19:56:19 +0530 Message-Id: <1592835984-28613-3-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1592835984-28613-1-git-send-email-sumit.garg@linaro.org> References: <1592835984-28613-1-git-send-email-sumit.garg@linaro.org> Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org From: Daniel Thompson Add new API: poll_get_irq() to the polling interface in order for user of polling interface to retrieve allocated IRQ corresponding to underlying serial device. Although, serial interface still works in polling mode but interrupt associated with serial device can be leveraged for special purposes like debugger(kgdb) entry. Signed-off-by: Daniel Thompson Signed-off-by: Sumit Garg --- drivers/tty/serial/serial_core.c | 18 ++++++++++++++++++ include/linux/serial_core.h | 1 + include/linux/tty_driver.h | 1 + 3 files changed, 20 insertions(+) -- 2.7.4 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 66a5e2f..1bb033c 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -2470,6 +2470,23 @@ static void uart_poll_put_char(struct tty_driver *driver, int line, char ch) port->ops->poll_put_char(port, ch); uart_port_deref(port); } + +static int uart_poll_get_irq(struct tty_driver *driver, int line) +{ + struct uart_driver *drv = driver->driver_state; + struct uart_state *state = drv->state + line; + struct uart_port *port; + int ret = -ENODEV; + + port = uart_port_ref(state); + if (port && port->ops->poll_get_irq) { + ret = port->ops->poll_get_irq(port); + uart_port_deref(port); + } + + return ret; +} + #endif static const struct tty_operations uart_ops = { @@ -2505,6 +2522,7 @@ static const struct tty_operations uart_ops = { .poll_init = uart_poll_init, .poll_get_char = uart_poll_get_char, .poll_put_char = uart_poll_put_char, + .poll_get_irq = uart_poll_get_irq, #endif }; diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index 92f5eba..8b132e6 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -78,6 +78,7 @@ struct uart_ops { int (*poll_init)(struct uart_port *); void (*poll_put_char)(struct uart_port *, unsigned char); int (*poll_get_char)(struct uart_port *); + int (*poll_get_irq)(struct uart_port *); #endif }; diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h index 3584462..d6da5c5 100644 --- a/include/linux/tty_driver.h +++ b/include/linux/tty_driver.h @@ -295,6 +295,7 @@ struct tty_operations { int (*poll_init)(struct tty_driver *driver, int line, char *options); int (*poll_get_char)(struct tty_driver *driver, int line); void (*poll_put_char)(struct tty_driver *driver, int line, char ch); + int (*poll_get_irq)(struct tty_driver *driver, int line); #endif int (*proc_show)(struct seq_file *, void *); } __randomize_layout; From patchwork Mon Jun 22 14:26:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 191333 Delivered-To: patch@linaro.org Received: by 2002:a92:1f07:0:0:0:0:0 with SMTP id i7csp1092728ile; Mon, 22 Jun 2020 07:27:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPvU8sAF+qtcfWM5Y+H8d1e5kbs+R2vqy7WpZg0dq2pSlouSsFTslYCzSYqwzcgyviqTv+ X-Received: by 2002:a17:906:1499:: with SMTP id x25mr202359ejc.406.1592836061527; Mon, 22 Jun 2020 07:27:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592836061; cv=none; d=google.com; s=arc-20160816; b=h/F5zPYqBzrb4OoPAOejetf6QRnQ0/pZxEeMsIiqUaqgnFfr8UbAOjs9RQuAkzTr0p cbu2L0YDkEl4Vwo+TtJdhKrjbva4RmoouUYteaQwise4EiNsFDXJl3vKz6ftftrwHZq2 vsc6Yq2wUGzuaWNc7dGOUf632fo3wbajkTy4HGnVHJXhTGv0gAIRUI/3xbr8OXMSWFiK vt9zvonu2L7PzJm062Qn+yj1xx80i7I9OhNpr2sIZv/8cJlE3WPwUnplbKbyeYWHMb5n QYsqPMshmE3oE7Y+liQATZ6SHggAa8cRf3xCws+MooP8i0gb4BXZDDJZ3LSjGoHnK2li s+UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=SpQVzSBjDEPebQy5qXPK/BkcdPQ45hc1OKMcPgP/hpg=; b=kdGslPP4Zod3oMQyGZ2F5e4EGXUgCsPj245/fkA0qMWKCxUNBUeb1saj6F3HFTOQtG Ro0ngNiYCqCzsm8ucI3S2x/fksdjlyDL5K25cOWmXhbV5XwQypKyQ4VVFp93nWnrOZzB z/rgYczekEz6n7/E14+TnL+ama46nAoX3ck6Gd8hUYdf4sewgu/gzcKY3ZXvJ4/Hg2Xz bFN5hmOQ2hGRSPKAHyi36Vlx40VjqYDStPU7/GCMUuclvXa4QExkzjkpgJnDblzyPZ7B iwXFwDFdG80nM+d8Rs1i4ugyGtc3Ec4j5szC1kEjIThDT7yhlQoas6wMeDNlz6El/KC4 UewA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hI2iPwM6; spf=pass (google.com: domain of linux-serial-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w26si9077893edq.285.2020.06.22.07.27.41; Mon, 22 Jun 2020 07:27:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-serial-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hI2iPwM6; spf=pass (google.com: domain of linux-serial-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729281AbgFVO1h (ORCPT + 1 other); Mon, 22 Jun 2020 10:27:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729414AbgFVO1f (ORCPT ); Mon, 22 Jun 2020 10:27:35 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A609C061795 for ; Mon, 22 Jun 2020 07:27:35 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id r18so8201733pgk.11 for ; Mon, 22 Jun 2020 07:27:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SpQVzSBjDEPebQy5qXPK/BkcdPQ45hc1OKMcPgP/hpg=; b=hI2iPwM6eHl78f/Rf8OaivVcHz3gxNYp7IujpJ0Fw4woi28ptBxRkJmesqWs9PJ8eq yFgt6ooC0ATzyjeS3E3XgbmXm+QpmI3HL0rWsAUsTdQfAkLwHauCN9foUfI51PEMGHZ8 yODUaCBZN8pKYgqZBYI9xuc0XcLmgHZwlVFZ3KYI3auT9hZPwg6xMXFq9NPQ8FSG50FJ oR8FlHOsAAzKbPhx4LYo0bJFdsUWcoUsugtAVKLcLzmcam3p7brbYKkOdLUOjAkWmQ16 9WZbzObPYrGJctJ6gY4fm+CGqzRaZTkVF7lUIi5989wtOBl4m4X8YvITzEhSBDAYRgCI lq0g== 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; bh=SpQVzSBjDEPebQy5qXPK/BkcdPQ45hc1OKMcPgP/hpg=; b=iKYnfkz8876fuJCUsgAL42s2qE0e5TTxzHVcB7fK3tmbmrvWNXcT0Ndz6cbwoKxBfm CV0WsPAv82opxPK15fHvSDhzGjFh8Hqqr4W+ZNIcsx61uLN/+UwCyBzRaOnv6KUhLfnA l8xR7WuXhZMv5elTIvc/eaHGsqYOK/30wEkqNzIaZrxl2sphoNVuv2f+duzl/k7vIYDP UbhIOWiQC4JQ1mufOvH3k3/GeStjchDdh3j4Nkk8OF055kyhkQUybyKvB0iA8Bmg3wSt Ta9kTL3DzVNI34Sj1dnK94FrLLutkG+pe9fIh00XDqU5dc+MhRC0mXeFhePzeybZJGH8 h84A== X-Gm-Message-State: AOAM531nASJAsvbRplm+n69lO8Y/2s3C4MjRB/IdlTneUZ0MVfYNLuLp 9e/iYW+vIJ7xMIVa+/WbOirU3Q== X-Received: by 2002:a63:eb54:: with SMTP id b20mr13113025pgk.380.1592836055116; Mon, 22 Jun 2020 07:27:35 -0700 (PDT) Received: from localhost.localdomain ([117.252.67.186]) by smtp.gmail.com with ESMTPSA id d6sm14547939pjh.5.2020.06.22.07.27.30 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Jun 2020 07:27:34 -0700 (PDT) From: Sumit Garg To: kgdb-bugreport@lists.sourceforge.net, linux-serial@vger.kernel.org Cc: gregkh@linuxfoundation.org, daniel.thompson@linaro.org, jason.wessel@windriver.com, dianders@chromium.org, jslaby@suse.com, linux@armlinux.org.uk, linux-kernel@vger.kernel.org, Sumit Garg Subject: [PATCH 3/7] kgdb: Add request_nmi() to the io ops table for kgdboc Date: Mon, 22 Jun 2020 19:56:20 +0530 Message-Id: <1592835984-28613-4-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1592835984-28613-1-git-send-email-sumit.garg@linaro.org> References: <1592835984-28613-1-git-send-email-sumit.garg@linaro.org> Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org From: Daniel Thompson Add request_nmi() callback to install a non-maskable interrupt handler corresponding to IRQ retrieved from polling interface. If NMI handler installation fails due to missing support from underlying irqchip driver then fallback to install it as normal interrupt handler. Signed-off-by: Daniel Thompson Co-developed-by: Sumit Garg Signed-off-by: Sumit Garg --- drivers/tty/serial/kgdboc.c | 35 +++++++++++++++++++++++++++++++++++ include/linux/kgdb.h | 7 +++++++ 2 files changed, 42 insertions(+) -- 2.7.4 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c index 84ffede..263afae 100644 --- a/drivers/tty/serial/kgdboc.c +++ b/drivers/tty/serial/kgdboc.c @@ -19,6 +19,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -390,12 +393,44 @@ static void kgdboc_post_exp_handler(void) kgdboc_restore_input(); } +static int kgdb_tty_irq; + +static int kgdboc_request_nmi(irq_handler_t fn, void *dev_id) +{ + int irq, res; + + /* Better to avoid double allocation in the tty driver! */ + if (kgdb_tty_irq) + return 0; + + if (!kgdb_tty_driver->ops->poll_get_irq) + return -ENODEV; + + irq = + kgdb_tty_driver->ops->poll_get_irq(kgdb_tty_driver, kgdb_tty_line); + if (irq <= 0) + return irq ? irq : -ENODEV; + + irq_set_status_flags(irq, IRQ_NOAUTOEN); + res = request_nmi(irq, fn, IRQF_PERCPU, "kgdboc", dev_id); + if (res) { + res = request_irq(irq, fn, IRQF_SHARED, "kgdboc", dev_id); + WARN_ON(res); + } + + enable_irq(irq); + + kgdb_tty_irq = irq; + return 0; +} + static struct kgdb_io kgdboc_io_ops = { .name = "kgdboc", .read_char = kgdboc_get_char, .write_char = kgdboc_put_char, .pre_exception = kgdboc_pre_exp_handler, .post_exception = kgdboc_post_exp_handler, + .request_nmi = kgdboc_request_nmi, }; #if IS_BUILTIN(CONFIG_KGDB_SERIAL_CONSOLE) diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h index 529116b..b32b044 100644 --- a/include/linux/kgdb.h +++ b/include/linux/kgdb.h @@ -16,6 +16,7 @@ #include #include #include +#include #ifdef CONFIG_HAVE_ARCH_KGDB #include #endif @@ -276,6 +277,10 @@ struct kgdb_arch { * the I/O driver. * @post_exception: Pointer to a function that will do any cleanup work * for the I/O driver. + * @request_nmi: Pointer to a function that can install an non-maskable + * interrupt handler that will be called when a character is pending and that + * can be cleared by calling @read_char until it returns NO_POLL_CHAR. If NMI + * installation fails then fallback to install normal interrupt handler. * @cons: valid if the I/O device is a console; else NULL. */ struct kgdb_io { @@ -287,6 +292,8 @@ struct kgdb_io { void (*deinit) (void); void (*pre_exception) (void); void (*post_exception) (void); + int (*request_nmi)(irq_handler_t nmi_handler, + void *dev_id); struct console *cons; }; From patchwork Mon Jun 22 14:26:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 191335 Delivered-To: patch@linaro.org Received: by 2002:a92:1f07:0:0:0:0:0 with SMTP id i7csp1092797ile; Mon, 22 Jun 2020 07:27:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxV22MwNhF1K3pRec9CyGRiiDyFLKAkc7Kv31iWVjirEikX4sdDv4MmIrIJFGphrkzdtIh3 X-Received: by 2002:a50:c44b:: with SMTP id w11mr17965346edf.317.1592836065941; Mon, 22 Jun 2020 07:27:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592836065; cv=none; d=google.com; s=arc-20160816; b=gtIpc8OotaELHRR1+5gyRe51fF9sKeNfBrzY1W5nDzhof7uZgVRPnh2XBZcrBG/dbl EURbg6f7S/HzoIfis/AxH5QDWbGn768C/gpC2+OZ5ak056JAkao2ODv4f2PbZZGamIP/ yG0OZcOhLx9mvZqBntOgs9203TuIGsCYBtChoDJjHjzLCYPYbBkU7m2ezn0d23SYxFpB ExFAWaFZGhLqWtaJZuFRNzuxupM7S4824EUkIYQ731rxq4RWzYVtkxPZ9Vw5wdv97HWh l/2zb96YF0FiteNntwS1nJHyXYqaYHbpe59DeEpdp/ux/uTCZ52PJJqqBIKrLStG3obq SbZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=sjUQXgLs8QLSZt9fRiSIf9rP+l/zfeDDFs4yVtYk7Z0=; b=zg8bvtAFAPL7NtdaZSQn0d/dqYmcGAMMTucP9w6YCCAuwjFQgVwuCrCoEd3vrRxY3p KUlpVsugLP9EC0w5DztrTM7gzevaDoUzaj+IlkN75ovtQ8RzVqL5fo7wRgJxhZI18Q/w CqG6RW/AzUHxjwt97ElKr8zJVfL6EwTtshRtcNa64NKD23E3gVjuU9W8Efm8tZUt28PI 9Z6aafIp9wWKYp/r3/IOMuakN0hAIwTonlSKaRqTe8ZCpypseH0mOIFj2uWXx9R4kIgu Fpou3y7dtrTQu8Hu4IYolAvIue6kP/Lz63AkO5OaHCVU3sJrhnNVfrIBURsVsTSBcPuw biTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QOeLXcXX; spf=pass (google.com: domain of linux-serial-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y25si1753981edi.139.2020.06.22.07.27.45; Mon, 22 Jun 2020 07:27:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-serial-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QOeLXcXX; spf=pass (google.com: domain of linux-serial-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729160AbgFVO1n (ORCPT + 1 other); Mon, 22 Jun 2020 10:27:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729485AbgFVO1k (ORCPT ); Mon, 22 Jun 2020 10:27:40 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F6FFC061573 for ; Mon, 22 Jun 2020 07:27:40 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id u14so2935097pjj.2 for ; Mon, 22 Jun 2020 07:27:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sjUQXgLs8QLSZt9fRiSIf9rP+l/zfeDDFs4yVtYk7Z0=; b=QOeLXcXXYJY7Mbx/0GKxWfojZNvqp1+/iUKrhHvJJPT9TVW7hdHXE2t9l97MfMSFpN a08ODnr/u8hVAu7RVgm3nwaohgTk6yIAfdCRoM5WfyRsqxQHCEGEzi9wTA/yKOQSDDTn EspPlVmFhi6LGov/zu0zVQxHn0TORwdNIp4Tz25YBXpANqqkhTFuF4GxAxBipD+4hDqG jmvq8KHWY56pQ4Uhc3UmRVKr91Ozy+VR2DUlvgYbGewgO3jRkY/Dp81cKfOw8z4F75Dm Z8nwP0kHFAnNAqtxxXXSBop65W6O3MFJ//0g5Mpc6ZSBKBujqa7snPffto/Uxw5BV9qX S9qA== 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; bh=sjUQXgLs8QLSZt9fRiSIf9rP+l/zfeDDFs4yVtYk7Z0=; b=QTmxIjEjqvvuCoQ0FZST/EAfc5XfdufzwuMMPIdTOu4t9vhoFClodMDYu2EPc5q9Ti b/+l0hTuFYXjFWdRcnAu143H0mBOefefx+/Fy3yBslvMGhRoc4u3fkjW2C5CQ+ZmS0/4 aqAX05Xb9rmhs73U/SSRv0xwDzgFRCvL3fkYtP6xwcpK/OupkMnhcP5XXFAqYFcKxsix Gl/q9jK2O953Kge/ylNJTToI9dXqCswvaX5J5CuhkYv523wx901RJEmYIt6l42i/Pcnz qE8a0ktwmYbk2UhZzTjA4iLFPZnN4munYdNPFxX3E8rtHaD3jEHSvvwnANNvy4zseYbD NpLg== X-Gm-Message-State: AOAM53194KlOUwCOdn1jEHNeqdBGsad0wfBWaiOmuHYkGfu7oBPh9z+8 Rv4cnoff/HIPXm4tJs7oQfVCoQmxli4= X-Received: by 2002:a17:90a:d485:: with SMTP id s5mr17596432pju.61.1592836060022; Mon, 22 Jun 2020 07:27:40 -0700 (PDT) Received: from localhost.localdomain ([117.252.67.186]) by smtp.gmail.com with ESMTPSA id d6sm14547939pjh.5.2020.06.22.07.27.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Jun 2020 07:27:39 -0700 (PDT) From: Sumit Garg To: kgdb-bugreport@lists.sourceforge.net, linux-serial@vger.kernel.org Cc: gregkh@linuxfoundation.org, daniel.thompson@linaro.org, jason.wessel@windriver.com, dianders@chromium.org, jslaby@suse.com, linux@armlinux.org.uk, linux-kernel@vger.kernel.org, Sumit Garg Subject: [PATCH 4/7] serial: kgdb_nmi: Add support for interrupt based fallback Date: Mon, 22 Jun 2020 19:56:21 +0530 Message-Id: <1592835984-28613-5-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1592835984-28613-1-git-send-email-sumit.garg@linaro.org> References: <1592835984-28613-1-git-send-email-sumit.garg@linaro.org> Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org From: Daniel Thompson Add a generic NMI fallback to support kgdb NMI console feature which can be overridden by arch specific implementation. This common fallback mechanism utilizes kgdb IO based interrupt in order to support entry into kgdb if a user types in kgdb_nmi_magic sequence. So during NMI console init, NMI handler is installed corresponding to kgdb IO based NMI which is invoked when a character is pending and that can be cleared by calling @read_char until it returns NO_POLL_CHAR. Signed-off-by: Daniel Thompson Co-developed-by: Sumit Garg Signed-off-by: Sumit Garg --- drivers/tty/serial/kgdb_nmi.c | 47 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 7 deletions(-) -- 2.7.4 diff --git a/drivers/tty/serial/kgdb_nmi.c b/drivers/tty/serial/kgdb_nmi.c index b32c6b1..2580f39 100644 --- a/drivers/tty/serial/kgdb_nmi.c +++ b/drivers/tty/serial/kgdb_nmi.c @@ -42,9 +42,46 @@ MODULE_PARM_DESC(magic, "magic sequence to enter NMI debugger (default $3#33)"); static atomic_t kgdb_nmi_num_readers = ATOMIC_INIT(0); static struct console *orig_dbg_cons; +static int kgdb_nmi_poll_one_knock(void); + +static irqreturn_t kgdb_handle_nmi(int irq, void *dev_id) +{ + int ret; + + if (kgdb_nmi_knock < 0) { + kgdb_breakpoint(); + return IRQ_HANDLED; + } + + ret = kgdb_nmi_poll_one_knock(); + if (ret == NO_POLL_CHAR) + return IRQ_NONE; + + while (ret != 1) { + ret = kgdb_nmi_poll_one_knock(); + if (ret == NO_POLL_CHAR) + return IRQ_HANDLED; + } + + kgdb_breakpoint(); + return IRQ_HANDLED; +} + static int kgdb_nmi_console_setup(struct console *co, char *options) { - arch_kgdb_ops.enable_nmi(1); + int res; + + if (arch_kgdb_ops.enable_nmi) { + arch_kgdb_ops.enable_nmi(1); + } else if (dbg_io_ops->request_nmi) { + res = dbg_io_ops->request_nmi(kgdb_handle_nmi, co); + if (res) { + pr_err("ttyNMI0: Cannot request nmi/irq\n"); + return res; + } + } else { + return -ENODEV; + } /* The NMI console uses the dbg_io_ops to issue console messages. To * avoid duplicate messages during kdb sessions we must inform kdb's @@ -328,9 +365,6 @@ int kgdb_register_nmi_console(void) { int ret; - if (!arch_kgdb_ops.enable_nmi) - return 0; - kgdb_nmi_tty_driver = alloc_tty_driver(1); if (!kgdb_nmi_tty_driver) { pr_err("%s: cannot allocate tty\n", __func__); @@ -380,9 +414,8 @@ int kgdb_unregister_nmi_console(void) { int ret; - if (!arch_kgdb_ops.enable_nmi) - return 0; - arch_kgdb_ops.enable_nmi(0); + if (arch_kgdb_ops.enable_nmi) + arch_kgdb_ops.enable_nmi(0); ret = unregister_console(&kgdb_nmi_console); if (ret) From patchwork Mon Jun 22 14:26:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 191336 Delivered-To: patch@linaro.org Received: by 2002:a92:1f07:0:0:0:0:0 with SMTP id i7csp1092844ile; Mon, 22 Jun 2020 07:27:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9CkOD5Tge/dx+BC/SZ1XXhkt6xBKQiekbIc6cEmNLemefUipZXPRhKWAZY1v0dh4O4Hyh X-Received: by 2002:a17:906:3154:: with SMTP id e20mr16598509eje.171.1592836068977; Mon, 22 Jun 2020 07:27:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592836068; cv=none; d=google.com; s=arc-20160816; b=HDcH2+gEhwUTT1TrHowTc1P3SL8UuVSON/+tJU2aNmXmGYQ4b59u9TzyptrwAsHNg4 ukTxKR4FGY+dck1+1x3mr3RPZCt0JB6Mq2IST27Z5KtJZyG5y2bMFPdPn/pyn8QZ3Wti HiZVVVsOY3eSF6E8MV33q2Goi+zZPRohRY5im7jinh5XB3nkpKDucw/F5bwYFbvsx2+I +Y1gxf8mwqBJGnrddR/zoMrwOSz59zwiQ5plwaFpL0FqaUptcIGql6tnMH3MdjKXcxwE 8owwalnL+HQGwnODGYGs+aW6Cjb3pl8LlMnOhw8OAKpyjH7hstkxLX2o4o+1P/Y4zRau 7KSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=Q8XZGlRV/H7ipjUMwZ0R6upcC6zi/GhiQnizl6ayNWQ=; b=m8j8vRV2T+3EBto/PSAFFo1no0li9+Jp1iX12gsMNtu4HgbNRfArQ+AHM51t/J2t5p Uw4vRyJSOp+m++CNDr+mqMcYvy2G8G2+SvSChYrgVA4a1d8xiB9R4oIn7PL4x5/St3o4 Fjl7+Fdap7cGjEeLxMHBVzhxN4vzew+dOXWDv9wCrHAvqmcVtaG5bVs412h/xpxgE578 CqvF46+zkzLirW7f4EX90ytOOqmmKw5lGorgTCPzsdunmrw6Q3jGC/0jj1hWBlokLP07 CDnC+hRw0N2fOiXuuYTp5NMO2/1YqmGB3bsUPSiv3FsGzYVYkd1voCy3tnleJuba4pS5 dG/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iES2Z3LS; spf=pass (google.com: domain of linux-serial-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y16si9037717ejr.344.2020.06.22.07.27.48; Mon, 22 Jun 2020 07:27:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-serial-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iES2Z3LS; spf=pass (google.com: domain of linux-serial-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729783AbgFVO1q (ORCPT + 1 other); Mon, 22 Jun 2020 10:27:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729799AbgFVO1p (ORCPT ); Mon, 22 Jun 2020 10:27:45 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEB73C061573 for ; Mon, 22 Jun 2020 07:27:45 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id d10so5753809pls.5 for ; Mon, 22 Jun 2020 07:27:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Q8XZGlRV/H7ipjUMwZ0R6upcC6zi/GhiQnizl6ayNWQ=; b=iES2Z3LS/+1ufp5YulU7Lewvw1bchggk2aWycD2ouwUfDqw/J2BDmhkYLoA5Q8Xi1/ czE87Id/eTsr/WIJUHU8BJT+s05ule9+LYv0Ido5T4GknU8qZXkBGUNrJUw9Yoc9s4/b GbKx6DlF9lfyzRTu+u41x/JFhfpsQDL13xVlQtBdo9b5QcM3gFxunzDEApVgBt2ZCiMC fe4kGGgabD666+6T0pGDqHa2rTr0hbLHGBP9dQ91Z9MHTbd+skiPXa44ljD14bUyQwDe IqyvhXNM6ncGGDSSPex+2Zmrr3VIqDY+mSqst1UwK3XIJ5tQNVugk+49gE/f2ylISQlv Zfzw== 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; bh=Q8XZGlRV/H7ipjUMwZ0R6upcC6zi/GhiQnizl6ayNWQ=; b=lDJZHEskMkBUqgfWceurRmu1ibsgU9o/05KGpl1QAdiTW+O54PNHUSqj5Of7H9xHIi Bl3q2z2jRxHrHcdIqP2V5NjYLFh4VTgNZ3IQ+iPJgmfFZrcp4YuSIBpAHmxzqvtAWwLk 1JJUP0pW5QJ7f0n0Q9QlQOpnBzhOzU9p8Xn6tHoDlK1q1Rrs2c3DYVBY4e/vGl/MQBR5 VbRQ582Zw0oy2f1JSwqpGGSyoz8ZTo6GgDcBIWytCHSrHoEOwpmkkT1ei92OfHeUCBaw gcNlrseB8uh7Ll57A9MmaKWqIPxh0bhES4uinGFDcvG4SUJBvmy9ZR0P+Qtu5mpOmhGB ux4A== X-Gm-Message-State: AOAM5310oUXXob+x/L4SXLSjfwLfP18RdUadX4kuKdB82ithcJqn4Mca 2exD/J0aQQsVooBNS21phGsA0g== X-Received: by 2002:a17:90a:36cf:: with SMTP id t73mr19089365pjb.100.1592836065367; Mon, 22 Jun 2020 07:27:45 -0700 (PDT) Received: from localhost.localdomain ([117.252.67.186]) by smtp.gmail.com with ESMTPSA id d6sm14547939pjh.5.2020.06.22.07.27.40 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Jun 2020 07:27:44 -0700 (PDT) From: Sumit Garg To: kgdb-bugreport@lists.sourceforge.net, linux-serial@vger.kernel.org Cc: gregkh@linuxfoundation.org, daniel.thompson@linaro.org, jason.wessel@windriver.com, dianders@chromium.org, jslaby@suse.com, linux@armlinux.org.uk, linux-kernel@vger.kernel.org, Sumit Garg Subject: [PATCH 5/7] serial: 8250: Implement poll_get_irq() interface Date: Mon, 22 Jun 2020 19:56:22 +0530 Message-Id: <1592835984-28613-6-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1592835984-28613-1-git-send-email-sumit.garg@linaro.org> References: <1592835984-28613-1-git-send-email-sumit.garg@linaro.org> Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org From: Daniel Thompson Support kgdb NMI console feature via implementing poll_get_irq() interface. This will allow usage of RX interrupts to support kgdb entry while serial device is operating in polling mode. Signed-off-by: Daniel Thompson Signed-off-by: Sumit Garg --- drivers/tty/serial/8250/8250_port.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) -- 2.7.4 diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c index f77bf82..1473b1a 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -2138,6 +2138,21 @@ static void serial8250_put_poll_char(struct uart_port *port, serial8250_rpm_put(up); } +static int serial8250_get_poll_irq(struct uart_port *port) +{ + unsigned int ier; + struct uart_8250_port *up = up_to_u8250p(port); + + serial8250_rpm_get(up); + + ier = serial_port_in(port, UART_IER); + ier |= UART_IER_RLSI | UART_IER_RDI; + serial_port_out(port, UART_IER, ier); + + serial8250_rpm_put(up); + return port->irq; +} + #endif /* CONFIG_CONSOLE_POLL */ int serial8250_do_startup(struct uart_port *port) @@ -3141,6 +3156,7 @@ static const struct uart_ops serial8250_pops = { #ifdef CONFIG_CONSOLE_POLL .poll_get_char = serial8250_get_poll_char, .poll_put_char = serial8250_put_poll_char, + .poll_get_irq = serial8250_get_poll_irq, #endif }; From patchwork Mon Jun 22 14:26:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 191337 Delivered-To: patch@linaro.org Received: by 2002:a92:1f07:0:0:0:0:0 with SMTP id i7csp1092925ile; Mon, 22 Jun 2020 07:27:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvgZ4JjDD/8sdF3kT5M+i6wCtEqyBdy8PBWpqj1IsvlAvLJwzFOna3T6kfEyohuj+KM5FX X-Received: by 2002:a50:8e1e:: with SMTP id 30mr6684836edw.283.1592836074723; Mon, 22 Jun 2020 07:27:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592836074; cv=none; d=google.com; s=arc-20160816; b=yVCw0v4UFSDXxRCPrbConnDp8XUHIHPvYvGOVTStWDm2vfb2EW+60iwTTvXGRZmDEJ kpzK2716gPzWX9U+4FBbhveGXOF0HPLYUKleUS/D49BwXFgNTNiniaEdwTZfFJLClZFB 2F52XfQNHMHGbwz0eIL1CpLaeTKY/L56a3nShnxsWwjL49DwcFe3WphKLAlz7JQcrmRh sqFUilaToLPKkCmzktyY4CT9WNA7801gGiXlPrpjDap+Eyictvq6gnMzRQhZY5MzzQ+j RWv0SvTRxEVto9/ckS8Pcn1p8FbiTNLuB61O4Vid/reUq7bg23asj2plsTQsKUWJGUTP blwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=M9KwMzs626zZhBtIoTQs5efdkplmNJ79hSzl8cSVNjw=; b=LBeh3sI0nDdfbaILLXIQkebADhDYtLQnH4iLefsSiZM4P1a4p05OEI3Q45IqxXewna XNCxNPKc1qh6Rie6OwMdoCS9gsBhRqo5zXGa9dLF3qJl+SPhDezIkFXIlPrdIPJN8OwD 4veTJpsfuAK2OfBVkpQCIcRp9dpPzBpnDBa5oCx7kzf4l31MuWkl8e3lzqn5OnZsBuyM MM0NX5MNPJ776oiOBcAOPF2OyualXnuhTwsvdQ9Tl2T7GCXt4wiTFUSq354RJ6uivmo2 UvxsKDzrRdJsoYsINWj5IBlmjK8fc5f9wTR2gI+mJmmNpc3W1pkaM6zaCuqcU5oxD5a2 /ZFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fcYOxIUy; spf=pass (google.com: domain of linux-serial-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y16si9037717ejr.344.2020.06.22.07.27.54; Mon, 22 Jun 2020 07:27:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-serial-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fcYOxIUy; spf=pass (google.com: domain of linux-serial-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729386AbgFVO1w (ORCPT + 1 other); Mon, 22 Jun 2020 10:27:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729812AbgFVO1v (ORCPT ); Mon, 22 Jun 2020 10:27:51 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F854C061795 for ; Mon, 22 Jun 2020 07:27:51 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id k6so7641502pll.9 for ; Mon, 22 Jun 2020 07:27:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=M9KwMzs626zZhBtIoTQs5efdkplmNJ79hSzl8cSVNjw=; b=fcYOxIUyQqvxk/LMxj5k2PcHWbKksWlVM0RADhm7nGAokdEUmwV3EEiZC6qY8FZN+u MXoiD9Bl8uV3mE4dflId5Ysj9kk2DyS+ixwUWTwMxgQNlEF/UXTDXHxh7aeIfq/mou+U eOEgNlbrFUBNwfhMfJmEyGzg5fmJfkUD5+UTEteGBQmEZK7I1tsSoxz7idIIF4PWOgEv 3wQpxAZvdSHhEhomUs3Z4VP2UfDdFTNS9ukNUxnLQOoybV0TbZMI9blZV8rUJ1CsWUdM EJwzGZlCgI6Rtzeeiy5wd0ZheSlc3cyB8kuXh84pgLq/xOC7zPeMMPf0jJb4+LZ6QsuT hT8A== 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; bh=M9KwMzs626zZhBtIoTQs5efdkplmNJ79hSzl8cSVNjw=; b=O9sJcF0mPghMqch6Bto2p1tJrxVlp3XYU96nw2LeMDfcb6Hn8/d+nP9JguHnh4Gm+f R5P7eAvh7YtWgFLtVYQqTsa0ay3ybMuz6sHPdj+CUo5GLQgtdG9G9wMxyktO8PWdIraz V+dDDXQICs5mcd+LDjtbdz4PLVJ/ESI47BZ/9lNeJ8YFg2mXdmhZS4nwGPtLBKSJs8o8 57c4z75QrY7fwlEYbW0ZIrRrWj1vUpWt7ey+4IxXFj4S5YjvOdLgce/5iq+Hbim/NQ7e N/gmwtIkApXTkE6cbYxF1AUtN/h4vd0NUWgb6Yo45u3ZKyAorO1q2p6hIYGr9d7lLUEE Tg7g== X-Gm-Message-State: AOAM531c3PgR52XFv4PDYFLF9U7E3Zo9LHNW4jNy4p/J6P8l8gsTsVd4 +1o+/tsKAEYpqxsntHqz+aHCpQ== X-Received: by 2002:a17:902:d903:: with SMTP id c3mr18839486plz.229.1592836070328; Mon, 22 Jun 2020 07:27:50 -0700 (PDT) Received: from localhost.localdomain ([117.252.67.186]) by smtp.gmail.com with ESMTPSA id d6sm14547939pjh.5.2020.06.22.07.27.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Jun 2020 07:27:49 -0700 (PDT) From: Sumit Garg To: kgdb-bugreport@lists.sourceforge.net, linux-serial@vger.kernel.org Cc: gregkh@linuxfoundation.org, daniel.thompson@linaro.org, jason.wessel@windriver.com, dianders@chromium.org, jslaby@suse.com, linux@armlinux.org.uk, linux-kernel@vger.kernel.org, Sumit Garg Subject: [PATCH 6/7] serial: amba-pl011: Implement poll_get_irq() interface Date: Mon, 22 Jun 2020 19:56:23 +0530 Message-Id: <1592835984-28613-7-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1592835984-28613-1-git-send-email-sumit.garg@linaro.org> References: <1592835984-28613-1-git-send-email-sumit.garg@linaro.org> Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Support kgdb NMI console feature via implementing poll_get_irq() interface. This will allow usage of RX interrupts to support kgdb entry while serial device is operating in polling mode. Signed-off-by: Sumit Garg --- drivers/tty/serial/amba-pl011.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) -- 2.7.4 diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index c010f63..d620d12 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -1637,6 +1637,16 @@ static void pl011_put_poll_char(struct uart_port *port, pl011_write(ch, uap, REG_DR); } +static int pl011_get_poll_irq(struct uart_port *port) +{ + struct uart_amba_port *uap = + container_of(port, struct uart_amba_port, port); + + pl011_write(UART011_RTIM | UART011_RXIM, uap, REG_IMSC); + + return uap->port.irq; +} + #endif /* CONFIG_CONSOLE_POLL */ static int pl011_hwinit(struct uart_port *port) @@ -2145,6 +2155,7 @@ static const struct uart_ops amba_pl011_pops = { .poll_init = pl011_hwinit, .poll_get_char = pl011_get_poll_char, .poll_put_char = pl011_put_poll_char, + .poll_get_irq = pl011_get_poll_irq, #endif }; @@ -2176,6 +2187,7 @@ static const struct uart_ops sbsa_uart_pops = { .poll_init = pl011_hwinit, .poll_get_char = pl011_get_poll_char, .poll_put_char = pl011_put_poll_char, + .poll_get_irq = pl011_get_poll_irq, #endif }; From patchwork Mon Jun 22 14:26:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 191338 Delivered-To: patch@linaro.org Received: by 2002:a92:1f07:0:0:0:0:0 with SMTP id i7csp1092988ile; Mon, 22 Jun 2020 07:27:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNHSl9E+3uJ6Zpdef7t+Vs3aN4tz3oJN6Y2iUcF1PA2AotRfMmITmfzXMhsyd+FC4XDvUF X-Received: by 2002:aa7:ce93:: with SMTP id y19mr16667636edv.50.1592836078615; Mon, 22 Jun 2020 07:27:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592836078; cv=none; d=google.com; s=arc-20160816; b=CbEtz38+5PE/rldy2mDa2LGCVdOtU58y2E1gj2tytsYnTLrl86wAOOvrzsOii7b6JK rZQFcASHyLEz8Mk5wGUAq7QWGlEmhMYgGtt8VXod6k9lNHemL5NZ9M66V2pLyr8B/ihY WjQ/L2Lfz9kKo1U3O2YaV+iEsS/hW44ZDm+c6tA0WZ/Cobg7xMVVwPk5djkjNPi6sfsv 1qwUyDgLNKCrNZZwE+veTqDiDZF87P3xzy9ucs3hG3Cn6VTUVxTZaWOY+TNJVw8tPIoq IeIkN6vk3ZXGgv6g1EujLEz+NXqMb/0jmG5Ecy8+UvlDPLVuFMODq7unG3qCdXVpyy/Z ndgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=JRSHvl6U+IZL0NsvNZuwTx0bEAhR9MBQN7axB8epcUs=; b=pc+U0P/AR9qtpkq8zTOWkCnw6ZuVQgOVonwl6k91GoJQjenG9dL0vnM4BJ7WoFmK0t qP5f0uid9sdwuosD5tqIjXwv9uc7fpvBEX8c7QMpSjzIL11ishQxuk1+vkHASAoz+SXv pt4rMPP2B9t/1eFyX6dgQQo6gTmW6mpNurKm65/i4OkSVyeBTR7cMiGN0cfqL9S1cDEd 86pw6IajMAxudVv+rRsVKtt/jlBDIrl6y0LEOygI6ibE3KM9Ql8XR0l5T0MysNmptNw7 BrW4xvk2x0uJzhfNbNih0Oa/MyzQ7PflSeUFhuSmCxgtthetgkkfLTa3O0gEh2mgURFJ KArg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S8TezEvu; spf=pass (google.com: domain of linux-serial-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y16si9037717ejr.344.2020.06.22.07.27.58; Mon, 22 Jun 2020 07:27:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-serial-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S8TezEvu; spf=pass (google.com: domain of linux-serial-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729813AbgFVO15 (ORCPT + 1 other); Mon, 22 Jun 2020 10:27:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729818AbgFVO1z (ORCPT ); Mon, 22 Jun 2020 10:27:55 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9313C061795 for ; Mon, 22 Jun 2020 07:27:55 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id b5so8214562pgm.8 for ; Mon, 22 Jun 2020 07:27:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JRSHvl6U+IZL0NsvNZuwTx0bEAhR9MBQN7axB8epcUs=; b=S8TezEvuiSh9r4tBiJ8Y0oZfklqL3bPKvd/7r3OyPqXHHov7Otay0asDWDli0VDaTF KFKyvZN2KacrOaS0MVEXkb9jRAT3dQ4+Cf6+zAfEvJedm3lyOYDDTqLOfN/36anHjr9r KsqPKjJzOfSAwUn3oO5oleQ5ofNvOhbgSz8gIHtWYPg+o2u7HtyH8K3QJE5pq3xfJxCf 709Ko3xFJDv3Pq4cJf9abD0OkIiy+mcEygCEca/dxQTzzLvArfOFqQzOToCln2rtZ7F3 ckoSN05a+EOUNIWgO9ziPfaAC+soDU1jlx1wKcwKemwABOOuuzqjb6b6ae8iByzjA2HG bZ6A== 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; bh=JRSHvl6U+IZL0NsvNZuwTx0bEAhR9MBQN7axB8epcUs=; b=mqFeGRq9KD5OFA43TjSZA4rI0hYHmolVF6XY575Ue9TaUDP1ZqTSWTyUwMyOSGW1xk 7N7Or+Hti0BYnuP/pVvm40kp3VG+luA28y7HP55CYIGt/R3bK/LcLxxyy1bOJcp72azt XZerlbJ+75tJsQ6jQkbrWujt+aO+3rSAGf0yvcnmBXWZXj8+XuWOJdvy0Cuk3CiUie/f vbcrf0wxk69OrS/dGoSvQ1SB02FBC1d6snAUu8xZ6GSBDsKWIzXOsnqDHjLYcMmJzlxw kB33rT6z131nU28Ji2lWeeYYuEEhSc0KKICqFJGdUBgZpkihjbsQcWvObSLLELTLjAlG b5ZQ== X-Gm-Message-State: AOAM530ad0BXep+I7yHaQUEqX78WqoiKHb5qtoRyoJC1QD38pdU20uNM UUD6aFWaGuFwPqtAQlGNdJRSHg== X-Received: by 2002:a63:d652:: with SMTP id d18mr13372987pgj.164.1592836075366; Mon, 22 Jun 2020 07:27:55 -0700 (PDT) Received: from localhost.localdomain ([117.252.67.186]) by smtp.gmail.com with ESMTPSA id d6sm14547939pjh.5.2020.06.22.07.27.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Jun 2020 07:27:54 -0700 (PDT) From: Sumit Garg To: kgdb-bugreport@lists.sourceforge.net, linux-serial@vger.kernel.org Cc: gregkh@linuxfoundation.org, daniel.thompson@linaro.org, jason.wessel@windriver.com, dianders@chromium.org, jslaby@suse.com, linux@armlinux.org.uk, linux-kernel@vger.kernel.org, Sumit Garg Subject: [PATCH 7/7] serial: kgdb_nmi: Replace hrtimer with irq_work ping Date: Mon, 22 Jun 2020 19:56:24 +0530 Message-Id: <1592835984-28613-8-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1592835984-28613-1-git-send-email-sumit.garg@linaro.org> References: <1592835984-28613-1-git-send-email-sumit.garg@linaro.org> Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org From: Daniel Thompson Currently kgdb_nmi relies on a 100Hz timer to "defer" work from an NMI handler. This is essentially doing the job that irq_work is designed to do but in an odd and inefficient manner. Remove the timer code and replace it with more appropriate irq_work related APIs. Signed-off-by: Daniel Thompson Signed-off-by: Sumit Garg --- drivers/tty/serial/kgdb_nmi.c | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-) -- 2.7.4 diff --git a/drivers/tty/serial/kgdb_nmi.c b/drivers/tty/serial/kgdb_nmi.c index 2580f39..ad84eef 100644 --- a/drivers/tty/serial/kgdb_nmi.c +++ b/drivers/tty/serial/kgdb_nmi.c @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include @@ -127,7 +127,7 @@ static struct console kgdb_nmi_console = { struct kgdb_nmi_tty_priv { struct tty_port port; - struct timer_list timer; + struct irq_work work; STRUCT_KFIFO(char, KGDB_NMI_FIFO_SIZE) fifo; }; @@ -141,13 +141,12 @@ static void kgdb_tty_recv(int ch) if (!kgdb_nmi_port || ch < 0) return; /* - * Can't use port->tty->driver_data as tty might be not there. Timer - * will check for tty and will get the ref, but here we don't have to - * do that, and actually, we can't: we're in NMI context, no locks are - * possible. + * Can't use port->tty->driver_data as tty might be not there. Also, we + * can't even do that as we're in NMI context, no locks are possible. */ priv = container_of(kgdb_nmi_port, struct kgdb_nmi_tty_priv, port); kfifo_in(&priv->fifo, &c, 1); + irq_work_queue(&priv->work); } static int kgdb_nmi_poll_one_knock(void) @@ -222,18 +221,12 @@ bool kgdb_nmi_poll_knock(void) return true; } -/* - * The tasklet is cheap, it does not cause wakeups when reschedules itself, - * instead it waits for the next tick. - */ -static void kgdb_nmi_tty_receiver(struct timer_list *t) +static void kgdb_nmi_tty_receiver(struct irq_work *work) { - struct kgdb_nmi_tty_priv *priv = from_timer(priv, t, timer); + struct kgdb_nmi_tty_priv *priv = + container_of(work, struct kgdb_nmi_tty_priv, work); char ch; - priv->timer.expires = jiffies + (HZ/100); - add_timer(&priv->timer); - if (likely(!atomic_read(&kgdb_nmi_num_readers) || !kfifo_len(&priv->fifo))) return; @@ -245,22 +238,13 @@ static void kgdb_nmi_tty_receiver(struct timer_list *t) static int kgdb_nmi_tty_activate(struct tty_port *port, struct tty_struct *tty) { - struct kgdb_nmi_tty_priv *priv = - container_of(port, struct kgdb_nmi_tty_priv, port); - kgdb_nmi_port = port; - priv->timer.expires = jiffies + (HZ/100); - add_timer(&priv->timer); return 0; } static void kgdb_nmi_tty_shutdown(struct tty_port *port) { - struct kgdb_nmi_tty_priv *priv = - container_of(port, struct kgdb_nmi_tty_priv, port); - - del_timer(&priv->timer); kgdb_nmi_port = NULL; } @@ -279,7 +263,8 @@ static int kgdb_nmi_tty_install(struct tty_driver *drv, struct tty_struct *tty) return -ENOMEM; INIT_KFIFO(priv->fifo); - timer_setup(&priv->timer, kgdb_nmi_tty_receiver, 0); + init_irq_work(&priv->work, kgdb_nmi_tty_receiver); + atomic_set(&priv->work.flags, IRQ_WORK_LAZY); tty_port_init(&priv->port); priv->port.ops = &kgdb_nmi_tty_port_ops; tty->driver_data = priv;