Messages in this thread Patch in this message | | | From | Bartlomiej Zolnierkiewicz <> | Subject | [PATCH 11/20] async_tx: do DMA unmap in core for MEMSET operations | Date | Mon, 05 Nov 2012 11:00:22 +0100 |
| |
Convert core async_tx code (async_memset()) to do DMA unmapping itself using the ->callback functionality.
Cc: Dan Williams <djbw@fb.com> Cc: Tomasz Figa <t.figa@samsung.com> Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> --- crypto/async_tx/async_memset.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/crypto/async_tx/async_memset.c b/crypto/async_tx/async_memset.c index a6a667b..cf30bf1 100644 --- a/crypto/async_tx/async_memset.c +++ b/crypto/async_tx/async_memset.c @@ -30,6 +30,17 @@ #include <linux/dma-mapping.h> #include <linux/async_tx.h> +static void async_memset_cb(void *dma_async_param) +{ + struct dma_async_tx_descriptor *tx = dma_async_param; + struct dma_device *dev = tx->chan->device; + + dma_unmap_page(dev->dev, tx->dma_dst, tx->dma_len, DMA_FROM_DEVICE); + + if (tx->orig_callback) + tx->orig_callback(tx->orig_callback_param); +} + /** * async_memset - attempt to fill memory with a dma engine. * @dest: destination page @@ -47,10 +58,11 @@ async_memset(struct page *dest, int val, unsigned int offset, size_t len, &dest, 1, NULL, 0, len); struct dma_device *device = chan ? chan->device : NULL; struct dma_async_tx_descriptor *tx = NULL; + dma_addr_t dma_dest; if (device && is_dma_fill_aligned(device, offset, 0, len)) { - dma_addr_t dma_dest; - unsigned long dma_prep_flags = 0; + unsigned long dma_prep_flags = DMA_COMPL_SKIP_SRC_UNMAP | + DMA_COMPL_SKIP_DEST_UNMAP; if (submit->cb_fn) dma_prep_flags |= DMA_PREP_INTERRUPT; @@ -68,7 +80,11 @@ async_memset(struct page *dest, int val, unsigned int offset, size_t len, if (tx) { pr_debug("%s: (async) len: %zu\n", __func__, len); - async_tx_submit(chan, tx, submit); + + tx->dma_dst = dma_dest; + tx->dma_len = len; + + __async_tx_submit(chan, tx, async_memset_cb, tx, submit); } else { /* run the memset synchronously */ void *dest_buf; pr_debug("%s: (sync) len: %zu\n", __func__, len); -- 1.8.0
| |