[PATCH 05/12] async_memset: convert to dmaengine_unmap_data

From: Dan Williams
Date: Thu Dec 06 2012 - 04:48:41 EST


Use the generic unmap object to unmap dma buffers.

Cc: Tomasz Figa <t.figa@xxxxxxxxxxx>
Cc: Kyungmin Park <kyungmin.park@xxxxxxxxxxx>
Reported-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@xxxxxxxxxxx>
Signed-off-by: Dan Williams <djbw@xxxxxx>
---
crypto/async_tx/async_memset.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/crypto/async_tx/async_memset.c b/crypto/async_tx/async_memset.c
index 05a4d1e..ffca53b 100644
--- a/crypto/async_tx/async_memset.c
+++ b/crypto/async_tx/async_memset.c
@@ -47,17 +47,22 @@ 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;
+ struct dmaengine_unmap_data *unmap = NULL;

- if (device && is_dma_fill_aligned(device, offset, 0, len)) {
- dma_addr_t dma_dest;
- unsigned long dma_prep_flags = 0;
+ if (device)
+ unmap = dmaengine_get_unmap_data(device->dev, 1, GFP_NOIO);
+
+ if (unmap && is_dma_fill_aligned(device, offset, 0, len)) {
+ 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;
if (submit->flags & ASYNC_TX_FENCE)
dma_prep_flags |= DMA_PREP_FENCE;
- dma_dest = dma_map_page(device->dev, dest, offset, len,
- DMA_FROM_DEVICE);
+ unmap->from_cnt = 1;
+ unmap->addr[0] = dma_map_page(device->dev, dest, offset, len,
+ DMA_FROM_DEVICE);

tx = device->device_prep_dma_memset(chan, dma_dest, val, len,
dma_prep_flags);
@@ -65,6 +70,8 @@ async_memset(struct page *dest, int val, unsigned int offset, size_t len,

if (tx) {
pr_debug("%s: (async) len: %zu\n", __func__, len);
+
+ dma_set_unmap(tx, unmap);
async_tx_submit(chan, tx, submit);
} else { /* run the memset synchronously */
void *dest_buf;
@@ -79,6 +86,7 @@ async_memset(struct page *dest, int val, unsigned int offset, size_t len,

async_tx_sync_epilog(submit);
}
+ dmaengine_unmap_put(unmap);

return tx;
}

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/