Subject: general {82,164,165}50 UART driver
To: None <tech-kern@NetBSD.ORG>
From: Onno van der Linden <>
List: tech-kern
Date: 05/29/1996 21:13:44
After Chris' justified complaints about the i386ness of an ISA serial driver
that I made available for anonymous ftp I gave it some thoughts.

Here are a couple of remarks about a NetBSD driver for the {82,164,165}50 UART.
Four ports currently use this chip: i386, hp300, alpha and amiga with zorro(?)

The first step is to split the driver up into chip specific and
bus specific parts. John Kohl has already done this.

The second step is to get maximum performance out of the driver on *all*
the ports. There are basically three strategies for the handling of
a serial interrupt:
(1) handle *everything* in the interrupt routine itself.
    hp300 uses this strategy. i386 used to do this until 1.1.
(2) receive the data, put it in queue and let a higher level
    routine handle the rest (mainly line->l_rint). compoll()
    is the higher level routine that does this. It's periodically
    called from softclock() and reads all the queues for all the
    serial lines and put the contents into the buffers at the tty layer.
    the current isa driver in /sys/dev/isa/com.c uses this strategy.
(3) receive the data, put it in a queue and generate a software interrupt
    (setsofttty()). comsoft() is the higher level routine that handles
    this software interrupt. It checks all the queues etc. etc.
    the serial driver available from uses this strategy

(1) is out of the question on i386 because it drops too many characters
at higher speeds.
(2) is possible for all ports. Currently the isa driver isn't receiving
data at a high enough intr level for the i386 to handle higher speeds well.
(3) is currently not possible on the alpha. They have no such thing as
setsofttty(). There's however support in /sys/arch/alpha/alpha/machdep.c
for software interrupts in the do_sir routine.

A big question about the "higher level" routine (compoll() or comsoft())
still is whether to run at spltty() for most of the time (just like the
z8530 driver) or to minimize it like the current isa driver.

(1) define IPL_SER (interrupt level for the serial driver) for each
    architecture. IPL_SER would be IPL_HIGH on the i386.
    run the interrupt routine at IPL_SER.

(2a) change my driver (the one on to use the 
     softclock interrupt routine for comsoft() instead of
     the tty software interrupt.

(2b) if possible, add a bit of code to alpha/machdep.c for tty software
     interrupts in do_sir() and call comsoft() from there.
     It looks like the hp300 needs this too.

Should I go for (2a) or (2b) ?
Which is "better" 'software interrupts' or 'periodic checks via softclock()' ?