Subject: Re: Soekris Net4801: panic on
To: None <port-i386@NetBSD.org>
From: Jun-ichiro itojun Hagino <itojun@iijlab.net>
List: port-i386
Date: 08/15/2003 08:21:27
>>Seems following might be the required change - can you try it out?
>	your patch does not seem to change the situation, unfortunately.
>
>	if i "break" instead of "continue" on the 2nd if statement,
>	most of the pci devices (ethernet chips) are skipped but i can go to
>	multiuser.  so there has to be something to do with the 2nd loop.

	with this diff i finally got to multiuser with pci devices.
	ok to commit? (does anyone knkow the name for 0x100b/0x0510?)

	the panic occurred when we try to access id/csr/class on
	function 1 of vendor 0x100b/prod 0x0510 (which claims to be
	multifunction).  adding quirk table to make it non-multifunction
	workaround the situation.

itojun


Index: pci.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/pci.c,v
retrieving revision 1.80
diff -u -r1.80 pci.c
--- pci.c	2003/06/15 23:09:09	1.80
+++ pci.c	2003/08/14 23:11:27
@@ -262,11 +262,13 @@
 
 	pci_decompose_tag(pc, tag, &bus, &device, &function);
 
+	bhlcr = pci_conf_read(pc, tag, PCI_BHLC_REG);
+	if (PCI_HDRTYPE_TYPE(bhlcr) > 2)
+		return (0);
+
 	id = pci_conf_read(pc, tag, PCI_ID_REG);
 	csr = pci_conf_read(pc, tag, PCI_COMMAND_STATUS_REG);
 	class = pci_conf_read(pc, tag, PCI_CLASS_REG);
-	intr = pci_conf_read(pc, tag, PCI_INTERRUPT_REG);
-	bhlcr = pci_conf_read(pc, tag, PCI_BHLC_REG);
 
 	/* Invalid vendor ID value? */
 	if (PCI_VENDOR(id) == PCI_VENDOR_INVALID)
@@ -312,6 +314,9 @@
 		pa.pa_intrswiz = sc->sc_intrswiz + device;
 		pa.pa_intrtag = sc->sc_intrtag;
 	}
