Convert core async_tx code (async_xor_val()) to do DMA unmapping itself using the ->callback functionality.
Cc: Dan Williams <d...@fb.com> Cc: Tomasz Figa <t.f...@samsung.com> Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnier...@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.p...@samsung.com> --- crypto/async_tx/async_xor.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/crypto/async_tx/async_xor.c b/crypto/async_tx/async_xor.c index 59a4af3..d44da16 100644 --- a/crypto/async_tx/async_xor.c +++ b/crypto/async_tx/async_xor.c @@ -284,6 +284,20 @@ xor_val_chan(struct async_submit_ctl *submit, struct page *dest, src_cnt, len); } +static void async_xor_val_cb(void *dma_async_param) +{ + struct dma_async_tx_descriptor *tx = dma_async_param; + struct dma_device *dev = tx->chan->device; + int i; + + for (i = 0; i < tx->dma_src_cnt; i++) + dma_unmap_page(dev->dev, tx->dma_src[i], tx->dma_len, + DMA_TO_DEVICE); + + if (tx->orig_callback) + tx->orig_callback(tx->orig_callback_param); +} + /** * async_xor_val - attempt a xor parity check with a dma engine. * @dest: destination page used if the xor is performed synchronously @@ -319,7 +333,8 @@ async_xor_val(struct page *dest, struct page **src_list, unsigned int offset, if (dma_src && device && src_cnt <= device->max_xor && is_dma_xor_aligned(device, offset, 0, len)) { - unsigned long dma_prep_flags = 0; + unsigned long dma_prep_flags = DMA_COMPL_SKIP_SRC_UNMAP | + DMA_COMPL_SKIP_DEST_UNMAP; int i; pr_debug("%s: (async) len: %zu\n", __func__, len); @@ -346,7 +361,12 @@ async_xor_val(struct page *dest, struct page **src_list, unsigned int offset, } } - async_tx_submit(chan, tx, submit); + for (i = 0; i < src_cnt; i++) + tx->dma_src[i] = dma_src[i]; + tx->dma_src_cnt = src_cnt; + tx->dma_len = len; + + __async_tx_submit(chan, tx, async_xor_val_cb, tx, submit); } else { enum async_tx_flags flags_orig = submit->flags; -- 1.8.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/