From 44e529fecc89baa030bea1214df56a37c2ae43ab Mon Sep 17 00:00:00 2001 From: thorpej Date: Thu, 19 Jul 2001 16:36:14 +0000 Subject: [PATCH] Use BUS_DMA_READ and BUS_DMA_WRITE in some obvious places. --- sys/dev/isa/isadma.c | 5 +++-- sys/dev/isa/wds.c | 10 +++++++--- sys/dev/pci/if_sip.c | 11 ++++++----- sys/dev/pci/if_ste.c | 9 +++++---- sys/dev/pci/if_ti.c | 12 +++++++----- sys/dev/pci/if_vr.c | 9 +++++---- sys/dev/pci/isp_pci.c | 5 +++-- sys/dev/pci/pciide.c | 5 +++-- sys/dev/pci/pcscp.c | 6 ++++-- sys/dev/pci/twe.c | 6 ++++-- sys/dev/tc/asc_tcds.c | 6 +++--- sys/dev/tc/bba.c | 6 +++--- 12 files changed, 53 insertions(+), 37 deletions(-) diff --git a/sys/dev/isa/isadma.c b/sys/dev/isa/isadma.c index 775716bdce94..1920fc8c2463 100644 --- a/sys/dev/isa/isadma.c +++ b/sys/dev/isa/isadma.c @@ -1,4 +1,4 @@ -/* $NetBSD: isadma.c,v 1.47 2001/02/12 15:49:19 briggs Exp $ */ +/* $NetBSD: isadma.c,v 1.48 2001/07/19 16:41:11 thorpej Exp $ */ /*- * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc. @@ -375,7 +375,8 @@ _isa_dmastart(ids, chan, addr, nbytes, p, flags, busdmaflags) panic("_isa_dmastart: no DMA map for chan %d\n", chan); error = bus_dmamap_load(ids->ids_dmat, dmam, addr, nbytes, - p, busdmaflags); + p, busdmaflags | + ((flags & DMAMODE_READ) ? BUS_DMA_READ : BUS_DMA_WRITE)); if (error) return (error); diff --git a/sys/dev/isa/wds.c b/sys/dev/isa/wds.c index 6ad1a7cd2849..97fce1e9ed30 100644 --- a/sys/dev/isa/wds.c +++ b/sys/dev/isa/wds.c @@ -1,4 +1,4 @@ -/* $NetBSD: wds.c,v 1.44 2001/07/18 20:52:48 thorpej Exp $ */ +/* $NetBSD: wds.c,v 1.45 2001/07/19 16:38:40 thorpej Exp $ */ #include "opt_ddb.h" @@ -1179,13 +1179,17 @@ wds_scsipi_request(chan, req, arg) if (flags & XS_CTL_DATA_UIO) { error = bus_dmamap_load_uio(dmat, scb->dmamap_xfer, (struct uio *)xs->data, - BUS_DMA_NOWAIT); + BUS_DMA_NOWAIT | + ((flags & XS_CTL_DATA_IN) ? BUS_DMA_READ : + BUS_DMA_WRITE)); } else #endif /* TFS */ { error = bus_dmamap_load(dmat, scb->dmamap_xfer, xs->data, xs->datalen, - NULL, BUS_DMA_NOWAIT); + NULL, BUS_DMA_NOWAIT | + ((flags & XS_CTL_DATA_IN) ? BUS_DMA_READ : + BUS_DMA_WRITE)); } switch (error) { diff --git a/sys/dev/pci/if_sip.c b/sys/dev/pci/if_sip.c index 0eff060d03e7..64be0b3e314e 100644 --- a/sys/dev/pci/if_sip.c +++ b/sys/dev/pci/if_sip.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_sip.c,v 1.40 2001/07/08 17:15:45 thorpej Exp $ */ +/* $NetBSD: if_sip.c,v 1.41 2001/07/19 16:36:14 thorpej Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -986,7 +986,7 @@ SIP_DECL(start)(struct ifnet *ifp) * buffer. */ error = bus_dmamap_load_mbuf(sc->sc_dmat, dmamap, m0, - BUS_DMA_NOWAIT); + BUS_DMA_WRITE|BUS_DMA_NOWAIT); if (error) { if (error == EFBIG) { printf("%s: Tx packet consumes too many " @@ -1009,7 +1009,7 @@ SIP_DECL(start)(struct ifnet *ifp) * and try again. */ if (bus_dmamap_load_mbuf(sc->sc_dmat, dmamap, m0, - BUS_DMA_NOWAIT) != 0) { + BUS_DMA_WRITE|BUS_DMA_NOWAIT) != 0) { MGETHDR(m, M_DONTWAIT, MT_DATA); if (m == NULL) { printf("%s: unable to allocate Tx mbuf\n", @@ -1028,7 +1028,7 @@ SIP_DECL(start)(struct ifnet *ifp) m_copydata(m0, 0, m0->m_pkthdr.len, mtod(m, caddr_t)); m->m_pkthdr.len = m->m_len = m0->m_pkthdr.len; error = bus_dmamap_load_mbuf(sc->sc_dmat, dmamap, - m, BUS_DMA_NOWAIT); + m, BUS_DMA_WRITE|BUS_DMA_NOWAIT); if (error) { printf("%s: unable to load Tx buffer, " "error = %d\n", sc->sc_dev.dv_xname, error); @@ -2378,7 +2378,8 @@ SIP_DECL(add_rxbuf)(struct sip_softc *sc, int idx) rxs->rxs_mbuf = m; error = bus_dmamap_load(sc->sc_dmat, rxs->rxs_dmamap, - m->m_ext.ext_buf, m->m_ext.ext_size, NULL, BUS_DMA_NOWAIT); + m->m_ext.ext_buf, m->m_ext.ext_size, NULL, + BUS_DMA_READ|BUS_DMA_NOWAIT); if (error) { printf("%s: can't load rx DMA map %d, error = %d\n", sc->sc_dev.dv_xname, idx, error); diff --git a/sys/dev/pci/if_ste.c b/sys/dev/pci/if_ste.c index 0fa947a63715..b169a1a23cad 100644 --- a/sys/dev/pci/if_ste.c +++ b/sys/dev/pci/if_ste.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ste.c,v 1.3 2001/06/30 01:05:25 thorpej Exp $ */ +/* $NetBSD: if_ste.c,v 1.4 2001/07/19 16:36:15 thorpej Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -644,7 +644,7 @@ ste_start(struct ifnet *ifp) * and try again. */ if (bus_dmamap_load_mbuf(sc->sc_dmat, dmamap, m0, - BUS_DMA_NOWAIT) != 0) { + BUS_DMA_WRITE|BUS_DMA_NOWAIT) != 0) { MGETHDR(m, M_DONTWAIT, MT_DATA); if (m == NULL) { printf("%s: unable to allocate Tx mbuf\n", @@ -663,7 +663,7 @@ ste_start(struct ifnet *ifp) m_copydata(m0, 0, m0->m_pkthdr.len, mtod(m, caddr_t)); m->m_pkthdr.len = m->m_len = m0->m_pkthdr.len; error = bus_dmamap_load_mbuf(sc->sc_dmat, dmamap, - m, BUS_DMA_NOWAIT); + m, BUS_DMA_WRITE|BUS_DMA_NOWAIT); if (error) { printf("%s: unable to load Tx buffer, " "error = %d\n", sc->sc_dev.dv_xname, error); @@ -1448,7 +1448,8 @@ ste_add_rxbuf(struct ste_softc *sc, int idx) ds->ds_mbuf = m; error = bus_dmamap_load(sc->sc_dmat, ds->ds_dmamap, - m->m_ext.ext_buf, m->m_ext.ext_size, NULL, BUS_DMA_NOWAIT); + m->m_ext.ext_buf, m->m_ext.ext_size, NULL, + BUS_DMA_READ|BUS_DMA_NOWAIT); if (error) { printf("%s: can't load rx DMA map %d, error = %d\n", sc->sc_dev.dv_xname, idx, error); diff --git a/sys/dev/pci/if_ti.c b/sys/dev/pci/if_ti.c index f250371e15b5..e3cdaa6360c1 100644 --- a/sys/dev/pci/if_ti.c +++ b/sys/dev/pci/if_ti.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ti.c,v 1.39 2001/07/07 16:46:35 thorpej Exp $ */ +/* $NetBSD: if_ti.c,v 1.40 2001/07/19 16:36:15 thorpej Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -760,7 +760,7 @@ static int ti_newbuf_std(sc, i, m, dmamap) if ((error = bus_dmamap_load(sc->sc_dmat, dmamap, mtod(m_new, caddr_t), m_new->m_len, NULL, - BUS_DMA_NOWAIT)) != 0) { + BUS_DMA_READ|BUS_DMA_NOWAIT)) != 0) { printf("%s: can't load recv map, error = %d\n", sc->sc_dev.dv_xname, error); return (ENOMEM); @@ -829,7 +829,7 @@ static int ti_newbuf_mini(sc, i, m, dmamap) if ((error = bus_dmamap_load(sc->sc_dmat, dmamap, mtod(m_new, caddr_t), m_new->m_len, NULL, - BUS_DMA_NOWAIT)) != 0) { + BUS_DMA_READ|BUS_DMA_NOWAIT)) != 0) { printf("%s: can't load recv map, error = %d\n", sc->sc_dev.dv_xname, error); return (ENOMEM); @@ -2285,7 +2285,8 @@ static int ti_encap_tigon1(sc, m_head, txidx) } dmamap = dma->dmamap; - error = bus_dmamap_load_mbuf(sc->sc_dmat, dmamap, m_head, 0); + error = bus_dmamap_load_mbuf(sc->sc_dmat, dmamap, m_head, + BUS_DMA_WRITE); if (error) { struct mbuf *m; int i = 0; @@ -2391,7 +2392,8 @@ static int ti_encap_tigon2(sc, m_head, txidx) } dmamap = dma->dmamap; - error = bus_dmamap_load_mbuf(sc->sc_dmat, dmamap, m_head, 0); + error = bus_dmamap_load_mbuf(sc->sc_dmat, dmamap, m_head, + BUS_DMA_WRITE); if (error) { struct mbuf *m; int i = 0; diff --git a/sys/dev/pci/if_vr.c b/sys/dev/pci/if_vr.c index 82e6a8d55c9d..526415d33654 100644 --- a/sys/dev/pci/if_vr.c +++ b/sys/dev/pci/if_vr.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_vr.c,v 1.49 2001/07/07 16:40:24 thorpej Exp $ */ +/* $NetBSD: if_vr.c,v 1.50 2001/07/19 16:36:15 thorpej Exp $ */ /*- * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc. @@ -541,7 +541,8 @@ vr_add_rxbuf(sc, i) ds->ds_mbuf = m_new; error = bus_dmamap_load(sc->vr_dmat, ds->ds_dmamap, - m_new->m_ext.ext_buf, m_new->m_ext.ext_size, NULL, BUS_DMA_NOWAIT); + m_new->m_ext.ext_buf, m_new->m_ext.ext_size, NULL, + BUS_DMA_READ|BUS_DMA_NOWAIT); if (error) { printf("%s: unable to load rx DMA map %d, error = %d\n", sc->vr_dev.dv_xname, i, error); @@ -938,7 +939,7 @@ vr_start(ifp) */ if ((mtod(m0, bus_addr_t) & 3) != 0 || bus_dmamap_load_mbuf(sc->vr_dmat, ds->ds_dmamap, m0, - BUS_DMA_NOWAIT) != 0) { + BUS_DMA_WRITE|BUS_DMA_NOWAIT) != 0) { MGETHDR(m, M_DONTWAIT, MT_DATA); if (m == NULL) { printf("%s: unable to allocate Tx mbuf\n", @@ -957,7 +958,7 @@ vr_start(ifp) m_copydata(m0, 0, m0->m_pkthdr.len, mtod(m, caddr_t)); m->m_pkthdr.len = m->m_len = m0->m_pkthdr.len; error = bus_dmamap_load_mbuf(sc->vr_dmat, - ds->ds_dmamap, m, BUS_DMA_NOWAIT); + ds->ds_dmamap, m, BUS_DMA_WRITE|BUS_DMA_NOWAIT); if (error) { printf("%s: unable to load Tx buffer, " "error = %d\n", sc->vr_dev.dv_xname, error); diff --git a/sys/dev/pci/isp_pci.c b/sys/dev/pci/isp_pci.c index 0e873ecb80f5..ea87ded1e4f7 100644 --- a/sys/dev/pci/isp_pci.c +++ b/sys/dev/pci/isp_pci.c @@ -1,4 +1,4 @@ -/* $NetBSD: isp_pci.c,v 1.70 2001/07/07 16:46:35 thorpej Exp $ */ +/* $NetBSD: isp_pci.c,v 1.71 2001/07/19 16:36:15 thorpej Exp $ */ /* * This driver, which is contained in NetBSD in the files: * @@ -852,7 +852,8 @@ isp_pci_dmasetup(struct ispsoftc *isp, struct scsipi_xfer *xs, ispreq_t *rq, } error = bus_dmamap_load(pcs->pci_dmat, dmap, xs->data, xs->datalen, NULL, ((xs->xs_control & XS_CTL_NOSLEEP) ? - BUS_DMA_NOWAIT : BUS_DMA_WAITOK) | BUS_DMA_STREAMING); + BUS_DMA_NOWAIT : BUS_DMA_WAITOK) | BUS_DMA_STREAMING | + ((xs->xs_control & XS_CTL_DATA_IN) ? BUS_DMA_READ : BUS_DMA_WRITE)); if (error) { XS_SETERR(xs, HBA_BOTCH); return (CMD_COMPLETE); diff --git a/sys/dev/pci/pciide.c b/sys/dev/pci/pciide.c index fd4a0abadf70..0feda3965302 100644 --- a/sys/dev/pci/pciide.c +++ b/sys/dev/pci/pciide.c @@ -1,4 +1,4 @@ -/* $NetBSD: pciide.c,v 1.121 2001/07/04 16:26:17 bouyer Exp $ */ +/* $NetBSD: pciide.c,v 1.122 2001/07/19 16:36:16 thorpej Exp $ */ /* @@ -1012,7 +1012,8 @@ pciide_dma_init(v, channel, drive, databuf, datalen, flags) error = bus_dmamap_load(sc->sc_dmat, dma_maps->dmamap_xfer, - databuf, datalen, NULL, BUS_DMA_NOWAIT | BUS_DMA_STREAMING); + databuf, datalen, NULL, BUS_DMA_NOWAIT | BUS_DMA_STREAMING | + ((flags & WDC_DMA_READ) ? BUS_DMA_READ : BUS_DMA_WRITE)); if (error) { printf("%s:%d: unable to load xfer DMA map for" "drive %d, error=%d\n", sc->sc_wdcdev.sc_dev.dv_xname, diff --git a/sys/dev/pci/pcscp.c b/sys/dev/pci/pcscp.c index 49a1ff076aa6..cde2abc0284d 100644 --- a/sys/dev/pci/pcscp.c +++ b/sys/dev/pci/pcscp.c @@ -1,4 +1,4 @@ -/* $NetBSD: pcscp.c,v 1.15 2001/04/25 17:53:37 bouyer Exp $ */ +/* $NetBSD: pcscp.c,v 1.16 2001/07/19 16:36:16 thorpej Exp $ */ /*- * Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc. @@ -565,7 +565,9 @@ pcscp_dma_setup(sc, addr, len, datain, dmasize) error = bus_dmamap_load(esc->sc_dmat, dmap, *esc->sc_dmaaddr, *esc->sc_dmalen, NULL, ((sc->sc_nexus->xs->xs_control & XS_CTL_NOSLEEP) ? - BUS_DMA_NOWAIT : BUS_DMA_WAITOK) | BUS_DMA_STREAMING); + BUS_DMA_NOWAIT : BUS_DMA_WAITOK) | BUS_DMA_STREAMING | + ((sc->sc_nexus->xs->xs_control & XS_CTL_DATA_IN) ? + BUS_DMA_READ : BUS_DMA_WRITE)); if (error) { printf("%s: unable to load dmamap, error = %d\n", sc->sc_dev.dv_xname, error); diff --git a/sys/dev/pci/twe.c b/sys/dev/pci/twe.c index 7c03418ba3d8..00ea8c8ba19c 100644 --- a/sys/dev/pci/twe.c +++ b/sys/dev/pci/twe.c @@ -1,4 +1,4 @@ -/* $NetBSD: twe.c,v 1.15 2001/05/31 11:31:43 ad Exp $ */ +/* $NetBSD: twe.c,v 1.16 2001/07/19 16:36:16 thorpej Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -835,7 +835,9 @@ twe_ccb_map(struct twe_softc *sc, struct twe_ccb *ccb) * Map the data buffer into bus space and build the S/G list. */ rv = bus_dmamap_load(sc->sc_dmat, ccb->ccb_dmamap_xfer, data, - ccb->ccb_datasize, NULL, BUS_DMA_NOWAIT | BUS_DMA_STREAMING); + ccb->ccb_datasize, NULL, BUS_DMA_NOWAIT | BUS_DMA_STREAMING | + ((ccb->ccb_flags & TWE_CCB_DATA_IN) ? + BUS_DMA_READ : BUS_DMA_WRITE)); if (rv != 0) { if (ccb->ccb_abuf != (vaddr_t)0) { s = splvm(); diff --git a/sys/dev/tc/asc_tcds.c b/sys/dev/tc/asc_tcds.c index e5d5b0d2ae7a..52adfcb57c0b 100644 --- a/sys/dev/tc/asc_tcds.c +++ b/sys/dev/tc/asc_tcds.c @@ -1,4 +1,4 @@ -/* $NetBSD: asc_tcds.c,v 1.2 2001/04/25 17:53:42 bouyer Exp $ */ +/* $NetBSD: asc_tcds.c,v 1.3 2001/07/19 16:43:44 thorpej Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: asc_tcds.c,v 1.2 2001/04/25 17:53:42 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: asc_tcds.c,v 1.3 2001/07/19 16:43:44 thorpej Exp $"); #include #include @@ -290,7 +290,7 @@ tcds_dma_setup(sc, addr, len, ispullup, dmasize) return 0; if (bus_dmamap_load(asc->sc_dmat, asc->sc_dmamap, *addr, size, - NULL, BUS_DMA_NOWAIT)) { + NULL, BUS_DMA_NOWAIT | (ispullup ? BUS_DMA_READ : BUS_DMA_WRITE))) { /* * XXX Should return an error, here, but the upper-layer * XXX doesn't check the return value! diff --git a/sys/dev/tc/bba.c b/sys/dev/tc/bba.c index 410ef651d86b..67d2ad262d67 100644 --- a/sys/dev/tc/bba.c +++ b/sys/dev/tc/bba.c @@ -1,4 +1,4 @@ -/* $NetBSD: bba.c,v 1.12 2000/07/18 06:14:05 thorpej Exp $ */ +/* $NetBSD: bba.c,v 1.13 2001/07/19 16:43:44 thorpej Exp $ */ /* * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -478,7 +478,7 @@ bba_trigger_output(addr, start, end, blksize, intr, arg, param) state |= 1; if (bus_dmamap_load(sc->sc_dmat, d->dmam, start, - (char *)end - (char *)start, NULL, BUS_DMA_NOWAIT)) { + (char *)end - (char *)start, NULL, BUS_DMA_WRITE|BUS_DMA_NOWAIT)) { printf("bba_trigger_output: can't load DMA map\n"); goto bad; } @@ -547,7 +547,7 @@ bba_trigger_input(addr, start, end, blksize, intr, arg, param) state |= 1; if (bus_dmamap_load(sc->sc_dmat, d->dmam, start, - (char *)end - (char *)start, NULL, BUS_DMA_NOWAIT)) { + (char *)end - (char *)start, NULL, BUS_DMA_READ|BUS_DMA_NOWAIT)) { printf("bba_trigger_input: can't load DMA map\n"); goto bad; }