All of lore.kernel.org
 help / color / mirror / Atom feed
* Minimal patch against TI AM335x UART swallowing the first byte using the 8250_omap driver in RS485 mode
@ 2019-11-08 14:41 Falco Hyfing
  2019-11-08 15:45 ` Marek Vasut
  0 siblings, 1 reply; 2+ messages in thread
From: Falco Hyfing @ 2019-11-08 14:41 UTC (permalink / raw)
  To: linux-omap, linux-serial
  Cc: Marek Vasut, giulio.benetti, aford173, andrej.skvortzov, sr,
	rafael.gago, avistel, matwey.kornilov, yegorslists

I stumbled upon this unresolved issue where the TI AM335x UART is 
sporadically swallowing the first byte using the 8250_omap driver in 
RS485 mode.

Previous discussions of the issue ended on Christmas Eve last year. For 
reference:
https://marc.info/?w=2&r=1&s=fix+clearing+fifos+rs485+mode+again&q=t

As our company plans to move our serial device servers' firmware to an 
upstream kernel version we need a solution for this problem.

I appended a small patch that seems to resolve the issue for our products.

I would like to kindly ask whether you could test this patch with 
various serial hardware that would be affected by this driver.

Kind regards,

     Falco Hyfing
     Software Engineer at VisionSystems GmbH


diff --git a/drivers/tty/serial/8250/8250_port.c 
b/drivers/tty/serial/8250/8250_port.c
index 8407166610ce..25dd44d5f6ff 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -1405,7 +1405,8 @@ static void __do_stop_tx_rs485(struct 
uart_8250_port *p)
          * Enable previously disabled RX interrupts.
          */
         if (!(p->port.rs485.flags & SER_RS485_RX_DURING_TX)) {
-               serial8250_clear_and_reinit_fifos(p);
+               serial_port_out(&p->port, UART_FCR, p->fcr |
+                               UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT);

                 p->ier |= UART_IER_RLSI | UART_IER_RDI;
                 serial_port_out(&p->port, UART_IER, p->ier);


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: Minimal patch against TI AM335x UART swallowing the first byte using the 8250_omap driver in RS485 mode
  2019-11-08 14:41 Minimal patch against TI AM335x UART swallowing the first byte using the 8250_omap driver in RS485 mode Falco Hyfing
@ 2019-11-08 15:45 ` Marek Vasut
  0 siblings, 0 replies; 2+ messages in thread
From: Marek Vasut @ 2019-11-08 15:45 UTC (permalink / raw)
  To: Falco Hyfing, linux-omap, linux-serial
  Cc: giulio.benetti, aford173, andrej.skvortzov, sr, rafael.gago,
	avistel, matwey.kornilov, yegorslists, Greg Kroah-Hartman

On 11/8/19 3:41 PM, Falco Hyfing wrote:

Hi,

> I stumbled upon this unresolved issue where the TI AM335x UART is
> sporadically swallowing the first byte using the 8250_omap driver in
> RS485 mode.
> 
> Previous discussions of the issue ended on Christmas Eve last year. For
> reference:
> https://marc.info/?w=2&r=1&s=fix+clearing+fifos+rs485+mode+again&q=t

Right, I'm sorry for not following up on that thread anymore. I was ill
during that time and I didn't have the energy to counter all those
negative emails. So thanks for picking this up.

I think the issue is a generic one though, and affects various other
16550 UARTs, it's not isolated to the OMAP UART, which is why I patched
the generic code. I think if we could solve the quirk of that JZ4780
UART, the generic approach would work.

> As our company plans to move our serial device servers' firmware to an
> upstream kernel version we need a solution for this problem.
> 
> I appended a small patch that seems to resolve the issue for our products.
> 
> I would like to kindly ask whether you could test this patch with
> various serial hardware that would be affected by this driver.
> 
> Kind regards,
> 
>     Falco Hyfing
>     Software Engineer at VisionSystems GmbH
> 
> 
> diff --git a/drivers/tty/serial/8250/8250_port.c
> b/drivers/tty/serial/8250/8250_port.c
> index 8407166610ce..25dd44d5f6ff 100644
> --- a/drivers/tty/serial/8250/8250_port.c
> +++ b/drivers/tty/serial/8250/8250_port.c
> @@ -1405,7 +1405,8 @@ static void __do_stop_tx_rs485(struct
> uart_8250_port *p)
>          * Enable previously disabled RX interrupts.
>          */
>         if (!(p->port.rs485.flags & SER_RS485_RX_DURING_TX)) {
> -               serial8250_clear_and_reinit_fifos(p);
> +               serial_port_out(&p->port, UART_FCR, p->fcr |
> +                               UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT);
> 
>                 p->ier |= UART_IER_RLSI | UART_IER_RDI;
>                 serial_port_out(&p->port, UART_IER, p->ier);
> 


-- 
Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-11-08 15:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-08 14:41 Minimal patch against TI AM335x UART swallowing the first byte using the 8250_omap driver in RS485 mode Falco Hyfing
2019-11-08 15:45 ` Marek Vasut

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.