+
+	intr = pci_conf_read(pc, tag, PCI_INTERRUPT_REG);
+
 	pin = PCI_INTERRUPT_PIN(intr);
 	pa.pa_rawintrpin = pin;
 	if (pin == PCI_INTERRUPT_PIN_NONE) {
@@ -431,6 +436,11 @@
 #endif
 	{
 		tag = pci_make_tag(pc, sc->sc_bus, device, 0);
+
+		bhlcr = pci_conf_read(pc, tag, PCI_BHLC_REG);
+		if (PCI_HDRTYPE_TYPE(bhlcr) > 2)
+			continue;
+
 		id = pci_conf_read(pc, tag, PCI_ID_REG);
 
 		/* Invalid vendor ID value? */
@@ -442,13 +452,14 @@
 
 		qd = pci_lookup_quirkdata(PCI_VENDOR(id), PCI_PRODUCT(id));
 
-		bhlcr = pci_conf_read(pc, tag, PCI_BHLC_REG);
-		if (PCI_HDRTYPE_MULTIFN(bhlcr) ||
-		    (qd != NULL &&
-		      (qd->quirks & PCI_QUIRK_MULTIFUNCTION) != 0))
+		if (qd != NULL &&
+		      (qd->quirks & PCI_QUIRK_MULTIFUNCTION) != 0)
 			nfunctions = 8;
-		else
+		else if (qd != NULL &&
+		      (qd->quirks & PCI_QUIRK_NONMULTIFUNCTION) != 0)
 			nfunctions = 1;
+		else
+			nfunctions = PCI_HDRTYPE_MULTIFN(bhlcr) ? 8 : 1;
 
 		for (function = 0; function < nfunctions; function++) {
 			tag = pci_make_tag(pc, sc->sc_bus, device, function);
Index: pci_quirks.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/pci_quirks.c,v
retrieving revision 1.2
diff -u -r1.2 pci_quirks.c
--- pci_quirks.c	2001/11/13 07:48:47	1.2
+++ pci_quirks.c	2003/08/14 23:11:27
@@ -47,6 +47,8 @@
 static const struct pci_quirkdata pci_quirks[] = {
 	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82371FB_ISA,
 	    PCI_QUIRK_MULTIFUNCTION },
+	{ PCI_VENDOR_NS, 0x0510,
+	    PCI_QUIRK_NONMULTIFUNCTION },
 };
 
 const struct pci_quirkdata *
Index: pcivar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/pcivar.h,v
retrieving revision 1.58
diff -u -r1.58 pcivar.h
--- pcivar.h	2003/06/29 22:30:27	1.58
+++ pcivar.h	2003/08/14 23:11:27
@@ -144,6 +144,7 @@
 	int			quirks;		/* quirks; see below */
 };
 #define	PCI_QUIRK_MULTIFUNCTION		1
+#define	PCI_QUIRK_NONMULTIFUNCTION	2
 
 struct pci_softc {
 	struct device sc_dev;


>> Memory: 639/130048 k
Press return to boot now, any other key for boot menu
booting hd0e:netbsd - starting in 5 4 3 2 1 0
6384816+133800+438404 [322272+294306]=0x73a284
BIOS CFG: Model-SubM-Rev: fc-00-00, 0x7c<EBDA,WAITEV,KBDINT,RTC,IC2>
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
    The NetBSD Foundation, Inc.  All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
    The Regents of the University of California.  All rights reserved.

NetBSD 1.6W (NET4801) #15: Fri Aug 15 08:07:39 JST 2003
	itojun@starfruit.itojun.org:/home/itojun/NetBSD/src/sys/arch/i386/compile/NET4801
total memory = 127 MB
avail memory = 110 MB
using 1659 buffers containing 6636 KB of memory
BIOS32 rev. 0 found at 0xf7840
mainbus0 (root)
cpu0 at mainbus0: (uniprocessor)
cpu0: National Semiconductor Geode GX1 (586-class), 266.72 MHz, id 0x540
cpu0: features 808131<FPU,TSC,MSR,CX8>
cpu0: features 808131<CMOV,MMX>
cpu0: I-cache 12K uOp cache 8-way
pci0 at mainbus0 bus 0: configuration mode 1
pci0: i/o space, memory space enabled, rd/line, rd/mult, wr/inv ok
bus 0 device 0, type 0
read ID
read ID done
vendor 1078 prod 1
quirkdata 0x0
try function 0/1
bus 0 device 0, type 0
read id, csr, class
read id, csr, class done
vendor 1078 prod 1
try to configure it
pchb0 at pci0 dev 0 function 0
pchb0: Cyrix Corporation MediaGX Built-in PCI Host Controller (rev. 0x00)
bus 0 device 1, type 7f
bus 0 device 2, type 7f
bus 0 device 3, type 7f
bus 0 device 4, type 7f
bus 0 device 5, type 7f
bus 0 device 6, type 0
read ID
read ID done
vendor 100b prod 20
quirkdata 0x0
try function 0/1
bus 0 device 6, type 0
read id, csr, class
read id, csr, class done
vendor 100b prod 20
try to configure it
sip0 at pci0 dev 6 function 0: NatSemi DP83815 10/100 Ethernet, rev 00
sip0: interrupting at irq 10
sip0: Ethernet address 00:00:24:c1:34:cc
nsphyter0 at sip0 phy 0: DP83815 10/100 media interface, rev. 1
nsphyter0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
bus 0 device 7, type 0
read ID
read ID done
vendor 100b prod 20
quirkdata 0x0
try function 0/1
bus 0 device 7, type 0
read id, csr, class
read id, csr, class done
vendor 100b prod 20
try to configure it
sip1 at pci0 dev 7 function 0: NatSemi DP83815 10/100 Ethernet, rev 00
sip1: interrupting at irq 10
sip1: Ethernet address 00:00:24:c1:34:cd
nsphyter1 at sip1 phy 0: DP83815 10/100 media interface, rev. 1
nsphyter1: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
bus 0 device 8, type 0
read ID
read ID done
vendor 100b prod 20
quirkdata 0x0
try function 0/1
bus 0 device 8, type 0
read id, csr, class
read id, csr, class done
vendor 100b prod 20
try to configure it
sip2 at pci0 dev 8 function 0: NatSemi DP83815 10/100 Ethernet, rev 00
sip2: interrupting at irq 10
sip2: Ethernet address 00:00:24:c1:34:ce
nsphyter2 at sip2 phy 0: DP83815 10/100 media interface, rev. 1
nsphyter2: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
bus 0 device 9, type 7f
bus 0 device a, type 7f
bus 0 device b, type 7f
bus 0 device c, type 7f
bus 0 device d, type 7f
bus 0 device e, type 7f
bus 0 device f, type 7f
bus 0 device 10, type 7f
bus 0 device 11, type 7f
bus 0 device 12, type 0
read ID
read ID done
vendor 100b prod 510
quirkdata 0xc05e4998			<--- not multifunction
try function 0/1
bus 0 device 12, type 0
read id, csr, class
read id, csr, class done
vendor 100b prod 510
try to configure it
pcib0 at pci0 dev 18 function 0
pcib0: National Semiconductor product 0x0510 (rev. 0x00)
bus 0 device 13, type 0
read ID
read ID done
vendor e11 prod a0f8
quirkdata 0x0
try function 0/1
bus 0 device 13, type 0
read id, csr, class
read id, csr, class done
vendor e11 prod a0f8
try to configure it
ohci0 at pci0 dev 19 function 0: Compaq USB Controller (rev. 0x08)
ohci0: interrupting at irq 11
ohci0: OHCI version 1.0, legacy support
usb0 at ohci0: USB revision 1.0
uhub0 at usb0
uhub0: Compaq OHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub0: 3 ports with 3 removable, self powered
bus 0 device 14, type 7f
bus 0 device 15, type 7f
bus 0 device 16, type 7f
bus 0 device 17, type 7f
bus 0 device 18, type 7f
bus 0 device 19, type 7f
bus 0 device 1a, type 7f
bus 0 device 1b, type 7f
bus 0 device 1c, type 7f
bus 0 device 1d, type 7f
bus 0 device 1e, type 7f
bus 0 device 1f, type 7f
isa0 at pcib0
com0 at isa0 port 0x3f8-0x3ff irq 4: ns16550a, working fifo
com0: console
com1 at isa0 port 0x2f8-0x2ff irq 3: ns16550a, working fifo
pckbc0 at isa0 port 0x60-0x64
wdc0 at isa0 port 0x1f0-0x1f7 irq 14
wd0 at wdc0 channel 0 drive 0: <SanDisk SDCFB-1024>
wd0: drive supports 1-sector PIO transfers, LBA addressing
wd0: 977 MB, 1986 cyl, 16 head, 63 sec, 512 bytes/sect x 2001888 sectors
pcppi0 at isa0 port 0x61
midi0 at pcppi0: PC speaker
sysbeep0 at pcppi0
isapnp0 at isa0 port 0x279: ISA Plug 'n Play device support
npx0 at isa0 port 0xf0-0xff: using exception 16
isapnp0: no ISA Plug 'n Play devices found
Kernelized RAIDframe activated
IPsec: Initialized Security Association Processing.
boot device: wd0
root on wd0e dumps on wd0b
WARNING: clock time much less than file system time
WARNING: using file system time
WARNING: CHECK AND RESET THE DATE!
root file system type: ffs