atmel_serial: receive data lost in RS485 mode

From: Ronald Wahl
Date: Thu Jun 23 2011 - 06:15:29 EST


Hi,

on our AT91 board we use the RS485 mode on the serial port and noticed some data loss in some circumstances. (kernel 2.6.38.7)

What happens is the following: When starting TX the RX part is disabled:

atmel_start_tx():
...
if (atmel_port->rs485.flags & SER_RS485_ENABLED)
atmel_stop_rx(port);
...

When TX is done it is enabled again:

atmel_tx_dma():
...
if (atmel_port->rs485.flags & SER_RS485_ENABLED) {
/* DMA done, stop TX, start RX for RS485 */
atmel_start_rx(port);
}
...

Since the RS485 mode is only half duplex this looks ok (or at least not wrong) at the first glance but it only works if RX is enabled synchronously when TX is done. Actually it happens under some circumstances that there is a latency between TX done and enabling RX again. All data received during that time is lost.

So the question is: Why disabling RX at all during TX? I can't see any benefit. I removed this two code parts above and all works perfectly well and no data is lost anymore.

greets,
ron

PS: I'm not on the list - please keep me in Cc. Thx!

--
Ronald Wahl - ronald.wahl@xxxxxxxxxxx - Phone +49 375271349-0 Fax -99
Raritan Deutschland GmbH, Kornmarkt 7, 08056 Zwickau, Germany
USt-IdNr. DE813094160, Steuer-Nr. 227/117/01749
Amtsgericht Chemnitz HRB 23605
GeschÃftsfÃhrung: Stuart Hopper, Burkhard Wessler
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/