From 0c340d7ed9072218c10e52a40b500befe2bafe58 Mon Sep 17 00:00:00 2001 From: Ruslan Bukin Date: Thu, 4 Jul 2019 14:04:08 +0000 Subject: Negate the logic of XCHAN_CAP_NOBUFS macro and rename it to XCHAN_CAP_BOUNCE. The only application that uses bounce buffering for now is the Government Furnished Equipment (GFE) P2's dma core (AXIDMA) with its own dedicated cacheless bounce buffer. Sponsored by: DARPA, AFRL --- sys/dev/altera/softdma/softdma.c | 1 - sys/dev/xdma/xdma.h | 2 +- sys/dev/xdma/xdma_sg.c | 16 ++++++++-------- sys/dev/xilinx/axidma.c | 1 + 4 files changed, 10 insertions(+), 10 deletions(-) (limited to 'sys/dev') diff --git a/sys/dev/altera/softdma/softdma.c b/sys/dev/altera/softdma/softdma.c index b60d642d0ada0..7d4932083b0cb 100644 --- a/sys/dev/altera/softdma/softdma.c +++ b/sys/dev/altera/softdma/softdma.c @@ -616,7 +616,6 @@ softdma_channel_alloc(device_t dev, struct xdma_channel *xchan) if (chan->used == 0) { chan->xchan = xchan; xchan->chan = (void *)chan; - xchan->caps |= XCHAN_CAP_NOBUFS; xchan->caps |= XCHAN_CAP_NOSEG; chan->index = i; chan->idx_head = 0; diff --git a/sys/dev/xdma/xdma.h b/sys/dev/xdma/xdma.h index 583ad63e4e0f8..b645bd50adb38 100644 --- a/sys/dev/xdma/xdma.h +++ b/sys/dev/xdma/xdma.h @@ -137,7 +137,7 @@ struct xdma_channel { uint32_t caps; #define XCHAN_CAP_BUSDMA (1 << 0) #define XCHAN_CAP_NOSEG (1 << 1) -#define XCHAN_CAP_NOBUFS (1 << 2) +#define XCHAN_CAP_BOUNCE (1 << 2) /* A real hardware driver channel. */ void *chan; diff --git a/sys/dev/xdma/xdma_sg.c b/sys/dev/xdma/xdma_sg.c index e6c593c7c47a8..2dff9761e8dd6 100644 --- a/sys/dev/xdma/xdma_sg.c +++ b/sys/dev/xdma/xdma_sg.c @@ -290,7 +290,7 @@ xdma_prep_sg(xdma_channel_t *xchan, uint32_t xr_num, } /* Allocate buffers if required. */ - if ((xchan->caps & XCHAN_CAP_NOBUFS) == 0) { + if (xchan->caps & (XCHAN_CAP_BUSDMA | XCHAN_CAP_BOUNCE)) { ret = xchan_bufs_alloc(xchan); if (ret != 0) { device_printf(xdma->dev, @@ -347,9 +347,8 @@ xchan_seg_done(xdma_channel_t *xchan, bus_dmamap_sync(xchan->dma_tag_bufs, b->map, BUS_DMASYNC_POSTREAD); bus_dmamap_unload(xchan->dma_tag_bufs, b->map); - } else { - if ((xchan->caps & XCHAN_CAP_NOBUFS) == 0 && - xr->req_type == XR_TYPE_MBUF && + } else if (xchan->caps & XCHAN_CAP_BOUNCE) { + if (xr->req_type == XR_TYPE_MBUF && xr->direction == XDMA_DEV_TO_MEM) m_copyback(xr->m, 0, st->transferred, (void *)xr->buf.vaddr); @@ -494,13 +493,14 @@ _xdma_load_data(xdma_channel_t *xchan, struct xdma_request *xr, switch (xr->req_type) { case XR_TYPE_MBUF: - if ((xchan->caps & XCHAN_CAP_NOBUFS) == 0) { + if (xchan->caps & XCHAN_CAP_BUSDMA) + seg[0].ds_addr = mtod(m, bus_addr_t); + else if (xchan->caps & XCHAN_CAP_BOUNCE) { if (xr->direction == XDMA_MEM_TO_DEV) m_copydata(m, 0, m->m_pkthdr.len, (void *)xr->buf.vaddr); seg[0].ds_addr = (bus_addr_t)xr->buf.paddr; - } else - seg[0].ds_addr = mtod(m, bus_addr_t); + } seg[0].ds_len = m->m_pkthdr.len; break; case XR_TYPE_BIO: @@ -626,7 +626,7 @@ xdma_queue_submit_sg(xdma_channel_t *xchan) sg = xchan->sg; - if ((xchan->caps & XCHAN_CAP_NOBUFS) == 0 && + if ((xchan->caps & (XCHAN_CAP_BOUNCE | XCHAN_CAP_BUSDMA)) && (xchan->flags & XCHAN_BUFS_ALLOCATED) == 0) { device_printf(xdma->dev, "%s: Can't submit a transfer: no bufs\n", diff --git a/sys/dev/xilinx/axidma.c b/sys/dev/xilinx/axidma.c index 8d5f05a0a5f13..3c9b1b5c6dc70 100644 --- a/sys/dev/xilinx/axidma.c +++ b/sys/dev/xilinx/axidma.c @@ -399,6 +399,7 @@ axidma_channel_alloc(device_t dev, struct xdma_channel *xchan) if (axidma_reset(sc, data->id) != 0) return (-1); chan->xchan = xchan; + xchan->caps |= XCHAN_CAP_BOUNCE; xchan->chan = (void *)chan; chan->sc = sc; chan->used = true; -- cgit v1.3