Subject: kern/24015: kernel crash with satalink
To: None <>
From: Arne H. Juul <>
List: netbsd-bugs
Date: 01/07/2004 22:40:39
>Number:         24015
>Category:       kern
>Synopsis:       kernel crash with satalink
>Confidential:   no
>Severity:       critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jan 07 21:41:00 UTC 2004
>Originator:     Arne H Juul
>Release:        NetBSD 1.6ZG
System: NetBSD blackbox 1.6ZG NetBSD 1.6ZG (BLACKBOX) #0: Tue Jan 6 11:48:45 CET 2004 arnej@blackbox:/sys/arch/i386/compile/BLACKBOX i386
Architecture: i386
Machine: i386
	when attaching a WD disk on a SATALink 3112 I get
	a kernel page fault in wdc_exec_command+0x19, line 1458:

 wdc_exec_command(struct ata_drive_datas *drvp, struct wdc_command *wdc_c)
        struct wdc_channel *chp = drvp->chnl_softc;
 -->    struct wdc_softc *wdc = chp->ch_wdc;

	The reason being that chnl_softc is never initialized.
	This normally happens in wdc_drvprobe but the satalink
	device driver sets up so its own sii3112_drv_probe is
	used instead.

	(It's strange nobody else have noticed this, so maybe
	there's some stupid mistake I've done?)

	Adding a line to set chnl_softc makes this driver work
	for me at least, yielding this dmesg snippet:

satalink0 at pci1 dev 13 function 0
satalink0: Silicon Image SATALink 3112 (rev. 0x02)
satalink0: SATALink BA5 register space disabled
satalink0: bus-master DMA support present
satalink0: primary channel wired to native-PCI mode
satalink0: using irq 11 for native-PCI interrupt
atabus0 at satalink0 channel 0
satalink0: secondary channel wired to native-PCI mode
atabus1 at satalink0 channel 1
satalink0: port 0: device present, speed: 1.5Gb/s
wd0 at atabus0 drive 0: <Maxtor 6Y120M0>
wd0: drive supports 16-sector PIO transfers, LBA addressing
wd0: 114 GB, 238216 cyl, 16 head, 63 sec, 512 bytes/sect x 240121728 sectors
wd0: 32-bit data port
wd0: drive supports PIO mode 4, DMA mode 2, Ultra-DMA mode 6 (Ultra/133)
wd0(satalink0:0:0): using PIO mode 4, Ultra-DMA mode 6 (Ultra/133) (using DMA data transfers)

	try to boot -current on a system with a WD attached
	via satalink.

Index: satalink.c
RCS file: /usr/cvs/src/sys/dev/pci/satalink.c,v
retrieving revision 1.11
diff -u -r1.11 satalink.c
--- satalink.c	3 Jan 2004 22:56:53 -0000	1.11
+++ satalink.c	6 Jan 2004 00:41:28 -0000
@@ -823,6 +823,7 @@
 			chp->ch_drive[0].drive_flags |= DRIVE_ATA;

+		chp->ch_drive[0].chnl_softc = chp;
 		aprint_normal("%s: port %d: device present, speed: %s\n",
 		    sc->sc_wdcdev.sc_dev.dv_xname, chp->ch_channel,
 		    sata_speed[(sstatus & SStatus_SPD_mask) >>
 	current as of 2004-01-06