tty: serial: fsl_lpuart: count tty buffer overruns
PATCH 1/1 tty: serial: fsl_lpuart: count tty buffer overruns
Added support for counting the tty buffer overruns in fsl_lpuart driver like other uart drivers.
--- drivers/tty/serial/fsl_lpuart.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
drivers/tty/serial/fsl_lpuart.c +13 -6
@@ -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:
Signature · 1 line
2.17.1
Jiri Slaby
maintainerQuoted 12 lines · Sherry Sun
Added support for counting the tty buffer overruns in
fsl_lpuartdriver like other uart drivers.Signed-off-by Sherry Sun <[email protected]>--- drivers/tty/serial/fsl_lpuart.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)drivers/tty/serial/fsl_lpuart.c +0
-0
...
Quoted 9 lines
drivers/tty/serial/fsl_lpuart.c +1
-0@@ -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 );
drivers/tty/serial/fsl_lpuart.c static void lpuart_copy_rx_to_tty(struct lpuart_port *sport) · line 1225
Quoted 6 lines
drivers/tty/serial/fsl_lpuart.c +2
-1@@ -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,
Signature · 2 lines
js suse labs
Hi Jiri,
Quoted 29 lines
Quoted 13 lines
Added support for counting the tty buffer overruns in
fsl_lpuartdriver like other uart drivers.Signed-off-by Sherry Sun <[email protected]>--- drivers/tty/serial/fsl_lpuart.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)(quoted diff) +0
-0
b/drivers/tty/serial/fsl_lpuart.cindexce3e26144689..1e6f924d8507100644drivers/tty/serial/fsl_lpuart.c +0
-0...
drivers/tty/serial/fsl_lpuart.c static void lpuart_copy_rx_to_tty(struct
Quoted 1 line
drivers/tty/serial/fsl_lpuart.c +0
-0@@ -1117,6 +1119,7 @@ static void lpuart_copy_rx_to_tty(struct
lpuart_port*sport)drivers/tty/serial/fsl_lpuart.c static void lpuart_copy_rx_to_tty(struct lpuart_port *sport) · line 1125
Quoted 7 lines
drivers/tty/serial/fsl_lpuart.c +1
-0struct 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 );@@
Quoted 1 line
-1218,20 +1221,24 @@ static void lpuart_copy_rx_to_tty(struct
lpuart_port*sport)
Quoted 3 lines
if (ring->head < ring->tail) { count = sport->rx_sgl.length - ring->tail;
Quoted 8 lines
drivers/tty/serial/fsl_lpuart.c
Quoted 2 lines
drivers/tty/serial/fsl_lpuart.c +1
-1-tty_insert_flip_string (port, ring->buf + ring->tail, count); + copied = tty_insert_flip_string(port, ring->buf + ring->tail,count);
drivers/tty/serial/fsl_lpuart.c
Quoted 1 line
drivers/tty/serial/fsl_lpuart.c +1
-0+if (copied != count)Overall looks good, except
tty_insert_flip_stringreturns 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