Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2873011ybt; Mon, 22 Jun 2020 09:06:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdVXPvi1Zwq8vs9EZQWe22rHlhUSfmTJjfgtRifx6iWY2btMvLo5glgjSqLiQHGJyXHL8n X-Received: by 2002:a17:906:f752:: with SMTP id jp18mr6262366ejb.538.1592841963194; Mon, 22 Jun 2020 09:06:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592841963; cv=none; d=google.com; s=arc-20160816; b=IZ3od0PCX5K6zILHQle5giRP6Nbg08QspTUHyxnQjmgy1W0stY8d7BmBFSXW3+fBSw NP5MjZNHkZv5HKtcPnGawXmEFM7FaJZCmBFik1wYZ/AwTxFljH12CnUcsTQD2Gnwmz/y p5ADZ9+MR+ihfrzKR1LolMvCuQ0QMVQekoZ2dwO8UQAKCkagrlbo2Y8A5Uj3bJZqs22K A9UrJmCil4IB3sVshL9vxmpV3QWzx9UpNEJ6VT2ztBO7Ua0evKjDizem0gdPQl5P2GVk KUGVX/f46bJSOFHJ2tQjdXVlnvoxMO6i5O6S3eeyFw2+Hr+9t3JNig9l7a62WiObVnfl qb3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=G7tyEQo0BCpuFpa+wLLnML4BSViFafq4hYNcPsQY6yA=; b=aCeCmDOKen7XOtzkdnbYVxGcCsGAclR7RvTcrXI2ajklnhGdvy0vxgjF8nVdtb1lOi FHdUxO+n4qwhcTUWLMXb+zAEOXiuxEB+m+ZDqGyU65rVyLlq1oETCqNbYEjaT9UkcazW gqAIoDRYDzkjwkTe3e5MKClg2Bzd0oC/CmldP+ViKPjG3e6258HbRPnxpwPKRABT/4on 0NmndED/7L0KW67lnrH+aR9g+XAfeYpR/cJI+t3eXcHJEXNqRvWAbgP2RKBF4+9fo/6f uyvvXRFC+d/Zk6xCx7QvXkfyTcxKrt05+thvLub8JBQ1qqz9DGpRM8duGPl9ZV/K1aH6 5dgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OFzgfBlw; 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 a22si9061447ejr.529.2020.06.22.09.05.39; Mon, 22 Jun 2020 09:06:03 -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=OFzgfBlw; 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 S1729893AbgFVQDG (ORCPT + 99 others); Mon, 22 Jun 2020 12:03:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729871AbgFVQDE (ORCPT ); Mon, 22 Jun 2020 12:03:04 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 153CAC061796 for ; Mon, 22 Jun 2020 09:03:04 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id t194so90792wmt.4 for ; Mon, 22 Jun 2020 09:03:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=G7tyEQo0BCpuFpa+wLLnML4BSViFafq4hYNcPsQY6yA=; b=OFzgfBlwCkrOzvIyVR98+1/FXds75qvrmXjxqkeiZis2MHuM8t8xekOzHXDkzHuUqC /Um6dZ6t4Srg/Fp14boWWHax79dKiFmIXrhDSdg8YDHvC8v2X46ysLHrIqLc49O3yk9v g4GxaTx1Hr78vxDccYzfFtECXgXqX1pOyPLoVzuHjWHax5i8FNFSYgOjRmkBoSzvoPVx XED1CZ5vMKFHce07Ux4WKGnUSF5k2sMmuddM43Ab1B4iGGnPLHMWo4w5jJUdbh43V0nD vSTgBCy/aJDKy9zjT6fEMZ1n9SGFXHZd5sC9LdGsI7hzu2crXDasuj1vY44cIQm7vTNE sCmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=G7tyEQo0BCpuFpa+wLLnML4BSViFafq4hYNcPsQY6yA=; b=cxkmmJXYHG3vecjb3pQCbIhMAUfxgVpFGgZTlY9IN54XKCwjlahuaTDMW2B3jfR741 qEHM7k8e+TLuDEjhwRpk45++ffXJ8yQSorC+qCbLUSSRSdFuX0RaB5Oe8BEF62sRvRex nP8/U051ediv7A8WTlvX+ccuzHp88xJDcfRdb1kThSbkFOuvwAPUjYEH79zh4bRE5911 sqiYBKWaiLQEEptrnHJoGCiZJpBV93N4u8pstn+PtOs3Fvj616q2KRJhqJ3EqiseyNZe BkMBoseLhhz3b9LP8AOmM4oyGO+XrkbKyJh1BM2UErDtOVW3hJe0C61VC4rcE/toUsnw klXQ== X-Gm-Message-State: AOAM532qSbFl0A/f1eTCOKT+34RHiF4+LdYFX4bd8mG67dUUDrAiRXzH OKiVNk3r6vTil8k91KxNIDQ0Kw== X-Received: by 2002:a05:600c:2201:: with SMTP id z1mr18818319wml.70.1592841782682; Mon, 22 Jun 2020 09:03:02 -0700 (PDT) Received: from holly.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id j18sm18502577wrn.59.2020.06.22.09.03.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2020 09:03:02 -0700 (PDT) Date: Mon, 22 Jun 2020 17:03:00 +0100 From: Daniel Thompson To: Sumit Garg Cc: kgdb-bugreport@lists.sourceforge.net, linux-serial@vger.kernel.org, gregkh@linuxfoundation.org, jason.wessel@windriver.com, dianders@chromium.org, jslaby@suse.com, linux@armlinux.org.uk, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/7] kgdb: Add request_nmi() to the io ops table for kgdboc Message-ID: <20200622160300.avgfhnfkpqzqqtsr@holly.lan> References: <1592835984-28613-1-git-send-email-sumit.garg@linaro.org> <1592835984-28613-4-git-send-email-sumit.garg@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1592835984-28613-4-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 On Mon, Jun 22, 2020 at 07:56:20PM +0530, Sumit Garg wrote: > 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); Why do we need IRQF_PERCPU here. A UART interrupt is not normally per-cpu? > + if (res) { > + res = request_irq(irq, fn, IRQF_SHARED, "kgdboc", dev_id); IRQF_SHARED? Currrently there is nothing that prevents concurrent activation of ttyNMI0 and the underlying serial driver. Using IRQF_SHARED means it becomes possible for both drivers to try to service the same interrupt. That risks some rather "interesting" problems. Daniel. > + 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 >