Subject: Re: looking for VIA/NVIDIA sata testers
To: None <paul@whooppee.com>
From: Manuel Bouyer <bouyer@antioche.eu.org>
List: current-users
Date: 10/27/2006 10:30:07
--VbJkn9YxBvnuCH5J
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Thu, Oct 26, 2006 at 06:11:56PM -0700, paul@whooppee.com wrote:
> [...]
> I'm not sure why I'm seeing the "pci_io_find" messages;
> they don't show up during a normal boot.  And I don't know

The attached patch should make the message go away, can you test it ?
Note that I didn't even try to compile it ...

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

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

Index: viaide.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/viaide.c,v
retrieving revision 1.35
diff -u -u -r1.35 viaide.c
--- viaide.c	27 Oct 2006 08:22:31 -0000	1.35
+++ viaide.c	27 Oct 2006 08:29:08 -0000
@@ -651,6 +651,7 @@
 via_sata_chip_map_common(struct pciide_softc *sc, struct pci_attach_args *pa)
 {
 	bus_size_t satasize;
+	int maptype, ret;
 
 	if (pciide_chipen(sc, pa) == 0)
 		return 0;
@@ -674,17 +675,30 @@
 	sc->sc_wdcdev.sc_atac.atac_set_modes = sata_setup_channel;
 
 	wdc_allocate_regs(&sc->sc_wdcdev);
-	if (pci_mapreg_map(pa, PCI_MAPREG_START + 0x14,
-	    PCI_MAPREG_TYPE_IO, 0, &sc->sc_ba5_st, &sc->sc_ba5_sh,
-	    NULL, &satasize) != 0) {
-		if (pci_mapreg_map(pa, PCI_MAPREG_START + 0x14,
+	maptype = pci_mapreg_type(pa->pa_pc, pa->pa_tag,
+	    PCI_MAPREG_START + 0x14);
+	switch(maptype) {
+	case PCI_MAPREG_TYPE_IO:
+		ret = pci_mapreg_map(pa, PCI_MAPREG_START + 0x14,
+		    PCI_MAPREG_TYPE_IO, 0, &sc->sc_ba5_st, &sc->sc_ba5_sh,
+		    NULL, &satasize);
+		break;
+	case PCI_MAPREG_MEM_TYPE_32BIT:
+		ret = pci_mapreg_map(pa, PCI_MAPREG_START + 0x14,
 		    PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT,
 		    0, &sc->sc_ba5_st, &sc->sc_ba5_sh,
-		    NULL, &satasize) != 0) {
-			aprint_error("%s: couldn't map sata regs\n",
-			sc->sc_wdcdev.sc_atac.atac_dev.dv_xname);
-			return 0;
-		}
+		    NULL, &satasize);
+		break;
+	default:
+		aprint_error("%s: couldn't map sata regs, unsupported"
+		    "maptype (0x%x)\n", sc->sc_wdcdev.sc_atac.atac_dev.dv_xname,
+		    maptype);
+		return 0;
+	}
+	if (ret != 0) {
+		aprint_error("%s: couldn't map sata regs\n",
+		    sc->sc_wdcdev.sc_atac.atac_dev.dv_xname);
+		return 0;
 	}
 	return 1;
 }

--VbJkn9YxBvnuCH5J--