aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/mps/mps.c
diff options
context:
space:
mode:
authorScott Long <scottl@FreeBSD.org>2020-09-14 05:58:12 +0000
committerScott Long <scottl@FreeBSD.org>2020-09-14 05:58:12 +0000
commit74c781ed913dc866ec596e3a7875e5b0c76f7e22 (patch)
tree1604f8bdd0adc7691f3a39cd1afac4f0583b8b82 /sys/dev/mps/mps.c
parent7c9b0046d420a1b979961122ca4bd21efbb2978f (diff)
Notes
Diffstat (limited to 'sys/dev/mps/mps.c')
-rw-r--r--sys/dev/mps/mps.c45
1 files changed, 20 insertions, 25 deletions
diff --git a/sys/dev/mps/mps.c b/sys/dev/mps/mps.c
index f577bcb77355..e3db1e49118f 100644
--- a/sys/dev/mps/mps.c
+++ b/sys/dev/mps/mps.c
@@ -1278,7 +1278,7 @@ mps_alloc_queues(struct mps_softc *sc)
static int
mps_alloc_hw_queues(struct mps_softc *sc)
{
- bus_dma_tag_template_t t;
+ bus_dma_template_t t;
bus_addr_t queues_busaddr;
uint8_t *queues;
int qsize, fqsize, pqsize;
@@ -1301,10 +1301,9 @@ mps_alloc_hw_queues(struct mps_softc *sc)
qsize = fqsize + pqsize;
bus_dma_template_init(&t, sc->mps_parent_dmat);
- t.alignment = 16;
- t.lowaddr = BUS_SPACE_MAXADDR_32BIT;
- t.maxsize = t.maxsegsize = qsize;
- t.nsegments = 1;
+ BUS_DMA_TEMPLATE_FILL(&t, BD_ALIGNMENT(16), BD_MAXSIZE(qsize),
+ BD_MAXSEGSIZE(qsize), BD_NSEGMENTS(1),
+ BD_LOWADDR(BUS_SPACE_MAXADDR_32BIT));
if (bus_dma_template_tag(&t, &sc->queues_dmat)) {
mps_dprint(sc, MPS_ERROR, "Cannot allocate queues DMA tag\n");
return (ENOMEM);
@@ -1333,7 +1332,7 @@ mps_alloc_hw_queues(struct mps_softc *sc)
static int
mps_alloc_replies(struct mps_softc *sc)
{
- bus_dma_tag_template_t t;
+ bus_dma_template_t t;
int rsize, num_replies;
/* Store the reply frame size in bytes rather than as 32bit words */
@@ -1348,10 +1347,9 @@ mps_alloc_replies(struct mps_softc *sc)
rsize = sc->replyframesz * num_replies;
bus_dma_template_init(&t, sc->mps_parent_dmat);
- t.alignment = 4;
- t.lowaddr = BUS_SPACE_MAXADDR_32BIT;
- t.maxsize = t.maxsegsize = rsize;
- t.nsegments = 1;
+ BUS_DMA_TEMPLATE_FILL(&t, BD_ALIGNMENT(4), BD_MAXSIZE(rsize),
+ BD_MAXSEGSIZE(rsize), BD_NSEGMENTS(1),
+ BD_LOWADDR(BUS_SPACE_MAXADDR_32BIT));
if (bus_dma_template_tag(&t, &sc->reply_dmat)) {
mps_dprint(sc, MPS_ERROR, "Cannot allocate replies DMA tag\n");
return (ENOMEM);
@@ -1400,16 +1398,15 @@ mps_load_chains_cb(void *arg, bus_dma_segment_t *segs, int nsegs, int error)
static int
mps_alloc_requests(struct mps_softc *sc)
{
- bus_dma_tag_template_t t;
+ bus_dma_template_t t;
struct mps_command *cm;
int i, rsize, nsegs;
rsize = sc->reqframesz * sc->num_reqs;
bus_dma_template_init(&t, sc->mps_parent_dmat);
- t.alignment = 16;
- t.lowaddr = BUS_SPACE_MAXADDR_32BIT;
- t.maxsize = t.maxsegsize = rsize;
- t.nsegments = 1;
+ BUS_DMA_TEMPLATE_FILL(&t, BD_ALIGNMENT(16), BD_MAXSIZE(rsize),
+ BD_MAXSEGSIZE(rsize), BD_NSEGMENTS(1),
+ BD_LOWADDR(BUS_SPACE_MAXADDR_32BIT));
if (bus_dma_template_tag(&t, &sc->req_dmat)) {
mps_dprint(sc, MPS_ERROR, "Cannot allocate request DMA tag\n");
return (ENOMEM);
@@ -1433,8 +1430,8 @@ mps_alloc_requests(struct mps_softc *sc)
}
rsize = sc->reqframesz * sc->num_chains;
bus_dma_template_clone(&t, sc->req_dmat);
- t.maxsize = t.maxsegsize = rsize;
- t.nsegments = howmany(rsize, PAGE_SIZE);
+ BUS_DMA_TEMPLATE_FILL(&t, BD_MAXSIZE(rsize), BD_MAXSEGSIZE(rsize),
+ BD_NSEGMENTS(howmany(rsize, PAGE_SIZE)));
if (bus_dma_template_tag(&t, &sc->chain_dmat)) {
mps_dprint(sc, MPS_ERROR, "Cannot allocate chain DMA tag\n");
return (ENOMEM);
@@ -1454,8 +1451,8 @@ mps_alloc_requests(struct mps_softc *sc)
rsize = MPS_SENSE_LEN * sc->num_reqs;
bus_dma_template_clone(&t, sc->req_dmat);
- t.maxsize = t.maxsegsize = rsize;
- t.alignment = 1;
+ BUS_DMA_TEMPLATE_FILL(&t, BD_ALIGNMENT(1), BD_MAXSIZE(rsize),
+ BD_MAXSEGSIZE(rsize));
if (bus_dma_template_tag(&t, &sc->sense_dmat)) {
mps_dprint(sc, MPS_ERROR, "Cannot allocate sense DMA tag\n");
return (ENOMEM);
@@ -1473,12 +1470,10 @@ mps_alloc_requests(struct mps_softc *sc)
nsegs = (sc->maxio / PAGE_SIZE) + 1;
bus_dma_template_init(&t, sc->mps_parent_dmat);
- t.maxsize = BUS_SPACE_MAXSIZE_32BIT;
- t.nsegments = nsegs;
- t.maxsegsize = BUS_SPACE_MAXSIZE_24BIT;
- t.flags = BUS_DMA_ALLOCNOW;
- t.lockfunc = busdma_lock_mutex;
- t.lockfuncarg = &sc->mps_mtx;
+ BUS_DMA_TEMPLATE_FILL(&t, BD_MAXSIZE(BUS_SPACE_MAXSIZE_32BIT),
+ BD_NSEGMENTS(nsegs), BD_MAXSEGSIZE(BUS_SPACE_MAXSIZE_24BIT),
+ BD_FLAGS(BUS_DMA_ALLOCNOW), BD_LOCKFUNC(busdma_lock_mutex),
+ BD_LOCKFUNCARG(&sc->mps_mtx));
if (bus_dma_template_tag(&t, &sc->buffer_dmat)) {
mps_dprint(sc, MPS_ERROR, "Cannot allocate buffer DMA tag\n");
return (ENOMEM);