* [PATCH] tty: serial: fsl_lpuart: count tty buffer overruns
@ 2022-01-11 6:10 Sherry Sun
2022-01-11 7:08 ` Jiri Slaby
0 siblings, 1 reply; 3+ messages in thread
From: Sherry Sun @ 2022-01-11 6:10 UTC (permalink / raw)
To: gregkh, jirislaby; +Cc: linux-serial, linux-kernel, linux-imx
Added support for counting the tty buffer overruns in fsl_lpuart driver
like other uart drivers.
Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
---
drivers/tty/serial/fsl_lpuart.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index ce3e26144689..1e6f924d8507 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -931,7 +931,8 @@ static void lpuart_rxint(struct lpuart_port *sport)
sport->port.sysrq = 0;
}
- tty_insert_flip_char(port, rx, flg);
+ if (tty_insert_flip_char(port, rx, flg) == 0)
+ sport->port.icount.buf_overrun++;
}
out:
@@ -1024,7 +1025,8 @@ static void lpuart32_rxint(struct lpuart_port *sport)
flg = TTY_OVERRUN;
}
- tty_insert_flip_char(port, rx, flg);
+ if (tty_insert_flip_char(port, rx, flg) == 0)
+ sport->port.icount.buf_overrun++;
}
out:
@@ -1117,6 +1119,7 @@ static void lpuart_copy_rx_to_tty(struct lpuart_port *sport)
struct circ_buf *ring = &sport->rx_ring;
unsigned long flags;
int count = 0;
+ unsigned int copied = 0;
if (lpuart_is_32(sport)) {
unsigned long sr = lpuart32_read(&sport->port, UARTSTAT);
@@ -1218,20 +1221,24 @@ static void lpuart_copy_rx_to_tty(struct lpuart_port *sport)
if (ring->head < ring->tail) {
count = sport->rx_sgl.length - ring->tail;
- tty_insert_flip_string(port, ring->buf + ring->tail, count);
+ copied = tty_insert_flip_string(port, ring->buf + ring->tail, count);
+ if (copied != count)
+ sport->port.icount.buf_overrun++;
ring->tail = 0;
- sport->port.icount.rx += count;
+ sport->port.icount.rx += copied;
}
/* Finally we read data from tail to head */
if (ring->tail < ring->head) {
count = ring->head - ring->tail;
- tty_insert_flip_string(port, ring->buf + ring->tail, count);
+ copied = tty_insert_flip_string(port, ring->buf + ring->tail, count);
+ if (copied != count)
+ sport->port.icount.buf_overrun++;
/* Wrap ring->head if needed */
if (ring->head >= sport->rx_sgl.length)
ring->head = 0;
ring->tail = ring->head;
- sport->port.icount.rx += count;
+ sport->port.icount.rx += copied;
}
exit:
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] tty: serial: fsl_lpuart: count tty buffer overruns
2022-01-11 6:10 [PATCH] tty: serial: fsl_lpuart: count tty buffer overruns Sherry Sun
@ 2022-01-11 7:08 ` Jiri Slaby
2022-01-11 8:06 ` Sherry Sun
0 siblings, 1 reply; 3+ messages in thread
From: Jiri Slaby @ 2022-01-11 7:08 UTC (permalink / raw)
To: Sherry Sun, gregkh; +Cc: linux-serial, linux-kernel, linux-imx
On 11. 01. 22, 7:10, Sherry Sun wrote:
> Added support for counting the tty buffer overruns in fsl_lpuart driver
> like other uart drivers.
>
> Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
> ---
> drivers/tty/serial/fsl_lpuart.c | 19 +++++++++++++------
> 1 file changed, 13 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
> index ce3e26144689..1e6f924d8507 100644
> --- a/drivers/tty/serial/fsl_lpuart.c
> +++ b/drivers/tty/serial/fsl_lpuart.c
...
> @@ -1117,6 +1119,7 @@ static void lpuart_copy_rx_to_tty(struct lpuart_port *sport)
> struct circ_buf *ring = &sport->rx_ring;
> unsigned long flags;
> int count = 0;
> + unsigned int copied = 0;
>
> if (lpuart_is_32(sport)) {
> unsigned long sr = lpuart32_read(&sport->port, UARTSTAT);
> @@ -1218,20 +1221,24 @@ static void lpuart_copy_rx_to_tty(struct lpuart_port *sport)
> if (ring->head < ring->tail) {
> count = sport->rx_sgl.length - ring->tail;
>
> - tty_insert_flip_string(port, ring->buf + ring->tail, count);
> + copied = tty_insert_flip_string(port, ring->buf + ring->tail, count);
> + if (copied != count)
Overall looks good, except tty_insert_flip_string returns an int and
count is also an int. Wouldn't it be more consistent to declare copied
as int too? This comparison would be without implicit conversion then.
thanks,
--
js
suse labs
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH] tty: serial: fsl_lpuart: count tty buffer overruns
2022-01-11 7:08 ` Jiri Slaby
@ 2022-01-11 8:06 ` Sherry Sun
0 siblings, 0 replies; 3+ messages in thread
From: Sherry Sun @ 2022-01-11 8:06 UTC (permalink / raw)
To: Jiri Slaby, gregkh; +Cc: linux-serial, linux-kernel, dl-linux-imx
Hi Jiri,
> > Added support for counting the tty buffer overruns in fsl_lpuart
> > driver like other uart drivers.
> >
> > Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
> > ---
> > drivers/tty/serial/fsl_lpuart.c | 19 +++++++++++++------
> > 1 file changed, 13 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/tty/serial/fsl_lpuart.c
> > b/drivers/tty/serial/fsl_lpuart.c index ce3e26144689..1e6f924d8507
> > 100644
> > --- a/drivers/tty/serial/fsl_lpuart.c
> > +++ b/drivers/tty/serial/fsl_lpuart.c
> ...
> > @@ -1117,6 +1119,7 @@ static void lpuart_copy_rx_to_tty(struct
> lpuart_port *sport)
> > struct circ_buf *ring = &sport->rx_ring;
> > unsigned long flags;
> > int count = 0;
> > + unsigned int copied = 0;
> >
> > if (lpuart_is_32(sport)) {
> > unsigned long sr = lpuart32_read(&sport->port, UARTSTAT);
> @@
> > -1218,20 +1221,24 @@ static void lpuart_copy_rx_to_tty(struct lpuart_port
> *sport)
> > if (ring->head < ring->tail) {
> > count = sport->rx_sgl.length - ring->tail;
> >
> > - tty_insert_flip_string(port, ring->buf + ring->tail, count);
> > + copied = tty_insert_flip_string(port, ring->buf + ring->tail,
> count);
> > + if (copied != count)
>
> Overall looks good, except tty_insert_flip_string returns an int and count is
> also an int. Wouldn't it be more consistent to declare copied as int too? This
> comparison would be without implicit conversion then.
Sure, that's reasonable, I will change it to int type in the V2 patch. Thanks!
Best regards
Sherry
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-01-11 8:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-11 6:10 [PATCH] tty: serial: fsl_lpuart: count tty buffer overruns Sherry Sun
2022-01-11 7:08 ` Jiri Slaby
2022-01-11 8:06 ` Sherry Sun
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).