Subject: Re: Re: More com driver changes; need testers
To: Markus Kilbinger <kilbi@rad.rwth-aachen.de>
From: Andreas Gustafsson <gson@araneus.fi>
List: port-i386
Date: 05/01/1997 16:46:46
Markus Kilbinger <kilbi@rad.rwth-aachen.de> said:
> Hmm, I tried the patch, but it didn't change anything obviously. There
> are still lost chars on output decreasing dramatically the final
> transmission rate even at a serial speed down to 38400 baud.

I was also recently suffering from lost output characters on a com
port, after upgrading (!) the port from a 16450 to a 16550.  

The reason for this lossage appears to be that the com driver always
fills the _whole_ 16550 output FIFO with data whenever it gets a
"transmitter ready" interrupt.  Since there is no way of stopping
transmission of the data once it has been loaded into the FIFO, it
means that if CTS drops immediately after the FIFO has been filled, 
up to 16 characters will still be transmitted before the flow control 
takes effect.  This is more than enough to overflow the input buffer on 
some devices.

I see no way around this problem other than reducing the amount of
data loaded into the FIFO on each transmit interrupt.  On my own
system, I simply reduced it to a single character; that cured the
problem for me.  Here's the patch I'm using (against the stock
1.2 com.c):

*** com.c.old	Tue Dec  3 20:46:36 1996
--- com.c	Mon Apr 21 19:47:55 1997
***************
*** 1038,1040 ****
  	if (ISSET(sc->sc_hwflags, COM_HW_FIFO)) {
! 		u_char buffer[16], *cp = buffer;
  		int n = q_to_b(&tp->t_outq, cp, sizeof buffer);
--- 1038,1040 ----
  	if (ISSET(sc->sc_hwflags, COM_HW_FIFO)) {
! 		u_char buffer[1], *cp = buffer;
  		int n = q_to_b(&tp->t_outq, cp, sizeof buffer);

You may wonder why I haven't PR:ed this problem.  In fact I already
did, on April 21, but my PR was erased by a bug in send-pr (see PR
#2530 for the PR on the bug that erased my PR).  This was such a
frustrating experience that I have only now been able to work up the
energy to report the bug all over again.  

I am still disgusted at the nonchalant attitude shown by the core team
towards a bug which not only causes user data to be irretrievably
lost, but which affects a particular kind of data - bug reports -
which _should_ be considered vitally important to NetBSD's success.
-- 
Andreas Gustafsson, gson@araneus.fi