I have the following puc(4) device in a net5501 soekris:

puc0 at pci0 dev 14 function 0 "NetMos Nm9865" rev 0x00: ports: 1 com
com3 at puc0 port 0 irq 10: st16650, 32 byte fifo
puc1 at pci0 dev 14 function 1 "NetMos Nm9865" rev 0x00: ports: 1 com
com4 at puc1 port 0 irq 15: st16650, 32 byte fifo

It's a single PCI card with two com ports.

This card is causing the kernel to hang during boot when ttyflags -a is run.
The hang happens as soon as one of the com ports of the card is opened.
E.g. cat /dev/tty03 > /dev/null also triggers it (tested in single user mode).

Turns out that this loop in comopen() never finishes:

                        /*
                         * (Re)enable and drain FIFOs.
                         *
                         * Certain SMC chips cause problems if the FIFOs are
                         * enabled while input is ready. Turn off the FIFO
                         * if necessary to clear the input. Test the input
                         * ready bit after enabling the FIFOs to handle races
                         * between enabling and fresh input.
                         *
                         * Set the FIFO threshold based on the receive speed.
                         */
                        for (;;) {
                                bus_space_write_1(iot, ioh, com_fifo, 0);
                                delay(100);
                                (void) bus_space_read_1(iot, ioh, com_data);
                                bus_space_write_1(iot, ioh, com_fifo, fifo |
                                    FIFO_RCV_RST | FIFO_XMT_RST);
                                delay(100);
                                if(!ISSET(bus_space_read_1(iot, ioh,
                                    com_lsr), LSR_RXRDY))
                                        break;
                        }

It's possible that there is a hardware problem that triggers this.
When I first bought this card I had to get the shop to replace it because
the card's PCI product ID was off-by-one, preventing puc(4) from attaching.
(FYI this shop was Conrad, a German company that offers such cards under
their own brand name).
The replacement card they gave me works fine so far, with the diff below.
I use the ports on this card to attach serial consoles of other machines
to the soekris. There is no problem connecting to the machines with cu(1).

Another fun fact is that the problem does not happen while single-stepping
through comopen() in ddb. So maybe increasing the delay(100) would help.
But what's more important is that this code should not retry indefinitely.

