2022-07-15 03:18:49

by Sherry Sun

[permalink] [raw]
Subject: [PATCH 0/2] fsl_lpuart: fix the bugs in received break signal count and send break signal

This patchset fix some issues in the received break characters counts and send
break character in the lpuart driver.

Sherry Sun (2):
tty: serial: fsl_lpuart: correct the count of break characters
tty: serial: fsl_lpuart: writing a 1 and then a 0 to trigger a break
character

drivers/tty/serial/fsl_lpuart.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

--
2.17.1


2022-07-15 03:22:29

by Sherry Sun

[permalink] [raw]
Subject: [PATCH 1/2] tty: serial: fsl_lpuart: correct the count of break characters

The LPUART can't distinguish between a break signal and a framing error,
so need to count the break characters if there is a framing error and
received data is zero instead of the parity error.

Fixes: 5541a9bacfe5 ("serial: fsl_lpuart: handle break and make sysrq work")
Signed-off-by: Sherry Sun <[email protected]>
---
drivers/tty/serial/fsl_lpuart.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index fc7d235a1e27..b6365566a460 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -990,12 +990,12 @@ static void lpuart32_rxint(struct lpuart_port *sport)

if (sr & (UARTSTAT_PE | UARTSTAT_OR | UARTSTAT_FE)) {
if (sr & UARTSTAT_PE) {
+ sport->port.icount.parity++;
+ } else if (sr & UARTSTAT_FE) {
if (is_break)
sport->port.icount.brk++;
else
- sport->port.icount.parity++;
- } else if (sr & UARTSTAT_FE) {
- sport->port.icount.frame++;
+ sport->port.icount.frame++;
}

if (sr & UARTSTAT_OR)
@@ -1010,12 +1010,12 @@ static void lpuart32_rxint(struct lpuart_port *sport)
sr &= sport->port.read_status_mask;

if (sr & UARTSTAT_PE) {
+ flg = TTY_PARITY;
+ } else if (sr & UARTSTAT_FE) {
if (is_break)
flg = TTY_BREAK;
else
- flg = TTY_PARITY;
- } else if (sr & UARTSTAT_FE) {
- flg = TTY_FRAME;
+ flg = TTY_FRAME;
}

if (sr & UARTSTAT_OR)
--
2.17.1

2022-07-15 07:02:21

by Michael Walle

[permalink] [raw]
Subject: Re: [PATCH 1/2] tty: serial: fsl_lpuart: correct the count of break characters

Am 2022-07-15 04:59, schrieb Sherry Sun:
> The LPUART can't distinguish between a break signal and a framing
> error,
> so need to count the break characters if there is a framing error and
> received data is zero instead of the parity error.

Ah, it seems I mixed up the framing and the partiy error. Did you test
the break in the receive path, though?

-michael

>
> Fixes: 5541a9bacfe5 ("serial: fsl_lpuart: handle break and make sysrq
> work")
> Signed-off-by: Sherry Sun <[email protected]>
> ---
> drivers/tty/serial/fsl_lpuart.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/tty/serial/fsl_lpuart.c
> b/drivers/tty/serial/fsl_lpuart.c
> index fc7d235a1e27..b6365566a460 100644
> --- a/drivers/tty/serial/fsl_lpuart.c
> +++ b/drivers/tty/serial/fsl_lpuart.c
> @@ -990,12 +990,12 @@ static void lpuart32_rxint(struct lpuart_port
> *sport)
>
> if (sr & (UARTSTAT_PE | UARTSTAT_OR | UARTSTAT_FE)) {
> if (sr & UARTSTAT_PE) {
> + sport->port.icount.parity++;
> + } else if (sr & UARTSTAT_FE) {
> if (is_break)
> sport->port.icount.brk++;
> else
> - sport->port.icount.parity++;
> - } else if (sr & UARTSTAT_FE) {
> - sport->port.icount.frame++;
> + sport->port.icount.frame++;
> }
>
> if (sr & UARTSTAT_OR)
> @@ -1010,12 +1010,12 @@ static void lpuart32_rxint(struct lpuart_port
> *sport)
> sr &= sport->port.read_status_mask;
>
> if (sr & UARTSTAT_PE) {
> + flg = TTY_PARITY;
> + } else if (sr & UARTSTAT_FE) {
> if (is_break)
> flg = TTY_BREAK;
> else
> - flg = TTY_PARITY;
> - } else if (sr & UARTSTAT_FE) {
> - flg = TTY_FRAME;
> + flg = TTY_FRAME;
> }
>
> if (sr & UARTSTAT_OR)

--
-michael

2022-07-15 07:51:49

by Sherry Sun

[permalink] [raw]
Subject: RE: [PATCH 1/2] tty: serial: fsl_lpuart: correct the count of break characters



> Subject: Re: [PATCH 1/2] tty: serial: fsl_lpuart: correct the count of break
> characters
>
> Am 2022-07-15 04:59, schrieb Sherry Sun:
> > The LPUART can't distinguish between a break signal and a framing
> > error, so need to count the break characters if there is a framing
> > error and received data is zero instead of the parity error.
>
> Ah, it seems I mixed up the framing and the partiy error. Did you test the
> break in the receive path, though?
>

Hi Michael, yes, I have tested this, with this fix patch, the sport->port.icount.brk is correctly now.

Best regards
Sherry

> -michael
>
> >
> > Fixes: 5541a9bacfe5 ("serial: fsl_lpuart: handle break and make sysrq
> > work")
> > Signed-off-by: Sherry Sun <[email protected]>
> > ---
> > drivers/tty/serial/fsl_lpuart.c | 12 ++++++------
> > 1 file changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/tty/serial/fsl_lpuart.c
> > b/drivers/tty/serial/fsl_lpuart.c index fc7d235a1e27..b6365566a460
> > 100644
> > --- a/drivers/tty/serial/fsl_lpuart.c
> > +++ b/drivers/tty/serial/fsl_lpuart.c
> > @@ -990,12 +990,12 @@ static void lpuart32_rxint(struct lpuart_port
> > *sport)
> >
> > if (sr & (UARTSTAT_PE | UARTSTAT_OR | UARTSTAT_FE)) {
> > if (sr & UARTSTAT_PE) {
> > + sport->port.icount.parity++;
> > + } else if (sr & UARTSTAT_FE) {
> > if (is_break)
> > sport->port.icount.brk++;
> > else
> > - sport->port.icount.parity++;
> > - } else if (sr & UARTSTAT_FE) {
> > - sport->port.icount.frame++;
> > + sport->port.icount.frame++;
> > }
> >
> > if (sr & UARTSTAT_OR)
> > @@ -1010,12 +1010,12 @@ static void lpuart32_rxint(struct lpuart_port
> > *sport)
> > sr &= sport->port.read_status_mask;
> >
> > if (sr & UARTSTAT_PE) {
> > + flg = TTY_PARITY;
> > + } else if (sr & UARTSTAT_FE) {
> > if (is_break)
> > flg = TTY_BREAK;
> > else
> > - flg = TTY_PARITY;
> > - } else if (sr & UARTSTAT_FE) {
> > - flg = TTY_FRAME;
> > + flg = TTY_FRAME;
> > }
> >
> > if (sr & UARTSTAT_OR)
>
> --
> -michael

2022-07-15 13:07:04

by Michael Walle

[permalink] [raw]
Subject: Re: [PATCH 1/2] tty: serial: fsl_lpuart: correct the count of break characters

Am 2022-07-15 04:59, schrieb Sherry Sun:
> The LPUART can't distinguish between a break signal and a framing
> error,
> so need to count the break characters if there is a framing error and
> received data is zero instead of the parity error.
>
> Fixes: 5541a9bacfe5 ("serial: fsl_lpuart: handle break and make sysrq
> work")
> Signed-off-by: Sherry Sun <[email protected]>

Reviewed-by: Michael Walle <[email protected]>

-michael