drivers/tty/serial/fsl_lpuart.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)
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>
---
changes in V2
1. Change the copied type to int to avoid implicit conversion, as the
tty_insert_flip_string return type is int.
---
drivers/tty/serial/fsl_lpuart.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index ce3e26144689..82a1a2817750 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:
@@ -1116,7 +1118,7 @@ static void lpuart_copy_rx_to_tty(struct lpuart_port *sport)
struct dma_chan *chan = sport->dma_rx_chan;
struct circ_buf *ring = &sport->rx_ring;
unsigned long flags;
- int count = 0;
+ int count = 0, copied = 0;
if (lpuart_is_32(sport)) {
unsigned long sr = lpuart32_read(&sport->port, UARTSTAT);
@@ -1218,20 +1220,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
On 11. 01. 22, 9:22, 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> > > --- > changes in V2 > 1. Change the copied type to int to avoid implicit conversion, as the > tty_insert_flip_string return type is int. > --- > drivers/tty/serial/fsl_lpuart.c | 20 +++++++++++++------- > 1 file changed, 13 insertions(+), 7 deletions(-) > > diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c > index ce3e26144689..82a1a2817750 100644 > --- a/drivers/tty/serial/fsl_lpuart.c > +++ b/drivers/tty/serial/fsl_lpuart.c ... > @@ -1116,7 +1118,7 @@ static void lpuart_copy_rx_to_tty(struct lpuart_port *sport) > struct dma_chan *chan = sport->dma_rx_chan; > struct circ_buf *ring = &sport->rx_ring; > unsigned long flags; > - int count = 0; > + int count = 0, copied = 0; Why is it necessary to initialize copied? Actually neither count needs to be initialized AFAICT. Care to fix that too (in a separate patch). thanks, -- js suse labs
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> > > > > --- > > changes in V2 > > 1. Change the copied type to int to avoid implicit conversion, as the > > tty_insert_flip_string return type is int. > > --- > > drivers/tty/serial/fsl_lpuart.c | 20 +++++++++++++------- > > 1 file changed, 13 insertions(+), 7 deletions(-) > > > > diff --git a/drivers/tty/serial/fsl_lpuart.c > > b/drivers/tty/serial/fsl_lpuart.c index ce3e26144689..82a1a2817750 > > 100644 > > --- a/drivers/tty/serial/fsl_lpuart.c > > +++ b/drivers/tty/serial/fsl_lpuart.c > ... > > @@ -1116,7 +1118,7 @@ static void lpuart_copy_rx_to_tty(struct > lpuart_port *sport) > > struct dma_chan *chan = sport->dma_rx_chan; > > struct circ_buf *ring = &sport->rx_ring; > > unsigned long flags; > > - int count = 0; > > + int count = 0, copied = 0; > > Why is it necessary to initialize copied? > > Actually neither count needs to be initialized AFAICT. Care to fix that too (in a > separate patch). > You are right, actually here the initialization for copied is not necessary. I will remove it in V3. For the initialization for count, I can send another patch to remove it. Best regards Sherry
© 2016 - 2026 Red Hat, Inc.