Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3392762ybt; Tue, 23 Jun 2020 00:51:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwkZyDd8tthuE5RQ1UQOTaloiN/FO6+XBlDnuS8ML/MkRDeplrm6GHL0bk3jJUuOInP5my X-Received: by 2002:a5d:56d0:: with SMTP id m16mr22906806wrw.194.1592898683173; Tue, 23 Jun 2020 00:51:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592898683; cv=none; d=google.com; s=arc-20160816; b=EqE13N9bKBth0JP4zzbSN9kT3mlHmFTWUEvHynY/iTOKlkAPck1cnnnMP5fGel/1Y6 AZ3/tiwkh2lB0IIP1tbQwgcbDfFEUf8WXxOvx+xZNbf5MtpA/78eQ4CHgZoLyPD2g0Ak TxlqKrsJKoVVdgHo+zsS2+ZoEuNHAlHkUX+GvKMTbvlU3FTOmOgAveNAFhw99UgZGG4z fGt8zRatZ8yrBfUQadkMaqAiN48m60k+3Xu4Z1+iIHThIfdjERF9v0h8723occGLfiXi p6qohIQ6hE9ntmXZnmlwJUJaQWgdltZweqi8yxdrwG7VJmMDHyP/h4ztEvpmrN4fRVy4 Ktsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=rgZbUCewmd3JpSFrxwjakoIwIqrpt2vAjuWM35Dv1Bk=; b=SE3JW2eQkEAyAYfdtrCE9HSydXpFxKc3d9eGWi+MyUyqkROkVD80Io4OtTEanq07dQ AstH3gSbfWiyo01IP3R+nI70b+9PCJIoOy23cKDAk8BKUnlOgaSrbmZfJHskhvE9Iedd k5F8vBiOOQnEcijeraANZBrEBqC5tk2D5/UHjqXROTEq+Cg5DzxYbhaMFprftoycrP6O 20J2RzTYZi5Ivgf0Y9lc4HmdgOJQqK2ON7KKgrCEgzHgcpAr/lMZmkzIFFX+MKochP/c OznTNwgHNlb83pr71IhegxiLjSUFJFgb40JDJMYxTQj5EONquqdwlMuuXIhiKUuyv/qh Ef2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=I44oZZrX; 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 g6si2462319edl.330.2020.06.23.00.50.59; Tue, 23 Jun 2020 00:51:23 -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=I44oZZrX; 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 S1731543AbgFWHsk (ORCPT + 99 others); Tue, 23 Jun 2020 03:48:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731522AbgFWHsj (ORCPT ); Tue, 23 Jun 2020 03:48:39 -0400 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FA67C061795 for ; Tue, 23 Jun 2020 00:48:39 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id 9so22323643ljc.8 for ; Tue, 23 Jun 2020 00:48:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rgZbUCewmd3JpSFrxwjakoIwIqrpt2vAjuWM35Dv1Bk=; b=I44oZZrXmV9zsIep9z35wn/TfLK8oAFCUs6GPfhkGdU7gZuaQNG9ONyQlpqzqEhD+4 BJKObFrcqNpCMTIgejakJwOTULOqIcoHVjdEbZPaWC5GBkcAUVO8KO9vXIO4LMEMH8O/ 3TiyvCmKxxQE/6TTM2eT4qHlKaqczdtMCcuYHl8+i64j83hqQOGUCrmRRRq2MKaUUs4/ oFjgioZIOrNkGX5icvtdDGAURahxgae/fet56fCKX7g6ibosuh5reuQ6LqBd9trq5AeX Ukjm7Opyrg9HAskD5QYxEvdR5U4Yxy/vsQv9Sp96gb16+K4RcZBSbUFYiv7M4TRbXS6s fCbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rgZbUCewmd3JpSFrxwjakoIwIqrpt2vAjuWM35Dv1Bk=; b=rupz+3Goes8UdJ9ozEPDKm/OG6K+KyZ3vfCUP4fKgpSh5IcN2KErFQprQ1CcYv1gEj PyDWiW5iGHxp4eWzeeZjApWGvDugTQ2Fh94juxSnFooz40f+sw2n0b7KJMSUgYi3/4Wd RGxnxYBhxyd//dKnGSQwDcrRpzJwMaphgkN2/mjDLYsdZGMxz//mFNlATWk6BaxELCxO 2qM/6cocjChUtmzCpzEhUkic3xcmuQAQwpOWrKTGgd9I5tvccB3uTuPLoCRuE/Jo8c1e OU7mD1+zhOg1dK6EtBKxTQpyccE/YqYyUeqvzirvkWPUYplTFz/CsCPk12sURg2OcQSj vTWQ== X-Gm-Message-State: AOAM531/2X6exfVXhe2M8PSmF8YVxpVwpO7nnkZKYg63PjQkyjZ8HGh5 O/VjxixETGypOg0sBEd5m2OBFZh83mGmXVh9xVu60A== X-Received: by 2002:a05:651c:1103:: with SMTP id d3mr11029863ljo.110.1592898517647; Tue, 23 Jun 2020 00:48:37 -0700 (PDT) MIME-Version: 1.0 References: <1592835984-28613-1-git-send-email-sumit.garg@linaro.org> <1592835984-28613-3-git-send-email-sumit.garg@linaro.org> <20200622155624.he2vs2r3e5yzf3sl@holly.lan> In-Reply-To: <20200622155624.he2vs2r3e5yzf3sl@holly.lan> From: Sumit Garg Date: Tue, 23 Jun 2020 13:18:25 +0530 Message-ID: Subject: Re: [PATCH 2/7] tty: serial: Add poll_get_irq() to the polling interface To: Daniel Thompson Cc: kgdb-bugreport@lists.sourceforge.net, linux-serial@vger.kernel.org, Greg Kroah-Hartman , Jason Wessel , Douglas Anderson , Jiri Slaby , Russell King - ARM Linux admin , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 22 Jun 2020 at 21:26, Daniel Thompson wrote: > > On Mon, Jun 22, 2020 at 07:56:19PM +0530, Sumit Garg wrote: > > From: Daniel Thompson > > Sumit, to some extent this mail is me yelling at myself two years ago > although, in my defence, at the time I choose not to post it because I > knew it wasn't right. > > I'm a bit concerned to see the TODO: comment critiquing this interface > being removed (from patch 3) without this patch being changed to > address that comment. > I did consider that comment but I couldn't think of a normal scenario where request_irq() should fail. And in case it fails as well, I did put in "WARN_ON(res);" so that the user is notified of that particular error scenario. > > > 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(+) > > > > 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, > > The TODO comments claimed this API was bogus because it doesn't permit > a free and that can cause interoperation problems with the real serial > driver. I'll cover some of that in a reply to patch 3 but for now. > > Anyhow, for this patch, what are the expected semantics for > uart_poll_get_irq(). Currently, the expected use for this API is to enable uart RX interrupts and return corresponding IRQ id. Although, we can make this interface modular as follows: .poll_get_irq .poll_enable_rx_int .poll_disable_rx_int Your views? > > In particular how do they ensure correct interlocking with the real > serial driver underlying it (if kgdb_nmi is active on a serial port > then the underlying driver better not be active at the same time). > AFAIU kgdb_nmi feature, it registers a new tty driver (ttyNMI0) which is expected to work alongside underlying tty driver (eg. ttyAMA0 with amba-pl011). So ttyAMA0 will only become active if user-space tries to interact with /dev/ttyAMA0 like: # echo "Hello World!" > /dev/ttyAMA0 So I would like to understand the downsides of having both of them active at the same time using shared IRQ (although that won't be possible with NMI as that doesn't support shared mode)? -Sumit > > Daniel. > > > > #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; > > -- > > 2.7.4 > >