Index: com.c
===================================================================
RCS file: /cvs/src/sys/dev/ic/com.c,v
retrieving revision 1.145
diff -u -p -r1.145 com.c
--- com.c       28 Aug 2010 12:48:14 -0000      1.145
+++ com.c       14 Jan 2011 01:39:19 -0000
@@ -353,6 +353,7 @@ comopen(dev_t dev, int flag, int mode, s
                if (ISSET(sc->sc_hwflags, COM_HW_FIFO)) {
                        u_int8_t fifo = FIFO_ENABLE|FIFO_RCV_RST|FIFO_XMT_RST;
                        u_int8_t lcr;
+                       int i;
 
                        if (tp->t_ispeed <= 1200)
                                fifo |= FIFO_TRIGGER_1;
@@ -378,7 +379,7 @@ comopen(dev_t dev, int flag, int mode, s
                         *
                         * Set the FIFO threshold based on the receive speed.
                         */
-                       for (;;) {
+                       for (i = 0; i < 100; i++) {
                                bus_space_write_1(iot, ioh, com_fifo, 0);
                                delay(100);
                                (void) bus_space_read_1(iot, ioh, com_data);
@@ -389,6 +390,9 @@ comopen(dev_t dev, int flag, int mode, s
                                    com_lsr), LSR_RXRDY))
                                        break;
                        }
+                       if (i >= 100)
+                               printf("%s: RXRDY after FIFO reset\n",
+                                   sc->sc_dev.dv_xname);
                        if (sc->sc_uarttype == COM_UART_TI16750)
                                bus_space_write_1(iot, ioh, com_lcr, lcr);
                }


OpenBSD 4.8-current (GENERIC) #3: Fri Jan 14 02:39:54 CET 2011
    s...@dougal.stsp.name:/usr/src/sys/arch/i386/compile/GENERIC
cpu0: Geode(TM) Integrated Processor by AMD PCS ("AuthenticAMD" 586-class) 434 
MHz
cpu0: FPU,DE,PSE,TSC,MSR,CX8,SEP,PGE,CMOV,CFLUSH,MMX
real mem  = 268005376 (255MB)
avail mem = 253517824 (241MB)
mainbus0 at root
bios0 at mainbus0: AT/286+ BIOS, date 20/71/05, BIOS32 rev. 0 @ 0xfac40
pcibios0 at bios0: rev 2.0 @ 0xf0000/0x10000
pcibios0: pcibios_get_intr_routing - function not supported
pcibios0: PCI IRQ Routing information unavailable.
pcibios0: PCI bus #0 is the last bus
bios0: ROM list: 0xc8000/0xa800
cpu0 at mainbus0: (uniprocessor)
amdmsr0 at mainbus0
pci0 at mainbus0 bus 0: configuration mode 1 (bios)
io address conflict 0x6100/0x100
io address conflict 0x6200/0x200
pchb0 at pci0 dev 1 function 0 "AMD Geode LX" rev 0x30
glxsb0 at pci0 dev 1 function 2 "AMD Geode LX Crypto" rev 0x00: RNG AES
vr0 at pci0 dev 6 function 0 "VIA VT6105M RhineIII" rev 0x96: irq 11, address 
00:00:24:c9:2f:00
ukphy0 at vr0 phy 1: Generic IEEE 802.3u media interface, rev. 3: OUI 0x004063, 
model 0x0034
vr1 at pci0 dev 7 function 0 "VIA VT6105M RhineIII" rev 0x96: irq 5, address 
00:00:24:c9:2f:01
ukphy1 at vr1 phy 1: Generic IEEE 802.3u media interface, rev. 3: OUI 0x004063, 
model 0x0034
vr2 at pci0 dev 8 function 0 "VIA VT6105M RhineIII" rev 0x96: irq 9, address 
00:00:24:c9:2f:02
ukphy2 at vr2 phy 1: Generic IEEE 802.3u media interface, rev. 3: OUI 0x004063, 
model 0x0034
vr3 at pci0 dev 9 function 0 "VIA VT6105M RhineIII" rev 0x96: irq 12, address 
00:00:24:c9:2f:03
ukphy3 at vr3 phy 1: Generic IEEE 802.3u media interface, rev. 3: OUI 0x004063, 
model 0x0034
puc0 at pci0 dev 14 function 0 "NetMos Nm9865" rev 0x00: ports: 1 com
com3 at puc0 port 0 irq 10: st16650, 32 byte fifo
puc1 at pci0 dev 14 function 1 "NetMos Nm9865" rev 0x00: ports: 1 com
com4 at puc1 port 0 irq 15: st16650, 32 byte fifo
ral0 at pci0 dev 17 function 0 "Ralink RT2561S" rev 0x00: irq 7, address 
00:12:0e:61:7f:cc
ral0: MAC/BBP RT2561C, RF RT5225
glxpcib0 at pci0 dev 20 function 0 "AMD CS5536 ISA" rev 0x03: rev 3, 32-bit 
3579545Hz timer, watchdog, gpio
gpio0 at glxpcib0: 32 pins
pciide0 at pci0 dev 20 function 2 "AMD CS5536 IDE" rev 0x01: DMA, channel 0 
wired to compatibility, channel 1 wired to compatibility
wd0 at pciide0 channel 0 drive 0: <WDC WD800UE-22HCT0>
wd0: 16-sector PIO, LBA, 76319MB, 156301488 sectors
wd1 at pciide0 channel 0 drive 1: <SanDisk SDCFX3-2048>
wd1: 4-sector PIO, LBA, 1953MB, 4001760 sectors
wd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 2
wd1(pciide0:0:1): using PIO mode 4, DMA mode 2
pciide0: channel 1 ignored (disabled)
ohci0 at pci0 dev 21 function 0 "AMD CS5536 USB" rev 0x02: irq 6, version 1.0, 
legacy support
ehci0 at pci0 dev 21 function 1 "AMD CS5536 USB" rev 0x02: irq 6
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 "AMD EHCI root hub" rev 2.00/1.00 addr 1
isa0 at glxpcib0
isadma0 at isa0
com0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo
com0: console
com1 at isa0 port 0x2f8/8 irq 3: ns16550a, 16 byte fifo
pckbc0 at isa0 port 0x60/5
pckbd0 at pckbc0 (kbd slot)
pckbc0: using irq 1 for kbd slot
wskbd0 at pckbd0: console keyboard
pcppi0 at isa0 port 0x61
spkr0 at pcppi0
nsclpcsio0 at isa0 port 0x2e/2: NSC PC87366 rev 9: GPIO VLM TMS
gpio1 at nsclpcsio0: 29 pins
npx0 at isa0 port 0xf0/16: reported by CPUID; using exception 16
usb1 at ohci0: USB revision 1.0
uhub1 at usb1 "AMD OHCI root hub" rev 1.00/1.00 addr 1
biomask 6145 netmask 7be5 ttymask ffff
mtrr: K6-family MTRR support (2 registers)
uchcom0 at uhub1 port 1 "QinHeng Electronics CH341 serial/parallel" rev 
1.10/2.50 addr 2
uchcom0: CH340
ucom0 at uchcom0
vscsi0 at root
scsibus0 at vscsi0: 256 targets
softraid0 at root
root on wd1a swap on wd1b dump on wd1b
com3: RXRDY after FIFO reset
com4: RXRDY after FIFO reset


Domain /dev/pci0:
 0:1:0: AMD Geode LX
        0x0000: Vendor ID: 1022 Product ID: 2080
        0x0004: Command: 0005 Status ID: 0220
        0x0008: Class: 06 Subclass: 00 Interface: 00 Revision: 30
        0x000c: BIST: 00 Header Type: 80 Latency Timer: f8 Cache Line Size: 08
        0x0010: BAR empty (00000000)
        0x0014: BAR empty (00000000)
        0x0018: BAR empty (00000000)
        0x001c: BAR empty (00000000)
        0x0020: BAR empty (00000000)
        0x0024: BAR empty (00000000)
        0x0028: Cardbus CIS: 00000000
        0x002c: Subsystem Vendor ID: 1022 Product ID: 2080
        0x0030: Expansion ROM Base Address: 00000000
        0x0038: 00000000
        0x003c: Interrupt Pin: 00 Line: 00 Min Gnt: 00 Max Lat: 00
 0:1:2: AMD Geode LX Crypto
        0x0000: Vendor ID: 1022 Product ID: 2082
        0x0004: Command: 0006 Status ID: 0220
        0x0008: Class: 10 Subclass: 10 Interface: 00 Revision: 00
        0x000c: BIST: 00 Header Type: 00 Latency Timer: 00 Cache Line Size: 08
        0x0010: BAR mem 32bit addr: 0xa0000000/0x00004000
        0x0014: BAR empty (00000000)
        0x0018: BAR empty (00000000)
        0x001c: BAR empty (00000000)
        0x0020: BAR empty (00000000)
        0x0024: BAR empty (00000000)
        0x0028: Cardbus CIS: 00000000
        0x002c: Subsystem Vendor ID: 1022 Product ID: 2082
        0x0030: Expansion ROM Base Address: 00000000
        0x0038: 00000000
        0x003c: Interrupt Pin: 01 Line: 0a Min Gnt: 00 Max Lat: 00
 0:6:0: VIA VT6105M RhineIII
        0x0000: Vendor ID: 1106 Product ID: 3053
        0x0004: Command: 0117 Status ID: 0210
        0x0008: Class: 02 Subclass: 00 Interface: 00 Revision: 96
        0x000c: BIST: 00 Header Type: 00 Latency Timer: 40 Cache Line Size: 08
        0x0010: BAR io addr: 0x0000e100/0x0100
        0x0014: BAR mem 32bit addr: 0xa0004000/0x00000100
        0x0018: BAR empty (00000000)
        0x001c: BAR empty (00000000)
        0x0020: BAR empty (00000000)
        0x0024: BAR empty (00000000)
        0x0028: Cardbus CIS: 00000000
        0x002c: Subsystem Vendor ID: 1106 Product ID: 0106
        0x0030: Expansion ROM Base Address: 00000000
        0x0038: 00000000
        0x003c: Interrupt Pin: 01 Line: 0b Min Gnt: 03 Max Lat: 08
        0x0040: Capability 0x01: Power Management
 0:7:0: VIA VT6105M RhineIII
        0x0000: Vendor ID: 1106 Product ID: 3053
        0x0004: Command: 0117 Status ID: 0210
        0x0008: Class: 02 Subclass: 00 Interface: 00 Revision: 96
        0x000c: BIST: 00 Header Type: 00 Latency Timer: 40 Cache Line Size: 08
        0x0010: BAR io addr: 0x0000e200/0x0100
        0x0014: BAR mem 32bit addr: 0xa0004100/0x00000100
        0x0018: BAR empty (00000000)
        0x001c: BAR empty (00000000)
        0x0020: BAR empty (00000000)
        0x0024: BAR empty (00000000)
        0x0028: Cardbus CIS: 00000000
        0x002c: Subsystem Vendor ID: 1106 Product ID: 0106
        0x0030: Expansion ROM Base Address: 00000000
        0x0038: 00000000
        0x003c: Interrupt Pin: 01 Line: 05 Min Gnt: 03 Max Lat: 08
        0x0040: Capability 0x01: Power Management
 0:8:0: VIA VT6105M RhineIII
        0x0000: Vendor ID: 1106 Product ID: 3053
        0x0004: Command: 0117 Status ID: 0210
        0x0008: Class: 02 Subclass: 00 Interface: 00 Revision: 96
        0x000c: BIST: 00 Header Type: 00 Latency Timer: 40 Cache Line Size: 08
        0x0010: BAR io addr: 0x0000e300/0x0100
        0x0014: BAR mem 32bit addr: 0xa0004200/0x00000100
        0x0018: BAR empty (00000000)
        0x001c: BAR empty (00000000)
        0x0020: BAR empty (00000000)
        0x0024: BAR empty (00000000)
        0x0028: Cardbus CIS: 00000000
        0x002c: Subsystem Vendor ID: 1106 Product ID: 0106
        0x0030: Expansion ROM Base Address: 00000000
        0x0038: 00000000
        0x003c: Interrupt Pin: 01 Line: 09 Min Gnt: 03 Max Lat: 08
        0x0040: Capability 0x01: Power Management
 0:9:0: VIA VT6105M RhineIII
        0x0000: Vendor ID: 1106 Product ID: 3053
        0x0004: Command: 0117 Status ID: 0210
        0x0008: Class: 02 Subclass: 00 Interface: 00 Revision: 96
        0x000c: BIST: 00 Header Type: 00 Latency Timer: 40 Cache Line Size: 08
        0x0010: BAR io addr: 0x0000e400/0x0100
        0x0014: BAR mem 32bit addr: 0xa0004300/0x00000100
        0x0018: BAR empty (00000000)
        0x001c: BAR empty (00000000)
        0x0020: BAR empty (00000000)
        0x0024: BAR empty (00000000)
        0x0028: Cardbus CIS: 00000000
        0x002c: Subsystem Vendor ID: 1106 Product ID: 0106
        0x0030: Expansion ROM Base Address: 00000000
        0x0038: 00000000
        0x003c: Interrupt Pin: 01 Line: 0c Min Gnt: 03 Max Lat: 08
        0x0040: Capability 0x01: Power Management
 0:14:0: NetMos Nm9865
        0x0000: Vendor ID: 9710 Product ID: 9865
        0x0004: Command: 0107 Status ID: 0290
        0x0008: Class: 07 Subclass: 00 Interface: 02 Revision: 00
        0x000c: BIST: 00 Header Type: 80 Latency Timer: 40 Cache Line Size: 08
        0x0010: BAR io addr: 0x0000e500/0x0008
        0x0014: BAR mem 32bit addr: 0xa0005000/0x00001000
        0x0018: BAR empty (00000000)
        0x001c: BAR empty (00000000)
        0x0020: BAR mem 32bit addr: 0xa0006000/0x00001000
        0x0024: BAR empty (00000000)
        0x0028: Cardbus CIS: 00000000
        0x002c: Subsystem Vendor ID: a000 Product ID: 1000
        0x0030: Expansion ROM Base Address: 00000000
        0x0038: 00000000
        0x003c: Interrupt Pin: 01 Line: 0a Min Gnt: 00 Max Lat: 00
        0x0048: Capability 0x01: Power Management
 0:14:1: NetMos Nm9865
        0x0000: Vendor ID: 9710 Product ID: 9865
        0x0004: Command: 0107 Status ID: 0290
        0x0008: Class: 07 Subclass: 00 Interface: 02 Revision: 00
        0x000c: BIST: 00 Header Type: 80 Latency Timer: 40 Cache Line Size: 08
        0x0010: BAR io addr: 0x0000e508/0x0008
        0x0014: BAR mem 32bit addr: 0xa0007000/0x00001000
        0x0018: BAR empty (00000000)
        0x001c: BAR empty (00000000)
        0x0020: BAR mem 32bit addr: 0xa0008000/0x00001000
        0x0024: BAR empty (00000000)
        0x0028: Cardbus CIS: 00000000
        0x002c: Subsystem Vendor ID: a000 Product ID: 1000
        0x0030: Expansion ROM Base Address: 00000000
        0x0038: 00000000
        0x003c: Interrupt Pin: 02 Line: 0f Min Gnt: 00 Max Lat: 00
        0x0048: Capability 0x01: Power Management
 0:17:0: Ralink RT2561S
        0x0000: Vendor ID: 1814 Product ID: 0301
        0x0004: Command: 0117 Status ID: 0410
        0x0008: Class: 02 Subclass: 80 Interface: 00 Revision: 00
        0x000c: BIST: 00 Header Type: 00 Latency Timer: 40 Cache Line Size: 08
        0x0010: BAR mem 32bit addr: 0xa0010000/0x00008000
        0x0014: BAR empty (00000000)
        0x0018: BAR empty (00000000)
        0x001c: BAR empty (00000000)
        0x0020: BAR empty (00000000)
        0x0024: BAR empty (00000000)
        0x0028: Cardbus CIS: 00000601
        0x002c: Subsystem Vendor ID: 13d1 Product ID: abe3
        0x0030: Expansion ROM Base Address: 00000000
        0x0038: 00000000
        0x003c: Interrupt Pin: 01 Line: 07 Min Gnt: 00 Max Lat: 00
        0x0040: Capability 0x01: Power Management
 0:20:0: AMD CS5536 ISA
        0x0000: Vendor ID: 1022 Product ID: 2090
        0x0004: Command: 0009 Status ID: 02a0
        0x0008: Class: 06 Subclass: 01 Interface: 00 Revision: 03
        0x000c: BIST: 00 Header Type: 80 Latency Timer: 40 Cache Line Size: 08
        0x0010: BAR io addr: 0x00006000/0x2000
        0x0014: BAR io addr: 0x00006100/0x0100
        0x0018: BAR io addr: 0x00006200/0x0200
        0x001c: BAR empty (00000000)
        0x0020: BAR empty (00000000)
        0x0024: BAR empty (00000000)
        0x0028: Cardbus CIS: 00000000
        0x002c: Subsystem Vendor ID: 1022 Product ID: 2090
        0x0030: Expansion ROM Base Address: 00000000
        0x0038: 00000000
        0x003c: Interrupt Pin: 00 Line: 00 Min Gnt: 00 Max Lat: 00
 0:20:2: AMD CS5536 IDE
        0x0000: Vendor ID: 1022 Product ID: 209a
        0x0004: Command: 0005 Status ID: 02a0
        0x0008: Class: 01 Subclass: 01 Interface: 80 Revision: 01
        0x000c: BIST: 00 Header Type: 00 Latency Timer: 00 Cache Line Size: 08
        0x0010: BAR empty (00000000)
        0x0014: BAR empty (00000000)
        0x0018: BAR empty (00000000)
        0x001c: BAR empty (00000000)
        0x0020: BAR io addr: 0x0000e000/0x0010
        0x0024: BAR empty (00000000)
        0x0028: Cardbus CIS: 00000000
        0x002c: Subsystem Vendor ID: 1022 Product ID: 209a
        0x0030: Expansion ROM Base Address: 00000000
        0x0038: 00000000
        0x003c: Interrupt Pin: 00 Line: 00 Min Gnt: 00 Max Lat: 00
 0:21:0: AMD CS5536 USB
        0x0000: Vendor ID: 1022 Product ID: 2094
        0x0004: Command: 0006 Status ID: 0230
        0x0008: Class: 0c Subclass: 03 Interface: 10 Revision: 02
        0x000c: BIST: 00 Header Type: 80 Latency Timer: 00 Cache Line Size: 08
        0x0010: BAR mem 32bit addr: 0xa0018000/0x00001000
        0x0014: BAR empty (00000000)
        0x0018: BAR empty (00000000)
        0x001c: BAR empty (00000000)
        0x0020: BAR empty (00000000)
        0x0024: BAR empty (00000000)
        0x0028: Cardbus CIS: 00000000
        0x002c: Subsystem Vendor ID: 1022 Product ID: 2094
        0x0030: Expansion ROM Base Address: 00000000
        0x0038: 00000000
        0x003c: Interrupt Pin: 01 Line: 06 Min Gnt: 00 Max Lat: 00
 0:21:1: AMD CS5536 USB
        0x0000: Vendor ID: 1022 Product ID: 2095
        0x0004: Command: 0006 Status ID: 0230
        0x0008: Class: 0c Subclass: 03 Interface: 20 Revision: 02
        0x000c: BIST: 00 Header Type: 00 Latency Timer: 00 Cache Line Size: 08
        0x0010: BAR mem 32bit addr: 0xa0019000/0x00001000
        0x0014: BAR empty (00000000)
        0x0018: BAR empty (00000000)
        0x001c: BAR empty (00000000)
        0x0020: BAR empty (00000000)
        0x0024: BAR empty (00000000)
        0x0028: Cardbus CIS: 00000000
        0x002c: Subsystem Vendor ID: 1022 Product ID: 2095
        0x0030: Expansion ROM Base Address: 00000000
        0x0038: 00000000
        0x003c: Interrupt Pin: 01 Line: 06 Min Gnt: 00 Max Lat: 00

Reply via email to