Subject: Re: kern/26502: IDE broken with SiS 496
To: Christian Biere <christianbiere@gmx.de>
From: Manuel Bouyer <bouyer@antioche.lip6.fr>
List: netbsd-bugs
Date: 08/02/2004 12:55:28
--xHFwDpU9dbj6ez1V
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Sun, Aug 01, 2004 at 06:49:17PM +0200, Christian Biere wrote:
> pciide0 at pci0 dev 10 function 0
> pciide0: vendor 0x10ad product 0x0001 (rev. 0x02)
> pciide0: hardware does not support DMA
> pciide0: primary channel wired to compatibility mode
> pciide0: primary channel interrupting at irq 14
> pciide0: primary channel ignored (other hardware responding at addresses)

Ok, pciide releases the I/O address space in this case, but keep the interrupt
mapped. Previously this worked by acciddent, because we still attached
a atabus to a disabled channel, and the drive was probed on this atabus,
and was getting interrupts though the (disabled !) pciide0 device.
Now the drive gets probed on the atabus attached to wdc at isa, but wdc at isa
doesn't gets the interrupts.

The attached patch should fix this, can you give it a try ?

-- 
Manuel Bouyer <bouyer@antioche.eu.org>
     NetBSD: 26 ans d'experience feront toujours la difference
--

--xHFwDpU9dbj6ez1V
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=diff

Index: cypide.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/cypide.c,v
retrieving revision 1.7
diff -u -r1.7 cypide.c
--- cypide.c	3 Jan 2004 22:56:53 -0000	1.7
+++ cypide.c	2 Aug 2004 10:51:49 -0000
@@ -169,6 +169,8 @@
 		aprint_normal("compatibility mode\n");
 		pciide_mapregs_compat(pa, cp, sc->sc_cy_compatchan, &cmdsize,
 		    &ctlsize);
+		if ((cp->wdc_channel.ch_flags & WDCF_DISABLED) == 0)
+			pciide_map_compat_intr(pa, cp, sc->sc_cy_compatchan);
 	}
 	wdcattach(&cp->wdc_channel);
 }
Index: hptide.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/hptide.c,v
retrieving revision 1.9
diff -u -r1.9 hptide.c
--- hptide.c	3 Jan 2004 22:56:53 -0000	1.9
+++ hptide.c	2 Aug 2004 10:51:49 -0000
@@ -236,6 +236,9 @@
 		} else {
 			pciide_mapregs_compat(pa, cp, compatchan,
 			    &cmdsize, &ctlsize);
+			if ((cp->wdc_channel.ch_flags & WDCF_DISABLED) == 0)
+				pciide_map_compat_intr(pa, cp,
+				    sc->sc_cy_compatchan);
 		}
 		wdcattach(&cp->wdc_channel);
 	}
Index: pciide_common.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/pciide_common.c,v
retrieving revision 1.12
diff -u -r1.12 pciide_common.c
--- pciide_common.c	4 Jun 2004 21:15:00 -0000	1.12
+++ pciide_common.c	2 Aug 2004 10:51:49 -0000
@@ -239,7 +239,6 @@
 	wdc_init_shadow_regs(wdc_cp);
 	wdc_cp->data32iot = wdc_cp->cmd_iot;
 	wdc_cp->data32ioh = wdc_cp->cmd_iohs[0];
-	pciide_map_compat_intr(pa, cp, compatchan);
 	return;
 
 bad:
@@ -783,9 +782,12 @@
 
 	if (interface & PCIIDE_INTERFACE_PCI(wdc_cp->ch_channel))
 		pciide_mapregs_native(pa, cp, cmdsizep, ctlsizep, pci_intr);
-	else
+	else {
 		pciide_mapregs_compat(pa, cp, wdc_cp->ch_channel, cmdsizep,
 		    ctlsizep);
+		if ((cp->wdc_channel.ch_flags & WDCF_DISABLED) == 0)
+			pciide_map_compat_intr(pa, cp, wdc_cp->ch_channel);
+	}
 	wdcattach(wdc_cp);
 }
 
@@ -882,8 +884,10 @@
 		 * not possible to have an ISA board using the same address
 		 * anyway.
 		 */
-		if (interface & PCIIDE_INTERFACE_PCI(channel))
-			goto next;
+		if (interface & PCIIDE_INTERFACE_PCI(channel)) {
+			wdcattach(&cp->wdc_channel);
+			continue;
+		}
 		if (!wdcprobe(&cp->wdc_channel)) {
 			failreason = "not responding; disabled or no drives?";
 			goto next;
@@ -913,8 +917,9 @@
 			    cp->wdc_channel.cmd_baseioh, cmdsize);
 			bus_space_unmap(cp->wdc_channel.ctl_iot,
 			    cp->wdc_channel.ctl_ioh, ctlsize);
-
 		} else {
+			pciide_map_compat_intr(pa, cp,
+			    cp->wdc_channel.ch_channel);
 			wdcattach(&cp->wdc_channel);
 		}
 	}

--xHFwDpU9dbj6ez1V--