Subject: kern/34012: system crash when load a pci device driver with pcilkm.o
To: None <,,>
From: None <>
List: netbsd-bugs
Date: 07/16/2006 08:30:00
>Number:         34012
>Category:       kern
>Synopsis:       system crash when load a pci device driver with pcilkm.o
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jul 16 08:30:00 +0000 2006
>Originator:     George Chen
>Release:        3.0
Semptian Technologies
NetBSD fw022 3.0 NetBSD 3.0 (SEMPOS.debug) #128: Thu Jun 22 09:26:34 CST 2006  george@fw022:/home/george/usr/src/sys/arch/i386/compile/SEMPOS.debug i386

I was developing a driver for pci device as a loadable kernel module (LKM). ./sys/lkm/dev/pcilkm of BSD 3.0 provides very good example and support. The sample 'pcienum' worked well when pcilkm.o was loaded first. 'pcienum' listed all pci devices found on pci bus. However, if we modified 'pcienum' so that it listed a specified device, the system crashed.
1, modload -s pcilkm.o
2, modload pcienum.o
3, select any device from the output of pcienum.o, code the vender id and product id into function of pcienum_match() so that it matches only the specified device.
4, load it again after make. It goes crash.
It's solved though. only two lines are needed.

in pcilkm_lkm.c

line 76: should have four arguments
int		pcisubmatch __P((struct device *, struct cfdata *, void*, void *));

line 197: pass NULL for the third argument when call pcisubmatch.
	return (pcisubmatch(parent, cf, NULL, aux));