lkml.org 
[lkml]   [1998]   [Jan]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectNo subject given

Hi there,
I am trying to understand the tty subsystem of the kernel as I am
responsible for a serial multiport card. Please bear with me as this
is long!.

Based on a customer report that we were losing data on some of our
ports when the system is operating at full loads and in this
particular case,the system was a Pentium Pro with 256M of memory
trying to run about 256 ports, I was able to reproduce the problem on
my 75Mhz machine at much lower number of ports obviously. So I started
to look at the driver code to see if I was doing anything wrong and I
have not been able to find anything that is different from the way the
other serial drivers are written (I chose serial.c as the model when
developing the driver originally).

At this point I started to look at the kernel source (tty_io.c and
n_tty.c) and saw that it was possible to lose data when
"flush_to_ldisc" (tty_io.c) calls "tty->ldisc.receive_buf" and never
really checks the "count variable" to see how much has been written to
tty->read_buf buffer. Here's the code for our receive char routine,

.......
.......
.......
rcv_cnt = MIN(rcv_cnt, (TTY_FLIPBUF_SIZE - tty->flip.count));
.......
.......
....... more processing, fills up char_buf and flag_buf, count etc
.....
.......
.......
queue_task(&tt->flip.tqueue, &tq_timer);

So looking at the kernel source, I guess I have to do the
following as well (i.e check the read_buf in the line discipline)


rcv_cnt = MIN(rcv_cnt, MIN(N_TTY_BUF_SIZE - tty->read_cnt,
N_TTY_BUF_SIZE - tty_read_head));


I did this also even though the other serial drivers are not
doing but this did not help either and I was still losing data at the
"n_tty_receive_buf" function (Verified this by printing the value of
count variable at the end of the function). So this means that the
values of tty->read_cnt and tty->read_head is not being protected when
they are being referenced. Our driver is a polled driver and the input
routine is driven of the polling routine. Is'nt the tqueue structure
"tq_timer" list also scanned at the timer interrupt and are the
variables protected from the poll routine.

I would really appreciate if anybody can point out to any
misunderstanding on my part and suggest any changes that has to be
done.

Thank you
Shashi

shashi@equinox.com



\
 
 \ /
  Last update: 2005-03-22 13:41    [from the cache]
©2003-2011 Jasper Spaans