tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pciide detachment



Hi,

The attached patch lays the groundwork for detachment of
pciide(4)-family drivers.  Thoughts?

        Jonathan Kollasch
Index: sys/dev/ic/wdcvar.h
===================================================================
RCS file: /local/netbsd/anoncvs/src/sys/dev/ic/wdcvar.h,v
retrieving revision 1.90
diff -u -a -p -r1.90 wdcvar.h
--- sys/dev/ic/wdcvar.h 1 Dec 2009 01:06:31 -0000       1.90
+++ sys/dev/ic/wdcvar.h 10 Sep 2010 20:25:15 -0000
@@ -47,9 +47,11 @@ struct wdc_regs {
        /* Our registers */
        bus_space_tag_t       cmd_iot;
        bus_space_handle_t    cmd_baseioh;
+       bus_size_t            cmd_ios;
        bus_space_handle_t    cmd_iohs[WDC_NREG+WDC_NSHADOWREG];
        bus_space_tag_t       ctl_iot;
        bus_space_handle_t    ctl_ioh;
+       bus_size_t            ctl_ios;
 
        /* data32{iot,ioh} are only used for 32-bit data xfers */
        bus_space_tag_t       data32iot;
Index: sys/dev/pci/acardide.c
===================================================================
RCS file: /local/netbsd/anoncvs/src/sys/dev/pci/acardide.c,v
retrieving revision 1.23
diff -u -a -p -r1.23 acardide.c
--- sys/dev/pci/acardide.c      14 May 2008 13:29:29 -0000      1.23
+++ sys/dev/pci/acardide.c      10 Sep 2010 20:25:15 -0000
@@ -115,7 +115,6 @@ acard_chip_map(struct pciide_softc *sc, 
        struct pciide_channel *cp;
        int i;
        pcireg_t interface;
-       bus_size_t cmdsize, ctlsize;
 
        if (pciide_chipen(sc, pa) == 0)
                return;
@@ -167,8 +166,7 @@ acard_chip_map(struct pciide_softc *sc, 
                cp = &sc->pciide_channels[i];
                if (pciide_chansetup(sc, i, interface) == 0)
                        continue;
-               pciide_mapchan(pa, cp, interface, &cmdsize, &ctlsize,
-                   pciide_pci_intr);
+               pciide_mapchan(pa, cp, interface, pciide_pci_intr);
        }
        if (!ACARD_IS_850(sc)) {
                u_int32_t reg;
Index: sys/dev/pci/aceride.c
===================================================================
RCS file: /local/netbsd/anoncvs/src/sys/dev/pci/aceride.c,v
retrieving revision 1.27
diff -u -a -p -r1.27 aceride.c
--- sys/dev/pci/aceride.c       8 May 2010 19:49:02 -0000       1.27
+++ sys/dev/pci/aceride.c       10 Sep 2010 20:25:15 -0000
@@ -113,7 +113,6 @@ acer_chip_map(struct pciide_softc *sc, s
        struct pciide_channel *cp;
        int channel;
        pcireg_t cr, interface;
-       bus_size_t cmdsize, ctlsize;
        pcireg_t rev = PCI_REVISION(pa->pa_class);
        struct aceride_softc *acer_sc = (struct aceride_softc *)sc;
 
@@ -216,7 +215,7 @@ acer_chip_map(struct pciide_softc *sc, s
                        continue;
                }
                /* newer controllers seems to lack the ACER_CHIDS. Sigh */
-               pciide_mapchan(pa, cp, interface, &cmdsize, &ctlsize,
+               pciide_mapchan(pa, cp, interface,
                     (rev >= 0xC2) ? pciide_pci_intr : acer_pci_intr);
        }
 }
Index: sys/dev/pci/artsata.c
===================================================================
RCS file: /local/netbsd/anoncvs/src/sys/dev/pci/artsata.c,v
retrieving revision 1.19
diff -u -a -p -r1.19 artsata.c
--- sys/dev/pci/artsata.c       26 Nov 2009 15:17:08 -0000      1.19
+++ sys/dev/pci/artsata.c       10 Sep 2010 20:25:15 -0000
@@ -119,7 +119,6 @@ artsata_attach(device_t parent, device_t
 
 static void
 artisea_mapregs(struct pci_attach_args *pa, struct pciide_channel *cp,
-    bus_size_t *cmdsizep, bus_size_t *ctlsizep,
     int (*pci_intr)(void *))
 {
        struct pciide_softc *sc = CHAN_TO_PCIIDE(&cp->ata_channel);
@@ -320,7 +319,6 @@ static void
 artisea_chip_map_dpa(struct pciide_softc *sc, struct pci_attach_args *pa)
 {
        struct pciide_channel *cp;
-       bus_size_t cmdsize, ctlsize;
        pcireg_t interface;
        int channel;
 
@@ -330,7 +328,7 @@ artisea_chip_map_dpa(struct pciide_softc
            "interface wired in DPA mode\n");
 
        if (pci_mapreg_map(pa, ARTISEA_PCI_DPA_BASE, PCI_MAPREG_MEM_TYPE_64BIT,
-           0, &sc->sc_ba5_st, &sc->sc_ba5_sh, NULL, NULL) != 0)
+           0, &sc->sc_ba5_st, &sc->sc_ba5_sh, NULL, &sc->sc_ba5_ss) != 0)
                return;
 
        artisea_mapreg_dma(sc, pa);
@@ -380,7 +378,7 @@ artisea_chip_map_dpa(struct pciide_softc
                if (artisea_chansetup(sc, channel, interface) == 0)
                        continue;
                /* XXX We can probably do interrupts more efficiently.  */
-               artisea_mapregs(pa, cp, &cmdsize, &ctlsize, pciide_pci_intr);
+               artisea_mapregs(pa, cp, pciide_pci_intr);
        }
 }
 
@@ -388,7 +386,6 @@ static void
 artisea_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa)
 {
        struct pciide_channel *cp;
-       bus_size_t cmdsize, ctlsize;
        pcireg_t interface;
        int channel;
 
@@ -438,7 +435,6 @@ artisea_chip_map(struct pciide_softc *sc
                cp = &sc->pciide_channels[channel];
                if (pciide_chansetup(sc, channel, interface) == 0)
                        continue;
-               pciide_mapchan(pa, cp, interface, &cmdsize, &ctlsize,
-                   pciide_pci_intr);
+               pciide_mapchan(pa, cp, interface, pciide_pci_intr);
        }
 }
Index: sys/dev/pci/cmdide.c
===================================================================
RCS file: /local/netbsd/anoncvs/src/sys/dev/pci/cmdide.c,v
retrieving revision 1.29
diff -u -a -p -r1.29 cmdide.c
--- sys/dev/pci/cmdide.c        19 Oct 2009 18:41:14 -0000      1.29
+++ sys/dev/pci/cmdide.c        10 Sep 2010 20:25:15 -0000
@@ -124,7 +124,6 @@ cmd_channel_map(struct pci_attach_args *
     int channel)
 {
        struct pciide_channel *cp = &sc->pciide_channels[channel];
-       bus_size_t cmdsize, ctlsize;
        u_int8_t ctrl = pciide_pci_read(sc->sc_pc, sc->sc_tag, CMD_CTRL);
        int interface, one_channel;
 
@@ -194,7 +193,7 @@ cmd_channel_map(struct pci_attach_args *
                return;
        }
 
-       pciide_mapchan(pa, cp, interface, &cmdsize, &ctlsize, cmd_pci_intr);
+       pciide_mapchan(pa, cp, interface, cmd_pci_intr);
 }
 
 static int
@@ -499,7 +498,6 @@ cmd680_channel_map(struct pci_attach_arg
     int channel)
 {
        struct pciide_channel *cp = &sc->pciide_channels[channel];
-       bus_size_t cmdsize, ctlsize;
        int interface, i, reg;
        static const u_int8_t init_val[] =
            {             0x8a, 0x32, 0x8a, 0x32, 0x8a, 0x32,
@@ -541,7 +539,7 @@ cmd680_channel_map(struct pci_attach_arg
            (interface & PCIIDE_INTERFACE_PCI(channel)) ?
            "native-PCI" : "compatibility");
 
-       pciide_mapchan(pa, cp, interface, &cmdsize, &ctlsize, pciide_pci_intr);
+       pciide_mapchan(pa, cp, interface, pciide_pci_intr);
 }
 
 static void
Index: sys/dev/pci/cypide.c
===================================================================
RCS file: /local/netbsd/anoncvs/src/sys/dev/pci/cypide.c,v
retrieving revision 1.22
diff -u -a -p -r1.22 cypide.c
--- sys/dev/pci/cypide.c        19 Oct 2009 18:41:14 -0000      1.22
+++ sys/dev/pci/cypide.c        10 Sep 2010 20:25:15 -0000
@@ -93,7 +93,6 @@ cy693_chip_map(struct pciide_softc *sc, 
 {
        struct pciide_channel *cp;
        pcireg_t interface = PCI_INTERFACE(pa->pa_class);
-       bus_size_t cmdsize, ctlsize;
 
        if (pciide_chipen(sc, pa) == 0)
                return;
@@ -164,12 +163,10 @@ cy693_chip_map(struct pciide_softc *sc, 
            "configured" : "wired");
        if (interface & PCIIDE_INTERFACE_PCI(0)) {
                aprint_normal("native-PCI mode\n");
-               pciide_mapregs_native(pa, cp, &cmdsize, &ctlsize,
-                   pciide_pci_intr);
+               pciide_mapregs_native(pa, cp, pciide_pci_intr);
        } else {
                aprint_normal("compatibility mode\n");
-               pciide_mapregs_compat(pa, cp, sc->sc_cy_compatchan, &cmdsize,
-                   &ctlsize);
+               pciide_mapregs_compat(pa, cp, sc->sc_cy_compatchan);
                if ((cp->ata_channel.ch_flags & ATACH_DISABLED) == 0)
                        pciide_map_compat_intr(pa, cp, sc->sc_cy_compatchan);
        }
Index: sys/dev/pci/geodeide.c
===================================================================
RCS file: /local/netbsd/anoncvs/src/sys/dev/pci/geodeide.c,v
retrieving revision 1.16
diff -u -a -p -r1.16 geodeide.c
--- sys/dev/pci/geodeide.c      19 Oct 2009 18:41:15 -0000      1.16
+++ sys/dev/pci/geodeide.c      10 Sep 2010 20:25:15 -0000
@@ -106,7 +106,6 @@ geodeide_chip_map(struct pciide_softc *s
 {
        struct pciide_channel *cp;
        int channel;
-       bus_size_t cmdsize, ctlsize;
 
        if (pciide_chipen(sc, pa) == 0)
                return;
@@ -163,7 +162,7 @@ geodeide_chip_map(struct pciide_softc *s
                /* controller is compat-only */
                if (pciide_chansetup(sc, channel, 0) == 0)
                        continue;
-               pciide_mapchan(pa, cp, 0, &cmdsize, &ctlsize, pciide_pci_intr);
+               pciide_mapchan(pa, cp, 0, pciide_pci_intr);
        }
 }
 
Index: sys/dev/pci/hptide.c
===================================================================
RCS file: /local/netbsd/anoncvs/src/sys/dev/pci/hptide.c,v
retrieving revision 1.26
diff -u -a -p -r1.26 hptide.c
--- sys/dev/pci/hptide.c        19 Oct 2009 18:41:15 -0000      1.26
+++ sys/dev/pci/hptide.c        10 Sep 2010 20:25:15 -0000
@@ -110,7 +110,6 @@ hpt_chip_map(struct pciide_softc *sc, st
        struct pciide_channel *cp;
        int i, compatchan, revision;
        pcireg_t interface;
-       bus_size_t cmdsize, ctlsize;
 
        if (pciide_chipen(sc, pa) == 0)
                return;
@@ -238,11 +237,9 @@ hpt_chip_map(struct pciide_softc *sc, st
                if (pciide_chansetup(sc, i, interface) == 0)
                        continue;
                if (interface & PCIIDE_INTERFACE_PCI(i)) {
-                       pciide_mapregs_native(pa, cp, &cmdsize,
-                           &ctlsize, hpt_pci_intr);
+                       pciide_mapregs_native(pa, cp, hpt_pci_intr);
                } else {
-                       pciide_mapregs_compat(pa, cp, compatchan,
-                           &cmdsize, &ctlsize);
+                       pciide_mapregs_compat(pa, cp, compatchan);
                        if ((cp->ata_channel.ch_flags & ATACH_DISABLED) == 0)
                                pciide_map_compat_intr(pa, cp,
                                    sc->sc_cy_compatchan);
Index: sys/dev/pci/iteide.c
===================================================================
RCS file: /local/netbsd/anoncvs/src/sys/dev/pci/iteide.c,v
retrieving revision 1.10
diff -u -a -p -r1.10 iteide.c
--- sys/dev/pci/iteide.c        10 Apr 2008 19:13:37 -0000      1.10
+++ sys/dev/pci/iteide.c        10 Sep 2010 20:25:15 -0000
@@ -99,7 +99,6 @@ ite_chip_map(struct pciide_softc *sc, st
        struct pciide_channel *cp;
        int channel;
        pcireg_t interface;
-       bus_size_t cmdsize, ctlsize;
        pcireg_t cfg, modectl;
 
        /* fake interface since IT8212 claims to be a RAID device */
@@ -149,8 +148,7 @@ ite_chip_map(struct pciide_softc *sc, st
                if (pciide_chansetup(sc, channel, interface) == 0)
                        continue;
 
-               pciide_mapchan(pa, cp, interface, &cmdsize, &ctlsize,
-                   pciide_pci_intr);
+               pciide_mapchan(pa, cp, interface, pciide_pci_intr);
        }
        /* Re-read configuration registers after channels setup */
        cfg = pci_conf_read(sc->sc_pc, sc->sc_tag, IT_CFG);
Index: sys/dev/pci/ixpide.c
===================================================================
RCS file: /local/netbsd/anoncvs/src/sys/dev/pci/ixpide.c,v
retrieving revision 1.16
diff -u -a -p -r1.16 ixpide.c
--- sys/dev/pci/ixpide.c        24 Feb 2010 22:38:01 -0000      1.16
+++ sys/dev/pci/ixpide.c        10 Sep 2010 20:25:15 -0000
@@ -99,7 +99,6 @@ ixp_chip_map(struct pciide_softc *sc, st
        struct pciide_channel *cp;
        int channel;
        pcireg_t interface;
-       bus_size_t cmdsize, ctlsize;
 
        if (pciide_chipen(sc, pa) == 0)
                return;
@@ -131,8 +130,7 @@ ixp_chip_map(struct pciide_softc *sc, st
                cp = &sc->pciide_channels[channel];
                if (pciide_chansetup(sc, channel, interface) == 0)
                        continue;
-               pciide_mapchan(pa, cp, interface, &cmdsize, &ctlsize,
-                   pciide_pci_intr);
+               pciide_mapchan(pa, cp, interface, pciide_pci_intr);
        }
 }
 
Index: sys/dev/pci/jmide.c
===================================================================
RCS file: /local/netbsd/anoncvs/src/sys/dev/pci/jmide.c,v
retrieving revision 1.8
diff -u -a -p -r1.8 jmide.c
--- sys/dev/pci/jmide.c 27 Jul 2010 22:07:51 -0000      1.8
+++ sys/dev/pci/jmide.c 10 Sep 2010 20:25:15 -0000
@@ -308,7 +308,6 @@ jmpata_chip_map(struct pciide_softc *sc,
        struct jmide_softc *jmidesc = (struct jmide_softc *)sc;
        int channel;
        pcireg_t interface;
-       bus_size_t cmdsize, ctlsize;
        struct pciide_channel *cp;
 
        if (pciide_chipen(sc, pa) == 0)
@@ -358,8 +357,7 @@ jmpata_chip_map(struct pciide_softc *sc,
                        cp->ata_channel.ch_flags |= ATACH_DISABLED;
                        continue;
                }
-               pciide_mapchan(pa, cp, interface, &cmdsize, &ctlsize,
-                       pciide_pci_intr);
+               pciide_mapchan(pa, cp, interface, pciide_pci_intr);
        }
 }
 
Index: sys/dev/pci/optiide.c
===================================================================
RCS file: /local/netbsd/anoncvs/src/sys/dev/pci/optiide.c,v
retrieving revision 1.17
diff -u -a -p -r1.17 optiide.c
--- sys/dev/pci/optiide.c       28 Apr 2008 20:23:55 -0000      1.17
+++ sys/dev/pci/optiide.c       10 Sep 2010 20:25:15 -0000
@@ -104,7 +104,6 @@ static void
 opti_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa)
 {
        struct pciide_channel *cp;
-       bus_size_t cmdsize, ctlsize;
        pcireg_t interface;
        u_int8_t init_ctrl;
        int channel;
@@ -162,8 +161,7 @@ opti_chip_map(struct pciide_softc *sc, s
                        cp->ata_channel.ch_flags |= ATACH_DISABLED;
                        continue;
                }
-               pciide_mapchan(pa, cp, interface, &cmdsize, &ctlsize,
-                   pciide_pci_intr);
+               pciide_mapchan(pa, cp, interface, pciide_pci_intr);
        }
 }
 
Index: sys/dev/pci/pciide_common.c
===================================================================
RCS file: /local/netbsd/anoncvs/src/sys/dev/pci/pciide_common.c,v
retrieving revision 1.43
diff -u -a -p -r1.43 pciide_common.c
--- sys/dev/pci/pciide_common.c 19 Oct 2009 18:41:15 -0000      1.43
+++ sys/dev/pci/pciide_common.c 10 Sep 2010 20:25:15 -0000
@@ -171,6 +171,57 @@ pciide_common_attach(struct pciide_softc
            pci_conf_read(pc, tag, PCI_COMMAND_STATUS_REG)), DEBUG_PROBE);
 }
 
+int
+pciide_common_detach(struct pciide_softc *sc, int flags)
+{
+       struct pciide_channel *cp;
+       struct ata_channel *wdc_cp;
+       struct wdc_regs *wdr;
+       int channel, drive;
+       int rv;
+
+       rv = wdcdetach(sc->sc_wdcdev.sc_atac.atac_dev, flags);
+       if (rv)
+               return rv;
+
+       for (channel = 0; channel < sc->sc_wdcdev.sc_atac.atac_nchannels;
+            channel++) {
+               cp = &sc->pciide_channels[channel];
+               wdc_cp = &cp->ata_channel;
+               wdr = CHAN_TO_WDC_REGS(wdc_cp);
+
+               if (wdc_cp->ch_flags & ATACH_DISABLED)
+                       continue;
+
+               if (wdr->cmd_ios != 0)
+                       bus_space_unmap(wdr->cmd_iot,
+                           wdr->cmd_baseioh, wdr->cmd_ios);
+               if (cp->compat != 0) {
+                       if (wdr->ctl_ios != 0)
+                               bus_space_unmap(wdr->ctl_iot,
+                                   wdr->ctl_ioh, wdr->ctl_ios);
+               } else {
+                       if (cp->ctl_ios != 0)
+                               bus_space_unmap(wdr->ctl_iot,
+                                   cp->ctl_baseioh, cp->ctl_ios);
+               }
+
+               for (drive = 0; drive < cp->ata_channel.ch_ndrive; drive++) {
+                       pciide_dma_table_teardown(sc, channel, drive);
+               }
+
+               free(cp->ata_channel.ch_queue, M_DEVBUF);
+               cp->ata_channel.atabus = NULL;
+       }
+
+       if (sc->sc_dma_ios != 0)
+               bus_space_unmap(sc->sc_dma_iot, sc->sc_dma_ioh, sc->sc_dma_ios);
+       if (sc->sc_ba5_ss != 0)
+               bus_space_unmap(sc->sc_dma_iot, sc->sc_dma_ioh, sc->sc_dma_ios);
+
+       return 0;
+}
+
 /* tell whether the chip is enabled or not */
 int
 pciide_chipen(struct pciide_softc *sc, struct pci_attach_args *pa)
@@ -190,7 +241,7 @@ pciide_chipen(struct pciide_softc *sc, s
 }
 
 void
-pciide_mapregs_compat(struct pci_attach_args *pa, struct pciide_channel *cp, 
int compatchan, bus_size_t *cmdsizep, bus_size_t *ctlsizep)
+pciide_mapregs_compat(struct pci_attach_args *pa, struct pciide_channel *cp, 
int compatchan)
 {
        struct pciide_softc *sc = CHAN_TO_PCIIDE(&cp->ata_channel);
        struct ata_channel *wdc_cp = &cp->ata_channel;
@@ -198,8 +249,6 @@ pciide_mapregs_compat(struct pci_attach_
        int i;
 
        cp->compat = 1;
-       *cmdsizep = PCIIDE_COMPAT_CMD_SIZE;
-       *ctlsizep = PCIIDE_COMPAT_CTL_SIZE;
 
        wdr->cmd_iot = pa->pa_iot;
        if (bus_space_map(wdr->cmd_iot, PCIIDE_COMPAT_CMD_BASE(compatchan),
@@ -208,16 +257,17 @@ pciide_mapregs_compat(struct pci_attach_
                    "couldn't map %s channel cmd regs\n", cp->name);
                goto bad;
        }
+       wdr->cmd_ios = PCIIDE_COMPAT_CMD_SIZE;
 
        wdr->ctl_iot = pa->pa_iot;
        if (bus_space_map(wdr->ctl_iot, PCIIDE_COMPAT_CTL_BASE(compatchan),
            PCIIDE_COMPAT_CTL_SIZE, 0, &wdr->ctl_ioh) != 0) {
                aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev,
                    "couldn't map %s channel ctl regs\n", cp->name);
-               bus_space_unmap(wdr->cmd_iot, wdr->cmd_baseioh,
-                   PCIIDE_COMPAT_CMD_SIZE);
+               bus_space_unmap(wdr->cmd_iot, wdr->cmd_baseioh, wdr->cmd_ios);
                goto bad;
        }
+       wdr->ctl_ios = PCIIDE_COMPAT_CTL_SIZE;
 
        for (i = 0; i < WDC_NREG; i++) {
                if (bus_space_subregion(wdr->cmd_iot, wdr->cmd_baseioh, i,
@@ -240,8 +290,7 @@ bad:
 
 void
 pciide_mapregs_native(struct pci_attach_args *pa,
-       struct pciide_channel *cp, bus_size_t *cmdsizep,
-       bus_size_t *ctlsizep, int (*pci_intr)(void *))
+       struct pciide_channel *cp, int (*pci_intr)(void *))
 {
        struct pciide_softc *sc = CHAN_TO_PCIIDE(&cp->ata_channel);
        struct ata_channel *wdc_cp = &cp->ata_channel;
@@ -277,7 +326,7 @@ pciide_mapregs_native(struct pci_attach_
        cp->ih = sc->sc_pci_ih;
        if (pci_mapreg_map(pa, PCIIDE_REG_CMD_BASE(wdc_cp->ch_channel),
            PCI_MAPREG_TYPE_IO, 0,
-           &wdr->cmd_iot, &wdr->cmd_baseioh, NULL, cmdsizep) != 0) {
+           &wdr->cmd_iot, &wdr->cmd_baseioh, NULL, &wdr->cmd_ios) != 0) {
                aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev,
                    "couldn't map %s channel cmd regs\n", cp->name);
                goto bad;
@@ -285,11 +334,10 @@ pciide_mapregs_native(struct pci_attach_
 
        if (pci_mapreg_map(pa, PCIIDE_REG_CTL_BASE(wdc_cp->ch_channel),
            PCI_MAPREG_TYPE_IO, 0,
-           &wdr->ctl_iot, &cp->ctl_baseioh, NULL, ctlsizep) != 0) {
+           &wdr->ctl_iot, &cp->ctl_baseioh, NULL, &cp->ctl_ios) != 0) {
                aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev,
                    "couldn't map %s channel ctl regs\n", cp->name);
-               bus_space_unmap(wdr->cmd_iot, wdr->cmd_baseioh,
-                   *cmdsizep);
+               bus_space_unmap(wdr->cmd_iot, wdr->cmd_baseioh, wdr->cmd_ios);
                goto bad;
        }
        /*
@@ -301,9 +349,8 @@ pciide_mapregs_native(struct pci_attach_
            &wdr->ctl_ioh) != 0) {
                aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev,
                    "unable to subregion %s channel ctl regs\n", cp->name);
-               bus_space_unmap(wdr->cmd_iot, wdr->cmd_baseioh,
-                    *cmdsizep);
-               bus_space_unmap(wdr->cmd_iot, cp->ctl_baseioh, *ctlsizep);
+               bus_space_unmap(wdr->cmd_iot, wdr->cmd_baseioh, wdr->cmd_ios);
+               bus_space_unmap(wdr->cmd_iot, cp->ctl_baseioh, cp->ctl_ios);
                goto bad;
        }
 
@@ -377,7 +424,8 @@ pciide_mapreg_dma(struct pciide_softc *s
        case PCI_MAPREG_MEM_TYPE_32BIT:
                sc->sc_dma_ok = (pci_mapreg_map(pa,
                    PCIIDE_REG_BUS_MASTER_DMA, maptype, 0,
-                   &sc->sc_dma_iot, &sc->sc_dma_ioh, NULL, NULL) == 0);
+                   &sc->sc_dma_iot, &sc->sc_dma_ioh, NULL, &sc->sc_dma_ios)
+                   == 0);
                sc->sc_dmat = pa->pa_dmat;
                if (sc->sc_dma_ok == 0) {
                        aprint_verbose(", but unused (couldn't map registers)");
@@ -514,8 +562,7 @@ pciide_channel_dma_setup(struct pciide_c
 int
 pciide_dma_table_setup(struct pciide_softc *sc, int channel, int drive)
 {
-       bus_dma_segment_t seg;
-       int error, rseg;
+       int error;
        const bus_size_t dma_table_size =
            sizeof(struct idedma_table) * NIDEDMA_TABLES(sc);
        struct pciide_dma_maps *dma_maps =
@@ -527,15 +574,15 @@ pciide_dma_table_setup(struct pciide_sof
 
        /* Allocate memory for the DMA tables and map it */
        if ((error = bus_dmamem_alloc(sc->sc_dmat, dma_table_size,
-           IDEDMA_TBL_ALIGN, IDEDMA_TBL_ALIGN, &seg, 1, &rseg,
-           BUS_DMA_NOWAIT)) != 0) {
+           IDEDMA_TBL_ALIGN, IDEDMA_TBL_ALIGN, &dma_maps->dmamap_table_seg,
+           1, &dma_maps->dmamap_table_nseg, BUS_DMA_NOWAIT)) != 0) {
                aprint_error(dmaerrfmt,
                    device_xname(sc->sc_wdcdev.sc_atac.atac_dev), channel,
                    "allocate", drive, error);
                return error;
        }
-       if ((error = bus_dmamem_map(sc->sc_dmat, &seg, rseg,
-           dma_table_size,
+       if ((error = bus_dmamem_map(sc->sc_dmat, &dma_maps->dmamap_table_seg,
+           dma_maps->dmamap_table_nseg, dma_table_size,
            (void **)&dma_maps->dma_table,
            BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) {
                aprint_error(dmaerrfmt,
@@ -545,7 +592,7 @@ pciide_dma_table_setup(struct pciide_sof
        }
        ATADEBUG_PRINT(("pciide_dma_table_setup: table at %p len %lu, "
            "phy 0x%lx\n", dma_maps->dma_table, (u_long)dma_table_size,
-           (unsigned long)seg.ds_addr), DEBUG_PROBE);
+           (unsigned long)dma_maps->dmamap_table_seg.ds_addr), DEBUG_PROBE);
        /* Create and load table DMA map for this disk */
        if ((error = bus_dmamap_create(sc->sc_dmat, dma_table_size,
            1, dma_table_size, IDEDMA_TBL_ALIGN, BUS_DMA_NOWAIT,
@@ -580,6 +627,31 @@ pciide_dma_table_setup(struct pciide_sof
        return 0;
 }
 
+void
+pciide_dma_table_teardown(struct pciide_softc *sc, int channel, int drive)
+{
+       struct pciide_channel *cp;
+       struct pciide_dma_maps *dma_maps;
+
+       cp = &sc->pciide_channels[channel];
+       dma_maps = &cp->dma_maps[drive];
+
+       if (dma_maps->dma_table == NULL)
+               return;
+
+       bus_dmamap_destroy(sc->sc_dmat, dma_maps->dmamap_xfer);
+       bus_dmamap_unload(sc->sc_dmat, dma_maps->dmamap_table);
+       bus_dmamap_destroy(sc->sc_dmat, dma_maps->dmamap_table);
+       bus_dmamem_unmap(sc->sc_dmat, dma_maps->dma_table,
+           sizeof(struct idedma_table) * NIDEDMA_TABLES(sc));
+       bus_dmamem_free(sc->sc_dmat, &dma_maps->dmamap_table_seg,
+           dma_maps->dmamap_table_nseg);
+
+       dma_maps->dma_table = NULL;
+
+       return;
+}
+
 int
 pciide_dma_dmamap_setup(struct pciide_softc *sc, int channel, int drive, void 
*databuf, size_t datalen, int flags)
 {
@@ -778,16 +850,14 @@ pciide_chansetup(struct pciide_softc *sc
 void
 pciide_mapchan(struct pci_attach_args *pa,
        struct pciide_channel *cp,
-       pcireg_t interface, bus_size_t *cmdsizep,
-       bus_size_t *ctlsizep, int (*pci_intr)(void *))
+       pcireg_t interface, int (*pci_intr)(void *))
 {
        struct ata_channel *wdc_cp = &cp->ata_channel;
 
        if (interface & PCIIDE_INTERFACE_PCI(wdc_cp->ch_channel))
-               pciide_mapregs_native(pa, cp, cmdsizep, ctlsizep, pci_intr);
+               pciide_mapregs_native(pa, cp, pci_intr);
        else {
-               pciide_mapregs_compat(pa, cp, wdc_cp->ch_channel, cmdsizep,
-                   ctlsizep);
+               pciide_mapregs_compat(pa, cp, wdc_cp->ch_channel);
                if ((cp->ata_channel.ch_flags & ATACH_DISABLED) == 0)
                        pciide_map_compat_intr(pa, cp, wdc_cp->ch_channel);
        }
@@ -828,7 +898,6 @@ default_chip_map(struct pciide_softc *sc
        int drive;
        u_int8_t idedma_ctl;
 #endif
-       bus_size_t cmdsize, ctlsize;
        const char *failreason;
        struct wdc_regs *wdr;
 
@@ -887,11 +956,10 @@ default_chip_map(struct pciide_softc *sc
                        continue;
                wdr = CHAN_TO_WDC_REGS(&cp->ata_channel);
                if (interface & PCIIDE_INTERFACE_PCI(channel))
-                       pciide_mapregs_native(pa, cp, &cmdsize, &ctlsize,
-                           pciide_pci_intr);
+                       pciide_mapregs_native(pa, cp, pciide_pci_intr);
                else
                        pciide_mapregs_compat(pa, cp,
-                           cp->ata_channel.ch_channel, &cmdsize, &ctlsize);
+                           cp->ata_channel.ch_channel);
                if (cp->ata_channel.ch_flags & ATACH_DISABLED)
                        continue;
                /*
@@ -932,8 +1000,9 @@ next:
                            "%s channel ignored (%s)\n", cp->name, failreason);
                        cp->ata_channel.ch_flags |= ATACH_DISABLED;
                        bus_space_unmap(wdr->cmd_iot, wdr->cmd_baseioh,
-                           cmdsize);
-                       bus_space_unmap(wdr->ctl_iot, wdr->ctl_ioh, ctlsize);
+                           wdr->cmd_ios);
+                       bus_space_unmap(wdr->ctl_iot, wdr->ctl_ioh,
+                           wdr->ctl_ios);
                } else {
                        pciide_map_compat_intr(pa, cp,
                            cp->ata_channel.ch_channel);
Index: sys/dev/pci/pciidevar.h
===================================================================
RCS file: /local/netbsd/anoncvs/src/sys/dev/pci/pciidevar.h,v
retrieving revision 1.40
diff -u -a -p -r1.40 pciidevar.h
--- sys/dev/pci/pciidevar.h     14 Nov 2009 09:42:50 -0000      1.40
+++ sys/dev/pci/pciidevar.h     10 Sep 2010 20:25:15 -0000
@@ -89,6 +89,7 @@ struct pciide_softc {
         */
        bus_space_tag_t         sc_dma_iot;
        bus_space_handle_t      sc_dma_ioh;
+       bus_size_t              sc_dma_ios;
        bus_dma_tag_t           sc_dmat;
 
        /*
@@ -114,6 +115,7 @@ struct pciide_softc {
         */
        bus_space_tag_t sc_ba5_st;
        bus_space_handle_t sc_ba5_sh;
+       bus_size_t sc_ba5_ss;
        int sc_ba5_en;
 #endif /* NATA_DMA */
 
@@ -130,14 +132,17 @@ struct pciide_softc {
                int             compat; /* is it compat? */
                void            *ih;    /* compat or pci handle */
                bus_space_handle_t ctl_baseioh; /* ctrl regs blk, native mode */
+               bus_size_t      ctl_ios;
 #if NATA_DMA
                /* DMA tables and DMA map for xfer, for each drive */
                struct pciide_dma_maps {
+                       bus_dma_segment_t dmamap_table_seg;
+                       int             dmamap_table_nseg;
                        bus_dmamap_t    dmamap_table;
                        struct idedma_table *dma_table;
                        bus_dmamap_t    dmamap_xfer;
                        int dma_flags;
-               } dma_maps[2];
+               } dma_maps[ATA_MAXDRIVES];
                bus_space_handle_t      dma_iohs[IDEDMA_NREGS];
                /*
                 * Some controllers require certain bits to
@@ -164,9 +169,6 @@ struct pciide_product_desc {
        const char *ide_name;
        /* map and setup chip, probe drives */
        void (*chip_map)(struct pciide_softc*, struct pci_attach_args*);
-#if 0
-       void (*chip_unmap)(struct pciide_softc *);
-#endif
 };
 
 /* Flags for ide_flags */
@@ -202,6 +204,8 @@ void sata_setup_channel(struct ata_chann
 
 void pciide_channel_dma_setup(struct pciide_channel *);
 int  pciide_dma_table_setup(struct pciide_softc*, int, int);
+void pciide_dma_table_teardown(struct pciide_softc *, int, int);
+
 int  pciide_dma_dmamap_setup(struct pciide_softc *, int, int,
                                void *, size_t, int);
 int  pciide_dma_init(void*, int, int, void *, size_t, int);
@@ -223,19 +227,18 @@ const struct pciide_product_desc* pciide
        (u_int32_t, const struct pciide_product_desc *);
 void   pciide_common_attach(struct pciide_softc *, struct pci_attach_args *,
                const struct pciide_product_desc *);
+int    pciide_common_detach(struct pciide_softc *, int);
 
 int    pciide_chipen(struct pciide_softc *, struct pci_attach_args *);
 void   pciide_mapregs_compat(struct pci_attach_args *,
-           struct pciide_channel *, int, bus_size_t *, bus_size_t*);
+           struct pciide_channel *, int);
 void   pciide_mapregs_native(struct pci_attach_args *,
-           struct pciide_channel *, bus_size_t *, bus_size_t *,
-           int (*pci_intr)(void *));
+           struct pciide_channel *, int (*pci_intr)(void *));
 void   pciide_mapreg_dma(struct pciide_softc *,
            struct pci_attach_args *);
 int    pciide_chansetup(struct pciide_softc *, int, pcireg_t);
 void   pciide_mapchan(struct pci_attach_args *,
-           struct pciide_channel *, pcireg_t, bus_size_t *, bus_size_t *,
-           int (*pci_intr)(void *));
+           struct pciide_channel *, pcireg_t, int (*pci_intr)(void *));
 void   pciide_map_compat_intr(struct pci_attach_args *,
            struct pciide_channel *, int);
 int    pciide_compat_intr(void *);
Index: sys/dev/pci/pdcide.c
===================================================================
RCS file: /local/netbsd/anoncvs/src/sys/dev/pci/pdcide.c,v
retrieving revision 1.27
diff -u -a -p -r1.27 pdcide.c
--- sys/dev/pci/pdcide.c        19 Oct 2009 18:41:16 -0000      1.27
+++ sys/dev/pci/pdcide.c        10 Sep 2010 20:25:15 -0000
@@ -181,7 +181,6 @@ pdc202xx_chip_map(struct pciide_softc *s
        struct pciide_channel *cp;
        int channel;
        pcireg_t interface, st, mode;
-       bus_size_t cmdsize, ctlsize;
 
        if (!PDC_IS_268(sc)) {
                st = pci_conf_read(sc->sc_pc, sc->sc_tag, PDC2xx_STATE);
@@ -313,7 +312,7 @@ pdc202xx_chip_map(struct pciide_softc *s
                        cp->ata_channel.ch_flags |= ATACH_DISABLED;
                        continue;
                }
-               pciide_mapchan(pa, cp, interface, &cmdsize, &ctlsize,
+               pciide_mapchan(pa, cp, interface,
                    PDC_IS_265(sc) ? pdc20265_pci_intr : pdc202xx_pci_intr);
                /* clear interrupt, in case there is one pending */
                bus_space_write_1(sc->sc_dma_iot, cp->dma_iohs[IDEDMA_CTL], 0,
Index: sys/dev/pci/pdcsata.c
===================================================================
RCS file: /local/netbsd/anoncvs/src/sys/dev/pci/pdcsata.c,v
retrieving revision 1.18
diff -u -a -p -r1.18 pdcsata.c
--- sys/dev/pci/pdcsata.c       26 Nov 2009 15:17:10 -0000      1.18
+++ sys/dev/pci/pdcsata.c       10 Sep 2010 20:25:15 -0000
@@ -226,7 +226,6 @@ pdcsata_chip_map(struct pciide_softc *sc
        struct ata_channel *wdc_cp;
        struct wdc_regs *wdr;
        int channel, i;
-       bus_size_t dmasize;
        pci_intr_handle_t intrhandle;
        const char *intrstr;
 
@@ -257,7 +256,7 @@ pdcsata_chip_map(struct pciide_softc *sc
 
        sc->sc_dma_ok = (pci_mapreg_map(pa, PCIIDE_REG_BUS_MASTER_DMA,
            PCI_MAPREG_MEM_TYPE_32BIT, 0, &sc->sc_dma_iot,
-           &sc->sc_dma_ioh, NULL, &dmasize) == 0);
+           &sc->sc_dma_ioh, NULL, &sc->sc_dma_ios) == 0);
        if (!sc->sc_dma_ok) {
                aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev,
                    "couldn't map bus-master DMA registers\n");
@@ -269,10 +268,10 @@ pdcsata_chip_map(struct pciide_softc *sc
 
        if (pci_mapreg_map(pa, PDC203xx_BAR_IDEREGS,
            PCI_MAPREG_MEM_TYPE_32BIT, 0, &sc->sc_ba5_st,
-           &sc->sc_ba5_sh, NULL, NULL) != 0) {
+           &sc->sc_ba5_sh, NULL, &sc->sc_ba5_ss) != 0) {
                aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev,
                    "couldn't map IDE registers\n");
-               bus_space_unmap(sc->sc_dma_iot, sc->sc_dma_ioh, dmasize);
+               bus_space_unmap(sc->sc_dma_iot, sc->sc_dma_ioh, sc->sc_dma_ios);
                pci_intr_disestablish(pa->pa_pc, sc->sc_pci_ih);
                return;
        }
Index: sys/dev/pci/piixide.c
===================================================================
RCS file: /local/netbsd/anoncvs/src/sys/dev/pci/piixide.c,v
retrieving revision 1.55
diff -u -a -p -r1.55 piixide.c
--- sys/dev/pci/piixide.c       30 Jul 2010 15:28:09 -0000      1.55
+++ sys/dev/pci/piixide.c       10 Sep 2010 20:25:15 -0000
@@ -398,7 +398,6 @@ piix_chip_map(struct pciide_softc *sc, s
        struct pciide_channel *cp;
        int channel;
        u_int32_t idetim;
-       bus_size_t cmdsize, ctlsize;
        pcireg_t interface = PCI_INTERFACE(pa->pa_class);
 
        if (pciide_chipen(sc, pa) == 0)
@@ -523,8 +522,7 @@ piix_chip_map(struct pciide_softc *sc, s
                            channel, idetim, interface);
 #endif
                }
-               pciide_mapchan(pa, cp, interface,
-                   &cmdsize, &ctlsize, pciide_pci_intr);
+               pciide_mapchan(pa, cp, interface, pciide_pci_intr);
        }
 
        ATADEBUG_PRINT(("piix_setup_chip: idetim=0x%x",
@@ -894,7 +892,6 @@ static void
 piixsata_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa)
 {
        struct pciide_channel *cp;
-       bus_size_t cmdsize, ctlsize;
        pcireg_t interface, cmdsts;
        int channel;
 
@@ -938,8 +935,7 @@ piixsata_chip_map(struct pciide_softc *s
                cp = &sc->pciide_channels[channel];
                if (pciide_chansetup(sc, channel, interface) == 0)
                        continue;
-               pciide_mapchan(pa, cp, interface, &cmdsize, &ctlsize,
-                   pciide_pci_intr);
+               pciide_mapchan(pa, cp, interface, pciide_pci_intr);
        }
 }
 
Index: sys/dev/pci/rccide.c
===================================================================
RCS file: /local/netbsd/anoncvs/src/sys/dev/pci/rccide.c,v
retrieving revision 1.19
diff -u -a -p -r1.19 rccide.c
--- sys/dev/pci/rccide.c        14 Mar 2009 15:36:19 -0000      1.19
+++ sys/dev/pci/rccide.c        10 Sep 2010 20:25:15 -0000
@@ -116,7 +116,6 @@ serverworks_chip_map(struct pciide_softc
        pcireg_t interface = PCI_INTERFACE(pa->pa_class);
        pcitag_t pcib_tag;
        int channel;
-       bus_size_t cmdsize, ctlsize;
 
        if (pciide_chipen(sc, pa) == 0)
                return;
@@ -164,11 +163,11 @@ serverworks_chip_map(struct pciide_softc
                switch (sc->sc_pp->ide_product) {
                case PCI_PRODUCT_SERVERWORKS_CSB6_IDE:
                case PCI_PRODUCT_SERVERWORKS_CSB6_RAID:
-                       pciide_mapchan(pa, cp, interface, &cmdsize, &ctlsize,
+                       pciide_mapchan(pa, cp, interface,
                            serverworkscsb6_pci_intr);
                        break;
                default:
-                       pciide_mapchan(pa, cp, interface, &cmdsize, &ctlsize,
+                       pciide_mapchan(pa, cp, interface,
                            serverworks_pci_intr);
                }
        }
Index: sys/dev/pci/satalink.c
===================================================================
RCS file: /local/netbsd/anoncvs/src/sys/dev/pci/satalink.c,v
retrieving revision 1.41
diff -u -a -p -r1.41 satalink.c
--- sys/dev/pci/satalink.c      8 Jun 2010 05:06:10 -0000       1.41
+++ sys/dev/pci/satalink.c      10 Sep 2010 20:25:15 -0000
@@ -423,7 +423,6 @@ static void
 sii3112_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa)
 {
        struct pciide_channel *cp;
-       bus_size_t cmdsize, ctlsize;
        pcireg_t interface, scs_cmd, cfgctl;
        int channel;
 
@@ -453,7 +452,7 @@ sii3112_chip_map(struct pciide_softc *sc
                                   PCI_MAPREG_TYPE_MEM|
                                   PCI_MAPREG_MEM_TYPE_32BIT, 0,
                                   &sc->sc_ba5_st, &sc->sc_ba5_sh,
-                                  NULL, NULL) != 0)
+                                  NULL, &sc->sc_ba5_ss) != 0)
                        aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev,
                            "unable to map SATALink BA5 register space\n");
                else
@@ -523,8 +522,7 @@ sii3112_chip_map(struct pciide_softc *sc
                cp = &sc->pciide_channels[channel];
                if (pciide_chansetup(sc, channel, interface) == 0)
                        continue;
-               pciide_mapchan(pa, cp, interface, &cmdsize, &ctlsize,
-                   pciide_pci_intr);
+               pciide_mapchan(pa, cp, interface, pciide_pci_intr);
        }
 }
 
@@ -709,7 +707,7 @@ sii3114_chip_map(struct pciide_softc *sc
                           PCI_MAPREG_TYPE_MEM|
                           PCI_MAPREG_MEM_TYPE_32BIT, 0,
                           &sc->sc_ba5_st, &sc->sc_ba5_sh,
-                          NULL, NULL) != 0) {
+                          NULL, &sc->sc_ba5_ss) != 0) {
                aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev,
                    "unable to map SATALink BA5 register space\n");
                return;
Index: sys/dev/pci/siside.c
===================================================================
RCS file: /local/netbsd/anoncvs/src/sys/dev/pci/siside.c,v
retrieving revision 1.25
diff -u -a -p -r1.25 siside.c
--- sys/dev/pci/siside.c        19 Oct 2009 18:41:16 -0000      1.25
+++ sys/dev/pci/siside.c        10 Sep 2010 20:25:15 -0000
@@ -226,7 +226,6 @@ sis_chip_map(struct pciide_softc *sc, st
        u_int8_t sis_ctr0 = pciide_pci_read(sc->sc_pc, sc->sc_tag, SIS_CTRL0);
        pcireg_t interface = PCI_INTERFACE(pa->pa_class);
        pcireg_t rev = PCI_REVISION(pa->pa_class);
-       bus_size_t cmdsize, ctlsize;
 
        if (pciide_chipen(sc, pa) == 0)
                return;
@@ -331,8 +330,7 @@ sis_chip_map(struct pciide_softc *sc, st
                        cp->ata_channel.ch_flags |= ATACH_DISABLED;
                        continue;
                }
-               pciide_mapchan(pa, cp, interface, &cmdsize, &ctlsize,
-                   pciide_pci_intr);
+               pciide_mapchan(pa, cp, interface, pciide_pci_intr);
        }
 }
 
@@ -513,7 +511,6 @@ sis_sata_chip_map(struct pciide_softc *s
        struct pciide_channel *cp;
        pcireg_t interface = PCI_INTERFACE(pa->pa_class);
        int channel;
-       bus_size_t cmdsize, ctlsize;
 
        if (pciide_chipen(sc, pa) == 0)
                return;
@@ -554,7 +551,6 @@ sis_sata_chip_map(struct pciide_softc *s
                cp = &sc->pciide_channels[channel];
                if (pciide_chansetup(sc, channel, interface) == 0)
                        continue;
-               pciide_mapchan(pa, cp, interface, &cmdsize, &ctlsize,
-                   pciide_pci_intr);
+               pciide_mapchan(pa, cp, interface, pciide_pci_intr);
        }
 }
Index: sys/dev/pci/slide.c
===================================================================
RCS file: /local/netbsd/anoncvs/src/sys/dev/pci/slide.c,v
retrieving revision 1.20
diff -u -a -p -r1.20 slide.c
--- sys/dev/pci/slide.c 28 Apr 2008 20:23:55 -0000      1.20
+++ sys/dev/pci/slide.c 10 Sep 2010 20:25:15 -0000
@@ -128,7 +128,6 @@ static void
 sl82c105_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa)
 {
        struct pciide_channel *cp;
-       bus_size_t cmdsize, ctlsize;
        pcireg_t interface, idecr;
        int channel;
 
@@ -179,8 +178,7 @@ sl82c105_chip_map(struct pciide_softc *s
                        cp->ata_channel.ch_flags |= ATACH_DISABLED;
                        continue;
                }
-               pciide_mapchan(pa, cp, interface, &cmdsize, &ctlsize,
-                   pciide_pci_intr);
+               pciide_mapchan(pa, cp, interface, pciide_pci_intr);
        }
 }
 
Index: sys/dev/pci/stpcide.c
===================================================================
RCS file: /local/netbsd/anoncvs/src/sys/dev/pci/stpcide.c,v
retrieving revision 1.19
diff -u -a -p -r1.19 stpcide.c
--- sys/dev/pci/stpcide.c       26 May 2008 10:31:22 -0000      1.19
+++ sys/dev/pci/stpcide.c       10 Sep 2010 20:25:15 -0000
@@ -89,7 +89,6 @@ stpc_chip_map(struct pciide_softc *sc, s
        struct pciide_channel *cp;
        int channel;
        pcireg_t interface = PCI_INTERFACE(pa->pa_class);
-       bus_size_t cmdsize, ctlsize;
 
        if (pciide_chipen(sc, pa) == 0)
                return;
@@ -117,8 +116,7 @@ stpc_chip_map(struct pciide_softc *sc, s
                cp = &sc->pciide_channels[channel];
                if (pciide_chansetup(sc, channel, interface) == 0)
                        continue;
-               pciide_mapchan(pa, cp, interface, &cmdsize, &ctlsize,
-                   pciide_pci_intr);
+               pciide_mapchan(pa, cp, interface, pciide_pci_intr);
        }
 }
 
Index: sys/dev/pci/svwsata.c
===================================================================
RCS file: /local/netbsd/anoncvs/src/sys/dev/pci/svwsata.c,v
retrieving revision 1.11
diff -u -a -p -r1.11 svwsata.c
--- sys/dev/pci/svwsata.c       26 Nov 2009 15:17:10 -0000      1.11
+++ sys/dev/pci/svwsata.c       10 Sep 2010 20:25:15 -0000
@@ -122,7 +122,7 @@ svwsata_chip_map(struct pciide_softc *sc
                           PCI_MAPREG_TYPE_MEM |
                           PCI_MAPREG_MEM_TYPE_32BIT, 0,
                           &sc->sc_ba5_st, &sc->sc_ba5_sh,
-                          NULL, NULL) != 0) {
+                          NULL, &sc->sc_ba5_ss) != 0) {
                aprint_error(": unable to map BA5 register space\n");
                return;
        }
Index: sys/dev/pci/toshide.c
===================================================================
RCS file: /local/netbsd/anoncvs/src/sys/dev/pci/toshide.c,v
retrieving revision 1.2
diff -u -a -p -r1.2 toshide.c
--- sys/dev/pci/toshide.c       20 Sep 2009 01:12:30 -0000      1.2
+++ sys/dev/pci/toshide.c       10 Sep 2010 20:25:15 -0000
@@ -114,7 +114,6 @@ static void
 piccolo_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa)
 {
        struct pciide_channel *cp;
-       bus_size_t cmdsize, ctlsize;
        pcireg_t interface;
        int channel;
 
@@ -157,8 +156,7 @@ piccolo_chip_map(struct pciide_softc *sc
                if (pciide_chansetup(sc, channel, interface) == 0)
                        continue;
 
-               pciide_mapchan(pa, cp, interface, &cmdsize, &ctlsize,
-                   pciide_pci_intr);
+               pciide_mapchan(pa, cp, interface, pciide_pci_intr);
        }
 }
 
Index: sys/dev/pci/viaide.c
===================================================================
RCS file: /local/netbsd/anoncvs/src/sys/dev/pci/viaide.c,v
retrieving revision 1.69
diff -u -a -p -r1.69 viaide.c
--- sys/dev/pci/viaide.c        22 Mar 2010 22:39:48 -0000      1.69
+++ sys/dev/pci/viaide.c        10 Sep 2010 20:25:15 -0000
@@ -40,9 +40,9 @@ __KERNEL_RCSID(0, "$NetBSD: viaide.c,v 1
 static int     via_pcib_match(struct pci_attach_args *);
 static void    via_chip_map(struct pciide_softc *, struct pci_attach_args *);
 static void    via_mapchan(struct pci_attach_args *, struct pciide_channel *,
-                   pcireg_t, bus_size_t *, bus_size_t *, int (*)(void *));
+                   pcireg_t, int (*)(void *));
 static void    via_mapregs_compat_native(struct pci_attach_args *,
-                   struct pciide_channel *, bus_size_t *, bus_size_t *);
+                   struct pciide_channel *);
 static int     via_sata_chip_map_common(struct pciide_softc *,
                    struct pci_attach_args *);
 static void    via_sata_chip_map(struct pciide_softc *,
@@ -440,7 +440,6 @@ via_chip_map(struct pciide_softc *sc, st
        pcireg_t vendor = PCI_VENDOR(pa->pa_id);
        int channel;
        u_int32_t ideconf;
-       bus_size_t cmdsize, ctlsize;
        pcireg_t pcib_id, pcib_class;
        struct pci_attach_args pcib_pa;
 
@@ -614,15 +613,13 @@ unknown:
                        cp->ata_channel.ch_flags |= ATACH_DISABLED;
                        continue;
                }
-               via_mapchan(pa, cp, interface, &cmdsize, &ctlsize,
-                   pciide_pci_intr);
+               via_mapchan(pa, cp, interface, pciide_pci_intr);
        }
 }
 
 static void
 via_mapchan(struct pci_attach_args *pa,        struct pciide_channel *cp,
-    pcireg_t interface, bus_size_t *cmdsizep, bus_size_t *ctlsizep,
-    int (*pci_intr)(void *))
+    pcireg_t interface, int (*pci_intr)(void *))
 {
        struct ata_channel *wdc_cp;
        struct pciide_softc *sc;
@@ -638,13 +635,11 @@ via_mapchan(struct pci_attach_args *pa,   
                /* native mode with irq 14/15 requested? */
                if (compat_nat_enable != NULL &&
                    prop_bool_true(compat_nat_enable))
-                       via_mapregs_compat_native(pa, cp, cmdsizep, ctlsizep);
+                       via_mapregs_compat_native(pa, cp);
                else
-                       pciide_mapregs_native(pa, cp, cmdsizep, ctlsizep,
-                           pci_intr);
+                       pciide_mapregs_native(pa, cp, pci_intr);
        } else {
-               pciide_mapregs_compat(pa, cp, wdc_cp->ch_channel, cmdsizep,
-                   ctlsizep);
+               pciide_mapregs_compat(pa, cp, wdc_cp->ch_channel);
                if ((cp->ata_channel.ch_flags & ATACH_DISABLED) == 0)
                        pciide_map_compat_intr(pa, cp, wdc_cp->ch_channel);
        }
@@ -659,7 +654,7 @@ via_mapchan(struct pci_attach_args *pa,     
  */
 static void
 via_mapregs_compat_native(struct pci_attach_args *pa,
-    struct pciide_channel *cp, bus_size_t *cmdsizep, bus_size_t *ctlsizep)
+    struct pciide_channel *cp)
 {
        struct ata_channel *wdc_cp;
        struct pciide_softc *sc;
@@ -670,7 +665,7 @@ via_mapregs_compat_native(struct pci_att
        /* XXX prevent pciide_mapregs_native from installing a handler */
        if (sc->sc_pci_ih == NULL)
                sc->sc_pci_ih = (void *)~0;
-       pciide_mapregs_native(pa, cp, cmdsizep, ctlsizep, NULL);
+       pciide_mapregs_native(pa, cp, NULL);
 
        /* interrupts are fixed to 14/15, as in compatibility mode */
        cp->compat = 1;
@@ -840,7 +835,6 @@ pio:                /* setup PIO mode */
 static int
 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)
@@ -875,7 +869,7 @@ via_sata_chip_map_common(struct pciide_s
        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);
+                   NULL, &sc->sc_ba5_ss);
                break;
        case PCI_MAPREG_MEM_TYPE_32BIT:
                /*
@@ -895,7 +889,7 @@ via_sata_chip_map_common(struct pciide_s
                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);
+                   NULL, &sc->sc_ba5_ss);
                break;
        default:
                aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev,
@@ -920,7 +914,6 @@ via_sata_chip_map(struct pciide_softc *s
        struct wdc_regs *wdr;
        pcireg_t interface = PCI_INTERFACE(pa->pa_class);
        int channel;
-       bus_size_t cmdsize, ctlsize;
 
        if (via_sata_chip_map_common(sc, pa) == 0)
                return;
@@ -966,8 +959,7 @@ via_sata_chip_map(struct pciide_softc *s
                        continue;
                }
                sc->sc_wdcdev.sc_atac.atac_probe = wdc_sataprobe;
-               pciide_mapchan(pa, cp, interface, &cmdsize, &ctlsize,
-                   pciide_pci_intr);
+               pciide_mapchan(pa, cp, interface, pciide_pci_intr);
        }
 }
 
@@ -991,7 +983,6 @@ via_sata_chip_map_new(struct pciide_soft
        struct wdc_regs *wdr;
        pcireg_t interface = PCI_INTERFACE(pa->pa_class);
        int channel;
-       bus_size_t cmdsize;
        pci_intr_handle_t intrhandle;
        const char *intrstr;
        int i;
@@ -1065,7 +1056,7 @@ via_sata_chip_map_new(struct pciide_soft
 
                if (pci_mapreg_map(pa, (PCI_MAPREG_START + (4 * (channel))),
                    PCI_MAPREG_TYPE_IO, 0, &wdr->cmd_iot, &wdr->cmd_baseioh,
-                   NULL, &cmdsize) != 0) {
+                   NULL, &wdr->cmd_ios) != 0) {
                        aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev,
                            "couldn't map %s channel regs\n", cp->name);
                }
Index: sys/arch/i386/pci/gcscide.c
===================================================================
RCS file: /local/netbsd/anoncvs/src/sys/arch/i386/pci/gcscide.c,v
retrieving revision 1.7
diff -u -a -p -r1.7 gcscide.c
--- sys/arch/i386/pci/gcscide.c 18 Mar 2008 20:46:36 -0000      1.7
+++ sys/arch/i386/pci/gcscide.c 10 Sep 2010 20:25:15 -0000
@@ -153,7 +153,6 @@ static void
 gcscide_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa)
 {
        pcireg_t interface;
-       bus_size_t cmdsize, ctlsize;
 
        if (pciide_chipen(sc, pa) == 0)
                return;
@@ -184,7 +183,7 @@ gcscide_chip_map(struct pciide_softc *sc
                return;
 
        pciide_mapchan(pa, &sc->pciide_channels[0], interface,
-           &cmdsize, &ctlsize, pciide_pci_intr);
+           pciide_pci_intr);
 }
 
 static void


Home | Main Index | Thread Index | Old Index