Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2807762ybt; Mon, 22 Jun 2020 07:32:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwXVt6RyG4Kkxk7Jhrq1WIKmUUrK2zMyo1DEegW+tBMPb2fGXQDkf7McDQFTzdHhKA4Cjdp X-Received: by 2002:a17:906:94c4:: with SMTP id d4mr3036475ejy.232.1592836349400; Mon, 22 Jun 2020 07:32:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592836349; cv=none; d=google.com; s=arc-20160816; b=gk8O9Y1/iD6vzR+5WHPxZcrA2jr3QBBT43T5bn93P8a8pCIRcyk9MN6dO4wbi9nvVi eLsuWEDNuOGQGCgMeud0y1KmyV50fFRDHZrCOTZMMszzbRAOGr4LFtTcuhmi9l7jFSaA DS1gKPJHXcNdazauvHumD6vs9kNczonLgFgC0l8WUhLURbF/11mSsRrz7Ce3qo6tRl4o oaR+8Ehg/TxUHjmb0KIfKpAQPi+k+A0KICdgoGt4/Q8Ero7ft8nurLuFRGlIb4eAxvfF ciukJYmae8ZmGFKI+rKzNbQZ2hSprmQIwCbrQaQue1a7xJMLpnuihyb/EydBm8TSEahB ce2w== 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=giOvUnVTBYQPB7iIpKXfUto6KECGN4zwkR0eO+pnGQZqRejTfHwkCHJK4p0XOUQzcC nKOkdlauqykn1+ovsk2M27Wng+heauY/DfNXuwapjnO51BZcJ+N//RiSJMc4HFD00V8o nX4LQyLm6nSP+9QKRzQaiN9lC4B068dGtIGU1XxIXqvAU2Lc4PTNQC7wWYS+UkVIwe1T iE72m+K0zcn3PmAO4GoNzqX5MawmNeUwhk3GS6P1bpsUkwLw067btrxmFft27hUSa/JZ hYbCe6K+ryuv4txG6ReP1QMvY8eHMTb2pVnqw/OUBmdDCHYnO1SdrLBn5MLsj6f6416o yqSA== 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-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 w5si4455905ejb.404.2020.06.22.07.32.06; Mon, 22 Jun 2020 07:32:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S1729167AbgFVO1h (ORCPT + 99 others); Mon, 22 Jun 2020 10:27:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729485AbgFVO1f (ORCPT ); Mon, 22 Jun 2020 10:27:35 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99E38C061573 for ; Mon, 22 Jun 2020 07:27:35 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id a127so8474500pfa.12 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=tUHmLSBIlQKKWBlKUtLkjEXx7YWF26wEqi25Jq+u7/wanIQfdU2jVqiycEWslDbwaC ZH+YpKbJAo5mUjyEjcYSMeg90jTJ+g/Yl6pvnyLSd33d4sXcISZrfJWcIzVf+2TZ1MIE Ta6I6Ma7w1ir0pUwCs7mP7YB8S9BVVcX96uXxnkFjhpoT8ap6VP9nsi3w2WcaRT8ZH3U BlJtq0ei+R6iIKrizwS6ve023QnE2qo2IHV+MWav3aK2fT4Ym6+TUvhAB0Ep8C0ieQox 3P9aP0g34RmlOQBv8VGPxeoPruW6kllnGuOwwAtT3op9b0fcRh0c9ZB6ZBg54K9pHItj yxuA== X-Gm-Message-State: AOAM531ADeJDWEgSbTVvItbNsYlwgne+h4TfBkJPBhnXuwk0Y7D3vX49 IOdjEE/bnad/pXsnPxOXnE+3SQ== 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(+) 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; }; -- 2.7.4