linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Thompson <daniel.thompson@linaro.org>
To: Sumit Garg <sumit.garg@linaro.org>
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 2/7] tty: serial: Add poll_get_irq() to the polling interface
Date: Mon, 22 Jun 2020 16:56:24 +0100	[thread overview]
Message-ID: <20200622155624.he2vs2r3e5yzf3sl@holly.lan> (raw)
In-Reply-To: <1592835984-28613-3-git-send-email-sumit.garg@linaro.org>

On Mon, Jun 22, 2020 at 07:56:19PM +0530, Sumit Garg wrote:
> From: Daniel Thompson <daniel.thompson@linaro.org>

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.


> 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 <daniel.thompson@linaro.org>
> Signed-off-by: Sumit Garg <sumit.garg@linaro.org>
> ---
>  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().

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).


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
> 

  reply	other threads:[~2020-06-22 15:56 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-22 14:26 [PATCH 0/7] Enable support for kgdb NMI console feature Sumit Garg
2020-06-22 14:26 ` [PATCH 1/7] serial: kgdb_nmi: Allow NMI console to replace kgdb IO console Sumit Garg
2020-06-22 14:26 ` [PATCH 2/7] tty: serial: Add poll_get_irq() to the polling interface Sumit Garg
2020-06-22 15:56   ` Daniel Thompson [this message]
2020-06-23  7:48     ` Sumit Garg
2020-06-23 10:52       ` Daniel Thompson
2020-06-22 14:26 ` [PATCH 3/7] kgdb: Add request_nmi() to the io ops table for kgdboc Sumit Garg
2020-06-22 16:03   ` Daniel Thompson
2020-06-23  8:37     ` Sumit Garg
2020-06-23 10:59       ` Daniel Thompson
2020-06-26 19:44         ` Doug Anderson
2020-06-29 11:45           ` Daniel Thompson
2020-06-30  6:09             ` Sumit Garg
2020-06-22 14:26 ` [PATCH 4/7] serial: kgdb_nmi: Add support for interrupt based fallback Sumit Garg
2020-06-22 16:36   ` Daniel Thompson
2020-06-23  9:59     ` Sumit Garg
2020-06-22 14:26 ` [PATCH 5/7] serial: 8250: Implement poll_get_irq() interface Sumit Garg
2020-06-22 14:26 ` [PATCH 6/7] serial: amba-pl011: " Sumit Garg
2020-06-22 14:26 ` [PATCH 7/7] serial: kgdb_nmi: Replace hrtimer with irq_work ping Sumit Garg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200622155624.he2vs2r3e5yzf3sl@holly.lan \
    --to=daniel.thompson@linaro.org \
    --cc=dianders@chromium.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jason.wessel@windriver.com \
    --cc=jslaby@suse.com \
    --cc=kgdb-bugreport@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=sumit.garg@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).