Subject: Re: Serial port driver
To: None <port-i386@NetBSD.ORG>
From: D'Arcy J.M. Cain <darcy@druid.net>
List: port-i386
Date: 05/19/1997 19:22:26
Thus spake Onno van der Linden
> 'people' most certainly includes me, and when I made my first
> patches (based on message from Bill Wells to current-users) I was
> able to do 115200 bps on a null modem cable between two 486DX2's
> that had 8250s in 'em.

I'm getting overflows at 28.8K on a DX2/66 486.

> If I remember it correctly (Frank ?) it's also possible
> to get overflows when
> (1) there's a network connection between two machines with lots of traffic
>     (e.g. an ftp session) and
> (2) at the same time you transfer data at 115200 bps (e.g. termcap.db)
>     between these machines.

The system has two ethernet cards and there is a fair amount of traffic
but it still seems odd that it can't handle a 28.8K connection.

> The serial driver runs at IPL_SERIAL (see <machine/intr.h> and isa_machdep.c)
> which blocks all the other interrupts. The comintr() routine puts the
> received data in a ring buffer that is handled at SOFT_SERIAL (a soft
> interrupt that is scheduled via a call to setsoftserial()) and quits
> as soon as possible.

I wonder about the following bit of code in that routine:

            /*
             * If we're out of space, throw away any further input.
             */
            if (!cc) {
                while (ISSET(lsr, LSR_RCV_MASK)) {
                    bus_space_read_1(iot, ioh, com_data);
                    lsr = bus_space_read_1(iot, ioh,
                                com_lsr);
                }

Now I realize that the test is pretty much guaranteed to fail with a 2K
ring buffer so this code won't be called very often but I wonder why we
even bother testing at all.  If there is an overflow then the on-chip
buffer will overflow and eventually we'll get garbage in when we go
back to the chip.  We're going to get that anyway if we don't get the
character we should have got so why bother making this test for each
character (or string of characters?)  I don't know if it will improve
much but it can't hurt as far as I can see and it may help.  I haven't
checked the assembler output but from scanning the source it looks like
it can't count on it being in a register so it is a memory access to
test for zero.  That's 5 clocks that we don't need to waste. (*)

> One request at the end of all this: if someone still has problems
> with overflows on x86 machines can they please give a very accurate
> description of the situation (software, hardware and processes that
> are running) in which the overflows occur.

Well, besides what I mentioned above, this is a gateway machine with one
28.8K PPP user.  It is running routed and not much else.  No web, ftp or
logins except for maintenance by me.

(*) In fact a quick check seems to indicate the situation is worse than
that.  If I am following the code correctly, there is a move and an and
before the test.  Does anyone know how to output C code as comments into
assembler output using the -S option to gcc?

-- 
D'Arcy J.M. Cain                           |  Democracy is three wolves
darcy@{druid.net|vex.net}                  |  and a sheep voting on         
+1 416 424 2871     (DoD#0082)    (eNTP)   |  what's for dinner.
                --  http://www.druid.net/darcy  --