Hello,
I wrote a program that reads from the serial port as fast as it can, and I
noticed that I was losing bytes. I figured it was because I didn't have
flow controlled turned on, but after turning on RTSCTS flow control I am
still losing bytes. I checked the uart with a logic analyzer, and it is
funtioning properly (i.e. the RTS and CTS lines are asserted properly and
in a timely manner).
I started perusing the source code and I ran across this in
drivers/char/serial.c (kernel 2.2.5)
static _INLINE_ void receive_chars(struct async_struct *info, int *status)
{
struct tty_struct *tty = info->tty;
unsigned char ch;
int ignored = 0;
struct async_icount *icount;
icount =
&info->state->icount;
do {
HERE--> ch = serial_inp(info,
UART_RX);
HERE--> if (tty->flip.count >= TTY_FLIPBUF_SIZE)
HERE-->
break;
*tty->flip.char_buf_ptr = ch;
icount->rx++;
. . .
This is the begining of the function that reads the characters from the
uart after receiving an interrupt. If you notice the lines labeled with HERE
you will see that the character is read from the uart, ttty->flip.count is
checked to see if the flip buffer is full, and if it is the function breaks
out of the loop, losing the character it just read from the uart. I changed
the code to increment a counter if I reach the state where I have to break
out of this loop, and I am losing on average a 100 bytes to this per
1,000,000 bytes. I realize that this isn't a large percentage, but as the
processor gets busier or the baud rate increases I am losing more bytes.
With flow control on I would expect to never drop any bytes.
Increasing the size of the flip buffer does not help, and you have to be
careful doing that any way per TYT's comment on the tty_struct.
/*
* Where all of the state associated with a tty is kept while the tty
[non relavent lines DELETED]
* size each time the window is created or
resized anyway.
* IMPORTANT: since this structure is dynamically
allocated, it must
* be no larger than 4096 bytes. Changing
TTY_FLIPBUF_SIZE will change
* the size of this structure, and it needs to
be done with care.
* - TYT, 9/14/92
*/
Any help, comments or suggestions would be appreciated.
I almost forgot here are the numbers.
I am losing bytes at 115200, 230400, and 460800, and
I am using an EXAR 16C864IQ. The driver code has also been slightly
modified to
take advantage of the deeper fifos on the UART.
I am subscribed to the list so you can answer to the list or directly to me
whichever is easier.
Thanks,
Dudley Fox
-
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to [EMAIL PROTECTED]