Linux-kernel mailing list archive 1999-41,: serial.c (race?)

# serial.c (race?)

kees (kees@schoen.nl)
Fri, 15 Oct 1999 19:30:10 +0200 (MEST)

- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Next message: Philip Blundell: "Re: D-Link DFE 530-TX 10/100"
- Previous message: Riley Williams: "Re: Linux 2.3.21 Gripes."

Hi,

I ran into an effect which might be a race in the serial drivers of
2.2.12. I run a program which communicates via the Hart protocol. This is
a simplex protocol and uses the IO port more or less like RS485.

The basic function to communicate does:
- open the port
- write a few bytes (about 10) with single writes to the port
- test for the transmitter register empty bit in the LSR with an
ioctl call
- drop RTS so that the Hart modem goes from Xmit to Rcv.
- collect data with single reads each after a poll call, to detect
timeouts and interrupted data stream
- close the port

With various machines: 130 MHz Pentium, 200 Mhz-K6 this worked always
with ports with an 16450 chip, like a fourport ttyS4..S7. It NEVER worked
on ttyS0/ttyS1 which were 16550A chips.

Some checking and putting DEBUG flags in ../drivers/char/serial.c showed
in the logs that the Xmit cycle completed but NO data was received. In my
program I added a check BEFORE the rts drop which tested the status of the
Transmitter Empty bit: it was set!!.

For me this means that on a sufficient fast machine even when there is
already data in the output buffers there is no reliable check to see if
all this data is processed.

I added a check in my program after the first write call to wait for the
drop of the Transmitter Empty bit first before to proceed. That worked.

This effect would also cause trouble for real RS485 applications.
I believe that for the return status of Transmitter Register Empty also
the output buffer should be checked.

The effect was fully reproducable.

Kees

BTW: should it be possible to downgrade the port with setserial?
I tried to use setserial to set uart to 16450 on a real 16550A
but then nothing worked...

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

- Next message: Philip Blundell: "Re: D-Link DFE 530-TX 10/100"
- Previous message: Riley Williams: "Re: Linux 2.3.21 Gripes."