dmaengine: introduce dmaengine_unmap_data
Subsystems (18)
v2 cover dmaengine: introduce dmaengine_unmap_data
[ Original patch series description by Dan. ]
dmaengine from the beginning has placed the burden of unmapping dma buffers on the individual drivers. The thought being that since the dma driver already has the descriptor it can use that information for unmapping. This results in a lot of cruft to read back data from descriptors, places a burden on channels that need to break up an operation internally into multiple descriptors, and makes it difficult to have dma mappings with different lifetimes than the current operation.
For example an xor->copy->xor chain wants to leave all buffers mapped until completion, async_tx currently performs invalid overlapping mappings. With dmaengine_unmap_data map once and take a reference for descriptor that uses the mapping.
Reference to v1:
https://lkml.org/lkml/2012/12/6/71
Changes since v1:
- synced patch series with next-20131016
- removed no longer needed "async_memset: convert to dmaengine_unmap_data" patch (patch #5 in v1)
- added patch #1 ("dmatest: make driver unmap also source buffers by itself")
- added patch #11 ("NTB: convert to dmaengine_unmap_data")
- prepared pl330 driver for adding missing unmap in patch #3
- in patch #4:
- fixed IS_ENABLED() check
- fixed release ordering in dmaengine_destroy_unmap_pool()
- fixed check for success in dmaengine_init_unmap_pool()
- replaced kmem_cache_free() by mempool_free()
- added missing unmap->len initializations
- added __init tag to dmaengine_init_unmap_pool()
- in patch #5:
- added missing unmap->len initialization
- fixed whitespace damage
- did minor cleanups in patches #6 & #7
- added temporary dma_dest array in patches #8 & #9
Tested on Exynos4412-based Trats2 board containing PL330 DMA engine, with additional patches doing memory copying tests using DMA memcpy API.
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
Bartlomiej Zolnierkiewicz (4):
dmatest: make driver unmap also source buffers by itself
NTB: convert to dmaengine_unmap_data
dmaengine: remove DMA unmap from drivers
dmaengine: remove DMA unmap flags
Dan Williams (9):
dmaengine: consolidate memcpy apis
dmaengine: prepare for generic 'unmap' data
dmaengine: reference counted unmap data
async_memcpy: convert to dmaengine_unmap_data
async_xor: convert to dmaengine_unmap_data
async_xor_val: convert to dmaengine_unmap_data
async_raid6_recov: convert to dmaengine_unmap_data
async_pq: convert to dmaengine_unmap_data
async_pq_val: convert to dmaengine_unmap_data
arch/arm/include/asm/hardware/iop3xx-adma.h | 30 ---- arch/arm/include/asm/hardware/iop_adma.h | 4 - arch/arm/mach-iop13xx/include/mach/adma.h | 26 --- crypto/async_tx/async_memcpy.c | 37 ++-- crypto/async_tx/async_pq.c | 174 ++++++++++-------- crypto/async_tx/async_raid6_recov.c | 61 +++++-- crypto/async_tx/async_xor.c | 123 +++++++------ drivers/ata/pata_arasan_cf.c | 3 +- drivers/dma/amba-pl08x.c | 32 +--- drivers/dma/at_hdmac.c | 26 +-- drivers/dma/dmaengine.c | 262 ++++++++++++++++++--------- drivers/dma/dmatest.c | 9 +- drivers/dma/dw/core.c | 21 +-- drivers/dma/ep93xx_dma.c | 30 +--- drivers/dma/fsldma.c | 17 +- drivers/dma/ioat/dma.c | 20 +-- drivers/dma/ioat/dma.h | 12 -- drivers/dma/ioat/dma_v2.c | 2 +- drivers/dma/ioat/dma_v3.c | 179 +----------------- drivers/dma/iop-adma.c | 97 +--------- drivers/dma/mv_xor.c | 45 +---- drivers/dma/pl330.c | 2 + drivers/dma/ppc4xx/adma.c | 270 +--------------------------- drivers/dma/timb_dma.c | 37 +--- drivers/dma/txx9dmac.c | 25 +-- drivers/media/platform/m2m-deinterlace.c | 3 +- drivers/media/platform/timblogiw.c | 2 +- drivers/misc/carma/carma-fpga.c | 3 +- drivers/mtd/nand/atmel_nand.c | 3 +- drivers/mtd/nand/fsmc_nand.c | 2 - drivers/net/ethernet/micrel/ks8842.c | 6 +- drivers/ntb/ntb_transport.c | 64 +++++-- drivers/spi/spi-dw-mid.c | 4 +- include/linux/dmaengine.h | 64 +++++-- 34 files changed, 538 insertions(+), 1157 deletions(-)
Signature · 1 line
1.8.2.3
PATCH v2 1/13 dmatest: make driver unmap also source buffers by itself
Make the driver DMA unmap also source buffers by itself (currently it DMA unmaps only destination buffers) as a preparation for introducing generic 'ummap' data.
--- drivers/dma/dmatest.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/dma/dmatest.c +5 -5
@@ -597,11 +597,10 @@ static int dmatest_func(void *data)set_user_nice (current,10 );/* -* src buffers are freed by the DMAEngine code with dma_unmap_single() -* dst buffers are freed by ourselves below +* src and dst buffers are freed by ourselves below */ - flags =DMA_CTRL_ACK |DMA_PREP_INTERRUPT - |DMA_COMPL_SKIP_DEST_UNMAP |DMA_COMPL_SRC_UNMAP_SINGLE ; + flags =DMA_CTRL_ACK |DMA_PREP_INTERRUPT | +DMA_COMPL_SKIP_SRC_UNMAP |DMA_COMPL_SKIP_DEST_UNMAP ;while (!kthread_should_stop () && !(params->iterations && total_tests >= params->iterations)) {
@@ -750,7 +749,8 @@ static int dmatest_func(void *data)continue ; } -/* Unmap by myself (see DMA_COMPL_SKIP_DEST_UNMAP above) */ +/* Unmap by myself */ +unmap_src (dev->dev, dma_srcs, len, src_cnt);unmap_dst (dev->dev, dma_dsts, params->buf_size, dst_cnt); error_count =0 ;
Signature · 1 line
1.8.2.3
Re: [PATCH v2 01/13] dmatest: make driver unmap also source buffers by itself
Quoted 5 lines · Bartlomiej Zolnierkiewicz
Make the driver DMA unmap also source buffers by itself (currently it DMA unmaps only destination buffers) as a preparation for introducing generic 'ummap' data.
Cc Dan Williams <[email protected]>
I think you may update Dan's address.
I assume you run exactly this module to test your DMA drivers. If so, please take my
Quoted 39 lines
Cc Vinod Koul <[email protected]>Cc Tomasz Figa <[email protected]>Cc Dave Jiang <[email protected]>Cc Andy Shevchenko <[email protected]>Signed-off-by Bartlomiej Zolnierkiewicz <[email protected]>Signed-off-by Kyungmin Park <[email protected]>--- drivers/dma/dmatest.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/dma/dmatest.c +5
-5@@ -597,11 +597,10 @@ static int dmatest_func(void *data)set_user_nice (current,10 );/* -* src buffers are freed by the DMAEngine code with dma_unmap_single() -* dst buffers are freed by ourselves below +* src and dst buffers are freed by ourselves below */ - flags =DMA_CTRL_ACK |DMA_PREP_INTERRUPT - |DMA_COMPL_SKIP_DEST_UNMAP |DMA_COMPL_SRC_UNMAP_SINGLE ; + flags =DMA_CTRL_ACK |DMA_PREP_INTERRUPT | +DMA_COMPL_SKIP_SRC_UNMAP |DMA_COMPL_SKIP_DEST_UNMAP ;while (!kthread_should_stop () && !(params->iterations && total_tests >= params->iterations)) {@@ -750,7 +749,8 @@ static int dmatest_func(void *data)continue ; } -/* Unmap by myself (see DMA_COMPL_SKIP_DEST_UNMAP above) */ +/* Unmap by myself */ +unmap_src (dev->dev, dma_srcs, len, src_cnt);unmap_dst (dev->dev, dma_dsts, params->buf_size, dst_cnt); error_count =0 ;
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
PATCH v2 1/13 dmatest: make driver unmap also source buffers by itself
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Make the driver DMA unmap also source buffers by itself (currently it DMA unmaps only destination buffers) as a preparation for introducing generic 'ummap' data.
---
Resend to:
1/ add it to the new dmaengine patchwork
2/ cc maintainers of affected drivers
3/ fixup some mail addresses
drivers/dma/dmatest.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
drivers/dma/dmatest.c +5 -5
@@ -597,11 +597,10 @@ static int dmatest_func(void *data)set_user_nice (current,10 );/* -* src buffers are freed by the DMAEngine code with dma_unmap_single() -* dst buffers are freed by ourselves below +* src and dst buffers are freed by ourselves below */ - flags =DMA_CTRL_ACK |DMA_PREP_INTERRUPT - |DMA_COMPL_SKIP_DEST_UNMAP |DMA_COMPL_SRC_UNMAP_SINGLE ; + flags =DMA_CTRL_ACK |DMA_PREP_INTERRUPT | +DMA_COMPL_SKIP_SRC_UNMAP |DMA_COMPL_SKIP_DEST_UNMAP ;while (!kthread_should_stop () && !(params->iterations && total_tests >= params->iterations)) {
@@ -750,7 +749,8 @@ static int dmatest_func(void *data)continue ; } -/* Unmap by myself (see DMA_COMPL_SKIP_DEST_UNMAP above) */ +/* Unmap by myself */ +unmap_src (dev->dev, dma_srcs, len, src_cnt);unmap_dst (dev->dev, dma_dsts, params->buf_size, dst_cnt); error_count =0 ;
PATCH v2 2/13 dmaengine: consolidate memcpy apis
In reply to Bartlomiej ZolnierkiewiczFrom: Dan Williams <[email protected]>
Copying from page to page (dma_async_memcpy_pg_to_pg) is the superset, make the other two apis use that one in preparation for providing a common dma unmap implementation. The common implementation just wants to assume all buffers are mapped with dma_map_page().
--- drivers/dma/dmaengine.c | 137 ++++++++++++++++-------------------------------- 1 file changed, 45 insertions(+), 92 deletions(-)
drivers/dma/dmaengine.c +45 -92
@@ -902,20 +902,23 @@ void dma_async_device_unregister(struct dma_device *device)EXPORT_SYMBOL (dma_async_device_unregister);/** -* dma_async_memcpy_buf_to_buf - offloaded copy between virtual addresses +* dma_async_memcpy_pg_to_pg - offloaded copy from page to page * @chan: DMA channel to offload copy to -* @dest: destination address (virtual) -* @src: source address (virtual) +* @dest_pg: destination page +* @dest_off: offset in page to copy to +* @src_pg: source page +* @src_off: offset in page to copy from * @len: length * -* Both @dest and @src must be mappable to a bus address according to the -* DMA mapping API rules for streaming mappings. -* Both @dest and @src must stay memory resident (kernel memory or locked -* user space pages). +* Both @dest_page/@dest_off and @src_page/@src_off must be mappable to a bus +* address according to the DMA mapping API rules for streaming mappings. +* Both @dest_page/@dest_off and @src_page/@src_off must stay memory resident +* (kernel memory or locked user space pages). */ dma_cookie_t -dma_async_memcpy_buf_to_buf (struct dma_chan *chan,void *dest, -void *src,size_t len) +dma_async_memcpy_pg_to_pg (struct dma_chan *chan,struct page *dest_pg, +unsigned int dest_off,struct page *src_pg,unsigned int src_off, +size_t len) {struct dma_device *dev = chan->device;struct dma_async_tx_descriptor *tx;
@@ -923,16 +926,15 @@ dma_async_memcpy_buf_to_buf(struct dma_chan *chan, void *dest,dma_cookie_t cookie;unsigned long flags; - dma_src =dma_map_single (dev->dev, src, len,DMA_TO_DEVICE ); - dma_dest =dma_map_single (dev->dev, dest, len,DMA_FROM_DEVICE ); - flags =DMA_CTRL_ACK | -DMA_COMPL_SRC_UNMAP_SINGLE | -DMA_COMPL_DEST_UNMAP_SINGLE ; + dma_src =dma_map_page (dev->dev, src_pg, src_off, len,DMA_TO_DEVICE ); + dma_dest =dma_map_page (dev->dev, dest_pg, dest_off, len, +DMA_FROM_DEVICE ); + flags =DMA_CTRL_ACK ; tx = dev->device_prep_dma_memcpy (chan, dma_dest, dma_src, len, flags);if (!tx) { -dma_unmap_single (dev->dev, dma_src, len,DMA_TO_DEVICE ); -dma_unmap_single (dev->dev, dma_dest, len,DMA_FROM_DEVICE ); +dma_unmap_page (dev->dev, dma_src, len,DMA_TO_DEVICE ); +dma_unmap_page (dev->dev, dma_dest, len,DMA_FROM_DEVICE );return -ENOMEM ; }
@@ -946,6 +948,29 @@ dma_async_memcpy_buf_to_buf(struct dma_chan *chan, void *dest,return cookie; } +EXPORT_SYMBOL (dma_async_memcpy_pg_to_pg); + +/** +* dma_async_memcpy_buf_to_buf - offloaded copy between virtual addresses +* @chan: DMA channel to offload copy to +* @dest: destination address (virtual) +* @src: source address (virtual) +* @len: length +* +* Both @dest and @src must be mappable to a bus address according to the +* DMA mapping API rules for streaming mappings. +* Both @dest and @src must stay memory resident (kernel memory or locked +* user space pages). +*/ +dma_cookie_t +dma_async_memcpy_buf_to_buf (struct dma_chan *chan,void *dest, +void *src,size_t len) +{ +return dma_async_memcpy_pg_to_pg (chan,virt_to_page (dest), + (unsigned long ) dest & ~PAGE_MASK , +virt_to_page (src), + (unsigned long ) src & ~PAGE_MASK , len); +}EXPORT_SYMBOL (dma_async_memcpy_buf_to_buf);/**
@@ -963,86 +988,14 @@ EXPORT_SYMBOL(dma_async_memcpy_buf_to_buf);*/ dma_cookie_t dma_async_memcpy_buf_to_pg (struct dma_chan *chan,struct page *page, -unsigned int offset,void *kdata,size_t len) +unsigned int offset,void *kdata,size_t len) { -struct dma_device *dev = chan->device; -struct dma_async_tx_descriptor *tx; -dma_addr_t dma_dest, dma_src; -dma_cookie_t cookie; -unsigned long flags; - - dma_src =dma_map_single (dev->dev, kdata, len,DMA_TO_DEVICE ); - dma_dest =dma_map_page (dev->dev, page, offset, len,DMA_FROM_DEVICE ); - flags =DMA_CTRL_ACK |DMA_COMPL_SRC_UNMAP_SINGLE ; - tx = dev->device_prep_dma_memcpy (chan, dma_dest, dma_src, len, flags); - -if (!tx) { -dma_unmap_single (dev->dev, dma_src, len,DMA_TO_DEVICE ); -dma_unmap_page (dev->dev, dma_dest, len,DMA_FROM_DEVICE ); -return -ENOMEM ; - } - - tx->callback =NULL ; - cookie = tx->tx_submit (tx); - -preempt_disable (); -__this_cpu_add (chan->local->bytes_transferred, len); -__this_cpu_inc (chan->local->memcpy_count); -preempt_enable (); - -return cookie; +return dma_async_memcpy_pg_to_pg (chan, page, offset, +virt_to_page (kdata), + (unsigned long ) kdata & ~PAGE_MASK , len); }EXPORT_SYMBOL (dma_async_memcpy_buf_to_pg); -/** -* dma_async_memcpy_pg_to_pg - offloaded copy from page to page -* @chan: DMA channel to offload copy to -* @dest_pg: destination page -* @dest_off: offset in page to copy to -* @src_pg: source page -* @src_off: offset in page to copy from -* @len: length -* -* Both @dest_page/@dest_off and @src_page/@src_off must be mappable to a bus -* address according to the DMA mapping API rules for streaming mappings. -* Both @dest_page/@dest_off and @src_page/@src_off must stay memory resident -* (kernel memory or locked user space pages). -*/ -dma_cookie_t -dma_async_memcpy_pg_to_pg (struct dma_chan *chan,struct page *dest_pg, -unsigned int dest_off,struct page *src_pg,unsigned int src_off, -size_t len) -{ -struct dma_device *dev = chan->device; -struct dma_async_tx_descriptor *tx; -dma_addr_t dma_dest, dma_src; -dma_cookie_t cookie; -unsigned long flags; - - dma_src =dma_map_page (dev->dev, src_pg, src_off, len,DMA_TO_DEVICE ); - dma_dest =dma_map_page (dev->dev, dest_pg, dest_off, len, -DMA_FROM_DEVICE ); - flags =DMA_CTRL_ACK ; - tx = dev->device_prep_dma_memcpy (chan, dma_dest, dma_src, len, flags); - -if (!tx) { -dma_unmap_page (dev->dev, dma_src, len,DMA_TO_DEVICE ); -dma_unmap_page (dev->dev, dma_dest, len,DMA_FROM_DEVICE ); -return -ENOMEM ; - } - - tx->callback =NULL ; - cookie = tx->tx_submit (tx); - -preempt_disable (); -__this_cpu_add (chan->local->bytes_transferred, len); -__this_cpu_inc (chan->local->memcpy_count); -preempt_enable (); - -return cookie; -} -EXPORT_SYMBOL (dma_async_memcpy_pg_to_pg); -void dma_async_tx_descriptor_init (struct dma_async_tx_descriptor *tx,struct dma_chan *chan) {
Signature · 1 line
1.8.2.3
PATCH v2 2/13 dmaengine: consolidate memcpy apis
Copying from page to page (dma_async_memcpy_pg_to_pg) is the superset, make the other two apis use that one in preparation for providing a common dma unmap implementation. The common implementation just wants to assume all buffers are mapped with dma_map_page().
---
Resend to:
1/ add it to the new dmaengine patchwork
2/ cc maintainers of affected drivers
3/ fixup some mail addresses
drivers/dma/dmaengine.c | 137 +++++++++++++++-------------------------------- 1 files changed, 45 insertions(+), 92 deletions(-)
drivers/dma/dmaengine.c +45 -92
@@ -902,20 +902,23 @@ void dma_async_device_unregister(struct dma_device *device)EXPORT_SYMBOL (dma_async_device_unregister);/** -* dma_async_memcpy_buf_to_buf - offloaded copy between virtual addresses +* dma_async_memcpy_pg_to_pg - offloaded copy from page to page * @chan: DMA channel to offload copy to -* @dest: destination address (virtual) -* @src: source address (virtual) +* @dest_pg: destination page +* @dest_off: offset in page to copy to +* @src_pg: source page +* @src_off: offset in page to copy from * @len: length * -* Both @dest and @src must be mappable to a bus address according to the -* DMA mapping API rules for streaming mappings. -* Both @dest and @src must stay memory resident (kernel memory or locked -* user space pages). +* Both @dest_page/@dest_off and @src_page/@src_off must be mappable to a bus +* address according to the DMA mapping API rules for streaming mappings. +* Both @dest_page/@dest_off and @src_page/@src_off must stay memory resident +* (kernel memory or locked user space pages). */ dma_cookie_t -dma_async_memcpy_buf_to_buf (struct dma_chan *chan,void *dest, -void *src,size_t len) +dma_async_memcpy_pg_to_pg (struct dma_chan *chan,struct page *dest_pg, +unsigned int dest_off,struct page *src_pg,unsigned int src_off, +size_t len) {struct dma_device *dev = chan->device;struct dma_async_tx_descriptor *tx;
@@ -923,16 +926,15 @@ dma_async_memcpy_buf_to_buf(struct dma_chan *chan, void *dest,dma_cookie_t cookie;unsigned long flags; - dma_src =dma_map_single (dev->dev, src, len,DMA_TO_DEVICE ); - dma_dest =dma_map_single (dev->dev, dest, len,DMA_FROM_DEVICE ); - flags =DMA_CTRL_ACK | -DMA_COMPL_SRC_UNMAP_SINGLE | -DMA_COMPL_DEST_UNMAP_SINGLE ; + dma_src =dma_map_page (dev->dev, src_pg, src_off, len,DMA_TO_DEVICE ); + dma_dest =dma_map_page (dev->dev, dest_pg, dest_off, len, +DMA_FROM_DEVICE ); + flags =DMA_CTRL_ACK ; tx = dev->device_prep_dma_memcpy (chan, dma_dest, dma_src, len, flags);if (!tx) { -dma_unmap_single (dev->dev, dma_src, len,DMA_TO_DEVICE ); -dma_unmap_single (dev->dev, dma_dest, len,DMA_FROM_DEVICE ); +dma_unmap_page (dev->dev, dma_src, len,DMA_TO_DEVICE ); +dma_unmap_page (dev->dev, dma_dest, len,DMA_FROM_DEVICE );return -ENOMEM ; }
@@ -946,6 +948,29 @@ dma_async_memcpy_buf_to_buf(struct dma_chan *chan, void *dest,return cookie; } +EXPORT_SYMBOL (dma_async_memcpy_pg_to_pg); + +/** +* dma_async_memcpy_buf_to_buf - offloaded copy between virtual addresses +* @chan: DMA channel to offload copy to +* @dest: destination address (virtual) +* @src: source address (virtual) +* @len: length +* +* Both @dest and @src must be mappable to a bus address according to the +* DMA mapping API rules for streaming mappings. +* Both @dest and @src must stay memory resident (kernel memory or locked +* user space pages). +*/ +dma_cookie_t +dma_async_memcpy_buf_to_buf (struct dma_chan *chan,void *dest, +void *src,size_t len) +{ +return dma_async_memcpy_pg_to_pg (chan,virt_to_page (dest), + (unsigned long ) dest & ~PAGE_MASK , +virt_to_page (src), + (unsigned long ) src & ~PAGE_MASK , len); +}EXPORT_SYMBOL (dma_async_memcpy_buf_to_buf);/**
@@ -963,86 +988,14 @@ EXPORT_SYMBOL(dma_async_memcpy_buf_to_buf);*/ dma_cookie_t dma_async_memcpy_buf_to_pg (struct dma_chan *chan,struct page *page, -unsigned int offset,void *kdata,size_t len) +unsigned int offset,void *kdata,size_t len) { -struct dma_device *dev = chan->device; -struct dma_async_tx_descriptor *tx; -dma_addr_t dma_dest, dma_src; -dma_cookie_t cookie; -unsigned long flags; - - dma_src =dma_map_single (dev->dev, kdata, len,DMA_TO_DEVICE ); - dma_dest =dma_map_page (dev->dev, page, offset, len,DMA_FROM_DEVICE ); - flags =DMA_CTRL_ACK |DMA_COMPL_SRC_UNMAP_SINGLE ; - tx = dev->device_prep_dma_memcpy (chan, dma_dest, dma_src, len, flags); - -if (!tx) { -dma_unmap_single (dev->dev, dma_src, len,DMA_TO_DEVICE ); -dma_unmap_page (dev->dev, dma_dest, len,DMA_FROM_DEVICE ); -return -ENOMEM ; - } - - tx->callback =NULL ; - cookie = tx->tx_submit (tx); - -preempt_disable (); -__this_cpu_add (chan->local->bytes_transferred, len); -__this_cpu_inc (chan->local->memcpy_count); -preempt_enable (); - -return cookie; +return dma_async_memcpy_pg_to_pg (chan, page, offset, +virt_to_page (kdata), + (unsigned long ) kdata & ~PAGE_MASK , len); }EXPORT_SYMBOL (dma_async_memcpy_buf_to_pg); -/** -* dma_async_memcpy_pg_to_pg - offloaded copy from page to page -* @chan: DMA channel to offload copy to -* @dest_pg: destination page -* @dest_off: offset in page to copy to -* @src_pg: source page -* @src_off: offset in page to copy from -* @len: length -* -* Both @dest_page/@dest_off and @src_page/@src_off must be mappable to a bus -* address according to the DMA mapping API rules for streaming mappings. -* Both @dest_page/@dest_off and @src_page/@src_off must stay memory resident -* (kernel memory or locked user space pages). -*/ -dma_cookie_t -dma_async_memcpy_pg_to_pg (struct dma_chan *chan,struct page *dest_pg, -unsigned int dest_off,struct page *src_pg,unsigned int src_off, -size_t len) -{ -struct dma_device *dev = chan->device; -struct dma_async_tx_descriptor *tx; -dma_addr_t dma_dest, dma_src; -dma_cookie_t cookie; -unsigned long flags; - - dma_src =dma_map_page (dev->dev, src_pg, src_off, len,DMA_TO_DEVICE ); - dma_dest =dma_map_page (dev->dev, dest_pg, dest_off, len, -DMA_FROM_DEVICE ); - flags =DMA_CTRL_ACK ; - tx = dev->device_prep_dma_memcpy (chan, dma_dest, dma_src, len, flags); - -if (!tx) { -dma_unmap_page (dev->dev, dma_src, len,DMA_TO_DEVICE ); -dma_unmap_page (dev->dev, dma_dest, len,DMA_FROM_DEVICE ); -return -ENOMEM ; - } - - tx->callback =NULL ; - cookie = tx->tx_submit (tx); - -preempt_disable (); -__this_cpu_add (chan->local->bytes_transferred, len); -__this_cpu_inc (chan->local->memcpy_count); -preempt_enable (); - -return cookie; -} -EXPORT_SYMBOL (dma_async_memcpy_pg_to_pg); -void dma_async_tx_descriptor_init (struct dma_async_tx_descriptor *tx,struct dma_chan *chan) {
PATCH v2 3/13 dmaengine: prepare for generic 'unmap' data
In reply to Bartlomiej ZolnierkiewiczFrom: Dan Williams <[email protected]>
Add a hook for a common dma unmap implementation to enable removal of the per driver custom unmap code. (A reworked version of Bartlomiej Zolnierkiewicz's patches to remove the custom callbacks and the size increase of dma_async_tx_descriptor for drivers that don't care about raid).
--- drivers/dma/amba-pl08x.c | 1 + drivers/dma/at_hdmac.c | 1 + drivers/dma/dw/core.c | 1 + drivers/dma/ep93xx_dma.c | 1 + drivers/dma/fsldma.c | 1 + drivers/dma/ioat/dma.c | 1 + drivers/dma/ioat/dma_v2.c | 1 + drivers/dma/ioat/dma_v3.c | 1 + drivers/dma/iop-adma.c | 1 + drivers/dma/mv_xor.c | 1 + drivers/dma/pl330.c | 2 ++ drivers/dma/ppc4xx/adma.c | 1 + drivers/dma/timb_dma.c | 1 + drivers/dma/txx9dmac.c | 1 + include/linux/dmaengine.h | 26 ++++++++++++++++++++++++++ 15 files changed, 41 insertions(+)
drivers/dma/amba-pl08x.c +1 -0
@@ -1197,6 +1197,7 @@ static void pl08x_desc_free(struct virt_dma_desc *vd)struct pl08x_txd *txd =to_pl08x_txd (&vd->tx);struct pl08x_dma_chan *plchan =to_pl08x_chan (vd->tx.chan); +dma_descriptor_unmap (txd);if (!plchan->slave)pl08x_unmap_buffers (txd);
drivers/dma/at_hdmac.c +1 -0
@@ -345,6 +345,7 @@ atc_chain_complete(struct at_dma_chan *atchan, struct at_desc *desc)list_move (&desc->desc_node, &atchan->free_list);/* unmap dma addresses (not on slave channels) */ +dma_descriptor_unmap (txd);if (!atchan->chan_common.private) {struct device *parent =chan2parent (&atchan->chan_common);if (!(txd->flags &DMA_COMPL_SKIP_DEST_UNMAP )) {
drivers/dma/dw/core.c +1 -0
@@ -311,6 +311,7 @@ dwc_descriptor_complete(struct dw_dma_chan *dwc, struct dw_desc *desc,list_splice_init (&desc->tx_list, &dwc->free_list);list_move (&desc->desc_node, &dwc->free_list); +dma_descriptor_unmap (txd);if (!is_slave_direction (dwc->direction)) {struct device *parent =chan2parent (&dwc->chan);if (!(txd->flags &DMA_COMPL_SKIP_DEST_UNMAP )) {
drivers/dma/ep93xx_dma.c +1 -0
@@ -791,6 +791,7 @@ static void ep93xx_dma_tasklet(unsigned long data)* For the memcpy channels the API requires us to unmap the * buffers unless requested otherwise. */ +dma_descriptor_unmap (&desc->txd);if (!edmac->chan.private)ep93xx_dma_unmap_buffers (desc);
drivers/dma/fsldma.c +1 -0
@@ -870,6 +870,7 @@ static void fsldma_cleanup_descriptor(struct fsldma_chan *chan,/* Run any dependencies */ dma_run_dependencies (txd); +dma_descriptor_unmap (txd);/* Unmap the dst buffer, if requested */ if (!(txd->flags &DMA_COMPL_SKIP_DEST_UNMAP )) {if (txd->flags &DMA_COMPL_DEST_UNMAP_SINGLE )
drivers/dma/ioat/dma.c +1 -0
@@ -602,6 +602,7 @@ static void __cleanup(struct ioat_dma_chan *ioat, dma_addr_t phys_complete)dump_desc_dbg (ioat, desc);if (tx->cookie) {dma_cookie_complete (tx); +dma_descriptor_unmap (tx);ioat_dma_unmap (chan, tx->flags, desc->len, desc->hw); ioat->active -= desc->hw->tx_cnt;if (tx->callback) {
drivers/dma/ioat/dma_v2.c +1 -0
@@ -148,6 +148,7 @@ static void __cleanup(struct ioat2_dma_chan *ioat, dma_addr_t phys_complete) tx = &desc->txd;dump_desc_dbg (ioat, desc);if (tx->cookie) { +dma_descriptor_unmap (tx);ioat_dma_unmap (chan, tx->flags, desc->len, desc->hw);dma_cookie_complete (tx);if (tx->callback) {
drivers/dma/ioat/dma_v3.c +1 -0
@@ -577,6 +577,7 @@ static void __cleanup(struct ioat2_dma_chan *ioat, dma_addr_t phys_complete) tx = &desc->txd;if (tx->cookie) {dma_cookie_complete (tx); +dma_descriptor_unmap (tx);ioat3_dma_unmap (ioat, desc, idx + i);if (tx->callback) { tx->callback (tx->callback_param);
drivers/dma/iop-adma.c +1 -0
@@ -152,6 +152,7 @@ iop_adma_run_tx_complete_actions(struct iop_adma_desc_slot *desc,if (tx->callback) tx->callback (tx->callback_param); +dma_descriptor_unmap (tx);/* unmap dma addresses * (unmap_single vs unmap_page?) */
drivers/dma/mv_xor.c +1 -0
@@ -278,6 +278,7 @@ mv_xor_run_tx_complete_actions(struct mv_xor_desc_slot *desc, desc->async_tx.callback ( desc->async_tx.callback_param); +dma_descriptor_unmap (&desc->async_tx);/* unmap dma addresses * (unmap_single vs unmap_page?) */
drivers/dma/pl330.c +2 -0
@@ -2268,6 +2268,8 @@ static void pl330_tasklet(unsigned long data)list_move_tail (&desc->node, &pch->dmac->desc_pool); } +dma_descriptor_unmap (&desc->txd); +if (callback) {spin_unlock_irqrestore (&pch->lock, flags);callback (callback_param);
drivers/dma/ppc4xx/adma.c +1 -0
@@ -1765,6 +1765,7 @@ static dma_cookie_t ppc440spe_adma_run_tx_complete_actions( desc->async_tx.callback ( desc->async_tx.callback_param); +dma_descriptor_unmap (&desc->async_tx);/* unmap dma addresses * (unmap_single vs unmap_page?) *
drivers/dma/timb_dma.c +1 -0
@@ -293,6 +293,7 @@ static void __td_finish(struct timb_dma_chan *td_chan)list_move (&td_desc->desc_node, &td_chan->free_list); +dma_descriptor_unmap (txd);if (!(txd->flags &DMA_COMPL_SKIP_SRC_UNMAP ))__td_unmap_descs (td_desc, txd->flags &DMA_COMPL_SRC_UNMAP_SINGLE );
drivers/dma/txx9dmac.c +1 -0
@@ -419,6 +419,7 @@ txx9dmac_descriptor_complete(struct txx9dmac_chan *dc,list_splice_init (&desc->tx_list, &dc->free_list);list_move (&desc->desc_node, &dc->free_list); +dma_descriptor_unmap (txd);if (!ds) {dma_addr_t dmaaddr;if (!(txd->flags &DMA_COMPL_SKIP_DEST_UNMAP )) {
include/linux/dmaengine.h +26 -0
@@ -413,6 +413,17 @@ void dma_chan_cleanup(struct kref *kref);typedef bool (*dma_filter_fn )(struct dma_chan *chan,void *filter_param);typedef void (*dma_async_tx_callback )(void *dma_async_param); + +struct dmaengine_unmap_data { +u8 to_cnt; +u8 from_cnt; +u8 bidi_cnt; +struct device *dev; +struct kref kref; +size_t len; +dma_addr_t addr[0 ]; +}; +/** * struct dma_async_tx_descriptor - async transaction descriptor * ---dma generic offload fields---
@@ -438,6 +449,7 @@ struct dma_async_tx_descriptor {dma_cookie_t (*tx_submit)(struct dma_async_tx_descriptor *tx);dma_async_tx_callback callback;void *callback_param; +struct dmaengine_unmap_data *unmap;#ifdef CONFIG_ASYNC_TX_ENABLE_CHANNEL_SWITCH struct dma_async_tx_descriptor *next;struct dma_async_tx_descriptor *parent;
@@ -445,6 +457,20 @@ struct dma_async_tx_descriptor {#endif }; +static inline void dma_set_unmap (struct dma_async_tx_descriptor *tx, +struct dmaengine_unmap_data *unmap) +{ +kref_get (&unmap->kref); + tx->unmap = unmap; +} + +static inline void dma_descriptor_unmap (struct dma_async_tx_descriptor *tx) +{ +if (tx->unmap) { + tx->unmap =NULL ; + } +} +#ifndef CONFIG_ASYNC_TX_ENABLE_CHANNEL_SWITCH static inline void txd_lock (struct dma_async_tx_descriptor *txd) {
Signature · 1 line
1.8.2.3
PATCH v2 3/13 dmaengine: prepare for generic 'unmap' data
Add a hook for a common dma unmap implementation to enable removal of the per driver custom unmap code. (A reworked version of Bartlomiej Zolnierkiewicz's patches to remove the custom callbacks and the size increase of dma_async_tx_descriptor for drivers that don't care about raid).
---
Resend to:
1/ add it to the new dmaengine patchwork
2/ cc maintainers of affected drivers
3/ fixup some mail addresses
drivers/dma/amba-pl08x.c | 1 + drivers/dma/at_hdmac.c | 1 + drivers/dma/dw/core.c | 1 + drivers/dma/ep93xx_dma.c | 1 + drivers/dma/fsldma.c | 1 + drivers/dma/ioat/dma.c | 1 + drivers/dma/ioat/dma_v2.c | 1 + drivers/dma/ioat/dma_v3.c | 1 + drivers/dma/iop-adma.c | 1 + drivers/dma/mv_xor.c | 1 + drivers/dma/pl330.c | 2 ++ drivers/dma/ppc4xx/adma.c | 1 + drivers/dma/timb_dma.c | 1 + drivers/dma/txx9dmac.c | 1 + include/linux/dmaengine.h | 26 ++++++++++++++++++++++++++ 15 files changed, 41 insertions(+), 0 deletions(-)
drivers/dma/amba-pl08x.c +1 -0
@@ -1197,6 +1197,7 @@ static void pl08x_desc_free(struct virt_dma_desc *vd)struct pl08x_txd *txd =to_pl08x_txd (&vd->tx);struct pl08x_dma_chan *plchan =to_pl08x_chan (vd->tx.chan); +dma_descriptor_unmap (txd);if (!plchan->slave)pl08x_unmap_buffers (txd);
drivers/dma/at_hdmac.c +1 -0
@@ -345,6 +345,7 @@ atc_chain_complete(struct at_dma_chan *atchan, struct at_desc *desc)list_move (&desc->desc_node, &atchan->free_list);/* unmap dma addresses (not on slave channels) */ +dma_descriptor_unmap (txd);if (!atchan->chan_common.private) {struct device *parent =chan2parent (&atchan->chan_common);if (!(txd->flags &DMA_COMPL_SKIP_DEST_UNMAP )) {
drivers/dma/dw/core.c +1 -0
@@ -311,6 +311,7 @@ dwc_descriptor_complete(struct dw_dma_chan *dwc, struct dw_desc *desc,list_splice_init (&desc->tx_list, &dwc->free_list);list_move (&desc->desc_node, &dwc->free_list); +dma_descriptor_unmap (txd);if (!is_slave_direction (dwc->direction)) {struct device *parent =chan2parent (&dwc->chan);if (!(txd->flags &DMA_COMPL_SKIP_DEST_UNMAP )) {
drivers/dma/ep93xx_dma.c +1 -0
@@ -791,6 +791,7 @@ static void ep93xx_dma_tasklet(unsigned long data)* For the memcpy channels the API requires us to unmap the * buffers unless requested otherwise. */ +dma_descriptor_unmap (&desc->txd);if (!edmac->chan.private)ep93xx_dma_unmap_buffers (desc);
drivers/dma/fsldma.c +1 -0
@@ -868,6 +868,7 @@ static void fsldma_cleanup_descriptor(struct fsldma_chan *chan,/* Run any dependencies */ dma_run_dependencies (txd); +dma_descriptor_unmap (txd);/* Unmap the dst buffer, if requested */ if (!(txd->flags &DMA_COMPL_SKIP_DEST_UNMAP )) {if (txd->flags &DMA_COMPL_DEST_UNMAP_SINGLE )
drivers/dma/ioat/dma.c +1 -0
@@ -602,6 +602,7 @@ static void __cleanup(struct ioat_dma_chan *ioat, dma_addr_t phys_complete)dump_desc_dbg (ioat, desc);if (tx->cookie) {dma_cookie_complete (tx); +dma_descriptor_unmap (tx);ioat_dma_unmap (chan, tx->flags, desc->len, desc->hw); ioat->active -= desc->hw->tx_cnt;if (tx->callback) {
drivers/dma/ioat/dma_v2.c +1 -0
@@ -148,6 +148,7 @@ static void __cleanup(struct ioat2_dma_chan *ioat, dma_addr_t phys_complete) tx = &desc->txd;dump_desc_dbg (ioat, desc);if (tx->cookie) { +dma_descriptor_unmap (tx);ioat_dma_unmap (chan, tx->flags, desc->len, desc->hw);dma_cookie_complete (tx);if (tx->callback) {
drivers/dma/ioat/dma_v3.c +1 -0
@@ -577,6 +577,7 @@ static void __cleanup(struct ioat2_dma_chan *ioat, dma_addr_t phys_complete) tx = &desc->txd;if (tx->cookie) {dma_cookie_complete (tx); +dma_descriptor_unmap (tx);ioat3_dma_unmap (ioat, desc, idx + i);if (tx->callback) { tx->callback (tx->callback_param);
drivers/dma/iop-adma.c +1 -0
@@ -152,6 +152,7 @@ iop_adma_run_tx_complete_actions(struct iop_adma_desc_slot *desc,if (tx->callback) tx->callback (tx->callback_param); +dma_descriptor_unmap (tx);/* unmap dma addresses * (unmap_single vs unmap_page?) */
drivers/dma/mv_xor.c +1 -0
@@ -278,6 +278,7 @@ mv_xor_run_tx_complete_actions(struct mv_xor_desc_slot *desc, desc->async_tx.callback ( desc->async_tx.callback_param); +dma_descriptor_unmap (&desc->async_tx);/* unmap dma addresses * (unmap_single vs unmap_page?) */
drivers/dma/pl330.c +2 -0
@@ -2268,6 +2268,8 @@ static void pl330_tasklet(unsigned long data)list_move_tail (&desc->node, &pch->dmac->desc_pool); } +dma_descriptor_unmap (&desc->txd); +if (callback) {spin_unlock_irqrestore (&pch->lock, flags);callback (callback_param);
drivers/dma/ppc4xx/adma.c +1 -0
@@ -1765,6 +1765,7 @@ static dma_cookie_t ppc440spe_adma_run_tx_complete_actions( desc->async_tx.callback ( desc->async_tx.callback_param); +dma_descriptor_unmap (&desc->async_tx);/* unmap dma addresses * (unmap_single vs unmap_page?) *
drivers/dma/timb_dma.c +1 -0
@@ -293,6 +293,7 @@ static void __td_finish(struct timb_dma_chan *td_chan)list_move (&td_desc->desc_node, &td_chan->free_list); +dma_descriptor_unmap (txd);if (!(txd->flags &DMA_COMPL_SKIP_SRC_UNMAP ))__td_unmap_descs (td_desc, txd->flags &DMA_COMPL_SRC_UNMAP_SINGLE );
drivers/dma/txx9dmac.c +1 -0
@@ -419,6 +419,7 @@ txx9dmac_descriptor_complete(struct txx9dmac_chan *dc,list_splice_init (&desc->tx_list, &dc->free_list);list_move (&desc->desc_node, &dc->free_list); +dma_descriptor_unmap (txd);if (!ds) {dma_addr_t dmaaddr;if (!(txd->flags &DMA_COMPL_SKIP_DEST_UNMAP )) {
include/linux/dmaengine.h +26 -0
@@ -413,6 +413,17 @@ void dma_chan_cleanup(struct kref *kref);typedef bool (*dma_filter_fn )(struct dma_chan *chan,void *filter_param);typedef void (*dma_async_tx_callback )(void *dma_async_param); + +struct dmaengine_unmap_data { +u8 to_cnt; +u8 from_cnt; +u8 bidi_cnt; +struct device *dev; +struct kref kref; +size_t len; +dma_addr_t addr[0 ]; +}; +/** * struct dma_async_tx_descriptor - async transaction descriptor * ---dma generic offload fields---
@@ -438,6 +449,7 @@ struct dma_async_tx_descriptor {dma_cookie_t (*tx_submit)(struct dma_async_tx_descriptor *tx);dma_async_tx_callback callback;void *callback_param; +struct dmaengine_unmap_data *unmap;#ifdef CONFIG_ASYNC_TX_ENABLE_CHANNEL_SWITCH struct dma_async_tx_descriptor *next;struct dma_async_tx_descriptor *parent;
@@ -445,6 +457,20 @@ struct dma_async_tx_descriptor {#endif }; +static inline void dma_set_unmap (struct dma_async_tx_descriptor *tx, +struct dmaengine_unmap_data *unmap) +{ +kref_get (&unmap->kref); + tx->unmap = unmap; +} + +static inline void dma_descriptor_unmap (struct dma_async_tx_descriptor *tx) +{ +if (tx->unmap) { + tx->unmap =NULL ; + } +} +#ifndef CONFIG_ASYNC_TX_ENABLE_CHANNEL_SWITCH static inline void txd_lock (struct dma_async_tx_descriptor *txd) {
PATCH v2 4/13 dmaengine: reference counted unmap data
In reply to Bartlomiej ZolnierkiewiczFrom: Dan Williams <[email protected]>
Hang a common 'unmap' object off of dma descriptors for the purpose of providing a unified unmapping interface. The lifetime of a mapping may span multiple descriptors, so these unmap objects are reference counted by related descriptor.
--- drivers/dma/dmaengine.c | 156 +++++++++++++++++++++++++++++++++++++++++++--- include/linux/dmaengine.h | 3 + 2 files changed, 150 insertions(+), 9 deletions(-)
drivers/dma/dmaengine.c +147 -9
@@ -65,6 +65,7 @@#include <linux/acpi.h> #include <linux/acpi_dma.h> #include <linux/of_dma.h> +#include <linux/mempool.h> static DEFINE_MUTEX (dma_list_mutex);static DEFINE_IDR (dma_idr);
@@ -901,6 +902,129 @@ void dma_async_device_unregister(struct dma_device *device) }EXPORT_SYMBOL (dma_async_device_unregister); +struct dmaengine_unmap_pool { +struct kmem_cache *cache; +const char *name; +mempool_t *pool; +size_t size; +}; + +#define __UNMAP_POOL (x) { .size = x, .name = "dmaengine-unmap-" __stringify(x) } +static struct dmaengine_unmap_pool unmap_pool[] = { +__UNMAP_POOL (2 ), + #if IS_ENABLED(CONFIG_ASYNC_TX_DMA) +__UNMAP_POOL (16 ), +__UNMAP_POOL (128 ), +__UNMAP_POOL (256 ), + #endif +}; + +static struct dmaengine_unmap_pool *__get_unmap_pool (int nr) +{ +int order =get_count_order (nr); + +switch (order) { + case 0 ... 1: +return &unmap_pool[0 ]; + case 2 ... 4: +return &unmap_pool[1 ]; + case 5 ... 7: +return &unmap_pool[2 ]; +case 8 : +return &unmap_pool[3 ]; +default : +BUG (); +return NULL ; + } +} + +static void dmaengine_unmap (struct kref *kref) +{ +struct dmaengine_unmap_data *unmap =container_of (kref,typeof (*unmap), kref); +struct device *dev = unmap->dev; +int cnt, i; + + cnt = unmap->to_cnt; +for (i =0 ; i < cnt; i++) +dma_unmap_page (dev, unmap->addr[i], unmap->len, +DMA_TO_DEVICE ); + cnt += unmap->from_cnt; +for (; i < cnt; i++) +dma_unmap_page (dev, unmap->addr[i], unmap->len, +DMA_FROM_DEVICE ); + cnt += unmap->bidi_cnt; +for (; i < cnt; i++) +dma_unmap_page (dev, unmap->addr[i], unmap->len, +DMA_BIDIRECTIONAL ); +mempool_free (unmap,__get_unmap_pool (cnt)->pool); +} + +void dmaengine_unmap_put (struct dmaengine_unmap_data *unmap) +{ +if (unmap) +kref_put (&unmap->kref, dmaengine_unmap); +} +EXPORT_SYMBOL_GPL (dmaengine_unmap_put); + +static void dmaengine_destroy_unmap_pool (void ) +{ +int i; + +for (i =0 ; i <ARRAY_SIZE (unmap_pool); i++) { +struct dmaengine_unmap_pool *p = &unmap_pool[i]; + +if (p->pool) +mempool_destroy (p->pool); + p->pool =NULL ; +if (p->cache) +kmem_cache_destroy (p->cache); + p->cache =NULL ; + } +} + +static int __init dmaengine_init_unmap_pool (void ) +{ +int i; + +for (i =0 ; i <ARRAY_SIZE (unmap_pool); i++) { +struct dmaengine_unmap_pool *p = &unmap_pool[i]; +size_t size; + + size =sizeof (struct dmaengine_unmap_data ) + +sizeof (dma_addr_t) * p->size; + + p->cache =kmem_cache_create (p->name, size,0 , +SLAB_HWCACHE_ALIGN ,NULL ); +if (!p->cache) +break ; + p->pool =mempool_create_slab_pool (1 , p->cache); +if (!p->pool) +break ; + } + +if (i ==ARRAY_SIZE (unmap_pool)) +return 0 ; + +dmaengine_destroy_unmap_pool (); +return -ENOMEM ; +} + +static struct dmaengine_unmap_data * +dmaengine_get_unmap_data (struct device *dev,int nr,gfp_t flags) +{ +struct dmaengine_unmap_data *unmap; + + unmap =mempool_alloc (__get_unmap_pool (nr)->pool, flags); +if (!unmap) +return NULL ; + +memset (unmap,0 ,sizeof (*unmap)); +kref_init (&unmap->kref); + unmap->dev = dev; + +return unmap; +} +/** * dma_async_memcpy_pg_to_pg - offloaded copy from page to page * @chan: DMA channel to offload copy to
@@ -922,24 +1046,34 @@ dma_async_memcpy_pg_to_pg(struct dma_chan *chan, struct page *dest_pg, {struct dma_device *dev = chan->device;struct dma_async_tx_descriptor *tx; -dma_addr_t dma_dest, dma_src; +struct dmaengine_unmap_data *unmap;dma_cookie_t cookie;unsigned long flags; - dma_src =dma_map_page (dev->dev, src_pg, src_off, len,DMA_TO_DEVICE ); - dma_dest =dma_map_page (dev->dev, dest_pg, dest_off, len, -DMA_FROM_DEVICE ); - flags =DMA_CTRL_ACK ; - tx = dev->device_prep_dma_memcpy (chan, dma_dest, dma_src, len, flags); + unmap =dmaengine_get_unmap_data (dev->dev,2 ,GFP_NOIO ); +if (!unmap) +return -ENOMEM ; + + unmap->to_cnt =1 ; + unmap->from_cnt =1 ; + unmap->addr[0 ] =dma_map_page (dev->dev, src_pg, src_off, len, +DMA_TO_DEVICE ); + unmap->addr[1 ] =dma_map_page (dev->dev, dest_pg, dest_off, len, +DMA_FROM_DEVICE ); + unmap->len = len; + flags =DMA_CTRL_ACK |DMA_COMPL_SKIP_SRC_UNMAP | +DMA_COMPL_SKIP_DEST_UNMAP ; + tx = dev->device_prep_dma_memcpy (chan, unmap->addr[1 ], unmap->addr[0 ], + len, flags);if (!tx) { -dma_unmap_page (dev->dev, dma_src, len,DMA_TO_DEVICE ); -dma_unmap_page (dev->dev, dma_dest, len,DMA_FROM_DEVICE ); +dmaengine_unmap_put (unmap);return -ENOMEM ; } - tx->callback =NULL ; +dma_set_unmap (tx, unmap); cookie = tx->tx_submit (tx); +dmaengine_unmap_put (unmap);preempt_disable ();__this_cpu_add (chan->local->bytes_transferred, len);
@@ -1069,6 +1203,10 @@ EXPORT_SYMBOL_GPL(dma_run_dependencies);static int __init dma_bus_init (void ) { +int err =dmaengine_init_unmap_pool (); + +if (err) +return err;return class_register (&dma_devclass); }arch_initcall (dma_bus_init);
include/linux/dmaengine.h +3 -0
@@ -464,9 +464,12 @@ static inline void dma_set_unmap(struct dma_async_tx_descriptor *tx, tx->unmap = unmap; } +void dmaengine_unmap_put (struct dmaengine_unmap_data *unmap); +static inline void dma_descriptor_unmap (struct dma_async_tx_descriptor *tx) {if (tx->unmap) { +dmaengine_unmap_put (tx->unmap); tx->unmap =NULL ; } }
Signature · 1 line
1.8.2.3
PATCH v2 4/13 dmaengine: reference counted unmap data
Hang a common 'unmap' object off of dma descriptors for the purpose of providing a unified unmapping interface. The lifetime of a mapping may span multiple descriptors, so these unmap objects are reference counted by related descriptor.
---
Resend to:
1/ add it to the new dmaengine patchwork
2/ cc maintainers of affected drivers
3/ fixup some mail addresses
drivers/dma/dmaengine.c | 156 ++++++++++++++++++++++++++++++++++++++++++--- include/linux/dmaengine.h | 3 + 2 files changed, 150 insertions(+), 9 deletions(-)
drivers/dma/dmaengine.c +147 -9
@@ -65,6 +65,7 @@#include <linux/acpi.h> #include <linux/acpi_dma.h> #include <linux/of_dma.h> +#include <linux/mempool.h> static DEFINE_MUTEX (dma_list_mutex);static DEFINE_IDR (dma_idr);
@@ -901,6 +902,129 @@ void dma_async_device_unregister(struct dma_device *device) }EXPORT_SYMBOL (dma_async_device_unregister); +struct dmaengine_unmap_pool { +struct kmem_cache *cache; +const char *name; +mempool_t *pool; +size_t size; +}; + +#define __UNMAP_POOL (x) { .size = x, .name = "dmaengine-unmap-" __stringify(x) } +static struct dmaengine_unmap_pool unmap_pool[] = { +__UNMAP_POOL (2 ), + #if IS_ENABLED(CONFIG_ASYNC_TX_DMA) +__UNMAP_POOL (16 ), +__UNMAP_POOL (128 ), +__UNMAP_POOL (256 ), + #endif +}; + +static struct dmaengine_unmap_pool *__get_unmap_pool (int nr) +{ +int order =get_count_order (nr); + +switch (order) { + case 0 ... 1: +return &unmap_pool[0 ]; + case 2 ... 4: +return &unmap_pool[1 ]; + case 5 ... 7: +return &unmap_pool[2 ]; +case 8 : +return &unmap_pool[3 ]; +default : +BUG (); +return NULL ; + } +} + +static void dmaengine_unmap (struct kref *kref) +{ +struct dmaengine_unmap_data *unmap =container_of (kref,typeof (*unmap), kref); +struct device *dev = unmap->dev; +int cnt, i; + + cnt = unmap->to_cnt; +for (i =0 ; i < cnt; i++) +dma_unmap_page (dev, unmap->addr[i], unmap->len, +DMA_TO_DEVICE ); + cnt += unmap->from_cnt; +for (; i < cnt; i++) +dma_unmap_page (dev, unmap->addr[i], unmap->len, +DMA_FROM_DEVICE ); + cnt += unmap->bidi_cnt; +for (; i < cnt; i++) +dma_unmap_page (dev, unmap->addr[i], unmap->len, +DMA_BIDIRECTIONAL ); +mempool_free (unmap,__get_unmap_pool (cnt)->pool); +} + +void dmaengine_unmap_put (struct dmaengine_unmap_data *unmap) +{ +if (unmap) +kref_put (&unmap->kref, dmaengine_unmap); +} +EXPORT_SYMBOL_GPL (dmaengine_unmap_put); + +static void dmaengine_destroy_unmap_pool (void ) +{ +int i; + +for (i =0 ; i <ARRAY_SIZE (unmap_pool); i++) { +struct dmaengine_unmap_pool *p = &unmap_pool[i]; + +if (p->pool) +mempool_destroy (p->pool); + p->pool =NULL ; +if (p->cache) +kmem_cache_destroy (p->cache); + p->cache =NULL ; + } +} + +static int __init dmaengine_init_unmap_pool (void ) +{ +int i; + +for (i =0 ; i <ARRAY_SIZE (unmap_pool); i++) { +struct dmaengine_unmap_pool *p = &unmap_pool[i]; +size_t size; + + size =sizeof (struct dmaengine_unmap_data ) + +sizeof (dma_addr_t) * p->size; + + p->cache =kmem_cache_create (p->name, size,0 , +SLAB_HWCACHE_ALIGN ,NULL ); +if (!p->cache) +break ; + p->pool =mempool_create_slab_pool (1 , p->cache); +if (!p->pool) +break ; + } + +if (i ==ARRAY_SIZE (unmap_pool)) +return 0 ; + +dmaengine_destroy_unmap_pool (); +return -ENOMEM ; +} + +static struct dmaengine_unmap_data * +dmaengine_get_unmap_data (struct device *dev,int nr,gfp_t flags) +{ +struct dmaengine_unmap_data *unmap; + + unmap =mempool_alloc (__get_unmap_pool (nr)->pool, flags); +if (!unmap) +return NULL ; + +memset (unmap,0 ,sizeof (*unmap)); +kref_init (&unmap->kref); + unmap->dev = dev; + +return unmap; +} +/** * dma_async_memcpy_pg_to_pg - offloaded copy from page to page * @chan: DMA channel to offload copy to
@@ -922,24 +1046,34 @@ dma_async_memcpy_pg_to_pg(struct dma_chan *chan, struct page *dest_pg, {struct dma_device *dev = chan->device;struct dma_async_tx_descriptor *tx; -dma_addr_t dma_dest, dma_src; +struct dmaengine_unmap_data *unmap;dma_cookie_t cookie;unsigned long flags; - dma_src =dma_map_page (dev->dev, src_pg, src_off, len,DMA_TO_DEVICE ); - dma_dest =dma_map_page (dev->dev, dest_pg, dest_off, len, -DMA_FROM_DEVICE ); - flags =DMA_CTRL_ACK ; - tx = dev->device_prep_dma_memcpy (chan, dma_dest, dma_src, len, flags); + unmap =dmaengine_get_unmap_data (dev->dev,2 ,GFP_NOIO ); +if (!unmap) +return -ENOMEM ; + + unmap->to_cnt =1 ; + unmap->from_cnt =1 ; + unmap->addr[0 ] =dma_map_page (dev->dev, src_pg, src_off, len, +DMA_TO_DEVICE ); + unmap->addr[1 ] =dma_map_page (dev->dev, dest_pg, dest_off, len, +DMA_FROM_DEVICE ); + unmap->len = len; + flags =DMA_CTRL_ACK |DMA_COMPL_SKIP_SRC_UNMAP | +DMA_COMPL_SKIP_DEST_UNMAP ; + tx = dev->device_prep_dma_memcpy (chan, unmap->addr[1 ], unmap->addr[0 ], + len, flags);if (!tx) { -dma_unmap_page (dev->dev, dma_src, len,DMA_TO_DEVICE ); -dma_unmap_page (dev->dev, dma_dest, len,DMA_FROM_DEVICE ); +dmaengine_unmap_put (unmap);return -ENOMEM ; } - tx->callback =NULL ; +dma_set_unmap (tx, unmap); cookie = tx->tx_submit (tx); +dmaengine_unmap_put (unmap);preempt_disable ();__this_cpu_add (chan->local->bytes_transferred, len);
@@ -1069,6 +1203,10 @@ EXPORT_SYMBOL_GPL(dma_run_dependencies);static int __init dma_bus_init (void ) { +int err =dmaengine_init_unmap_pool (); + +if (err) +return err;return class_register (&dma_devclass); }arch_initcall (dma_bus_init);
include/linux/dmaengine.h +3 -0
@@ -464,9 +464,12 @@ static inline void dma_set_unmap(struct dma_async_tx_descriptor *tx, tx->unmap = unmap; } +void dmaengine_unmap_put (struct dmaengine_unmap_data *unmap); +static inline void dma_descriptor_unmap (struct dma_async_tx_descriptor *tx) {if (tx->unmap) { +dmaengine_unmap_put (tx->unmap); tx->unmap =NULL ; } }
PATCH v2 5/13 async_memcpy: convert to dmaengine_unmap_data
In reply to Bartlomiej ZolnierkiewiczFrom: Dan Williams <[email protected]>
Use the generic unmap object to unmap dma buffers.
--- crypto/async_tx/async_memcpy.c | 40 +++++++++++++++++++++++----------------- drivers/dma/dmaengine.c | 3 ++- include/linux/dmaengine.h | 2 ++ 3 files changed, 27 insertions(+), 18 deletions(-)
crypto/async_tx/async_memcpy.c +23 -17
@@ -50,33 +50,37 @@ async_memcpy(struct page *dest, struct page *src, unsigned int dest_offset, &dest, 1, &src, 1, 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_copy_aligned (device, src_offset, dest_offset, len)) { -dma_addr_t dma_dest, dma_src; -unsigned long dma_prep_flags =0 ; +if (device) + unmap =dmaengine_get_unmap_data (device->dev,2 ,GFP_NOIO ); + +if (unmap &&is_dma_copy_aligned (device, src_offset, dest_offset, 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, dest_offset, len, -DMA_FROM_DEVICE ); - - dma_src =dma_map_page (device->dev, src, src_offset, len, -DMA_TO_DEVICE ); - - tx = device->device_prep_dma_memcpy (chan, dma_dest, dma_src, - len, dma_prep_flags); -if (!tx) { -dma_unmap_page (device->dev, dma_dest, len, -DMA_FROM_DEVICE ); -dma_unmap_page (device->dev, dma_src, len, -DMA_TO_DEVICE ); - } + + unmap->to_cnt =1 ; + unmap->addr[0 ] =dma_map_page (device->dev, src, src_offset, len, +DMA_TO_DEVICE ); + unmap->from_cnt =1 ; + unmap->addr[1 ] =dma_map_page (device->dev, dest, dest_offset, len, +DMA_FROM_DEVICE ); + unmap->len = len; + + tx = device->device_prep_dma_memcpy (chan, unmap->addr[1 ], + unmap->addr[0 ], len, + dma_prep_flags); }if (tx) {pr_debug ("%s: (async) len: %zu\n" , __func__, len); + +dma_set_unmap (tx, unmap);async_tx_submit (chan, tx, submit); }else {void *dest_buf, *src_buf;
@@ -96,6 +100,8 @@ async_memcpy(struct page *dest, struct page *src, unsigned int dest_offset,async_tx_sync_epilog (submit); } +dmaengine_unmap_put (unmap); +return tx; }EXPORT_SYMBOL_GPL (async_memcpy);
drivers/dma/dmaengine.c +2 -1
@@ -1009,7 +1009,7 @@ static int __init dmaengine_init_unmap_pool(void)return -ENOMEM ; } -static struct dmaengine_unmap_data * +struct dmaengine_unmap_data *dmaengine_get_unmap_data (struct device *dev,int nr,gfp_t flags) {struct dmaengine_unmap_data *unmap;
@@ -1024,6 +1024,7 @@ dmaengine_get_unmap_data(struct device *dev, int nr, gfp_t flags)return unmap; } +EXPORT_SYMBOL (dmaengine_get_unmap_data);/** * dma_async_memcpy_pg_to_pg - offloaded copy from page to page
include/linux/dmaengine.h +2 -0
@@ -464,6 +464,8 @@ static inline void dma_set_unmap(struct dma_async_tx_descriptor *tx, tx->unmap = unmap; } +struct dmaengine_unmap_data * +dmaengine_get_unmap_data (struct device *dev,int nr,gfp_t flags);void dmaengine_unmap_put (struct dmaengine_unmap_data *unmap);static inline void dma_descriptor_unmap (struct dma_async_tx_descriptor *tx)
Signature · 1 line
1.8.2.3
PATCH v2 5/13 async_memcpy: convert to dmaengine_unmap_data
Use the generic unmap object to unmap dma buffers.
---
Resend to:
1/ add it to the new dmaengine patchwork
2/ cc maintainers of affected drivers
3/ fixup some mail addresses
crypto/async_tx/async_memcpy.c | 40 +++++++++++++++++++++++----------------- drivers/dma/dmaengine.c | 3 ++- include/linux/dmaengine.h | 2 ++ 3 files changed, 27 insertions(+), 18 deletions(-)
crypto/async_tx/async_memcpy.c +23 -17
@@ -50,33 +50,37 @@ async_memcpy(struct page *dest, struct page *src, unsigned int dest_offset, &dest, 1, &src, 1, 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_copy_aligned (device, src_offset, dest_offset, len)) { -dma_addr_t dma_dest, dma_src; -unsigned long dma_prep_flags =0 ; +if (device) + unmap =dmaengine_get_unmap_data (device->dev,2 ,GFP_NOIO ); + +if (unmap &&is_dma_copy_aligned (device, src_offset, dest_offset, 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, dest_offset, len, -DMA_FROM_DEVICE ); - - dma_src =dma_map_page (device->dev, src, src_offset, len, -DMA_TO_DEVICE ); - - tx = device->device_prep_dma_memcpy (chan, dma_dest, dma_src, - len, dma_prep_flags); -if (!tx) { -dma_unmap_page (device->dev, dma_dest, len, -DMA_FROM_DEVICE ); -dma_unmap_page (device->dev, dma_src, len, -DMA_TO_DEVICE ); - } + + unmap->to_cnt =1 ; + unmap->addr[0 ] =dma_map_page (device->dev, src, src_offset, len, +DMA_TO_DEVICE ); + unmap->from_cnt =1 ; + unmap->addr[1 ] =dma_map_page (device->dev, dest, dest_offset, len, +DMA_FROM_DEVICE ); + unmap->len = len; + + tx = device->device_prep_dma_memcpy (chan, unmap->addr[1 ], + unmap->addr[0 ], len, + dma_prep_flags); }if (tx) {pr_debug ("%s: (async) len: %zu\n" , __func__, len); + +dma_set_unmap (tx, unmap);async_tx_submit (chan, tx, submit); }else {void *dest_buf, *src_buf;
@@ -96,6 +100,8 @@ async_memcpy(struct page *dest, struct page *src, unsigned int dest_offset,async_tx_sync_epilog (submit); } +dmaengine_unmap_put (unmap); +return tx; }EXPORT_SYMBOL_GPL (async_memcpy);
drivers/dma/dmaengine.c +2 -1
@@ -1009,7 +1009,7 @@ static int __init dmaengine_init_unmap_pool(void)return -ENOMEM ; } -static struct dmaengine_unmap_data * +struct dmaengine_unmap_data *dmaengine_get_unmap_data (struct device *dev,int nr,gfp_t flags) {struct dmaengine_unmap_data *unmap;
@@ -1024,6 +1024,7 @@ dmaengine_get_unmap_data(struct device *dev, int nr, gfp_t flags)return unmap; } +EXPORT_SYMBOL (dmaengine_get_unmap_data);/** * dma_async_memcpy_pg_to_pg - offloaded copy from page to page
include/linux/dmaengine.h +2 -0
@@ -464,6 +464,8 @@ static inline void dma_set_unmap(struct dma_async_tx_descriptor *tx, tx->unmap = unmap; } +struct dmaengine_unmap_data * +dmaengine_get_unmap_data (struct device *dev,int nr,gfp_t flags);void dmaengine_unmap_put (struct dmaengine_unmap_data *unmap);static inline void dma_descriptor_unmap (struct dma_async_tx_descriptor *tx)
PATCH v2 6/13 async_xor: convert to dmaengine_unmap_data
In reply to Bartlomiej ZolnierkiewiczFrom: Dan Williams <[email protected]>
Use the generic unmap object to unmap dma buffers.
Later we can push this unmap object up to the raid layer and get rid of the 'scribble' parameter.
--- crypto/async_tx/async_xor.c | 95 ++++++++++++++++++++++++--------------------- 1 file changed, 51 insertions(+), 44 deletions(-)
crypto/async_tx/async_xor.c +51 -44
@@ -33,48 +33,32 @@/* do_async_xor - dma map the pages and perform the xor with an engine */ static __async_inline struct dma_async_tx_descriptor * -do_async_xor (struct dma_chan *chan,struct page *dest,struct page **src_list, -unsigned int offset,int src_cnt,size_t len,dma_addr_t *dma_src, +do_async_xor (struct dma_chan *chan,struct dmaengine_unmap_data *unmap,struct async_submit_ctl *submit) {struct dma_device *dma = chan->device;struct dma_async_tx_descriptor *tx =NULL ; -int src_off =0 ; -int i;dma_async_tx_callback cb_fn_orig = submit->cb_fn;void *cb_param_orig = submit->cb_param;enum async_tx_flags flags_orig = submit->flags;enum dma_ctrl_flags dma_flags; -int xor_src_cnt =0 ; -dma_addr_t dma_dest; - -/* map the dest bidrectional in case it is re-used as a source */ - dma_dest =dma_map_page (dma->dev, dest, offset, len,DMA_BIDIRECTIONAL ); -for (i =0 ; i < src_cnt; i++) { -/* only map the dest once */ -if (!src_list[i]) -continue ; -if (unlikely (src_list[i] == dest)) { - dma_src[xor_src_cnt++] = dma_dest; -continue ; - } - dma_src[xor_src_cnt++] =dma_map_page (dma->dev, src_list[i], offset, - len,DMA_TO_DEVICE ); - } - src_cnt = xor_src_cnt; +int src_cnt = unmap->to_cnt; +int xor_src_cnt; +dma_addr_t dma_dest = unmap->addr[unmap->to_cnt]; +dma_addr_t *src_list = unmap->addr;while (src_cnt) { +dma_addr_t tmp; + submit->flags = flags_orig; - dma_flags =0 ; xor_src_cnt =min (src_cnt, (int )dma->max_xor); -/* if we are submitting additional xors, leave the chain open, -* clear the callback parameters, and leave the destination -* buffer mapped +/* if we are submitting additional xors, leave the chain open +* and clear the callback parameters */ + dma_flags =DMA_COMPL_SKIP_SRC_UNMAP |DMA_COMPL_SKIP_DEST_UNMAP ;if (src_cnt > xor_src_cnt) { submit->flags &= ~ASYNC_TX_ACK ; submit->flags |=ASYNC_TX_FENCE ; - dma_flags =DMA_COMPL_SKIP_DEST_UNMAP ; submit->cb_fn =NULL ; submit->cb_param =NULL ; }else {
@@ -85,12 +69,18 @@ do_async_xor(struct dma_chan *chan, struct page *dest, struct page **src_list, dma_flags |=DMA_PREP_INTERRUPT ;if (submit->flags &ASYNC_TX_FENCE ) dma_flags |=DMA_PREP_FENCE ; -/* Since we have clobbered the src_list we are committed -* to doing this asynchronously. Drivers force forward progress -* in case they can not provide a descriptor + +/* Drivers force forward progress in case they can not provide a +* descriptor */ - tx = dma->device_prep_dma_xor (chan, dma_dest, &dma_src[src_off], - xor_src_cnt, len, dma_flags); + tmp = src_list[0 ]; +if (src_list > unmap->addr) + src_list[0 ] = dma_dest; + tx = dma->device_prep_dma_xor (chan, dma_dest, src_list, + xor_src_cnt, unmap->len, + dma_flags); + src_list[0 ] = tmp; +if (unlikely (!tx))async_tx_quiesce (&submit->depend_tx);
@@ -99,22 +89,21 @@ do_async_xor(struct dma_chan *chan, struct page *dest, struct page **src_list,while (unlikely (!tx)) {dma_async_issue_pending (chan); tx = dma->device_prep_dma_xor (chan, dma_dest, - &dma_src[src_off], - xor_src_cnt, len, + src_list, + xor_src_cnt, unmap->len, dma_flags); } +dma_set_unmap (tx, unmap);async_tx_submit (chan, tx, submit); submit->depend_tx = tx;if (src_cnt > xor_src_cnt) {/* drop completed sources */ src_cnt -= xor_src_cnt; - src_off += xor_src_cnt; -/* use the intermediate result a source */ - dma_src[--src_off] = dma_dest; src_cnt++; + src_list += xor_src_cnt -1 ; }else break ; }
@@ -189,22 +178,40 @@ async_xor(struct page *dest, struct page **src_list, unsigned int offset,struct dma_chan *chan =async_tx_find_channel (submit,DMA_XOR , &dest,1 , src_list, src_cnt, len); -dma_addr_t *dma_src =NULL ; +struct dma_device *device = chan ? chan->device :NULL ; +struct dmaengine_unmap_data *unmap =NULL ;BUG_ON (src_cnt <=1 ); -if (submit->scribble) - dma_src = submit->scribble; -else if (sizeof (dma_addr_t) <=sizeof (struct page *)) - dma_src = (dma_addr_t *) src_list; +if (device) + unmap =dmaengine_get_unmap_data (device->dev, src_cnt+1 ,GFP_NOIO ); + +if (unmap &&is_dma_xor_aligned (device, offset,0 , len)) { +struct dma_async_tx_descriptor *tx; +int i, j; -if (dma_src && chan &&is_dma_xor_aligned (chan->device, offset,0 , len)) {/* run the xor asynchronously */ pr_debug ("%s (async): len: %zu\n" , __func__, len); -return do_async_xor (chan, dest, src_list, offset, src_cnt, len, - dma_src, submit); + unmap->len = len; +for (i =0 , j =0 ; i < src_cnt; i++) { +if (!src_list[i]) +continue ; + unmap->to_cnt++; + unmap->addr[j++] =dma_map_page (device->dev, src_list[i], + offset, len,DMA_TO_DEVICE ); + } + +/* map it bidirectional as it may be re-used as a source */ + unmap->addr[j] =dma_map_page (device->dev, dest, offset, len, +DMA_BIDIRECTIONAL ); + unmap->bidi_cnt =1 ; + + tx =do_async_xor (chan, unmap, submit); +dmaengine_unmap_put (unmap); +return tx; }else { +dmaengine_unmap_put (unmap);/* run the xor synchronously */ pr_debug ("%s (sync): len: %zu\n" , __func__, len); WARN_ONCE(chan, "%s: no space for dma address conversion\n",
Signature · 1 line
1.8.2.3
PATCH v2 6/13 async_xor: convert to dmaengine_unmap_data
Use the generic unmap object to unmap dma buffers.
Later we can push this unmap object up to the raid layer and get rid of the 'scribble' parameter.
---
Resend to:
1/ add it to the new dmaengine patchwork
2/ cc maintainers of affected drivers
3/ fixup some mail addresses
crypto/async_tx/async_xor.c | 95 +++++++++++++++++++++++-------------------- 1 files changed, 51 insertions(+), 44 deletions(-)
crypto/async_tx/async_xor.c +51 -44
@@ -33,48 +33,32 @@/* do_async_xor - dma map the pages and perform the xor with an engine */ static __async_inline struct dma_async_tx_descriptor * -do_async_xor (struct dma_chan *chan,struct page *dest,struct page **src_list, -unsigned int offset,int src_cnt,size_t len,dma_addr_t *dma_src, +do_async_xor (struct dma_chan *chan,struct dmaengine_unmap_data *unmap,struct async_submit_ctl *submit) {struct dma_device *dma = chan->device;struct dma_async_tx_descriptor *tx =NULL ; -int src_off =0 ; -int i;dma_async_tx_callback cb_fn_orig = submit->cb_fn;void *cb_param_orig = submit->cb_param;enum async_tx_flags flags_orig = submit->flags;enum dma_ctrl_flags dma_flags; -int xor_src_cnt =0 ; -dma_addr_t dma_dest; - -/* map the dest bidrectional in case it is re-used as a source */ - dma_dest =dma_map_page (dma->dev, dest, offset, len,DMA_BIDIRECTIONAL ); -for (i =0 ; i < src_cnt; i++) { -/* only map the dest once */ -if (!src_list[i]) -continue ; -if (unlikely (src_list[i] == dest)) { - dma_src[xor_src_cnt++] = dma_dest; -continue ; - } - dma_src[xor_src_cnt++] =dma_map_page (dma->dev, src_list[i], offset, - len,DMA_TO_DEVICE ); - } - src_cnt = xor_src_cnt; +int src_cnt = unmap->to_cnt; +int xor_src_cnt; +dma_addr_t dma_dest = unmap->addr[unmap->to_cnt]; +dma_addr_t *src_list = unmap->addr;while (src_cnt) { +dma_addr_t tmp; + submit->flags = flags_orig; - dma_flags =0 ; xor_src_cnt =min (src_cnt, (int )dma->max_xor); -/* if we are submitting additional xors, leave the chain open, -* clear the callback parameters, and leave the destination -* buffer mapped +/* if we are submitting additional xors, leave the chain open +* and clear the callback parameters */ + dma_flags =DMA_COMPL_SKIP_SRC_UNMAP |DMA_COMPL_SKIP_DEST_UNMAP ;if (src_cnt > xor_src_cnt) { submit->flags &= ~ASYNC_TX_ACK ; submit->flags |=ASYNC_TX_FENCE ; - dma_flags =DMA_COMPL_SKIP_DEST_UNMAP ; submit->cb_fn =NULL ; submit->cb_param =NULL ; }else {
@@ -85,12 +69,18 @@ do_async_xor(struct dma_chan *chan, struct page *dest, struct page **src_list, dma_flags |=DMA_PREP_INTERRUPT ;if (submit->flags &ASYNC_TX_FENCE ) dma_flags |=DMA_PREP_FENCE ; -/* Since we have clobbered the src_list we are committed -* to doing this asynchronously. Drivers force forward progress -* in case they can not provide a descriptor + +/* Drivers force forward progress in case they can not provide a +* descriptor */ - tx = dma->device_prep_dma_xor (chan, dma_dest, &dma_src[src_off], - xor_src_cnt, len, dma_flags); + tmp = src_list[0 ]; +if (src_list > unmap->addr) + src_list[0 ] = dma_dest; + tx = dma->device_prep_dma_xor (chan, dma_dest, src_list, + xor_src_cnt, unmap->len, + dma_flags); + src_list[0 ] = tmp; +if (unlikely (!tx))async_tx_quiesce (&submit->depend_tx);
@@ -99,22 +89,21 @@ do_async_xor(struct dma_chan *chan, struct page *dest, struct page **src_list,while (unlikely (!tx)) {dma_async_issue_pending (chan); tx = dma->device_prep_dma_xor (chan, dma_dest, - &dma_src[src_off], - xor_src_cnt, len, + src_list, + xor_src_cnt, unmap->len, dma_flags); } +dma_set_unmap (tx, unmap);async_tx_submit (chan, tx, submit); submit->depend_tx = tx;if (src_cnt > xor_src_cnt) {/* drop completed sources */ src_cnt -= xor_src_cnt; - src_off += xor_src_cnt; -/* use the intermediate result a source */ - dma_src[--src_off] = dma_dest; src_cnt++; + src_list += xor_src_cnt -1 ; }else break ; }
@@ -189,22 +178,40 @@ async_xor(struct page *dest, struct page **src_list, unsigned int offset,struct dma_chan *chan =async_tx_find_channel (submit,DMA_XOR , &dest,1 , src_list, src_cnt, len); -dma_addr_t *dma_src =NULL ; +struct dma_device *device = chan ? chan->device :NULL ; +struct dmaengine_unmap_data *unmap =NULL ;BUG_ON (src_cnt <=1 ); -if (submit->scribble) - dma_src = submit->scribble; -else if (sizeof (dma_addr_t) <=sizeof (struct page *)) - dma_src = (dma_addr_t *) src_list; +if (device) + unmap =dmaengine_get_unmap_data (device->dev, src_cnt+1 ,GFP_NOIO ); + +if (unmap &&is_dma_xor_aligned (device, offset,0 , len)) { +struct dma_async_tx_descriptor *tx; +int i, j; -if (dma_src && chan &&is_dma_xor_aligned (chan->device, offset,0 , len)) {/* run the xor asynchronously */ pr_debug ("%s (async): len: %zu\n" , __func__, len); -return do_async_xor (chan, dest, src_list, offset, src_cnt, len, - dma_src, submit); + unmap->len = len; +for (i =0 , j =0 ; i < src_cnt; i++) { +if (!src_list[i]) +continue ; + unmap->to_cnt++; + unmap->addr[j++] =dma_map_page (device->dev, src_list[i], + offset, len,DMA_TO_DEVICE ); + } + +/* map it bidirectional as it may be re-used as a source */ + unmap->addr[j] =dma_map_page (device->dev, dest, offset, len, +DMA_BIDIRECTIONAL ); + unmap->bidi_cnt =1 ; + + tx =do_async_xor (chan, unmap, submit); +dmaengine_unmap_put (unmap); +return tx; }else { +dmaengine_unmap_put (unmap);/* run the xor synchronously */ pr_debug ("%s (sync): len: %zu\n" , __func__, len); WARN_ONCE(chan, "%s: no space for dma address conversion\n",
PATCH v2 7/13 async_xor_val: convert to dmaengine_unmap_data
In reply to Bartlomiej ZolnierkiewiczFrom: Dan Williams <[email protected]>
Use the generic unmap object to unmap dma buffers.
--- crypto/async_tx/async_xor.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-)
crypto/async_tx/async_xor.c +17 -13
@@ -275,18 +275,17 @@ async_xor_val(struct page *dest, struct page **src_list, unsigned int offset,struct dma_chan *chan =xor_val_chan (submit, dest, src_list, src_cnt, len);struct dma_device *device = chan ? chan->device :NULL ;struct dma_async_tx_descriptor *tx =NULL ; -dma_addr_t *dma_src =NULL ; +struct dmaengine_unmap_data *unmap =NULL ;BUG_ON (src_cnt <=1 ); -if (submit->scribble) - dma_src = submit->scribble; -else if (sizeof (dma_addr_t) <=sizeof (struct page *)) - dma_src = (dma_addr_t *) src_list; +if (device) + unmap =dmaengine_get_unmap_data (device->dev, src_cnt,GFP_NOIO ); -if (dma_src && device && src_cnt <= device->max_xor && +if (unmap && 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);
@@ -295,11 +294,15 @@ async_xor_val(struct page *dest, struct page **src_list, unsigned int offset, dma_prep_flags |=DMA_PREP_INTERRUPT ;if (submit->flags &ASYNC_TX_FENCE ) dma_prep_flags |=DMA_PREP_FENCE ; -for (i =0 ; i < src_cnt; i++) - dma_src[i] =dma_map_page (device->dev, src_list[i], - offset, len,DMA_TO_DEVICE ); - tx = device->device_prep_dma_xor_val (chan, dma_src, src_cnt, +for (i =0 ; i < src_cnt; i++) { + unmap->addr[i] =dma_map_page (device->dev, src_list[i], + offset, len,DMA_TO_DEVICE ); + unmap->to_cnt++; + } + unmap->len = len; + + tx = device->device_prep_dma_xor_val (chan, unmap->addr, src_cnt, len, result, dma_prep_flags);if (unlikely (!tx)) {
@@ -308,11 +311,11 @@ async_xor_val(struct page *dest, struct page **src_list, unsigned int offset,while (!tx) {dma_async_issue_pending (chan); tx = device->device_prep_dma_xor_val (chan, - dma_src, src_cnt, len, result, + unmap->addr, src_cnt, len, result, dma_prep_flags); } } - +dma_set_unmap (tx, unmap);async_tx_submit (chan, tx, submit); }else {enum async_tx_flags flags_orig = submit->flags;
@@ -334,6 +337,7 @@ async_xor_val(struct page *dest, struct page **src_list, unsigned int offset,async_tx_sync_epilog (submit); submit->flags = flags_orig; } +dmaengine_unmap_put (unmap);return tx; }
Signature · 1 line
1.8.2.3
PATCH v2 7/13 async_xor_val: convert to dmaengine_unmap_data
Use the generic unmap object to unmap dma buffers.
---
Resend to:
1/ add it to the new dmaengine patchwork
2/ cc maintainers of affected drivers
3/ fixup some mail addresses
crypto/async_tx/async_xor.c | 30 +++++++++++++++++------------- 1 files changed, 17 insertions(+), 13 deletions(-)
crypto/async_tx/async_xor.c +17 -13
@@ -275,18 +275,17 @@ async_xor_val(struct page *dest, struct page **src_list, unsigned int offset,struct dma_chan *chan =xor_val_chan (submit, dest, src_list, src_cnt, len);struct dma_device *device = chan ? chan->device :NULL ;struct dma_async_tx_descriptor *tx =NULL ; -dma_addr_t *dma_src =NULL ; +struct dmaengine_unmap_data *unmap =NULL ;BUG_ON (src_cnt <=1 ); -if (submit->scribble) - dma_src = submit->scribble; -else if (sizeof (dma_addr_t) <=sizeof (struct page *)) - dma_src = (dma_addr_t *) src_list; +if (device) + unmap =dmaengine_get_unmap_data (device->dev, src_cnt,GFP_NOIO ); -if (dma_src && device && src_cnt <= device->max_xor && +if (unmap && 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);
@@ -295,11 +294,15 @@ async_xor_val(struct page *dest, struct page **src_list, unsigned int offset, dma_prep_flags |=DMA_PREP_INTERRUPT ;if (submit->flags &ASYNC_TX_FENCE ) dma_prep_flags |=DMA_PREP_FENCE ; -for (i =0 ; i < src_cnt; i++) - dma_src[i] =dma_map_page (device->dev, src_list[i], - offset, len,DMA_TO_DEVICE ); - tx = device->device_prep_dma_xor_val (chan, dma_src, src_cnt, +for (i =0 ; i < src_cnt; i++) { + unmap->addr[i] =dma_map_page (device->dev, src_list[i], + offset, len,DMA_TO_DEVICE ); + unmap->to_cnt++; + } + unmap->len = len; + + tx = device->device_prep_dma_xor_val (chan, unmap->addr, src_cnt, len, result, dma_prep_flags);if (unlikely (!tx)) {
@@ -308,11 +311,11 @@ async_xor_val(struct page *dest, struct page **src_list, unsigned int offset,while (!tx) {dma_async_issue_pending (chan); tx = device->device_prep_dma_xor_val (chan, - dma_src, src_cnt, len, result, + unmap->addr, src_cnt, len, result, dma_prep_flags); } } - +dma_set_unmap (tx, unmap);async_tx_submit (chan, tx, submit); }else {enum async_tx_flags flags_orig = submit->flags;
@@ -334,6 +337,7 @@ async_xor_val(struct page *dest, struct page **src_list, unsigned int offset,async_tx_sync_epilog (submit); submit->flags = flags_orig; } +dmaengine_unmap_put (unmap);return tx; }
PATCH v2 8/13 async_raid6_recov: convert to dmaengine_unmap_data
In reply to Bartlomiej ZolnierkiewiczFrom: Dan Williams <[email protected]>
Use the generic unmap object to unmap dma buffers.
--- crypto/async_tx/async_raid6_recov.c | 69 ++++++++++++++++++++++++++----------- 1 file changed, 49 insertions(+), 20 deletions(-)
crypto/async_tx/async_raid6_recov.c +49 -20
@@ -26,6 +26,7 @@#include <linux/dma-mapping.h> #include <linux/raid/pq.h> #include <linux/async_tx.h> +#include <linux/dmaengine.h> static struct dma_async_tx_descriptor * async_sum_product(struct page *dest, struct page **srcs, unsigned char *coef,
@@ -34,35 +35,47 @@ async_sum_product(struct page *dest, struct page **srcs, unsigned char *coef,struct dma_chan *chan =async_tx_find_channel (submit,DMA_PQ , &dest,1 , srcs,2 , len);struct dma_device *dma = chan ? chan->device :NULL ; +struct dmaengine_unmap_data *unmap =NULL ;const u8 *amul, *bmul;u8 ax, bx;u8 *a, *b, *c; -if (dma) { -dma_addr_t dma_dest[2 ]; -dma_addr_t dma_src[2 ]; +if (dma) + unmap =dmaengine_get_unmap_data (dma->dev,3 ,GFP_NOIO ); + +if (unmap) {struct device *dev = dma->dev; +dma_addr_t pq[2 ];struct dma_async_tx_descriptor *tx; -enum dma_ctrl_flags dma_flags =DMA_PREP_PQ_DISABLE_P ; +enum dma_ctrl_flags dma_flags =DMA_COMPL_SKIP_SRC_UNMAP | +DMA_COMPL_SKIP_DEST_UNMAP | +DMA_PREP_PQ_DISABLE_P ;if (submit->flags &ASYNC_TX_FENCE ) dma_flags |=DMA_PREP_FENCE ; - dma_dest[1 ] =dma_map_page (dev, dest,0 , len,DMA_BIDIRECTIONAL ); - dma_src[0 ] =dma_map_page (dev, srcs[0 ],0 , len,DMA_TO_DEVICE ); - dma_src[1 ] =dma_map_page (dev, srcs[1 ],0 , len,DMA_TO_DEVICE ); - tx = dma->device_prep_dma_pq (chan, dma_dest, dma_src,2 , coef, + unmap->addr[0 ] =dma_map_page (dev, srcs[0 ],0 , len,DMA_TO_DEVICE ); + unmap->addr[1 ] =dma_map_page (dev, srcs[1 ],0 , len,DMA_TO_DEVICE ); + unmap->to_cnt =2 ; + + unmap->addr[2 ] =dma_map_page (dev, dest,0 , len,DMA_BIDIRECTIONAL ); + unmap->bidi_cnt =1 ; +/* engine only looks at Q, but expects it to follow P */ + pq[1 ] = unmap->addr[2 ]; + + unmap->len = len; + tx = dma->device_prep_dma_pq (chan, pq, unmap->addr,2 , coef, len, dma_flags);if (tx) { +dma_set_unmap (tx, unmap);async_tx_submit (chan, tx, submit); +dmaengine_unmap_put (unmap);return tx; }/* could not get a descriptor, unmap and fall through to * the synchronous path */ -dma_unmap_page (dev, dma_dest[1 ], len,DMA_BIDIRECTIONAL ); -dma_unmap_page (dev, dma_src[0 ], len,DMA_TO_DEVICE ); -dma_unmap_page (dev, dma_src[1 ], len,DMA_TO_DEVICE ); +dmaengine_unmap_put (unmap); }/* run the operation synchronously */
@@ -89,23 +102,40 @@ async_mult(struct page *dest, struct page *src, u8 coef, size_t len,struct dma_chan *chan =async_tx_find_channel (submit,DMA_PQ , &dest,1 , &src,1 , len);struct dma_device *dma = chan ? chan->device :NULL ; +struct dmaengine_unmap_data *unmap =NULL ;const u8 *qmul;/* Q multiplier table */ u8 *d, *s; -if (dma) { +if (dma) + unmap =dmaengine_get_unmap_data (dma->dev,3 ,GFP_NOIO ); + +if (unmap) {dma_addr_t dma_dest[2 ]; -dma_addr_t dma_src[1 ];struct device *dev = dma->dev;struct dma_async_tx_descriptor *tx; -enum dma_ctrl_flags dma_flags =DMA_PREP_PQ_DISABLE_P ; +enum dma_ctrl_flags dma_flags =DMA_COMPL_SKIP_SRC_UNMAP | +DMA_COMPL_SKIP_DEST_UNMAP | +DMA_PREP_PQ_DISABLE_P ;if (submit->flags &ASYNC_TX_FENCE ) dma_flags |=DMA_PREP_FENCE ; - dma_dest[1 ] =dma_map_page (dev, dest,0 , len,DMA_BIDIRECTIONAL ); - dma_src[0 ] =dma_map_page (dev, src,0 , len,DMA_TO_DEVICE ); - tx = dma->device_prep_dma_pq (chan, dma_dest, dma_src,1 , &coef, - len, dma_flags); + unmap->addr[0 ] =dma_map_page (dev, src,0 , len,DMA_TO_DEVICE ); + unmap->to_cnt++; + unmap->addr[1 ] =dma_map_page (dev, dest,0 , len,DMA_BIDIRECTIONAL ); + dma_dest[1 ] = unmap->addr[1 ]; + unmap->bidi_cnt++; + unmap->len = len; + +/* this looks funny, but the engine looks for Q at +* dma_dest[1] and ignores dma_dest[0] as a dest +* due to DMA_PREP_PQ_DISABLE_P +*/ + tx = dma->device_prep_dma_pq (chan, dma_dest, unmap->addr, +1 , &coef, len, dma_flags); +if (tx) { +dma_set_unmap (tx, unmap); +dmaengine_unmap_put (unmap);async_tx_submit (chan, tx, submit);return tx; }
@@ -113,8 +143,7 @@ async_mult(struct page *dest, struct page *src, u8 coef, size_t len,/* could not get a descriptor, unmap and fall through to * the synchronous path */ -dma_unmap_page (dev, dma_dest[1 ], len,DMA_BIDIRECTIONAL ); -dma_unmap_page (dev, dma_src[0 ], len,DMA_TO_DEVICE ); +dmaengine_unmap_put (unmap); }/* no channel available, or failed to allocate a descriptor, so
Signature · 1 line
1.8.2.3
PATCH v2 8/13 async_raid6_recov: convert to dmaengine_unmap_data
Use the generic unmap object to unmap dma buffers.
---
Resend to:
1/ add it to the new dmaengine patchwork
2/ cc maintainers of affected drivers
3/ fixup some mail addresses
crypto/async_tx/async_raid6_recov.c | 69 +++++++++++++++++++++++++---------- 1 files changed, 49 insertions(+), 20 deletions(-)
crypto/async_tx/async_raid6_recov.c +49 -20
@@ -26,6 +26,7 @@#include <linux/dma-mapping.h> #include <linux/raid/pq.h> #include <linux/async_tx.h> +#include <linux/dmaengine.h> static struct dma_async_tx_descriptor * async_sum_product(struct page *dest, struct page **srcs, unsigned char *coef,
@@ -34,35 +35,47 @@ async_sum_product(struct page *dest, struct page **srcs, unsigned char *coef,struct dma_chan *chan =async_tx_find_channel (submit,DMA_PQ , &dest,1 , srcs,2 , len);struct dma_device *dma = chan ? chan->device :NULL ; +struct dmaengine_unmap_data *unmap =NULL ;const u8 *amul, *bmul;u8 ax, bx;u8 *a, *b, *c; -if (dma) { -dma_addr_t dma_dest[2 ]; -dma_addr_t dma_src[2 ]; +if (dma) + unmap =dmaengine_get_unmap_data (dma->dev,3 ,GFP_NOIO ); + +if (unmap) {struct device *dev = dma->dev; +dma_addr_t pq[2 ];struct dma_async_tx_descriptor *tx; -enum dma_ctrl_flags dma_flags =DMA_PREP_PQ_DISABLE_P ; +enum dma_ctrl_flags dma_flags =DMA_COMPL_SKIP_SRC_UNMAP | +DMA_COMPL_SKIP_DEST_UNMAP | +DMA_PREP_PQ_DISABLE_P ;if (submit->flags &ASYNC_TX_FENCE ) dma_flags |=DMA_PREP_FENCE ; - dma_dest[1 ] =dma_map_page (dev, dest,0 , len,DMA_BIDIRECTIONAL ); - dma_src[0 ] =dma_map_page (dev, srcs[0 ],0 , len,DMA_TO_DEVICE ); - dma_src[1 ] =dma_map_page (dev, srcs[1 ],0 , len,DMA_TO_DEVICE ); - tx = dma->device_prep_dma_pq (chan, dma_dest, dma_src,2 , coef, + unmap->addr[0 ] =dma_map_page (dev, srcs[0 ],0 , len,DMA_TO_DEVICE ); + unmap->addr[1 ] =dma_map_page (dev, srcs[1 ],0 , len,DMA_TO_DEVICE ); + unmap->to_cnt =2 ; + + unmap->addr[2 ] =dma_map_page (dev, dest,0 , len,DMA_BIDIRECTIONAL ); + unmap->bidi_cnt =1 ; +/* engine only looks at Q, but expects it to follow P */ + pq[1 ] = unmap->addr[2 ]; + + unmap->len = len; + tx = dma->device_prep_dma_pq (chan, pq, unmap->addr,2 , coef, len, dma_flags);if (tx) { +dma_set_unmap (tx, unmap);async_tx_submit (chan, tx, submit); +dmaengine_unmap_put (unmap);return tx; }/* could not get a descriptor, unmap and fall through to * the synchronous path */ -dma_unmap_page (dev, dma_dest[1 ], len,DMA_BIDIRECTIONAL ); -dma_unmap_page (dev, dma_src[0 ], len,DMA_TO_DEVICE ); -dma_unmap_page (dev, dma_src[1 ], len,DMA_TO_DEVICE ); +dmaengine_unmap_put (unmap); }/* run the operation synchronously */
@@ -89,23 +102,40 @@ async_mult(struct page *dest, struct page *src, u8 coef, size_t len,struct dma_chan *chan =async_tx_find_channel (submit,DMA_PQ , &dest,1 , &src,1 , len);struct dma_device *dma = chan ? chan->device :NULL ; +struct dmaengine_unmap_data *unmap =NULL ;const u8 *qmul;/* Q multiplier table */ u8 *d, *s; -if (dma) { +if (dma) + unmap =dmaengine_get_unmap_data (dma->dev,3 ,GFP_NOIO ); + +if (unmap) {dma_addr_t dma_dest[2 ]; -dma_addr_t dma_src[1 ];struct device *dev = dma->dev;struct dma_async_tx_descriptor *tx; -enum dma_ctrl_flags dma_flags =DMA_PREP_PQ_DISABLE_P ; +enum dma_ctrl_flags dma_flags =DMA_COMPL_SKIP_SRC_UNMAP | +DMA_COMPL_SKIP_DEST_UNMAP | +DMA_PREP_PQ_DISABLE_P ;if (submit->flags &ASYNC_TX_FENCE ) dma_flags |=DMA_PREP_FENCE ; - dma_dest[1 ] =dma_map_page (dev, dest,0 , len,DMA_BIDIRECTIONAL ); - dma_src[0 ] =dma_map_page (dev, src,0 , len,DMA_TO_DEVICE ); - tx = dma->device_prep_dma_pq (chan, dma_dest, dma_src,1 , &coef, - len, dma_flags); + unmap->addr[0 ] =dma_map_page (dev, src,0 , len,DMA_TO_DEVICE ); + unmap->to_cnt++; + unmap->addr[1 ] =dma_map_page (dev, dest,0 , len,DMA_BIDIRECTIONAL ); + dma_dest[1 ] = unmap->addr[1 ]; + unmap->bidi_cnt++; + unmap->len = len; + +/* this looks funny, but the engine looks for Q at +* dma_dest[1] and ignores dma_dest[0] as a dest +* due to DMA_PREP_PQ_DISABLE_P +*/ + tx = dma->device_prep_dma_pq (chan, dma_dest, unmap->addr, +1 , &coef, len, dma_flags); +if (tx) { +dma_set_unmap (tx, unmap); +dmaengine_unmap_put (unmap);async_tx_submit (chan, tx, submit);return tx; }
@@ -113,8 +143,7 @@ async_mult(struct page *dest, struct page *src, u8 coef, size_t len,/* could not get a descriptor, unmap and fall through to * the synchronous path */ -dma_unmap_page (dev, dma_dest[1 ], len,DMA_BIDIRECTIONAL ); -dma_unmap_page (dev, dma_src[0 ], len,DMA_TO_DEVICE ); +dmaengine_unmap_put (unmap); }/* no channel available, or failed to allocate a descriptor, so
PATCH v2 9/13 async_pq: convert to dmaengine_unmap_data
In reply to Bartlomiej ZolnierkiewiczFrom: Dan Williams <[email protected]>
Use the generic unmap object to unmap dma buffers.
--- crypto/async_tx/async_pq.c | 117 +++++++++++++++++++++++++-------------------- drivers/dma/dmaengine.c | 5 +- 2 files changed, 69 insertions(+), 53 deletions(-)
crypto/async_tx/async_pq.c +65 -52
@@ -46,49 +46,25 @@ static struct page *pq_scribble_page;* do_async_gen_syndrome - asynchronously calculate P and/or Q */ static __async_inline struct dma_async_tx_descriptor * -do_async_gen_syndrome (struct dma_chan *chan,struct page **blocks, -const unsigned char *scfs,unsigned int offset,int disks, -size_t len,dma_addr_t *dma_src, +do_async_gen_syndrome (struct dma_chan *chan, +const unsigned char *scfs,int disks, +struct dmaengine_unmap_data *unmap, +enum dma_ctrl_flags dma_flags,struct async_submit_ctl *submit) {struct dma_async_tx_descriptor *tx =NULL ;struct dma_device *dma = chan->device; -enum dma_ctrl_flags dma_flags =0 ;enum async_tx_flags flags_orig = submit->flags;dma_async_tx_callback cb_fn_orig = submit->cb_fn;dma_async_tx_callback cb_param_orig = submit->cb_param;int src_cnt = disks -2 ; -unsigned char coefs[src_cnt];unsigned short pq_src_cnt;dma_addr_t dma_dest[2 ];int src_off =0 ; -int idx; -int i; -/* DMAs use destinations as sources, so use BIDIRECTIONAL mapping */ -if (P (blocks, disks)) - dma_dest[0 ] =dma_map_page (dma->dev,P (blocks, disks), offset, - len,DMA_BIDIRECTIONAL ); -else - dma_flags |=DMA_PREP_PQ_DISABLE_P ; -if (Q (blocks, disks)) - dma_dest[1 ] =dma_map_page (dma->dev,Q (blocks, disks), offset, - len,DMA_BIDIRECTIONAL ); -else - dma_flags |=DMA_PREP_PQ_DISABLE_Q ; - -/* convert source addresses being careful to collapse 'empty' -* sources and update the coefficients accordingly -*/ -for (i =0 , idx =0 ; i < src_cnt; i++) { -if (blocks[i] ==NULL ) -continue ; - dma_src[idx] =dma_map_page (dma->dev, blocks[i], offset, len, -DMA_TO_DEVICE ); - coefs[idx] = scfs[i]; - idx++; - } - src_cnt = idx; + dma_flags |=DMA_COMPL_SKIP_SRC_UNMAP |DMA_COMPL_SKIP_DEST_UNMAP ; +if (submit->flags &ASYNC_TX_FENCE ) + dma_flags |=DMA_PREP_FENCE ;while (src_cnt >0 ) { submit->flags = flags_orig;
@@ -100,28 +76,25 @@ do_async_gen_syndrome(struct dma_chan *chan, struct page **blocks,if (src_cnt > pq_src_cnt) { submit->flags &= ~ASYNC_TX_ACK ; submit->flags |=ASYNC_TX_FENCE ; - dma_flags |=DMA_COMPL_SKIP_DEST_UNMAP ; submit->cb_fn =NULL ; submit->cb_param =NULL ; }else { - dma_flags &= ~DMA_COMPL_SKIP_DEST_UNMAP ; submit->cb_fn = cb_fn_orig; submit->cb_param = cb_param_orig;if (cb_fn_orig) dma_flags |=DMA_PREP_INTERRUPT ; } -if (submit->flags &ASYNC_TX_FENCE ) - dma_flags |=DMA_PREP_FENCE ; -/* Since we have clobbered the src_list we are committed -* to doing this asynchronously. Drivers force forward -* progress in case they can not provide a descriptor +/* Drivers force forward progress in case they can not provide +* a descriptor */ for (;;) { + dma_dest[0 ] = unmap->addr[disks -2 ]; + dma_dest[1 ] = unmap->addr[disks -1 ]; tx = dma->device_prep_dma_pq (chan, dma_dest, - &dma_src[src_off], + &unmap->addr[src_off], pq_src_cnt, - &coefs[src_off], len, + &scfs[src_off], unmap->len, dma_flags);if (likely (tx))break ;
@@ -129,6 +102,7 @@ do_async_gen_syndrome(struct dma_chan *chan, struct page **blocks,dma_async_issue_pending (chan); } +dma_set_unmap (tx, unmap);async_tx_submit (chan, tx, submit); submit->depend_tx = tx;
@@ -188,10 +162,6 @@ do_sync_gen_syndrome(struct page **blocks, unsigned int offset, int disks,* set to NULL those buffers will be replaced with the raid6_zero_page * in the synchronous path and omitted in the hardware-asynchronous * path. -* -* 'blocks' note: if submit->scribble is NULL then the contents of -* 'blocks' may be overwritten to perform address conversions -* (dma_map_page() or page_address()). */ struct dma_async_tx_descriptor * async_gen_syndrome(struct page **blocks, unsigned int offset, int disks,
@@ -202,26 +172,69 @@ async_gen_syndrome(struct page **blocks, unsigned int offset, int disks, &P (blocks, disks),2 , blocks, src_cnt, len);struct dma_device *device = chan ? chan->device :NULL ; -dma_addr_t *dma_src =NULL ; +struct dmaengine_unmap_data *unmap =NULL ;BUG_ON (disks >255 || !(P (blocks, disks) ||Q (blocks, disks))); -if (submit->scribble) - dma_src = submit->scribble; -else if (sizeof (dma_addr_t) <=sizeof (struct page *)) - dma_src = (dma_addr_t *) blocks; +if (device) + unmap =dmaengine_get_unmap_data (device->dev, disks,GFP_NOIO ); -if (dma_src && device && +if (unmap && (src_cnt <=dma_maxpq (device,0 ) ||dma_maxpq (device,DMA_PREP_CONTINUE ) >0 ) &&is_dma_pq_aligned (device, offset,0 , len)) { +struct dma_async_tx_descriptor *tx; +enum dma_ctrl_flags dma_flags =0 ; +unsigned char coefs[src_cnt]; +int i, j; +/* run the p+q asynchronously */ pr_debug ("%s: (async) disks: %d len: %zu\n" , __func__, disks, len); -return do_async_gen_syndrome (chan, blocks, raid6_gfexp, offset, - disks, len, dma_src, submit); + +/* convert source addresses being careful to collapse 'empty' +* sources and update the coefficients accordingly +*/ + unmap->len = len; +for (i =0 , j =0 ; i < src_cnt; i++) { +if (blocks[i] ==NULL ) +continue ; + unmap->addr[j] =dma_map_page (device->dev, blocks[i], offset, + len,DMA_TO_DEVICE ); + coefs[j] = raid6_gfexp[i]; + unmap->to_cnt++; + j++; + } + +/* +* DMAs use destinations as sources, +* so use BIDIRECTIONAL mapping +*/ + unmap->bidi_cnt++; +if (P (blocks, disks)) + unmap->addr[j++] =dma_map_page (device->dev,P (blocks, disks), + offset, len,DMA_BIDIRECTIONAL ); +else { + unmap->addr[j++] =0 ; + dma_flags |=DMA_PREP_PQ_DISABLE_P ; + } + + unmap->bidi_cnt++; +if (Q (blocks, disks)) + unmap->addr[j++] =dma_map_page (device->dev,Q (blocks, disks), + offset, len,DMA_BIDIRECTIONAL ); +else { + unmap->addr[j++] =0 ; + dma_flags |=DMA_PREP_PQ_DISABLE_Q ; + } + + tx =do_async_gen_syndrome (chan, coefs, j, unmap, dma_flags, submit); +dmaengine_unmap_put (unmap); +return tx; } +dmaengine_unmap_put (unmap); +/* run the pq synchronously */ pr_debug ("%s: (sync) disks: %d len: %zu\n" , __func__, disks, len);
drivers/dma/dmaengine.c +4 -1
@@ -953,9 +953,12 @@ static void dmaengine_unmap(struct kref *kref)dma_unmap_page (dev, unmap->addr[i], unmap->len,DMA_FROM_DEVICE ); cnt += unmap->bidi_cnt; -for (; i < cnt; i++) +for (; i < cnt; i++) { +if (unmap->addr[i] ==0 ) +continue ;dma_unmap_page (dev, unmap->addr[i], unmap->len,DMA_BIDIRECTIONAL ); + }mempool_free (unmap,__get_unmap_pool (cnt)->pool); }
Signature · 1 line
1.8.2.3
PATCH v2 9/13 async_pq: convert to dmaengine_unmap_data
Use the generic unmap object to unmap dma buffers.
---
Resend to:
1/ add it to the new dmaengine patchwork
2/ cc maintainers of affected drivers
3/ fixup some mail addresses
crypto/async_tx/async_pq.c | 117 ++++++++++++++++++++++++-------------------- drivers/dma/dmaengine.c | 5 ++ 2 files changed, 69 insertions(+), 53 deletions(-)
crypto/async_tx/async_pq.c +65 -52
@@ -46,49 +46,25 @@ static struct page *pq_scribble_page;* do_async_gen_syndrome - asynchronously calculate P and/or Q */ static __async_inline struct dma_async_tx_descriptor * -do_async_gen_syndrome (struct dma_chan *chan,struct page **blocks, -const unsigned char *scfs,unsigned int offset,int disks, -size_t len,dma_addr_t *dma_src, +do_async_gen_syndrome (struct dma_chan *chan, +const unsigned char *scfs,int disks, +struct dmaengine_unmap_data *unmap, +enum dma_ctrl_flags dma_flags,struct async_submit_ctl *submit) {struct dma_async_tx_descriptor *tx =NULL ;struct dma_device *dma = chan->device; -enum dma_ctrl_flags dma_flags =0 ;enum async_tx_flags flags_orig = submit->flags;dma_async_tx_callback cb_fn_orig = submit->cb_fn;dma_async_tx_callback cb_param_orig = submit->cb_param;int src_cnt = disks -2 ; -unsigned char coefs[src_cnt];unsigned short pq_src_cnt;dma_addr_t dma_dest[2 ];int src_off =0 ; -int idx; -int i; -/* DMAs use destinations as sources, so use BIDIRECTIONAL mapping */ -if (P (blocks, disks)) - dma_dest[0 ] =dma_map_page (dma->dev,P (blocks, disks), offset, - len,DMA_BIDIRECTIONAL ); -else - dma_flags |=DMA_PREP_PQ_DISABLE_P ; -if (Q (blocks, disks)) - dma_dest[1 ] =dma_map_page (dma->dev,Q (blocks, disks), offset, - len,DMA_BIDIRECTIONAL ); -else - dma_flags |=DMA_PREP_PQ_DISABLE_Q ; - -/* convert source addresses being careful to collapse 'empty' -* sources and update the coefficients accordingly -*/ -for (i =0 , idx =0 ; i < src_cnt; i++) { -if (blocks[i] ==NULL ) -continue ; - dma_src[idx] =dma_map_page (dma->dev, blocks[i], offset, len, -DMA_TO_DEVICE ); - coefs[idx] = scfs[i]; - idx++; - } - src_cnt = idx; + dma_flags |=DMA_COMPL_SKIP_SRC_UNMAP |DMA_COMPL_SKIP_DEST_UNMAP ; +if (submit->flags &ASYNC_TX_FENCE ) + dma_flags |=DMA_PREP_FENCE ;while (src_cnt >0 ) { submit->flags = flags_orig;
@@ -100,28 +76,25 @@ do_async_gen_syndrome(struct dma_chan *chan, struct page **blocks,if (src_cnt > pq_src_cnt) { submit->flags &= ~ASYNC_TX_ACK ; submit->flags |=ASYNC_TX_FENCE ; - dma_flags |=DMA_COMPL_SKIP_DEST_UNMAP ; submit->cb_fn =NULL ; submit->cb_param =NULL ; }else { - dma_flags &= ~DMA_COMPL_SKIP_DEST_UNMAP ; submit->cb_fn = cb_fn_orig; submit->cb_param = cb_param_orig;if (cb_fn_orig) dma_flags |=DMA_PREP_INTERRUPT ; } -if (submit->flags &ASYNC_TX_FENCE ) - dma_flags |=DMA_PREP_FENCE ; -/* Since we have clobbered the src_list we are committed -* to doing this asynchronously. Drivers force forward -* progress in case they can not provide a descriptor +/* Drivers force forward progress in case they can not provide +* a descriptor */ for (;;) { + dma_dest[0 ] = unmap->addr[disks -2 ]; + dma_dest[1 ] = unmap->addr[disks -1 ]; tx = dma->device_prep_dma_pq (chan, dma_dest, - &dma_src[src_off], + &unmap->addr[src_off], pq_src_cnt, - &coefs[src_off], len, + &scfs[src_off], unmap->len, dma_flags);if (likely (tx))break ;
@@ -129,6 +102,7 @@ do_async_gen_syndrome(struct dma_chan *chan, struct page **blocks,dma_async_issue_pending (chan); } +dma_set_unmap (tx, unmap);async_tx_submit (chan, tx, submit); submit->depend_tx = tx;
@@ -188,10 +162,6 @@ do_sync_gen_syndrome(struct page **blocks, unsigned int offset, int disks,* set to NULL those buffers will be replaced with the raid6_zero_page * in the synchronous path and omitted in the hardware-asynchronous * path. -* -* 'blocks' note: if submit->scribble is NULL then the contents of -* 'blocks' may be overwritten to perform address conversions -* (dma_map_page() or page_address()). */ struct dma_async_tx_descriptor * async_gen_syndrome(struct page **blocks, unsigned int offset, int disks,
@@ -202,26 +172,69 @@ async_gen_syndrome(struct page **blocks, unsigned int offset, int disks, &P (blocks, disks),2 , blocks, src_cnt, len);struct dma_device *device = chan ? chan->device :NULL ; -dma_addr_t *dma_src =NULL ; +struct dmaengine_unmap_data *unmap =NULL ;BUG_ON (disks >255 || !(P (blocks, disks) ||Q (blocks, disks))); -if (submit->scribble) - dma_src = submit->scribble; -else if (sizeof (dma_addr_t) <=sizeof (struct page *)) - dma_src = (dma_addr_t *) blocks; +if (device) + unmap =dmaengine_get_unmap_data (device->dev, disks,GFP_NOIO ); -if (dma_src && device && +if (unmap && (src_cnt <=dma_maxpq (device,0 ) ||dma_maxpq (device,DMA_PREP_CONTINUE ) >0 ) &&is_dma_pq_aligned (device, offset,0 , len)) { +struct dma_async_tx_descriptor *tx; +enum dma_ctrl_flags dma_flags =0 ; +unsigned char coefs[src_cnt]; +int i, j; +/* run the p+q asynchronously */ pr_debug ("%s: (async) disks: %d len: %zu\n" , __func__, disks, len); -return do_async_gen_syndrome (chan, blocks, raid6_gfexp, offset, - disks, len, dma_src, submit); + +/* convert source addresses being careful to collapse 'empty' +* sources and update the coefficients accordingly +*/ + unmap->len = len; +for (i =0 , j =0 ; i < src_cnt; i++) { +if (blocks[i] ==NULL ) +continue ; + unmap->addr[j] =dma_map_page (device->dev, blocks[i], offset, + len,DMA_TO_DEVICE ); + coefs[j] = raid6_gfexp[i]; + unmap->to_cnt++; + j++; + } + +/* +* DMAs use destinations as sources, +* so use BIDIRECTIONAL mapping +*/ + unmap->bidi_cnt++; +if (P (blocks, disks)) + unmap->addr[j++] =dma_map_page (device->dev,P (blocks, disks), + offset, len,DMA_BIDIRECTIONAL ); +else { + unmap->addr[j++] =0 ; + dma_flags |=DMA_PREP_PQ_DISABLE_P ; + } + + unmap->bidi_cnt++; +if (Q (blocks, disks)) + unmap->addr[j++] =dma_map_page (device->dev,Q (blocks, disks), + offset, len,DMA_BIDIRECTIONAL ); +else { + unmap->addr[j++] =0 ; + dma_flags |=DMA_PREP_PQ_DISABLE_Q ; + } + + tx =do_async_gen_syndrome (chan, coefs, j, unmap, dma_flags, submit); +dmaengine_unmap_put (unmap); +return tx; } +dmaengine_unmap_put (unmap); +/* run the pq synchronously */ pr_debug ("%s: (sync) disks: %d len: %zu\n" , __func__, disks, len);
drivers/dma/dmaengine.c +4 -1
@@ -953,9 +953,12 @@ static void dmaengine_unmap(struct kref *kref)dma_unmap_page (dev, unmap->addr[i], unmap->len,DMA_FROM_DEVICE ); cnt += unmap->bidi_cnt; -for (; i < cnt; i++) +for (; i < cnt; i++) { +if (unmap->addr[i] ==0 ) +continue ;dma_unmap_page (dev, unmap->addr[i], unmap->len,DMA_BIDIRECTIONAL ); + }mempool_free (unmap,__get_unmap_pool (cnt)->pool); }
PATCH v2 10/13 async_pq_val: convert to dmaengine_unmap_data
In reply to Bartlomiej ZolnierkiewiczFrom: Dan Williams <[email protected]>
Use the generic unmap object to unmap dma buffers.
--- crypto/async_tx/async_pq.c | 58 ++++++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 23 deletions(-)
crypto/async_tx/async_pq.c +35 -23
@@ -290,50 +290,60 @@ async_syndrome_val(struct page **blocks, unsigned int offset, int disks,struct dma_async_tx_descriptor *tx;unsigned char coefs[disks-2 ];enum dma_ctrl_flags dma_flags = submit->cb_fn ?DMA_PREP_INTERRUPT :0 ; -dma_addr_t *dma_src =NULL ; -int src_cnt =0 ; +struct dmaengine_unmap_data *unmap =NULL ;BUG_ON (disks <4 ); -if (submit->scribble) - dma_src = submit->scribble; -else if (sizeof (dma_addr_t) <=sizeof (struct page *)) - dma_src = (dma_addr_t *) blocks; +if (device) + unmap =dmaengine_get_unmap_data (device->dev, disks,GFP_NOIO ); -if (dma_src && device && disks <=dma_maxpq (device,0 ) && +if (unmap && disks <=dma_maxpq (device,0 ) &&is_dma_pq_aligned (device, offset,0 , len)) {struct device *dev = device->dev; -dma_addr_t *pq = &dma_src[disks-2 ]; -int i; +dma_addr_t pq[2 ]; +int i, j =0 , src_cnt =0 ;pr_debug ("%s: (async) disks: %d len: %zu\n" , __func__, disks, len); -if (!P (blocks, disks)) + + unmap->len = len; +for (i =0 ; i < disks-2 ; i++) +if (likely (blocks[i])) { + unmap->addr[j] =dma_map_page (dev, blocks[i], + offset, len, +DMA_TO_DEVICE ); + coefs[j] = raid6_gfexp[i]; + unmap->to_cnt++; + src_cnt++; + j++; + } + +if (!P (blocks, disks)) { + pq[0 ] =0 ; dma_flags |=DMA_PREP_PQ_DISABLE_P ; -else + }else { pq[0 ] =dma_map_page (dev,P (blocks, disks), offset, len,DMA_TO_DEVICE ); -if (!Q (blocks, disks)) + unmap->addr[j++] = pq[0 ]; + unmap->to_cnt++; + } +if (!Q (blocks, disks)) { + pq[1 ] =0 ; dma_flags |=DMA_PREP_PQ_DISABLE_Q ; -else + }else { pq[1 ] =dma_map_page (dev,Q (blocks, disks), offset, len,DMA_TO_DEVICE ); + unmap->addr[j++] = pq[1 ]; + unmap->to_cnt++; + }if (submit->flags &ASYNC_TX_FENCE ) dma_flags |=DMA_PREP_FENCE ; -for (i =0 ; i < disks-2 ; i++) -if (likely (blocks[i])) { - dma_src[src_cnt] =dma_map_page (dev, blocks[i], - offset, len, -DMA_TO_DEVICE ); - coefs[src_cnt] = raid6_gfexp[i]; - src_cnt++; - } -for (;;) { - tx = device->device_prep_dma_pq_val(chan, pq, dma_src, + tx = device->device_prep_dma_pq_val(chan, pq, + unmap->addr, src_cnt, coefs, len, pqres,
@@ -343,6 +353,8 @@ async_syndrome_val(struct page **blocks, unsigned int offset, int disks,async_tx_quiesce (&submit->depend_tx);dma_async_issue_pending (chan); } + +dma_set_unmap (tx, unmap);async_tx_submit (chan, tx, submit);return tx;
Signature · 1 line
1.8.2.3
PATCH v2 10/13 async_pq_val: convert to dmaengine_unmap_data
Use the generic unmap object to unmap dma buffers.
---
Resend to:
1/ add it to the new dmaengine patchwork
2/ cc maintainers of affected drivers
3/ fixup some mail addresses
crypto/async_tx/async_pq.c | 58 +++++++++++++++++++++++++++----------------- 1 files changed, 35 insertions(+), 23 deletions(-)
crypto/async_tx/async_pq.c +35 -23
@@ -290,50 +290,60 @@ async_syndrome_val(struct page **blocks, unsigned int offset, int disks,struct dma_async_tx_descriptor *tx;unsigned char coefs[disks-2 ];enum dma_ctrl_flags dma_flags = submit->cb_fn ?DMA_PREP_INTERRUPT :0 ; -dma_addr_t *dma_src =NULL ; -int src_cnt =0 ; +struct dmaengine_unmap_data *unmap =NULL ;BUG_ON (disks <4 ); -if (submit->scribble) - dma_src = submit->scribble; -else if (sizeof (dma_addr_t) <=sizeof (struct page *)) - dma_src = (dma_addr_t *) blocks; +if (device) + unmap =dmaengine_get_unmap_data (device->dev, disks,GFP_NOIO ); -if (dma_src && device && disks <=dma_maxpq (device,0 ) && +if (unmap && disks <=dma_maxpq (device,0 ) &&is_dma_pq_aligned (device, offset,0 , len)) {struct device *dev = device->dev; -dma_addr_t *pq = &dma_src[disks-2 ]; -int i; +dma_addr_t pq[2 ]; +int i, j =0 , src_cnt =0 ;pr_debug ("%s: (async) disks: %d len: %zu\n" , __func__, disks, len); -if (!P (blocks, disks)) + + unmap->len = len; +for (i =0 ; i < disks-2 ; i++) +if (likely (blocks[i])) { + unmap->addr[j] =dma_map_page (dev, blocks[i], + offset, len, +DMA_TO_DEVICE ); + coefs[j] = raid6_gfexp[i]; + unmap->to_cnt++; + src_cnt++; + j++; + } + +if (!P (blocks, disks)) { + pq[0 ] =0 ; dma_flags |=DMA_PREP_PQ_DISABLE_P ; -else + }else { pq[0 ] =dma_map_page (dev,P (blocks, disks), offset, len,DMA_TO_DEVICE ); -if (!Q (blocks, disks)) + unmap->addr[j++] = pq[0 ]; + unmap->to_cnt++; + } +if (!Q (blocks, disks)) { + pq[1 ] =0 ; dma_flags |=DMA_PREP_PQ_DISABLE_Q ; -else + }else { pq[1 ] =dma_map_page (dev,Q (blocks, disks), offset, len,DMA_TO_DEVICE ); + unmap->addr[j++] = pq[1 ]; + unmap->to_cnt++; + }if (submit->flags &ASYNC_TX_FENCE ) dma_flags |=DMA_PREP_FENCE ; -for (i =0 ; i < disks-2 ; i++) -if (likely (blocks[i])) { - dma_src[src_cnt] =dma_map_page (dev, blocks[i], - offset, len, -DMA_TO_DEVICE ); - coefs[src_cnt] = raid6_gfexp[i]; - src_cnt++; - } -for (;;) { - tx = device->device_prep_dma_pq_val(chan, pq, dma_src, + tx = device->device_prep_dma_pq_val(chan, pq, + unmap->addr, src_cnt, coefs, len, pqres,
@@ -343,6 +353,8 @@ async_syndrome_val(struct page **blocks, unsigned int offset, int disks,async_tx_quiesce (&submit->depend_tx);dma_async_issue_pending (chan); } + +dma_set_unmap (tx, unmap);async_tx_submit (chan, tx, submit);return tx;
PATCH v2 11/13 NTB: convert to dmaengine_unmap_data
In reply to Bartlomiej ZolnierkiewiczUse the generic unmap object to unmap dma buffers.
As NTB can be compiled without DMA_ENGINE support add stub functions to <linux/dmaengine.h> for dma_set_unmap(), dmaengine_get_unmap_data() and dmaengine_unmap_put().
--- drivers/ntb/ntb_transport.c | 63 +++++++++++++++++++++++++++++++++------------ include/linux/dmaengine.h | 15 +++++++++++ 2 files changed, 61 insertions(+), 17 deletions(-)
drivers/ntb/ntb_transport.c +46 -17
@@ -1034,7 +1034,7 @@ static void ntb_async_rx(struct ntb_queue_entry *entry, void *offset,struct dma_chan *chan = qp->dma_chan;struct dma_device *device;size_t pay_off, buff_off; -dma_addr_t src, dest; +struct dmaengine_unmap_data *unmap;dma_cookie_t cookie;void *buf = entry->buf;unsigned long flags;
@@ -1054,27 +1054,41 @@ static void ntb_async_rx(struct ntb_queue_entry *entry, void *offset,if (!is_dma_copy_aligned (device, pay_off, buff_off, len)) goto err1; - dest =dma_map_single (device->dev, buf, len,DMA_FROM_DEVICE ); -if (dma_mapping_error (device->dev, dest)) + unmap =dmaengine_get_unmap_data (device->dev,2 ,GFP_NOIO ); +if (!unmap) goto err1; - src =dma_map_single (device->dev, offset, len,DMA_TO_DEVICE ); -if (dma_mapping_error (device->dev, src)) + unmap->addr[0 ] =dma_map_page (device->dev,virt_to_page (offset), + pay_off, len,DMA_TO_DEVICE ); +if (dma_mapping_error (device->dev, unmap->addr[0 ])) goto err2; - flags =DMA_COMPL_DEST_UNMAP_SINGLE |DMA_COMPL_SRC_UNMAP_SINGLE | + unmap->to_cnt =1 ; + + unmap->addr[1 ] =dma_map_page (device->dev,virt_to_page (buf), + buff_off, len,DMA_FROM_DEVICE ); +if (dma_mapping_error (device->dev, unmap->addr[1 ])) + goto err2; + + unmap->from_cnt =1 ; + + flags =DMA_COMPL_SKIP_SRC_UNMAP |DMA_COMPL_SKIP_DEST_UNMAP |DMA_PREP_INTERRUPT ; - txd = device->device_prep_dma_memcpy (chan, dest, src, len, flags); + txd = device->device_prep_dma_memcpy (chan, unmap->addr[1 ], + unmap->addr[0 ], len, flags);if (!txd) - goto err3; + goto err2; txd->callback = ntb_rx_copy_callback; txd->callback_param = entry; +dma_set_unmap (txd, unmap); cookie =dmaengine_submit (txd);if (dma_submit_error (cookie)) goto err3; +dmaengine_unmap_put (unmap); + qp->last_cookie = cookie; qp->rx_async++;
@@ -1082,9 +1096,9 @@ static void ntb_async_rx(struct ntb_queue_entry *entry, void *offset,return ; err3: -dma_unmap_single (device->dev, src, len,DMA_TO_DEVICE ); +dmaengine_unmap_put (unmap); err2: -dma_unmap_single (device->dev, dest, len,DMA_FROM_DEVICE ); +dmaengine_unmap_put (unmap); err1:/* If the callbacks come out of order, the writing of the index to the * last completed will be out of order. This may result in the
@@ -1245,7 +1259,8 @@ static void ntb_async_tx(struct ntb_transport_qp *qp,struct dma_chan *chan = qp->dma_chan;struct dma_device *device;size_t dest_off, buff_off; -dma_addr_t src, dest; +struct dmaengine_unmap_data *unmap; +dma_addr_t dest;dma_cookie_t cookie;void __iomem *offset;size_t len = entry->len;
@@ -1273,28 +1288,42 @@ static void ntb_async_tx(struct ntb_transport_qp *qp,if (!is_dma_copy_aligned (device, buff_off, dest_off, len)) goto err; - src =dma_map_single (device->dev, buf, len,DMA_TO_DEVICE ); -if (dma_mapping_error (device->dev, src)) + unmap =dmaengine_get_unmap_data (device->dev,1 ,GFP_NOIO ); +if (!unmap) goto err; - flags =DMA_COMPL_SRC_UNMAP_SINGLE |DMA_PREP_INTERRUPT ; - txd = device->device_prep_dma_memcpy (chan, dest, src, len, flags); + unmap->addr[0 ] =dma_map_page (device->dev,virt_to_page (buf), + buff_off, len,DMA_TO_DEVICE ); +if (dma_mapping_error (device->dev, unmap->addr[0 ])) + goto err1; + + unmap->to_cnt =1 ; + + flags =DMA_COMPL_SKIP_SRC_UNMAP |DMA_COMPL_SKIP_DEST_UNMAP | +DMA_PREP_INTERRUPT ; + txd = device->device_prep_dma_memcpy (chan, dest, unmap->addr[0 ], len, + flags);if (!txd) goto err1; txd->callback = ntb_tx_copy_callback; txd->callback_param = entry; +dma_set_unmap (txd, unmap); cookie =dmaengine_submit (txd);if (dma_submit_error (cookie)) - goto err1; + goto err2; + +dmaengine_unmap_put (unmap);dma_async_issue_pending (chan); qp->tx_async++;return ; +err2: +dmaengine_unmap_put (unmap); err1: -dma_unmap_single (device->dev, src, len,DMA_TO_DEVICE ); +dmaengine_unmap_put (unmap); err:ntb_memcpy_tx (entry, offset); qp->tx_memcpy++;
include/linux/dmaengine.h +15 -0
@@ -457,6 +457,7 @@ struct dma_async_tx_descriptor {#endif }; +#ifdef CONFIG_DMA_ENGINE static inline void dma_set_unmap (struct dma_async_tx_descriptor *tx,struct dmaengine_unmap_data *unmap) {
@@ -467,6 +468,20 @@ static inline void dma_set_unmap(struct dma_async_tx_descriptor *tx,struct dmaengine_unmap_data *dmaengine_get_unmap_data (struct device *dev,int nr,gfp_t flags);void dmaengine_unmap_put (struct dmaengine_unmap_data *unmap); +#else +static inline void dma_set_unmap (struct dma_async_tx_descriptor *tx, +struct dmaengine_unmap_data *unmap) +{ +} +static inline struct dmaengine_unmap_data * +dmaengine_get_unmap_data (struct device *dev,int nr,gfp_t flags) +{ +return NULL ; +} +static inline void dmaengine_unmap_put (struct dmaengine_unmap_data *unmap) +{ +} +#endif static inline void dma_descriptor_unmap (struct dma_async_tx_descriptor *tx) {
Signature · 1 line
1.8.2.3
Re: [PATCH v2 11/13] NTB: convert to dmaengine_unmap_data
Quoted 3 lines · Bartlomiej Zolnierkiewicz
Use the generic unmap object to unmap dma buffers.
As NTB can be compiled without
DMA_ENGINEsupport add
Seems like the stubs should be added outside of this patch. Also, the comment implies that NTB could not be compiled without DMA_ENGINE support before, which it could be.
Quoted 50 lines
stub functions to <
linux/dmaengine.h> fordma_set_unmap(),dmaengine_get_unmap_data()anddmaengine_unmap_put().Cc Dan Williams <[email protected]>Cc Vinod Koul <[email protected]>Cc Tomasz Figa <[email protected]>Cc Dave Jiang <[email protected]>Cc Jon Mason <[email protected]>Signed-off-by Bartlomiej Zolnierkiewicz <[email protected]>Signed-off-by Kyungmin Park <[email protected]>--- drivers/ntb/ntb_transport.c | 63 +++++++++++++++++++++++++++++++++------------ include/linux/dmaengine.h | 15 +++++++++++ 2 files changed, 61 insertions(+), 17 deletions(-)drivers/ntb/ntb_transport.c +10
-6@@ -1034,7 +1034,7 @@ static void ntb_async_rx(struct ntb_queue_entry *entry, void *offset,struct dma_chan *chan = qp->dma_chan;struct dma_device *device;size_t pay_off, buff_off; -dma_addr_t src, dest; +struct dmaengine_unmap_data *unmap;dma_cookie_t cookie;void *buf = entry->buf;unsigned long flags;@@ -1054,27 +1054,41 @@ static void ntb_async_rx(struct ntb_queue_entry *entry, void *offset,if (!is_dma_copy_aligned (device, pay_off, buff_off, len)) goto err1; - dest =dma_map_single (device->dev, buf, len,DMA_FROM_DEVICE ); -if (dma_mapping_error (device->dev, dest)) + unmap =dmaengine_get_unmap_data (device->dev,2 ,GFP_NOIO ); +if (!unmap) goto err1; - src =dma_map_single (device->dev, offset, len,DMA_TO_DEVICE ); -if (dma_mapping_error (device->dev, src)) + unmap->addr[0 ] =dma_map_page (device->dev,virt_to_page (offset), + pay_off, len,DMA_TO_DEVICE ); +if (dma_mapping_error (device->dev, unmap->addr[0 ])) goto err2; - flags = DMA_COMPL_DEST_UNMAP_SINGLE | DMA_COMPL_SRC_UNMAP_SINGLE | + unmap->to_cnt =1 ; + + unmap->addr[1 ] =dma_map_page (device->dev,virt_to_page (buf), + buff_off, len,DMA_FROM_DEVICE );
drivers/ntb/ntb_transport.c static void ntb_async_rx(struct ntb_queue_entry *entry, void *offset, · line 1078
Quoted 10 lines
drivers/ntb/ntb_transport.c +8
-1+if (dma_mapping_error (device->dev, unmap->addr[1 ])) + goto err2; + + unmap->from_cnt =1 ; + + flags =DMA_COMPL_SKIP_SRC_UNMAP |DMA_COMPL_SKIP_DEST_UNMAP |DMA_PREP_INTERRUPT ; - txd = device->device_prep_dma_memcpy (chan, dest, src, len, flags); + txd = device->device_prep_dma_memcpy (chan, unmap->addr[1 ], + unmap->addr[0 ], len, flags);
I must say, as a user I dislike this interface much less than the previous. Can we abstract all of this away in a helper function that simply takes the src, dest, and len, then maps and calls device_prep_dma_memcpy? The driver does not keep track of the dmaengine_unmap_data, so the helper function could simply return an error if something isn't happy. Thoughts?
Thanks,
Jon
Quoted 124 lines
drivers/ntb/ntb_transport.c +28
-10if (!txd) - goto err3; + goto err2; txd->callback = ntb_rx_copy_callback; txd->callback_param = entry; +dma_set_unmap (txd, unmap); cookie =dmaengine_submit (txd);if (dma_submit_error (cookie)) goto err3; +dmaengine_unmap_put (unmap); + qp->last_cookie = cookie; qp->rx_async++;@@ -1082,9 +1096,9 @@ static void ntb_async_rx(struct ntb_queue_entry *entry, void *offset,return ; err3: -dma_unmap_single (device->dev, src, len,DMA_TO_DEVICE ); +dmaengine_unmap_put (unmap); err2: -dma_unmap_single (device->dev, dest, len,DMA_FROM_DEVICE ); +dmaengine_unmap_put (unmap); err1:/* If the callbacks come out of order, the writing of the index to the * last completed will be out of order. This may result in the @@ -1245,7 +1259,8 @@ static void ntb_async_tx(struct ntb_transport_qp *qp,struct dma_chan *chan = qp->dma_chan;struct dma_device *device;size_t dest_off, buff_off; -dma_addr_t src, dest; +struct dmaengine_unmap_data *unmap; +dma_addr_t dest;dma_cookie_t cookie;void __iomem *offset;size_t len = entry->len;@@ -1273,28 +1288,42 @@ static void ntb_async_tx(struct ntb_transport_qp *qp,if (!is_dma_copy_aligned (device, buff_off, dest_off, len)) goto err; - src =dma_map_single (device->dev, buf, len,DMA_TO_DEVICE ); -if (dma_mapping_error (device->dev, src)) + unmap =dmaengine_get_unmap_data (device->dev,1 ,GFP_NOIO ); +if (!unmap) goto err; - flags =DMA_COMPL_SRC_UNMAP_SINGLE |DMA_PREP_INTERRUPT ; - txd = device->device_prep_dma_memcpy (chan, dest, src, len, flags); + unmap->addr[0 ] =dma_map_page (device->dev,virt_to_page (buf), + buff_off, len,DMA_TO_DEVICE ); +if (dma_mapping_error (device->dev, unmap->addr[0 ])) + goto err1; + + unmap->to_cnt =1 ; + + flags =DMA_COMPL_SKIP_SRC_UNMAP |DMA_COMPL_SKIP_DEST_UNMAP | +DMA_PREP_INTERRUPT ; + txd = device->device_prep_dma_memcpy (chan, dest, unmap->addr[0 ], len, + flags);if (!txd) goto err1; txd->callback = ntb_tx_copy_callback; txd->callback_param = entry; +dma_set_unmap (txd, unmap); cookie =dmaengine_submit (txd);if (dma_submit_error (cookie)) - goto err1; + goto err2; + +dmaengine_unmap_put (unmap);dma_async_issue_pending (chan); qp->tx_async++;return ; +err2: +dmaengine_unmap_put (unmap); err1: -dma_unmap_single (device->dev, src, len,DMA_TO_DEVICE ); +dmaengine_unmap_put (unmap); err:ntb_memcpy_tx (entry, offset); qp->tx_memcpy++;include/linux/dmaengine.h +15
-0@@ -457,6 +457,7 @@ struct dma_async_tx_descriptor {#endif }; +#ifdef CONFIG_DMA_ENGINE static inline void dma_set_unmap (struct dma_async_tx_descriptor *tx,struct dmaengine_unmap_data *unmap) {@@ -467,6 +468,20 @@ static inline void dma_set_unmap(struct dma_async_tx_descriptor *tx,struct dmaengine_unmap_data *dmaengine_get_unmap_data (struct device *dev,int nr,gfp_t flags);void dmaengine_unmap_put (struct dmaengine_unmap_data *unmap); +#else +static inline void dma_set_unmap (struct dma_async_tx_descriptor *tx, +struct dmaengine_unmap_data *unmap) +{ +} +static inline struct dmaengine_unmap_data * +dmaengine_get_unmap_data (struct device *dev,int nr,gfp_t flags) +{ +return NULL ; +} +static inline void dmaengine_unmap_put (struct dmaengine_unmap_data *unmap) +{ +} +#endif static inline void dma_descriptor_unmap (struct dma_async_tx_descriptor *tx) {Signature · 1 line
1.8.2.3
PATCH v2 11/13 NTB: convert to dmaengine_unmap_data
In reply to Bartlomiej ZolnierkiewiczFrom: Bartlomiej Zolnierkiewicz <[email protected]>
Use the generic unmap object to unmap dma buffers.
As NTB can be compiled without DMA_ENGINE support add stub functions to <linux/dmaengine.h> for dma_set_unmap(), dmaengine_get_unmap_data() and dmaengine_unmap_put().
---
Resend to:
1/ add it to the new dmaengine patchwork
2/ cc maintainers of affected drivers
3/ fixup some mail addresses
drivers/ntb/ntb_transport.c | 63 +++++++++++++++++++++++++++++++------------ include/linux/dmaengine.h | 15 ++++++++++ 2 files changed, 61 insertions(+), 17 deletions(-)
drivers/ntb/ntb_transport.c +46 -17
@@ -1034,7 +1034,7 @@ static void ntb_async_rx(struct ntb_queue_entry *entry, void *offset,struct dma_chan *chan = qp->dma_chan;struct dma_device *device;size_t pay_off, buff_off; -dma_addr_t src, dest; +struct dmaengine_unmap_data *unmap;dma_cookie_t cookie;void *buf = entry->buf;unsigned long flags;
@@ -1054,27 +1054,41 @@ static void ntb_async_rx(struct ntb_queue_entry *entry, void *offset,if (!is_dma_copy_aligned (device, pay_off, buff_off, len)) goto err1; - dest =dma_map_single (device->dev, buf, len,DMA_FROM_DEVICE ); -if (dma_mapping_error (device->dev, dest)) + unmap =dmaengine_get_unmap_data (device->dev,2 ,GFP_NOIO ); +if (!unmap) goto err1; - src =dma_map_single (device->dev, offset, len,DMA_TO_DEVICE ); -if (dma_mapping_error (device->dev, src)) + unmap->addr[0 ] =dma_map_page (device->dev,virt_to_page (offset), + pay_off, len,DMA_TO_DEVICE ); +if (dma_mapping_error (device->dev, unmap->addr[0 ])) goto err2; - flags =DMA_COMPL_DEST_UNMAP_SINGLE |DMA_COMPL_SRC_UNMAP_SINGLE | + unmap->to_cnt =1 ; + + unmap->addr[1 ] =dma_map_page (device->dev,virt_to_page (buf), + buff_off, len,DMA_FROM_DEVICE ); +if (dma_mapping_error (device->dev, unmap->addr[1 ])) + goto err2; + + unmap->from_cnt =1 ; + + flags =DMA_COMPL_SKIP_SRC_UNMAP |DMA_COMPL_SKIP_DEST_UNMAP |DMA_PREP_INTERRUPT ; - txd = device->device_prep_dma_memcpy (chan, dest, src, len, flags); + txd = device->device_prep_dma_memcpy (chan, unmap->addr[1 ], + unmap->addr[0 ], len, flags);if (!txd) - goto err3; + goto err2; txd->callback = ntb_rx_copy_callback; txd->callback_param = entry; +dma_set_unmap (txd, unmap); cookie =dmaengine_submit (txd);if (dma_submit_error (cookie)) goto err3; +dmaengine_unmap_put (unmap); + qp->last_cookie = cookie; qp->rx_async++;
@@ -1082,9 +1096,9 @@ static void ntb_async_rx(struct ntb_queue_entry *entry, void *offset,return ; err3: -dma_unmap_single (device->dev, src, len,DMA_TO_DEVICE ); +dmaengine_unmap_put (unmap); err2: -dma_unmap_single (device->dev, dest, len,DMA_FROM_DEVICE ); +dmaengine_unmap_put (unmap); err1:/* If the callbacks come out of order, the writing of the index to the * last completed will be out of order. This may result in the
@@ -1245,7 +1259,8 @@ static void ntb_async_tx(struct ntb_transport_qp *qp,struct dma_chan *chan = qp->dma_chan;struct dma_device *device;size_t dest_off, buff_off; -dma_addr_t src, dest; +struct dmaengine_unmap_data *unmap; +dma_addr_t dest;dma_cookie_t cookie;void __iomem *offset;size_t len = entry->len;
@@ -1273,28 +1288,42 @@ static void ntb_async_tx(struct ntb_transport_qp *qp,if (!is_dma_copy_aligned (device, buff_off, dest_off, len)) goto err; - src =dma_map_single (device->dev, buf, len,DMA_TO_DEVICE ); -if (dma_mapping_error (device->dev, src)) + unmap =dmaengine_get_unmap_data (device->dev,1 ,GFP_NOIO ); +if (!unmap) goto err; - flags =DMA_COMPL_SRC_UNMAP_SINGLE |DMA_PREP_INTERRUPT ; - txd = device->device_prep_dma_memcpy (chan, dest, src, len, flags); + unmap->addr[0 ] =dma_map_page (device->dev,virt_to_page (buf), + buff_off, len,DMA_TO_DEVICE ); +if (dma_mapping_error (device->dev, unmap->addr[0 ])) + goto err1; + + unmap->to_cnt =1 ; + + flags =DMA_COMPL_SKIP_SRC_UNMAP |DMA_COMPL_SKIP_DEST_UNMAP | +DMA_PREP_INTERRUPT ; + txd = device->device_prep_dma_memcpy (chan, dest, unmap->addr[0 ], len, + flags);if (!txd) goto err1; txd->callback = ntb_tx_copy_callback; txd->callback_param = entry; +dma_set_unmap (txd, unmap); cookie =dmaengine_submit (txd);if (dma_submit_error (cookie)) - goto err1; + goto err2; + +dmaengine_unmap_put (unmap);dma_async_issue_pending (chan); qp->tx_async++;return ; +err2: +dmaengine_unmap_put (unmap); err1: -dma_unmap_single (device->dev, src, len,DMA_TO_DEVICE ); +dmaengine_unmap_put (unmap); err:ntb_memcpy_tx (entry, offset); qp->tx_memcpy++;
include/linux/dmaengine.h +15 -0
@@ -457,6 +457,7 @@ struct dma_async_tx_descriptor {#endif }; +#ifdef CONFIG_DMA_ENGINE static inline void dma_set_unmap (struct dma_async_tx_descriptor *tx,struct dmaengine_unmap_data *unmap) {
@@ -467,6 +468,20 @@ static inline void dma_set_unmap(struct dma_async_tx_descriptor *tx,struct dmaengine_unmap_data *dmaengine_get_unmap_data (struct device *dev,int nr,gfp_t flags);void dmaengine_unmap_put (struct dmaengine_unmap_data *unmap); +#else +static inline void dma_set_unmap (struct dma_async_tx_descriptor *tx, +struct dmaengine_unmap_data *unmap) +{ +} +static inline struct dmaengine_unmap_data * +dmaengine_get_unmap_data (struct device *dev,int nr,gfp_t flags) +{ +return NULL ; +} +static inline void dmaengine_unmap_put (struct dmaengine_unmap_data *unmap) +{ +} +#endif static inline void dma_descriptor_unmap (struct dma_async_tx_descriptor *tx) {
Re: [PATCH v2 11/13] NTB: convert to dmaengine_unmap_data
Quoted 6 lines · Jon Mason
Quoted 3 lines · Bartlomiej Zolnierkiewicz
Use the generic unmap object to unmap dma buffers.
As NTB can be compiled without
DMA_ENGINEsupport addSeems like the stubs should be added outside of this patch.
I think they are ok here as this is the only driver that uses them. The alternative is a new api patch without a user.
Quoted 3 lines
Also, the
comment implies that NTB could not be compiled withoutDMA_ENGINEsupport before, which it could be.
Hmm, I read it as "since NTB *can* be compiled without dmaengine here are some stubs".
Quoted 60 lines
Quoted 60 lines
stub functions to <
linux/dmaengine.h> fordma_set_unmap(),dmaengine_get_unmap_data()anddmaengine_unmap_put().Cc Dan Williams <[email protected]>Cc Vinod Koul <[email protected]>Cc Tomasz Figa <[email protected]>Cc Dave Jiang <[email protected]>Cc Jon Mason <[email protected]>Signed-off-by Bartlomiej Zolnierkiewicz <[email protected]>Signed-off-by Kyungmin Park <[email protected]>--- drivers/ntb/ntb_transport.c | 63 +++++++++++++++++++++++++++++++++------------ include/linux/dmaengine.h | 15 +++++++++++ 2 files changed, 61 insertions(+), 17 deletions(-)drivers/ntb/ntb_transport.c +17
-7@@ -1034,7 +1034,7 @@ static void ntb_async_rx(struct ntb_queue_entry *entry, void *offset,struct dma_chan *chan = qp->dma_chan;struct dma_device *device;size_t pay_off, buff_off; -dma_addr_t src, dest; +struct dmaengine_unmap_data *unmap;dma_cookie_t cookie;void *buf = entry->buf;unsigned long flags;@@ -1054,27 +1054,41 @@ static void ntb_async_rx(struct ntb_queue_entry *entry, void *offset,if (!is_dma_copy_aligned (device, pay_off, buff_off, len)) goto err1; - dest =dma_map_single (device->dev, buf, len,DMA_FROM_DEVICE ); -if (dma_mapping_error (device->dev, dest)) + unmap =dmaengine_get_unmap_data (device->dev,2 ,GFP_NOIO ); +if (!unmap) goto err1; - src =dma_map_single (device->dev, offset, len,DMA_TO_DEVICE ); -if (dma_mapping_error (device->dev, src)) + unmap->addr[0 ] =dma_map_page (device->dev,virt_to_page (offset), + pay_off, len,DMA_TO_DEVICE ); +if (dma_mapping_error (device->dev, unmap->addr[0 ])) goto err2; - flags =DMA_COMPL_DEST_UNMAP_SINGLE |DMA_COMPL_SRC_UNMAP_SINGLE | + unmap->to_cnt =1 ; + + unmap->addr[1 ] =dma_map_page (device->dev,virt_to_page (buf), + buff_off, len,DMA_FROM_DEVICE ); +if (dma_mapping_error (device->dev, unmap->addr[1 ])) + goto err2; + + unmap->from_cnt =1 ; + + flags =DMA_COMPL_SKIP_SRC_UNMAP |DMA_COMPL_SKIP_DEST_UNMAP |DMA_PREP_INTERRUPT ; - txd = device->device_prep_dma_memcpy (chan, dest, src, len, flags); + txd = device->device_prep_dma_memcpy(chan, unmap->addr[1],
Quoted 8 lines
drivers/ntb/ntb_transport.c static void ntb_async_rx(struct ntb_queue_entry *entry, void *offset, · line 1078
Quoted 1 line
drivers/ntb/ntb_transport.c +1
-0+ unmap->addr[0], len, flags);I must say, as a user I dislike this interface much less than the previous. Can we abstract all of this away in a helper function that simply takes the src, dest, and len, then maps and calls
device_prep_dma_memcpy? The driver does not keep track of thedmaengine_unmap_data, so the helper function could simply return an error if something isn't happy. Thoughts?
Well, that's almost dma_async_memcpy_pg_to_pg, except NTB wants it's own callback. We could add a new helper that does dma_async_memcpy_pg_to_pg() with callback, but I want to do a larger reorganization of dmaengine to try to kill off the need to specify the callback after ->prep(). Can we go with as is for now and cleanup later? The same is happening to the other clients in this patchset (async_tx, dmatest, net_dma) in terms of picking up unmap responsibility from the drivers. It looks "worse" for each client at this stage, but the overall effect is:
34 files changed, 538 insertions(+), 1157 deletions(-)
--
Dan
Re: [PATCH v2 11/13] NTB: convert to dmaengine_unmap_data
Quoted 11 lines · Dan Williams
Quoted 6 lines · Jon Mason
Quoted 3 lines · Bartlomiej Zolnierkiewicz
Use the generic unmap object to unmap dma buffers.
As NTB can be compiled without
DMA_ENGINEsupport addSeems like the stubs should be added outside of this patch.
I think they are ok here as this is the only driver that uses them. The alternative is a new api patch without a user.
Quoted 6 lines
Quoted 3 lines
Also, the
comment implies that NTB could not be compiled withoutDMA_ENGINEsupport before, which it could be.Hmm, I read it as "since NTB *can* be compiled without dmaengine here are some stubs".
This poses an overall question of whether it would simply be better to abstract all of the with/without DMA_ENGINE part and simply remap it to memcpy if DMA_ENGINE is not set (or if the DMA engine is hotplugged). Of course, this is outside the scope of this patch.
Quoted 79 lines
Quoted 60 lines
Quoted 60 lines
stub functions to <
linux/dmaengine.h> fordma_set_unmap(),dmaengine_get_unmap_data()anddmaengine_unmap_put().Cc Dan Williams <[email protected]>Cc Vinod Koul <[email protected]>Cc Tomasz Figa <[email protected]>Cc Dave Jiang <[email protected]>Cc Jon Mason <[email protected]>Signed-off-by Bartlomiej Zolnierkiewicz <[email protected]>Signed-off-by Kyungmin Park <[email protected]>--- drivers/ntb/ntb_transport.c | 63 +++++++++++++++++++++++++++++++++------------ include/linux/dmaengine.h | 15 +++++++++++ 2 files changed, 61 insertions(+), 17 deletions(-)drivers/ntb/ntb_transport.c +17
-7@@ -1034,7 +1034,7 @@ static void ntb_async_rx(struct ntb_queue_entry *entry, void *offset,struct dma_chan *chan = qp->dma_chan;struct dma_device *device;size_t pay_off, buff_off; -dma_addr_t src, dest; +struct dmaengine_unmap_data *unmap;dma_cookie_t cookie;void *buf = entry->buf;unsigned long flags;@@ -1054,27 +1054,41 @@ static void ntb_async_rx(struct ntb_queue_entry *entry, void *offset,if (!is_dma_copy_aligned (device, pay_off, buff_off, len)) goto err1; - dest =dma_map_single (device->dev, buf, len,DMA_FROM_DEVICE ); -if (dma_mapping_error (device->dev, dest)) + unmap =dmaengine_get_unmap_data (device->dev,2 ,GFP_NOIO ); +if (!unmap) goto err1; - src =dma_map_single (device->dev, offset, len,DMA_TO_DEVICE ); -if (dma_mapping_error (device->dev, src)) + unmap->addr[0 ] =dma_map_page (device->dev,virt_to_page (offset), + pay_off, len,DMA_TO_DEVICE ); +if (dma_mapping_error (device->dev, unmap->addr[0 ])) goto err2; - flags =DMA_COMPL_DEST_UNMAP_SINGLE |DMA_COMPL_SRC_UNMAP_SINGLE | + unmap->to_cnt =1 ; + + unmap->addr[1 ] =dma_map_page (device->dev,virt_to_page (buf), + buff_off, len,DMA_FROM_DEVICE ); +if (dma_mapping_error (device->dev, unmap->addr[1 ])) + goto err2; + + unmap->from_cnt =1 ; + + flags =DMA_COMPL_SKIP_SRC_UNMAP |DMA_COMPL_SKIP_DEST_UNMAP |DMA_PREP_INTERRUPT ; - txd = device->device_prep_dma_memcpy (chan, dest, src, len, flags); + txd = device->device_prep_dma_memcpy(chan, unmap->addr[1],Quoted 8 lines
drivers/ntb/ntb_transport.c static void ntb_async_rx(struct ntb_queue_entry *entry, void *offset, · line 1078
Quoted 1 line
drivers/ntb/ntb_transport.c +1
-0+ unmap->addr[0], len, flags);I must say, as a user I dislike this interface much less than the previous. Can we abstract all of this away in a helper function that simply takes the src, dest, and len, then maps and calls
device_prep_dma_memcpy? The driver does not keep track of thedmaengine_unmap_data, so the helper function could simply return an error if something isn't happy. Thoughts?Well, that's almost
dma_async_memcpy_pg_to_pg, except NTB wants it's own callback. We could add a new helper that doesdma_async_memcpy_pg_to_pg()with callback, but I want to do a larger reorganization of dmaengine to try to kill off the need to specify the callback after ->prep(). Can we go with as is for now and cleanup later? The same is happening to the other clients in this patchset (async_tx, dmatest,net_dma) in terms of picking up unmap responsibility from the drivers. It looks "worse" for each client at this stage, but the overall effect is:
Quoted 1 line
34 files changed, 538 insertions(+), 1157 deletions(-)
That is fine. It can be like this in the short term.
Thanks,
Jon
Quoted 3 lines
--
Dan
Dan Williams
Acked-by Jon MasonRe: [PATCH v2 11/13] NTB: convert to dmaengine_unmap_data
Quoted 16 lines · Jon Mason
Quoted 15 lines · Dan Williams
Quoted 6 lines · Jon Mason
Quoted 3 lines · Bartlomiej Zolnierkiewicz
Use the generic unmap object to unmap dma buffers.
As NTB can be compiled without
DMA_ENGINEsupport addSeems like the stubs should be added outside of this patch.
I think they are ok here as this is the only driver that uses them. The alternative is a new api patch without a user.
Quoted 3 lines
Also, the
comment implies that NTB could not be compiled withoutDMA_ENGINEsupport before, which it could be.
Quoted 7 lines
Quoted 2 lines
Hmm, I read it as "since NTB *can* be compiled without dmaengine here are some stubs".
This poses an overall question of whether it would simply be better to abstract all of the with/without
DMA_ENGINEpart and simply remap it to memcpy ifDMA_ENGINEis not set (or if the DMA engine is hotplugged). Of course, this is outside the scope of this patch.
That's at least the promise of async_memcpy() it does not care if a channel is there or not, but I think it is better if the client has a strict dma and non-dma path. Hiding the dma details from the client seems to have been the wrong choice at least for raid.
Quoted 4 lines
That is fine. It can be like this in the short term.
Thanks,
Jon
I'll take that as:
...but holler if not.
Re: [PATCH v2 11/13] NTB: convert to dmaengine_unmap_data
Quoted 30 lines · Dan Williams
Quoted 16 lines · Jon Mason
Quoted 15 lines · Dan Williams
Quoted 6 lines · Jon Mason
Quoted 3 lines · Bartlomiej Zolnierkiewicz
Use the generic unmap object to unmap dma buffers.
As NTB can be compiled without
DMA_ENGINEsupport addSeems like the stubs should be added outside of this patch.
I think they are ok here as this is the only driver that uses them. The alternative is a new api patch without a user.
Quoted 3 lines
Also, the
comment implies that NTB could not be compiled withoutDMA_ENGINEsupport before, which it could be.Quoted 7 lines
Quoted 2 lines
Hmm, I read it as "since NTB *can* be compiled without dmaengine here are some stubs".
This poses an overall question of whether it would simply be better to abstract all of the with/without
DMA_ENGINEpart and simply remap it to memcpy ifDMA_ENGINEis not set (or if the DMA engine is hotplugged). Of course, this is outside the scope of this patch.That's at least the promise of
async_memcpy()it does not care if a channel is there or not, but I think it is better if the client has a strict dma and non-dma path. Hiding the dma details from the client seems to have been the wrong choice at least for raid.
Quoted 8 lines
Quoted 4 lines
That is fine. It can be like this in the short term.
Thanks,
JonI'll take that as:
Acked-by Jon Mason <[email protected]>
Quoted 2 lines
...but holler if not.
PATCH v2 12/13 dmaengine: remove DMA unmap from drivers
In reply to Bartlomiej ZolnierkiewiczRemove support for DMA unmapping from drivers as it is no longer needed (DMA core code is now handling it).
--- arch/arm/include/asm/hardware/iop3xx-adma.h | 30 ---- arch/arm/include/asm/hardware/iop_adma.h | 4 - arch/arm/mach-iop13xx/include/mach/adma.h | 26 --- drivers/dma/amba-pl08x.c | 31 ---- drivers/dma/at_hdmac.c | 25 --- drivers/dma/dw/core.c | 20 --- drivers/dma/ep93xx_dma.c | 29 --- drivers/dma/fsldma.c | 16 -- drivers/dma/ioat/dma.c | 16 -- drivers/dma/ioat/dma.h | 12 -- drivers/dma/ioat/dma_v2.c | 1 - drivers/dma/ioat/dma_v3.c | 166 ----------------- drivers/dma/iop-adma.c | 96 +--------- drivers/dma/mv_xor.c | 44 +---- drivers/dma/ppc4xx/adma.c | 269 ---------------------------- drivers/dma/timb_dma.c | 36 ---- drivers/dma/txx9dmac.c | 24 --- 17 files changed, 3 insertions(+), 842 deletions(-)
arch/arm/include/asm/hardware/iop3xx-adma.h +0 -30
@@ -393,36 +393,6 @@ static inline int iop_chan_zero_sum_slot_count(size_t len, int src_cnt,return slot_cnt; } -static inline int iop_desc_is_pq (struct iop_adma_desc_slot *desc) -{ -return 0 ; -} - -static inline u32 iop_desc_get_dest_addr (struct iop_adma_desc_slot *desc, -struct iop_adma_chan *chan) -{ -union iop3xx_desc hw_desc = { .ptr = desc->hw_desc, }; - -switch (chan->device->id) { -case DMA0_ID : -case DMA1_ID : -return hw_desc.dma->dest_addr; -case AAU_ID : -return hw_desc.aau->dest_addr; -default : -BUG (); - } -return 0 ; -} - - -static inline u32 iop_desc_get_qdest_addr (struct iop_adma_desc_slot *desc, -struct iop_adma_chan *chan) -{ -BUG (); -return 0 ; -} -static inline u32 iop_desc_get_byte_count (struct iop_adma_desc_slot *desc,struct iop_adma_chan *chan) {
arch/arm/include/asm/hardware/iop_adma.h +0 -4
@@ -82,8 +82,6 @@ struct iop_adma_chan {* @slot_cnt: total slots used in an transaction (group of operations) * @slots_per_op: number of slots per operation * @idx: pool index -* @unmap_src_cnt: number of xor sources -* @unmap_len: transaction bytecount * @tx_list: list of descriptors that are associated with one operation * @async_tx: support for the async_tx api * @group_list: list of slots that make up a multi-descriptor transaction
@@ -99,8 +97,6 @@ struct iop_adma_desc_slot {u16 slot_cnt;u16 slots_per_op;u16 idx; -u16 unmap_src_cnt; -size_t unmap_len;struct list_head tx_list;struct dma_async_tx_descriptor async_tx;union {
arch/arm/mach-iop13xx/include/mach/adma.h +0 -26
@@ -218,20 +218,6 @@ iop_chan_xor_slot_count(size_t len, int src_cnt, int *slots_per_op)#define iop_chan_pq_slot_count iop_chan_xor_slot_count#define iop_chan_pq_zero_sum_slot_count iop_chan_xor_slot_count -static inline u32 iop_desc_get_dest_addr (struct iop_adma_desc_slot *desc, -struct iop_adma_chan *chan) -{ -struct iop13xx_adma_desc_hw *hw_desc = desc->hw_desc; -return hw_desc->dest_addr; -} - -static inline u32 iop_desc_get_qdest_addr (struct iop_adma_desc_slot *desc, -struct iop_adma_chan *chan) -{ -struct iop13xx_adma_desc_hw *hw_desc = desc->hw_desc; -return hw_desc->q_dest_addr; -} -static inline u32 iop_desc_get_byte_count (struct iop_adma_desc_slot *desc,struct iop_adma_chan *chan) {
@@ -350,18 +336,6 @@ iop_desc_init_pq(struct iop_adma_desc_slot *desc, int src_cnt, hw_desc->desc_ctrl = u_desc_ctrl.value; } -static inline int iop_desc_is_pq (struct iop_adma_desc_slot *desc) -{ -struct iop13xx_adma_desc_hw *hw_desc = desc->hw_desc; -union { -u32 value; -struct iop13xx_adma_desc_ctrl field; - } u_desc_ctrl; - - u_desc_ctrl.value = hw_desc->desc_ctrl; -return u_desc_ctrl.field.pq_xfer_en; -} -static inline void iop_desc_init_pq_zero_sum (struct iop_adma_desc_slot *desc,int src_cnt,unsigned long flags)
drivers/dma/amba-pl08x.c +0 -31
@@ -1164,43 +1164,12 @@ static void pl08x_free_txd(struct pl08x_driver_data *pl08x,kfree (txd); } -static void pl08x_unmap_buffers (struct pl08x_txd *txd) -{ -struct device *dev = txd->vd.tx.chan->device->dev; -struct pl08x_sg *dsg; - -if (!(txd->vd.tx.flags &DMA_COMPL_SKIP_SRC_UNMAP )) { -if (txd->vd.tx.flags &DMA_COMPL_SRC_UNMAP_SINGLE ) -list_for_each_entry (dsg, &txd->dsg_list, node) -dma_unmap_single (dev, dsg->src_addr, dsg->len, -DMA_TO_DEVICE ); -else { -list_for_each_entry (dsg, &txd->dsg_list, node) -dma_unmap_page (dev, dsg->src_addr, dsg->len, -DMA_TO_DEVICE ); - } - } -if (!(txd->vd.tx.flags &DMA_COMPL_SKIP_DEST_UNMAP )) { -if (txd->vd.tx.flags &DMA_COMPL_DEST_UNMAP_SINGLE ) -list_for_each_entry (dsg, &txd->dsg_list, node) -dma_unmap_single (dev, dsg->dst_addr, dsg->len, -DMA_FROM_DEVICE ); -else -list_for_each_entry (dsg, &txd->dsg_list, node) -dma_unmap_page (dev, dsg->dst_addr, dsg->len, -DMA_FROM_DEVICE ); - } -} -static void pl08x_desc_free (struct virt_dma_desc *vd) {struct pl08x_txd *txd =to_pl08x_txd (&vd->tx);struct pl08x_dma_chan *plchan =to_pl08x_chan (vd->tx.chan);dma_descriptor_unmap (txd); -if (!plchan->slave) -pl08x_unmap_buffers (txd); -if (!txd->done)pl08x_release_mux (plchan);
drivers/dma/at_hdmac.c +0 -25
@@ -344,32 +344,7 @@ atc_chain_complete(struct at_dma_chan *atchan, struct at_desc *desc)/* move myself to free_list */ list_move (&desc->desc_node, &atchan->free_list); -/* unmap dma addresses (not on slave channels) */ dma_descriptor_unmap (txd); -if (!atchan->chan_common.private) { -struct device *parent =chan2parent (&atchan->chan_common); -if (!(txd->flags &DMA_COMPL_SKIP_DEST_UNMAP )) { -if (txd->flags &DMA_COMPL_DEST_UNMAP_SINGLE ) -dma_unmap_single (parent, - desc->lli.daddr, - desc->len,DMA_FROM_DEVICE ); -else -dma_unmap_page (parent, - desc->lli.daddr, - desc->len,DMA_FROM_DEVICE ); - } -if (!(txd->flags &DMA_COMPL_SKIP_SRC_UNMAP )) { -if (txd->flags &DMA_COMPL_SRC_UNMAP_SINGLE ) -dma_unmap_single (parent, - desc->lli.saddr, - desc->len,DMA_TO_DEVICE ); -else -dma_unmap_page (parent, - desc->lli.saddr, - desc->len,DMA_TO_DEVICE ); - } - } -/* for cyclic transfers, * no need to replay callback function while stopping */ if (!atc_chan_is_cyclic (atchan)) {
drivers/dma/dw/core.c +0 -20
@@ -312,26 +312,6 @@ dwc_descriptor_complete(struct dw_dma_chan *dwc, struct dw_desc *desc,list_move (&desc->desc_node, &dwc->free_list);dma_descriptor_unmap (txd); -if (!is_slave_direction (dwc->direction)) { -struct device *parent =chan2parent (&dwc->chan); -if (!(txd->flags &DMA_COMPL_SKIP_DEST_UNMAP )) { -if (txd->flags &DMA_COMPL_DEST_UNMAP_SINGLE ) -dma_unmap_single (parent, desc->lli.dar, - desc->total_len,DMA_FROM_DEVICE ); -else -dma_unmap_page (parent, desc->lli.dar, - desc->total_len,DMA_FROM_DEVICE ); - } -if (!(txd->flags &DMA_COMPL_SKIP_SRC_UNMAP )) { -if (txd->flags &DMA_COMPL_SRC_UNMAP_SINGLE ) -dma_unmap_single (parent, desc->lli.sar, - desc->total_len,DMA_TO_DEVICE ); -else -dma_unmap_page (parent, desc->lli.sar, - desc->total_len,DMA_TO_DEVICE ); - } - } -spin_unlock_irqrestore (&dwc->lock, flags);if (callback)
drivers/dma/ep93xx_dma.c +0 -29
@@ -733,28 +733,6 @@ static void ep93xx_dma_advance_work(struct ep93xx_dma_chan *edmac)spin_unlock_irqrestore (&edmac->lock, flags); } -static void ep93xx_dma_unmap_buffers (struct ep93xx_dma_desc *desc) -{ -struct device *dev = desc->txd.chan->device->dev; - -if (!(desc->txd.flags &DMA_COMPL_SKIP_SRC_UNMAP )) { -if (desc->txd.flags &DMA_COMPL_SRC_UNMAP_SINGLE ) -dma_unmap_single (dev, desc->src_addr, desc->size, -DMA_TO_DEVICE ); -else -dma_unmap_page (dev, desc->src_addr, desc->size, -DMA_TO_DEVICE ); - } -if (!(desc->txd.flags &DMA_COMPL_SKIP_DEST_UNMAP )) { -if (desc->txd.flags &DMA_COMPL_DEST_UNMAP_SINGLE ) -dma_unmap_single (dev, desc->dst_addr, desc->size, -DMA_FROM_DEVICE ); -else -dma_unmap_page (dev, desc->dst_addr, desc->size, -DMA_FROM_DEVICE ); - } -} -static void ep93xx_dma_tasklet (unsigned long data) {struct ep93xx_dma_chan *edmac = (struct ep93xx_dma_chan *)data;
@@ -787,14 +765,7 @@ static void ep93xx_dma_tasklet(unsigned long data)/* Now we can release all the chained descriptors */ list_for_each_entry_safe (desc, d, &list, node) { -/* -* For the memcpy channels the API requires us to unmap the -* buffers unless requested otherwise. -*/ dma_descriptor_unmap (&desc->txd); -if (!edmac->chan.private) -ep93xx_dma_unmap_buffers (desc); -ep93xx_dma_desc_put (edmac, desc); }
drivers/dma/fsldma.c +0 -16
@@ -871,22 +871,6 @@ static void fsldma_cleanup_descriptor(struct fsldma_chan *chan,dma_run_dependencies (txd);dma_descriptor_unmap (txd); -/* Unmap the dst buffer, if requested */ -if (!(txd->flags &DMA_COMPL_SKIP_DEST_UNMAP )) { -if (txd->flags &DMA_COMPL_DEST_UNMAP_SINGLE ) -dma_unmap_single (dev, dst, len,DMA_FROM_DEVICE ); -else -dma_unmap_page (dev, dst, len,DMA_FROM_DEVICE ); - } - -/* Unmap the src buffer, if requested */ -if (!(txd->flags &DMA_COMPL_SKIP_SRC_UNMAP )) { -if (txd->flags &DMA_COMPL_SRC_UNMAP_SINGLE ) -dma_unmap_single (dev, src, len,DMA_TO_DEVICE ); -else -dma_unmap_page (dev, src, len,DMA_TO_DEVICE ); - } -#ifdef FSL_DMA_LD_DEBUG chan_dbg (chan,"LD %p free\n" , desc);#endif
drivers/dma/ioat/dma.c +0 -16
@@ -531,21 +531,6 @@ static void ioat1_cleanup_event(unsigned long data)writew (IOAT_CHANCTRL_RUN , ioat->base.reg_base +IOAT_CHANCTRL_OFFSET ); } -void ioat_dma_unmap (struct ioat_chan_common *chan,enum dma_ctrl_flags flags, -size_t len,struct ioat_dma_descriptor *hw) -{ -struct pci_dev *pdev = chan->device->pdev; -size_t offset = len - hw->size; - -if (!(flags &DMA_COMPL_SKIP_DEST_UNMAP )) -ioat_unmap (pdev, hw->dst_addr - offset, len, -PCI_DMA_FROMDEVICE , flags,1 ); - -if (!(flags &DMA_COMPL_SKIP_SRC_UNMAP )) -ioat_unmap (pdev, hw->src_addr - offset, len, -PCI_DMA_TODEVICE , flags,0 ); -} -dma_addr_t ioat_get_current_completion (struct ioat_chan_common *chan) {dma_addr_t phys_complete;
@@ -603,7 +588,6 @@ static void __cleanup(struct ioat_dma_chan *ioat, dma_addr_t phys_complete)if (tx->cookie) {dma_cookie_complete (tx);dma_descriptor_unmap (tx); -ioat_dma_unmap (chan, tx->flags, desc->len, desc->hw); ioat->active -= desc->hw->tx_cnt;if (tx->callback) { tx->callback (tx->callback_param);
drivers/dma/ioat/dma.h +0 -12
@@ -342,16 +342,6 @@ static inline bool is_ioat_bug(unsigned long err)return !!err; } -static inline void ioat_unmap (struct pci_dev *pdev,dma_addr_t addr,size_t len, -int direction,enum dma_ctrl_flags flags,bool dst) -{ -if ((dst && (flags &DMA_COMPL_DEST_UNMAP_SINGLE )) || - (!dst && (flags &DMA_COMPL_SRC_UNMAP_SINGLE ))) -pci_unmap_single (pdev, addr, len, direction); -else -pci_unmap_page (pdev, addr, len, direction); -} -int ioat_probe (struct ioatdma_device *device);int ioat_register (struct ioatdma_device *device);int ioat1_dma_probe (struct ioatdma_device *dev,int dca);
@@ -363,8 +353,6 @@ void ioat_init_channel(struct ioatdma_device *device, struct ioat_chan_common *chan, int idx);enum dma_status ioat_dma_tx_status (struct dma_chan *c,dma_cookie_t cookie,struct dma_tx_state *txstate); -void ioat_dma_unmap (struct ioat_chan_common *chan,enum dma_ctrl_flags flags, -size_t len,struct ioat_dma_descriptor *hw);bool ioat_cleanup_preamble (struct ioat_chan_common *chan,dma_addr_t *phys_complete);void ioat_kobject_add (struct ioatdma_device *device,struct kobj_type *type);
drivers/dma/ioat/dma_v2.c +0 -1
@@ -149,7 +149,6 @@ static void __cleanup(struct ioat2_dma_chan *ioat, dma_addr_t phys_complete)dump_desc_dbg (ioat, desc);if (tx->cookie) {dma_descriptor_unmap (tx); -ioat_dma_unmap (chan, tx->flags, desc->len, desc->hw);dma_cookie_complete (tx);if (tx->callback) { tx->callback (tx->callback_param);
drivers/dma/ioat/dma_v3.c +0 -166
184 lines not on this page · raw message
drivers/dma/iop-adma.c +2 -94
144 lines not on this page · raw message
drivers/dma/mv_xor.c +1 -43
57 lines not on this page · raw message
drivers/dma/ppc4xx/adma.c +0 -269
287 lines not on this page · raw message
drivers/dma/timb_dma.c +0 -36
@@ -154,38 +154,6 @@ static bool __td_dma_done_ack(struct timb_dma_chan *td_chan)return done; } -static void __td_unmap_desc (struct timb_dma_chan *td_chan,const u8 *dma_desc, -bool single) -{ -dma_addr_t addr; -int len; - - addr = (dma_desc[7 ] <<24 ) | (dma_desc[6 ] <<16 ) | (dma_desc[5 ] <<8 ) | - dma_desc[4 ]; - - len = (dma_desc[3 ] <<8 ) | dma_desc[2 ]; - -if (single) -dma_unmap_single (chan2dev (&td_chan->chan), addr, len, -DMA_TO_DEVICE ); -else -dma_unmap_page (chan2dev (&td_chan->chan), addr, len, -DMA_TO_DEVICE ); -} - -static void __td_unmap_descs (struct timb_dma_desc *td_desc,bool single) -{ -struct timb_dma_chan *td_chan =container_of (td_desc->txd.chan, - struct timb_dma_chan, chan); -u8 *descs; - -for (descs = td_desc->desc_list; ; descs +=TIMB_DMA_DESC_SIZE ) { -__td_unmap_desc (td_chan, descs, single); -if (descs[0 ] &0x02 ) -break ; - } -} -static int td_fill_desc (struct timb_dma_chan *td_chan,u8 *dma_desc,struct scatterlist *sg,bool last) {
@@ -294,10 +262,6 @@ static void __td_finish(struct timb_dma_chan *td_chan)list_move (&td_desc->desc_node, &td_chan->free_list);dma_descriptor_unmap (txd); -if (!(txd->flags &DMA_COMPL_SKIP_SRC_UNMAP )) -__td_unmap_descs (td_desc, - txd->flags &DMA_COMPL_SRC_UNMAP_SINGLE ); -/* * The API requires that no submissions are done from a * callback, so we don't need to drop the lock here
drivers/dma/txx9dmac.c +0 -24
@@ -420,30 +420,6 @@ txx9dmac_descriptor_complete(struct txx9dmac_chan *dc,list_move (&desc->desc_node, &dc->free_list);dma_descriptor_unmap (txd); -if (!ds) { -dma_addr_t dmaaddr; -if (!(txd->flags &DMA_COMPL_SKIP_DEST_UNMAP )) { - dmaaddr =is_dmac64 (dc) ? - desc->hwdesc.DAR : desc->hwdesc32.DAR; -if (txd->flags &DMA_COMPL_DEST_UNMAP_SINGLE ) -dma_unmap_single (chan2parent (&dc->chan), - dmaaddr, desc->len,DMA_FROM_DEVICE ); -else -dma_unmap_page (chan2parent (&dc->chan), - dmaaddr, desc->len,DMA_FROM_DEVICE ); - } -if (!(txd->flags &DMA_COMPL_SKIP_SRC_UNMAP )) { - dmaaddr =is_dmac64 (dc) ? - desc->hwdesc.SAR : desc->hwdesc32.SAR; -if (txd->flags &DMA_COMPL_SRC_UNMAP_SINGLE ) -dma_unmap_single (chan2parent (&dc->chan), - dmaaddr, desc->len,DMA_TO_DEVICE ); -else -dma_unmap_page (chan2parent (&dc->chan), - dmaaddr, desc->len,DMA_TO_DEVICE ); - } - } -/* * The API requires that no submissions are done from a * callback, so we don't need to drop the lock here
Signature · 1 line
1.8.2.3
PATCH v2 12/13 dmaengine: remove DMA unmap from drivers
From: Bartlomiej Zolnierkiewicz <[email protected]>
Remove support for DMA unmapping from drivers as it is no longer needed (DMA core code is now handling it).
---
Resend to:
1/ add it to the new dmaengine patchwork
2/ cc maintainers of affected drivers
3/ fixup some mail addresses
arch/arm/include/asm/hardware/iop3xx-adma.h | 30 --- arch/arm/include/asm/hardware/iop_adma.h | 4 arch/arm/mach-iop13xx/include/mach/adma.h | 26 --- drivers/dma/amba-pl08x.c | 31 --- drivers/dma/at_hdmac.c | 25 --- drivers/dma/dw/core.c | 20 -- drivers/dma/ep93xx_dma.c | 29 --- drivers/dma/fsldma.c | 16 -- drivers/dma/ioat/dma.c | 16 -- drivers/dma/ioat/dma.h | 12 - drivers/dma/ioat/dma_v2.c | 1 drivers/dma/ioat/dma_v3.c | 166 ----------------- drivers/dma/iop-adma.c | 96 ---------- drivers/dma/mv_xor.c | 44 ---- drivers/dma/ppc4xx/adma.c | 269 --------------------------- drivers/dma/timb_dma.c | 36 ---- drivers/dma/txx9dmac.c | 24 -- 17 files changed, 3 insertions(+), 842 deletions(-)
arch/arm/include/asm/hardware/iop3xx-adma.h +0 -30
@@ -393,36 +393,6 @@ static inline int iop_chan_zero_sum_slot_count(size_t len, int src_cnt,return slot_cnt; } -static inline int iop_desc_is_pq (struct iop_adma_desc_slot *desc) -{ -return 0 ; -} - -static inline u32 iop_desc_get_dest_addr (struct iop_adma_desc_slot *desc, -struct iop_adma_chan *chan) -{ -union iop3xx_desc hw_desc = { .ptr = desc->hw_desc, }; - -switch (chan->device->id) { -case DMA0_ID : -case DMA1_ID : -return hw_desc.dma->dest_addr; -case AAU_ID : -return hw_desc.aau->dest_addr; -default : -BUG (); - } -return 0 ; -} - - -static inline u32 iop_desc_get_qdest_addr (struct iop_adma_desc_slot *desc, -struct iop_adma_chan *chan) -{ -BUG (); -return 0 ; -} -static inline u32 iop_desc_get_byte_count (struct iop_adma_desc_slot *desc,struct iop_adma_chan *chan) {
arch/arm/include/asm/hardware/iop_adma.h +0 -4
@@ -82,8 +82,6 @@ struct iop_adma_chan {* @slot_cnt: total slots used in an transaction (group of operations) * @slots_per_op: number of slots per operation * @idx: pool index -* @unmap_src_cnt: number of xor sources -* @unmap_len: transaction bytecount * @tx_list: list of descriptors that are associated with one operation * @async_tx: support for the async_tx api * @group_list: list of slots that make up a multi-descriptor transaction
@@ -99,8 +97,6 @@ struct iop_adma_desc_slot {u16 slot_cnt;u16 slots_per_op;u16 idx; -u16 unmap_src_cnt; -size_t unmap_len;struct list_head tx_list;struct dma_async_tx_descriptor async_tx;union {
arch/arm/mach-iop13xx/include/mach/adma.h +0 -26
@@ -218,20 +218,6 @@ iop_chan_xor_slot_count(size_t len, int src_cnt, int *slots_per_op)#define iop_chan_pq_slot_count iop_chan_xor_slot_count#define iop_chan_pq_zero_sum_slot_count iop_chan_xor_slot_count -static inline u32 iop_desc_get_dest_addr (struct iop_adma_desc_slot *desc, -struct iop_adma_chan *chan) -{ -struct iop13xx_adma_desc_hw *hw_desc = desc->hw_desc; -return hw_desc->dest_addr; -} - -static inline u32 iop_desc_get_qdest_addr (struct iop_adma_desc_slot *desc, -struct iop_adma_chan *chan) -{ -struct iop13xx_adma_desc_hw *hw_desc = desc->hw_desc; -return hw_desc->q_dest_addr; -} -static inline u32 iop_desc_get_byte_count (struct iop_adma_desc_slot *desc,struct iop_adma_chan *chan) {
@@ -350,18 +336,6 @@ iop_desc_init_pq(struct iop_adma_desc_slot *desc, int src_cnt, hw_desc->desc_ctrl = u_desc_ctrl.value; } -static inline int iop_desc_is_pq (struct iop_adma_desc_slot *desc) -{ -struct iop13xx_adma_desc_hw *hw_desc = desc->hw_desc; -union { -u32 value; -struct iop13xx_adma_desc_ctrl field; - } u_desc_ctrl; - - u_desc_ctrl.value = hw_desc->desc_ctrl; -return u_desc_ctrl.field.pq_xfer_en; -} -static inline void iop_desc_init_pq_zero_sum (struct iop_adma_desc_slot *desc,int src_cnt,unsigned long flags)
drivers/dma/amba-pl08x.c +0 -31
@@ -1164,43 +1164,12 @@ static void pl08x_free_txd(struct pl08x_driver_data *pl08x,kfree (txd); } -static void pl08x_unmap_buffers (struct pl08x_txd *txd) -{ -struct device *dev = txd->vd.tx.chan->device->dev; -struct pl08x_sg *dsg; - -if (!(txd->vd.tx.flags &DMA_COMPL_SKIP_SRC_UNMAP )) { -if (txd->vd.tx.flags &DMA_COMPL_SRC_UNMAP_SINGLE ) -list_for_each_entry (dsg, &txd->dsg_list, node) -dma_unmap_single (dev, dsg->src_addr, dsg->len, -DMA_TO_DEVICE ); -else { -list_for_each_entry (dsg, &txd->dsg_list, node) -dma_unmap_page (dev, dsg->src_addr, dsg->len, -DMA_TO_DEVICE ); - } - } -if (!(txd->vd.tx.flags &DMA_COMPL_SKIP_DEST_UNMAP )) { -if (txd->vd.tx.flags &DMA_COMPL_DEST_UNMAP_SINGLE ) -list_for_each_entry (dsg, &txd->dsg_list, node) -dma_unmap_single (dev, dsg->dst_addr, dsg->len, -DMA_FROM_DEVICE ); -else -list_for_each_entry (dsg, &txd->dsg_list, node) -dma_unmap_page (dev, dsg->dst_addr, dsg->len, -DMA_FROM_DEVICE ); - } -} -static void pl08x_desc_free (struct virt_dma_desc *vd) {struct pl08x_txd *txd =to_pl08x_txd (&vd->tx);struct pl08x_dma_chan *plchan =to_pl08x_chan (vd->tx.chan);dma_descriptor_unmap (txd); -if (!plchan->slave) -pl08x_unmap_buffers (txd); -if (!txd->done)pl08x_release_mux (plchan);
drivers/dma/at_hdmac.c +0 -25
@@ -344,32 +344,7 @@ atc_chain_complete(struct at_dma_chan *atchan, struct at_desc *desc)/* move myself to free_list */ list_move (&desc->desc_node, &atchan->free_list); -/* unmap dma addresses (not on slave channels) */ dma_descriptor_unmap (txd); -if (!atchan->chan_common.private) { -struct device *parent =chan2parent (&atchan->chan_common); -if (!(txd->flags &DMA_COMPL_SKIP_DEST_UNMAP )) { -if (txd->flags &DMA_COMPL_DEST_UNMAP_SINGLE ) -dma_unmap_single (parent, - desc->lli.daddr, - desc->len,DMA_FROM_DEVICE ); -else -dma_unmap_page (parent, - desc->lli.daddr, - desc->len,DMA_FROM_DEVICE ); - } -if (!(txd->flags &DMA_COMPL_SKIP_SRC_UNMAP )) { -if (txd->flags &DMA_COMPL_SRC_UNMAP_SINGLE ) -dma_unmap_single (parent, - desc->lli.saddr, - desc->len,DMA_TO_DEVICE ); -else -dma_unmap_page (parent, - desc->lli.saddr, - desc->len,DMA_TO_DEVICE ); - } - } -/* for cyclic transfers, * no need to replay callback function while stopping */ if (!atc_chan_is_cyclic (atchan)) {
drivers/dma/dw/core.c +0 -20
@@ -312,26 +312,6 @@ dwc_descriptor_complete(struct dw_dma_chan *dwc, struct dw_desc *desc,list_move (&desc->desc_node, &dwc->free_list);dma_descriptor_unmap (txd); -if (!is_slave_direction (dwc->direction)) { -struct device *parent =chan2parent (&dwc->chan); -if (!(txd->flags &DMA_COMPL_SKIP_DEST_UNMAP )) { -if (txd->flags &DMA_COMPL_DEST_UNMAP_SINGLE ) -dma_unmap_single (parent, desc->lli.dar, - desc->total_len,DMA_FROM_DEVICE ); -else -dma_unmap_page (parent, desc->lli.dar, - desc->total_len,DMA_FROM_DEVICE ); - } -if (!(txd->flags &DMA_COMPL_SKIP_SRC_UNMAP )) { -if (txd->flags &DMA_COMPL_SRC_UNMAP_SINGLE ) -dma_unmap_single (parent, desc->lli.sar, - desc->total_len,DMA_TO_DEVICE ); -else -dma_unmap_page (parent, desc->lli.sar, - desc->total_len,DMA_TO_DEVICE ); - } - } -spin_unlock_irqrestore (&dwc->lock, flags);if (callback)
drivers/dma/ep93xx_dma.c +0 -29
@@ -733,28 +733,6 @@ static void ep93xx_dma_advance_work(struct ep93xx_dma_chan *edmac)spin_unlock_irqrestore (&edmac->lock, flags); } -static void ep93xx_dma_unmap_buffers (struct ep93xx_dma_desc *desc) -{ -struct device *dev = desc->txd.chan->device->dev; - -if (!(desc->txd.flags &DMA_COMPL_SKIP_SRC_UNMAP )) { -if (desc->txd.flags &DMA_COMPL_SRC_UNMAP_SINGLE ) -dma_unmap_single (dev, desc->src_addr, desc->size, -DMA_TO_DEVICE ); -else -dma_unmap_page (dev, desc->src_addr, desc->size, -DMA_TO_DEVICE ); - } -if (!(desc->txd.flags &DMA_COMPL_SKIP_DEST_UNMAP )) { -if (desc->txd.flags &DMA_COMPL_DEST_UNMAP_SINGLE ) -dma_unmap_single (dev, desc->dst_addr, desc->size, -DMA_FROM_DEVICE ); -else -dma_unmap_page (dev, desc->dst_addr, desc->size, -DMA_FROM_DEVICE ); - } -} -static void ep93xx_dma_tasklet (unsigned long data) {struct ep93xx_dma_chan *edmac = (struct ep93xx_dma_chan *)data;
@@ -787,14 +765,7 @@ static void ep93xx_dma_tasklet(unsigned long data)/* Now we can release all the chained descriptors */ list_for_each_entry_safe (desc, d, &list, node) { -/* -* For the memcpy channels the API requires us to unmap the -* buffers unless requested otherwise. -*/ dma_descriptor_unmap (&desc->txd); -if (!edmac->chan.private) -ep93xx_dma_unmap_buffers (desc); -ep93xx_dma_desc_put (edmac, desc); }
drivers/dma/fsldma.c +0 -16
@@ -869,22 +869,6 @@ static void fsldma_cleanup_descriptor(struct fsldma_chan *chan,dma_run_dependencies (txd);dma_descriptor_unmap (txd); -/* Unmap the dst buffer, if requested */ -if (!(txd->flags &DMA_COMPL_SKIP_DEST_UNMAP )) { -if (txd->flags &DMA_COMPL_DEST_UNMAP_SINGLE ) -dma_unmap_single (dev, dst, len,DMA_FROM_DEVICE ); -else -dma_unmap_page (dev, dst, len,DMA_FROM_DEVICE ); - } - -/* Unmap the src buffer, if requested */ -if (!(txd->flags &DMA_COMPL_SKIP_SRC_UNMAP )) { -if (txd->flags &DMA_COMPL_SRC_UNMAP_SINGLE ) -dma_unmap_single (dev, src, len,DMA_TO_DEVICE ); -else -dma_unmap_page (dev, src, len,DMA_TO_DEVICE ); - } -#ifdef FSL_DMA_LD_DEBUG chan_dbg (chan,"LD %p free\n" , desc);#endif
drivers/dma/ioat/dma.c +0 -16
@@ -531,21 +531,6 @@ static void ioat1_cleanup_event(unsigned long data)writew (IOAT_CHANCTRL_RUN , ioat->base.reg_base +IOAT_CHANCTRL_OFFSET ); } -void ioat_dma_unmap (struct ioat_chan_common *chan,enum dma_ctrl_flags flags, -size_t len,struct ioat_dma_descriptor *hw) -{ -struct pci_dev *pdev = chan->device->pdev; -size_t offset = len - hw->size; - -if (!(flags &DMA_COMPL_SKIP_DEST_UNMAP )) -ioat_unmap (pdev, hw->dst_addr - offset, len, -PCI_DMA_FROMDEVICE , flags,1 ); - -if (!(flags &DMA_COMPL_SKIP_SRC_UNMAP )) -ioat_unmap (pdev, hw->src_addr - offset, len, -PCI_DMA_TODEVICE , flags,0 ); -} -dma_addr_t ioat_get_current_completion (struct ioat_chan_common *chan) {dma_addr_t phys_complete;
@@ -603,7 +588,6 @@ static void __cleanup(struct ioat_dma_chan *ioat, dma_addr_t phys_complete)if (tx->cookie) {dma_cookie_complete (tx);dma_descriptor_unmap (tx); -ioat_dma_unmap (chan, tx->flags, desc->len, desc->hw); ioat->active -= desc->hw->tx_cnt;if (tx->callback) { tx->callback (tx->callback_param);
drivers/dma/ioat/dma.h +0 -12
@@ -342,16 +342,6 @@ static inline bool is_ioat_bug(unsigned long err)return !!err; } -static inline void ioat_unmap (struct pci_dev *pdev,dma_addr_t addr,size_t len, -int direction,enum dma_ctrl_flags flags,bool dst) -{ -if ((dst && (flags &DMA_COMPL_DEST_UNMAP_SINGLE )) || - (!dst && (flags &DMA_COMPL_SRC_UNMAP_SINGLE ))) -pci_unmap_single (pdev, addr, len, direction); -else -pci_unmap_page (pdev, addr, len, direction); -} -int ioat_probe (struct ioatdma_device *device);int ioat_register (struct ioatdma_device *device);int ioat1_dma_probe (struct ioatdma_device *dev,int dca);
@@ -363,8 +353,6 @@ void ioat_init_channel(struct ioatdma_device *device, struct ioat_chan_common *chan, int idx);enum dma_status ioat_dma_tx_status (struct dma_chan *c,dma_cookie_t cookie,struct dma_tx_state *txstate); -void ioat_dma_unmap (struct ioat_chan_common *chan,enum dma_ctrl_flags flags, -size_t len,struct ioat_dma_descriptor *hw);bool ioat_cleanup_preamble (struct ioat_chan_common *chan,dma_addr_t *phys_complete);void ioat_kobject_add (struct ioatdma_device *device,struct kobj_type *type);
drivers/dma/ioat/dma_v2.c +0 -1
@@ -149,7 +149,6 @@ static void __cleanup(struct ioat2_dma_chan *ioat, dma_addr_t phys_complete)dump_desc_dbg (ioat, desc);if (tx->cookie) {dma_descriptor_unmap (tx); -ioat_dma_unmap (chan, tx->flags, desc->len, desc->hw);dma_cookie_complete (tx);if (tx->callback) { tx->callback (tx->callback_param);
drivers/dma/ioat/dma_v3.c +0 -166
184 lines not on this page · raw message
drivers/dma/iop-adma.c +2 -94
144 lines not on this page · raw message
drivers/dma/mv_xor.c +1 -43
57 lines not on this page · raw message
drivers/dma/ppc4xx/adma.c +0 -269
287 lines not on this page · raw message
drivers/dma/timb_dma.c +0 -36
@@ -154,38 +154,6 @@ static bool __td_dma_done_ack(struct timb_dma_chan *td_chan)return done; } -static void __td_unmap_desc (struct timb_dma_chan *td_chan,const u8 *dma_desc, -bool single) -{ -dma_addr_t addr; -int len; - - addr = (dma_desc[7 ] <<24 ) | (dma_desc[6 ] <<16 ) | (dma_desc[5 ] <<8 ) | - dma_desc[4 ]; - - len = (dma_desc[3 ] <<8 ) | dma_desc[2 ]; - -if (single) -dma_unmap_single (chan2dev (&td_chan->chan), addr, len, -DMA_TO_DEVICE ); -else -dma_unmap_page (chan2dev (&td_chan->chan), addr, len, -DMA_TO_DEVICE ); -} - -static void __td_unmap_descs (struct timb_dma_desc *td_desc,bool single) -{ -struct timb_dma_chan *td_chan =container_of (td_desc->txd.chan, - struct timb_dma_chan, chan); -u8 *descs; - -for (descs = td_desc->desc_list; ; descs +=TIMB_DMA_DESC_SIZE ) { -__td_unmap_desc (td_chan, descs, single); -if (descs[0 ] &0x02 ) -break ; - } -} -static int td_fill_desc (struct timb_dma_chan *td_chan,u8 *dma_desc,struct scatterlist *sg,bool last) {
@@ -294,10 +262,6 @@ static void __td_finish(struct timb_dma_chan *td_chan)list_move (&td_desc->desc_node, &td_chan->free_list);dma_descriptor_unmap (txd); -if (!(txd->flags &DMA_COMPL_SKIP_SRC_UNMAP )) -__td_unmap_descs (td_desc, - txd->flags &DMA_COMPL_SRC_UNMAP_SINGLE ); -/* * The API requires that no submissions are done from a * callback, so we don't need to drop the lock here
drivers/dma/txx9dmac.c +0 -24
@@ -420,30 +420,6 @@ txx9dmac_descriptor_complete(struct txx9dmac_chan *dc,list_move (&desc->desc_node, &dc->free_list);dma_descriptor_unmap (txd); -if (!ds) { -dma_addr_t dmaaddr; -if (!(txd->flags &DMA_COMPL_SKIP_DEST_UNMAP )) { - dmaaddr =is_dmac64 (dc) ? - desc->hwdesc.DAR : desc->hwdesc32.DAR; -if (txd->flags &DMA_COMPL_DEST_UNMAP_SINGLE ) -dma_unmap_single (chan2parent (&dc->chan), - dmaaddr, desc->len,DMA_FROM_DEVICE ); -else -dma_unmap_page (chan2parent (&dc->chan), - dmaaddr, desc->len,DMA_FROM_DEVICE ); - } -if (!(txd->flags &DMA_COMPL_SKIP_SRC_UNMAP )) { - dmaaddr =is_dmac64 (dc) ? - desc->hwdesc.SAR : desc->hwdesc32.SAR; -if (txd->flags &DMA_COMPL_SRC_UNMAP_SINGLE ) -dma_unmap_single (chan2parent (&dc->chan), - dmaaddr, desc->len,DMA_TO_DEVICE ); -else -dma_unmap_page (chan2parent (&dc->chan), - dmaaddr, desc->len,DMA_TO_DEVICE ); - } - } -/* * The API requires that no submissions are done from a * callback, so we don't need to drop the lock here
PATCH v2 13/13 dmaengine: remove DMA unmap flags
In reply to Bartlomiej ZolnierkiewiczRemove no longer needed DMA unmap flags:
- DMA_COMPL_SKIP_SRC_UNMAP
- DMA_COMPL_SKIP_DEST_UNMAP
- DMA_COMPL_SRC_UNMAP_SINGLE
- DMA_COMPL_DEST_UNMAP_SINGLE
--- crypto/async_tx/async_memcpy.c | 3 +-- crypto/async_tx/async_pq.c | 1 - crypto/async_tx/async_raid6_recov.c | 8 ++------ crypto/async_tx/async_xor.c | 6 ++---- drivers/ata/pata_arasan_cf.c | 3 +-- drivers/dma/dmaengine.c | 3 +-- drivers/dma/dmatest.c | 3 +-- drivers/dma/ioat/dma.c | 3 +-- drivers/dma/ioat/dma_v3.c | 12 +++--------- drivers/media/platform/m2m-deinterlace.c | 3 +-- drivers/media/platform/timblogiw.c | 2 +- drivers/misc/carma/carma-fpga.c | 3 +-- drivers/mtd/nand/atmel_nand.c | 3 +-- drivers/mtd/nand/fsmc_nand.c | 2 -- drivers/net/ethernet/micrel/ks8842.c | 6 ++---- drivers/ntb/ntb_transport.c | 3 +-- drivers/spi/spi-dw-mid.c | 4 ++-- include/linux/dmaengine.h | 18 ++++-------------- 18 files changed, 25 insertions(+), 61 deletions(-)
crypto/async_tx/async_memcpy.c +1 -2
@@ -56,8 +56,7 @@ async_memcpy(struct page *dest, struct page *src, unsigned int dest_offset, unmap =dmaengine_get_unmap_data (device->dev,2 ,GFP_NOIO );if (unmap &&is_dma_copy_aligned (device, src_offset, dest_offset, len)) { -unsigned long dma_prep_flags =DMA_COMPL_SKIP_SRC_UNMAP | -DMA_COMPL_SKIP_DEST_UNMAP ; +unsigned long dma_prep_flags =0 ;if (submit->cb_fn) dma_prep_flags |=DMA_PREP_INTERRUPT ;
crypto/async_tx/async_pq.c +0 -1
@@ -62,7 +62,6 @@ do_async_gen_syndrome(struct dma_chan *chan,dma_addr_t dma_dest[2 ];int src_off =0 ; - dma_flags |=DMA_COMPL_SKIP_SRC_UNMAP |DMA_COMPL_SKIP_DEST_UNMAP ;if (submit->flags &ASYNC_TX_FENCE ) dma_flags |=DMA_PREP_FENCE ;
crypto/async_tx/async_raid6_recov.c +2 -6
@@ -47,9 +47,7 @@ async_sum_product(struct page *dest, struct page **srcs, unsigned char *coef,struct device *dev = dma->dev;dma_addr_t pq[2 ];struct dma_async_tx_descriptor *tx; -enum dma_ctrl_flags dma_flags =DMA_COMPL_SKIP_SRC_UNMAP | -DMA_COMPL_SKIP_DEST_UNMAP | -DMA_PREP_PQ_DISABLE_P ; +enum dma_ctrl_flags dma_flags =DMA_PREP_PQ_DISABLE_P ;if (submit->flags &ASYNC_TX_FENCE ) dma_flags |=DMA_PREP_FENCE ;
@@ -113,9 +111,7 @@ async_mult(struct page *dest, struct page *src, u8 coef, size_t len,dma_addr_t dma_dest[2 ];struct device *dev = dma->dev;struct dma_async_tx_descriptor *tx; -enum dma_ctrl_flags dma_flags =DMA_COMPL_SKIP_SRC_UNMAP | -DMA_COMPL_SKIP_DEST_UNMAP | -DMA_PREP_PQ_DISABLE_P ; +enum dma_ctrl_flags dma_flags =DMA_PREP_PQ_DISABLE_P ;if (submit->flags &ASYNC_TX_FENCE ) dma_flags |=DMA_PREP_FENCE ;
crypto/async_tx/async_xor.c +2 -4
@@ -41,7 +41,7 @@ do_async_xor(struct dma_chan *chan, struct dmaengine_unmap_data *unmap,dma_async_tx_callback cb_fn_orig = submit->cb_fn;void *cb_param_orig = submit->cb_param;enum async_tx_flags flags_orig = submit->flags; -enum dma_ctrl_flags dma_flags; +enum dma_ctrl_flags dma_flags =0 ;int src_cnt = unmap->to_cnt;int xor_src_cnt;dma_addr_t dma_dest = unmap->addr[unmap->to_cnt];
@@ -55,7 +55,6 @@ do_async_xor(struct dma_chan *chan, struct dmaengine_unmap_data *unmap,/* if we are submitting additional xors, leave the chain open * and clear the callback parameters */ - dma_flags =DMA_COMPL_SKIP_SRC_UNMAP |DMA_COMPL_SKIP_DEST_UNMAP ;if (src_cnt > xor_src_cnt) { submit->flags &= ~ASYNC_TX_ACK ; submit->flags |=ASYNC_TX_FENCE ;
@@ -284,8 +283,7 @@ async_xor_val(struct page *dest, struct page **src_list, unsigned int offset,if (unmap && src_cnt <= device->max_xor &&is_dma_xor_aligned (device, offset,0 , len)) { -unsigned long dma_prep_flags =DMA_COMPL_SKIP_SRC_UNMAP | -DMA_COMPL_SKIP_DEST_UNMAP ; +unsigned long dma_prep_flags =0 ;int i;pr_debug ("%s: (async) len: %zu\n" , __func__, len);
drivers/ata/pata_arasan_cf.c +1 -2
@@ -396,8 +396,7 @@ dma_xfer(struct arasan_cf_dev *acdev, dma_addr_t src, dma_addr_t dest, u32 len)struct dma_async_tx_descriptor *tx;struct dma_chan *chan = acdev->dma_chan;dma_cookie_t cookie; -unsigned long flags =DMA_PREP_INTERRUPT |DMA_COMPL_SKIP_SRC_UNMAP | -DMA_COMPL_SKIP_DEST_UNMAP ; +unsigned long flags =DMA_PREP_INTERRUPT ;int ret =0 ; tx = chan->device->device_prep_dma_memcpy (chan, dest, src, len, flags);
drivers/dma/dmaengine.c +1 -2
@@ -1065,8 +1065,7 @@ dma_async_memcpy_pg_to_pg(struct dma_chan *chan, struct page *dest_pg, unmap->addr[1 ] =dma_map_page (dev->dev, dest_pg, dest_off, len,DMA_FROM_DEVICE ); unmap->len = len; - flags =DMA_CTRL_ACK |DMA_COMPL_SKIP_SRC_UNMAP | -DMA_COMPL_SKIP_DEST_UNMAP ; + flags =DMA_CTRL_ACK ; tx = dev->device_prep_dma_memcpy (chan, unmap->addr[1 ], unmap->addr[0 ], len, flags);
drivers/dma/dmatest.c +1 -2
@@ -599,8 +599,7 @@ static int dmatest_func(void *data)/* * src and dst buffers are freed by ourselves below */ - flags =DMA_CTRL_ACK |DMA_PREP_INTERRUPT | -DMA_COMPL_SKIP_SRC_UNMAP |DMA_COMPL_SKIP_DEST_UNMAP ; + flags =DMA_CTRL_ACK |DMA_PREP_INTERRUPT ;while (!kthread_should_stop () && !(params->iterations && total_tests >= params->iterations)) {
drivers/dma/ioat/dma.c +1 -2
@@ -818,8 +818,7 @@ int ioat_dma_self_test(struct ioatdma_device *device) dma_src =dma_map_single (dev, src,IOAT_TEST_SIZE ,DMA_TO_DEVICE ); dma_dest =dma_map_single (dev, dest,IOAT_TEST_SIZE ,DMA_FROM_DEVICE ); - flags =DMA_COMPL_SKIP_SRC_UNMAP |DMA_COMPL_SKIP_DEST_UNMAP | -DMA_PREP_INTERRUPT ; + flags =DMA_PREP_INTERRUPT ; tx = device->common.device_prep_dma_memcpy (dma_chan, dma_dest, dma_src,IOAT_TEST_SIZE , flags);if (!tx) {
drivers/dma/ioat/dma_v3.c +3 -9
@@ -1279,9 +1279,7 @@ static int ioat_xor_val_self_test(struct ioatdma_device *device) DMA_TO_DEVICE); tx = dma->device_prep_dma_xor (dma_chan, dest_dma, dma_srcs,IOAT_NUM_SRC_TEST ,PAGE_SIZE , -DMA_PREP_INTERRUPT | -DMA_COMPL_SKIP_SRC_UNMAP | -DMA_COMPL_SKIP_DEST_UNMAP ); +DMA_PREP_INTERRUPT );if (!tx) {dev_err (dev,"Self-test xor prep failed\n" );
@@ -1342,9 +1340,7 @@ static int ioat_xor_val_self_test(struct ioatdma_device *device) DMA_TO_DEVICE); tx = dma->device_prep_dma_xor_val (dma_chan, dma_srcs,IOAT_NUM_SRC_TEST +1 ,PAGE_SIZE , - &xor_val_result,DMA_PREP_INTERRUPT | -DMA_COMPL_SKIP_SRC_UNMAP | -DMA_COMPL_SKIP_DEST_UNMAP ); + &xor_val_result,DMA_PREP_INTERRUPT );if (!tx) {dev_err (dev,"Self-test zero prep failed\n" ); err = -ENODEV ;
@@ -1389,9 +1385,7 @@ static int ioat_xor_val_self_test(struct ioatdma_device *device) DMA_TO_DEVICE); tx = dma->device_prep_dma_xor_val (dma_chan, dma_srcs,IOAT_NUM_SRC_TEST +1 ,PAGE_SIZE , - &xor_val_result,DMA_PREP_INTERRUPT | -DMA_COMPL_SKIP_SRC_UNMAP | -DMA_COMPL_SKIP_DEST_UNMAP ); + &xor_val_result,DMA_PREP_INTERRUPT );if (!tx) {dev_err (dev,"Self-test 2nd zero prep failed\n" ); err = -ENODEV ;
drivers/media/platform/m2m-deinterlace.c +1 -2
@@ -341,8 +341,7 @@ static void deinterlace_issue_dma(struct deinterlace_ctx *ctx, int op, ctx->xt->dir =DMA_MEM_TO_MEM ; ctx->xt->src_sgl = false; ctx->xt->dst_sgl = true; - flags =DMA_CTRL_ACK |DMA_PREP_INTERRUPT | -DMA_COMPL_SKIP_DEST_UNMAP |DMA_COMPL_SKIP_SRC_UNMAP ; + flags =DMA_CTRL_ACK |DMA_PREP_INTERRUPT ; tx = dmadev->device_prep_interleaved_dma (chan, ctx->xt, flags);if (tx ==NULL ) {
drivers/media/platform/timblogiw.c +1 -1
@@ -565,7 +565,7 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) desc =dmaengine_prep_slave_sg (fh->chan, buf->sg, sg_elems,DMA_DEV_TO_MEM , -DMA_PREP_INTERRUPT |DMA_COMPL_SKIP_SRC_UNMAP ); +DMA_PREP_INTERRUPT );if (!desc) {spin_lock_irq (&fh->queue_lock);list_del_init (&vb->queue);
drivers/misc/carma/carma-fpga.c +1 -2
@@ -633,8 +633,7 @@ static int data_submit_dma(struct fpga_device *priv, struct data_buf *buf)struct dma_async_tx_descriptor *tx;dma_cookie_t cookie;dma_addr_t dst, src; -unsigned long dma_flags =DMA_COMPL_SKIP_DEST_UNMAP | -DMA_COMPL_SKIP_SRC_UNMAP ; +unsigned long dma_flags =0 ; dst_sg = buf->vb.sglist; dst_nents = buf->vb.sglen;
drivers/mtd/nand/atmel_nand.c +1 -2
@@ -375,8 +375,7 @@ static int atmel_nand_dma_op(struct mtd_info *mtd, void *buf, int len, dma_dev = host->dma_chan->device; - flags =DMA_CTRL_ACK |DMA_PREP_INTERRUPT |DMA_COMPL_SKIP_SRC_UNMAP | -DMA_COMPL_SKIP_DEST_UNMAP ; + flags =DMA_CTRL_ACK |DMA_PREP_INTERRUPT ; phys_addr =dma_map_single (dma_dev->dev, p, len, dir);if (dma_mapping_error (dma_dev->dev, phys_addr)) {
drivers/mtd/nand/fsmc_nand.c +0 -2
@@ -573,8 +573,6 @@ static int dma_xfer(struct fsmc_nand_data *host, void *buffer, int len, dma_dev = chan->device; dma_addr =dma_map_single (dma_dev->dev, buffer, len, direction); - flags |=DMA_COMPL_SKIP_SRC_UNMAP |DMA_COMPL_SKIP_DEST_UNMAP ; -if (direction ==DMA_TO_DEVICE ) { dma_src = dma_addr; dma_dst = host->data_pa;
drivers/net/ethernet/micrel/ks8842.c +2 -4
@@ -459,8 +459,7 @@ static int ks8842_tx_frame_dma(struct sk_buff *skb, struct net_device *netdev)sg_dma_len (&ctl->sg) +=4 -sg_dma_len (&ctl->sg) %4 ; ctl->adesc =dmaengine_prep_slave_sg (ctl->chan, - &ctl->sg,1 ,DMA_MEM_TO_DEV , -DMA_PREP_INTERRUPT |DMA_COMPL_SKIP_SRC_UNMAP ); + &ctl->sg,1 ,DMA_MEM_TO_DEV ,DMA_PREP_INTERRUPT );if (!ctl->adesc)return NETDEV_TX_BUSY ;
@@ -571,8 +570,7 @@ static int __ks8842_start_new_rx_dma(struct net_device *netdev)sg_dma_len (sg) =DMA_BUFFER_SIZE ; ctl->adesc =dmaengine_prep_slave_sg (ctl->chan, - sg,1 ,DMA_DEV_TO_MEM , -DMA_PREP_INTERRUPT |DMA_COMPL_SKIP_SRC_UNMAP ); + sg,1 ,DMA_DEV_TO_MEM ,DMA_PREP_INTERRUPT );if (!ctl->adesc) goto out;
drivers/ntb/ntb_transport.c +1 -2
@@ -1072,8 +1072,7 @@ static void ntb_async_rx(struct ntb_queue_entry *entry, void *offset, unmap->from_cnt =1 ; - flags =DMA_COMPL_SKIP_SRC_UNMAP |DMA_COMPL_SKIP_DEST_UNMAP | -DMA_PREP_INTERRUPT ; + flags =DMA_PREP_INTERRUPT ; txd = device->device_prep_dma_memcpy (chan, unmap->addr[1 ], unmap->addr[0 ], len, flags);if (!txd)
drivers/spi/spi-dw-mid.c +2 -2
@@ -150,7 +150,7 @@ static int mid_spi_dma_transfer(struct dw_spi *dws, int cs_change) &dws->tx_sgl,1 ,DMA_MEM_TO_DEV , - DMA_PREP_INTERRUPT | DMA_COMPL_SKIP_DEST_UNMAP); + DMA_PREP_INTERRUPT); txdesc->callback = dw_spi_dma_done; txdesc->callback_param = dws;
@@ -173,7 +173,7 @@ static int mid_spi_dma_transfer(struct dw_spi *dws, int cs_change) &dws->rx_sgl,1 ,DMA_DEV_TO_MEM , - DMA_PREP_INTERRUPT | DMA_COMPL_SKIP_DEST_UNMAP); + DMA_PREP_INTERRUPT); rxdesc->callback = dw_spi_dma_done; rxdesc->callback_param = dws;
include/linux/dmaengine.h +4 -14
@@ -171,12 +171,6 @@ struct dma_interleaved_template {* @DMA_CTRL_ACK - if clear, the descriptor cannot be reused until the client * acknowledges receipt, i.e. has has a chance to establish any dependency * chains -* @DMA_COMPL_SKIP_SRC_UNMAP - set to disable dma-unmapping the source buffer(s) -* @DMA_COMPL_SKIP_DEST_UNMAP - set to disable dma-unmapping the destination(s) -* @DMA_COMPL_SRC_UNMAP_SINGLE - set to do the source dma-unmapping as single -* (if not set, do the source dma-unmapping as page) -* @DMA_COMPL_DEST_UNMAP_SINGLE - set to do the destination dma-unmapping as single -* (if not set, do the destination dma-unmapping as page) * @DMA_PREP_PQ_DISABLE_P - prevent generation of P while generating Q * @DMA_PREP_PQ_DISABLE_Q - prevent generation of Q while generating P * @DMA_PREP_CONTINUE - indicate to a driver that it is reusing buffers as
@@ -188,14 +182,10 @@ struct dma_interleaved_template {enum dma_ctrl_flags {DMA_PREP_INTERRUPT = (1 <<0 ),DMA_CTRL_ACK = (1 <<1 ), -DMA_COMPL_SKIP_SRC_UNMAP = (1 <<2 ), -DMA_COMPL_SKIP_DEST_UNMAP = (1 <<3 ), -DMA_COMPL_SRC_UNMAP_SINGLE = (1 <<4 ), -DMA_COMPL_DEST_UNMAP_SINGLE = (1 <<5 ), -DMA_PREP_PQ_DISABLE_P = (1 <<6 ), -DMA_PREP_PQ_DISABLE_Q = (1 <<7 ), -DMA_PREP_CONTINUE = (1 <<8 ), -DMA_PREP_FENCE = (1 <<9 ), +DMA_PREP_PQ_DISABLE_P = (1 <<2 ), +DMA_PREP_PQ_DISABLE_Q = (1 <<3 ), +DMA_PREP_CONTINUE = (1 <<4 ), +DMA_PREP_FENCE = (1 <<5 ), };/**
Signature · 1 line
1.8.2.3
PATCH v2 13/13 dmaengine: remove DMA unmap flags
From: Bartlomiej Zolnierkiewicz <[email protected]>
Remove no longer needed DMA unmap flags:
- DMA_COMPL_SKIP_SRC_UNMAP
- DMA_COMPL_SKIP_DEST_UNMAP
- DMA_COMPL_SRC_UNMAP_SINGLE
- DMA_COMPL_DEST_UNMAP_SINGLE
---
Resend to:
1/ add it to the new dmaengine patchwork
2/ cc maintainers of affected drivers
3/ fixup some mail addresses
crypto/async_tx/async_memcpy.c | 3 +-- crypto/async_tx/async_pq.c | 1 - crypto/async_tx/async_raid6_recov.c | 8 ++------ crypto/async_tx/async_xor.c | 6 ++---- drivers/ata/pata_arasan_cf.c | 3 +-- drivers/dma/dmaengine.c | 3 +-- drivers/dma/dmatest.c | 3 +-- drivers/dma/ioat/dma.c | 3 +-- drivers/dma/ioat/dma_v3.c | 12 +++--------- drivers/media/platform/m2m-deinterlace.c | 3 +-- drivers/media/platform/timblogiw.c | 2 +- drivers/misc/carma/carma-fpga.c | 3 +-- drivers/mtd/nand/atmel_nand.c | 3 +-- drivers/mtd/nand/fsmc_nand.c | 2 -- drivers/net/ethernet/micrel/ks8842.c | 6 ++---- drivers/ntb/ntb_transport.c | 3 +-- drivers/spi/spi-dw-mid.c | 4 ++-- include/linux/dmaengine.h | 18 ++++-------------- 18 files changed, 25 insertions(+), 61 deletions(-)
crypto/async_tx/async_memcpy.c +1 -2
@@ -56,8 +56,7 @@ async_memcpy(struct page *dest, struct page *src, unsigned int dest_offset, unmap =dmaengine_get_unmap_data (device->dev,2 ,GFP_NOIO );if (unmap &&is_dma_copy_aligned (device, src_offset, dest_offset, len)) { -unsigned long dma_prep_flags =DMA_COMPL_SKIP_SRC_UNMAP | -DMA_COMPL_SKIP_DEST_UNMAP ; +unsigned long dma_prep_flags =0 ;if (submit->cb_fn) dma_prep_flags |=DMA_PREP_INTERRUPT ;
crypto/async_tx/async_pq.c +0 -1
@@ -62,7 +62,6 @@ do_async_gen_syndrome(struct dma_chan *chan,dma_addr_t dma_dest[2 ];int src_off =0 ; - dma_flags |=DMA_COMPL_SKIP_SRC_UNMAP |DMA_COMPL_SKIP_DEST_UNMAP ;if (submit->flags &ASYNC_TX_FENCE ) dma_flags |=DMA_PREP_FENCE ;
crypto/async_tx/async_raid6_recov.c +2 -6
@@ -47,9 +47,7 @@ async_sum_product(struct page *dest, struct page **srcs, unsigned char *coef,struct device *dev = dma->dev;dma_addr_t pq[2 ];struct dma_async_tx_descriptor *tx; -enum dma_ctrl_flags dma_flags =DMA_COMPL_SKIP_SRC_UNMAP | -DMA_COMPL_SKIP_DEST_UNMAP | -DMA_PREP_PQ_DISABLE_P ; +enum dma_ctrl_flags dma_flags =DMA_PREP_PQ_DISABLE_P ;if (submit->flags &ASYNC_TX_FENCE ) dma_flags |=DMA_PREP_FENCE ;
@@ -113,9 +111,7 @@ async_mult(struct page *dest, struct page *src, u8 coef, size_t len,dma_addr_t dma_dest[2 ];struct device *dev = dma->dev;struct dma_async_tx_descriptor *tx; -enum dma_ctrl_flags dma_flags =DMA_COMPL_SKIP_SRC_UNMAP | -DMA_COMPL_SKIP_DEST_UNMAP | -DMA_PREP_PQ_DISABLE_P ; +enum dma_ctrl_flags dma_flags =DMA_PREP_PQ_DISABLE_P ;if (submit->flags &ASYNC_TX_FENCE ) dma_flags |=DMA_PREP_FENCE ;
crypto/async_tx/async_xor.c +2 -4
@@ -41,7 +41,7 @@ do_async_xor(struct dma_chan *chan, struct dmaengine_unmap_data *unmap,dma_async_tx_callback cb_fn_orig = submit->cb_fn;void *cb_param_orig = submit->cb_param;enum async_tx_flags flags_orig = submit->flags; -enum dma_ctrl_flags dma_flags; +enum dma_ctrl_flags dma_flags =0 ;int src_cnt = unmap->to_cnt;int xor_src_cnt;dma_addr_t dma_dest = unmap->addr[unmap->to_cnt];
@@ -55,7 +55,6 @@ do_async_xor(struct dma_chan *chan, struct dmaengine_unmap_data *unmap,/* if we are submitting additional xors, leave the chain open * and clear the callback parameters */ - dma_flags =DMA_COMPL_SKIP_SRC_UNMAP |DMA_COMPL_SKIP_DEST_UNMAP ;if (src_cnt > xor_src_cnt) { submit->flags &= ~ASYNC_TX_ACK ; submit->flags |=ASYNC_TX_FENCE ;
@@ -284,8 +283,7 @@ async_xor_val(struct page *dest, struct page **src_list, unsigned int offset,if (unmap && src_cnt <= device->max_xor &&is_dma_xor_aligned (device, offset,0 , len)) { -unsigned long dma_prep_flags =DMA_COMPL_SKIP_SRC_UNMAP | -DMA_COMPL_SKIP_DEST_UNMAP ; +unsigned long dma_prep_flags =0 ;int i;pr_debug ("%s: (async) len: %zu\n" , __func__, len);
drivers/ata/pata_arasan_cf.c +1 -2
@@ -396,8 +396,7 @@ dma_xfer(struct arasan_cf_dev *acdev, dma_addr_t src, dma_addr_t dest, u32 len)struct dma_async_tx_descriptor *tx;struct dma_chan *chan = acdev->dma_chan;dma_cookie_t cookie; -unsigned long flags =DMA_PREP_INTERRUPT |DMA_COMPL_SKIP_SRC_UNMAP | -DMA_COMPL_SKIP_DEST_UNMAP ; +unsigned long flags =DMA_PREP_INTERRUPT ;int ret =0 ; tx = chan->device->device_prep_dma_memcpy (chan, dest, src, len, flags);
drivers/dma/dmaengine.c +1 -2
@@ -1065,8 +1065,7 @@ dma_async_memcpy_pg_to_pg(struct dma_chan *chan, struct page *dest_pg, unmap->addr[1 ] =dma_map_page (dev->dev, dest_pg, dest_off, len,DMA_FROM_DEVICE ); unmap->len = len; - flags =DMA_CTRL_ACK |DMA_COMPL_SKIP_SRC_UNMAP | -DMA_COMPL_SKIP_DEST_UNMAP ; + flags =DMA_CTRL_ACK ; tx = dev->device_prep_dma_memcpy (chan, unmap->addr[1 ], unmap->addr[0 ], len, flags);
drivers/dma/dmatest.c +1 -2
@@ -599,8 +599,7 @@ static int dmatest_func(void *data)/* * src and dst buffers are freed by ourselves below */ - flags =DMA_CTRL_ACK |DMA_PREP_INTERRUPT | -DMA_COMPL_SKIP_SRC_UNMAP |DMA_COMPL_SKIP_DEST_UNMAP ; + flags =DMA_CTRL_ACK |DMA_PREP_INTERRUPT ;while (!kthread_should_stop () && !(params->iterations && total_tests >= params->iterations)) {
drivers/dma/ioat/dma.c +1 -2
@@ -818,8 +818,7 @@ int ioat_dma_self_test(struct ioatdma_device *device) dma_src =dma_map_single (dev, src,IOAT_TEST_SIZE ,DMA_TO_DEVICE ); dma_dest =dma_map_single (dev, dest,IOAT_TEST_SIZE ,DMA_FROM_DEVICE ); - flags =DMA_COMPL_SKIP_SRC_UNMAP |DMA_COMPL_SKIP_DEST_UNMAP | -DMA_PREP_INTERRUPT ; + flags =DMA_PREP_INTERRUPT ; tx = device->common.device_prep_dma_memcpy (dma_chan, dma_dest, dma_src,IOAT_TEST_SIZE , flags);if (!tx) {
drivers/dma/ioat/dma_v3.c +3 -9
@@ -1279,9 +1279,7 @@ static int ioat_xor_val_self_test(struct ioatdma_device *device) DMA_TO_DEVICE); tx = dma->device_prep_dma_xor (dma_chan, dest_dma, dma_srcs,IOAT_NUM_SRC_TEST ,PAGE_SIZE , -DMA_PREP_INTERRUPT | -DMA_COMPL_SKIP_SRC_UNMAP | -DMA_COMPL_SKIP_DEST_UNMAP ); +DMA_PREP_INTERRUPT );if (!tx) {dev_err (dev,"Self-test xor prep failed\n" );
@@ -1342,9 +1340,7 @@ static int ioat_xor_val_self_test(struct ioatdma_device *device) DMA_TO_DEVICE); tx = dma->device_prep_dma_xor_val (dma_chan, dma_srcs,IOAT_NUM_SRC_TEST +1 ,PAGE_SIZE , - &xor_val_result,DMA_PREP_INTERRUPT | -DMA_COMPL_SKIP_SRC_UNMAP | -DMA_COMPL_SKIP_DEST_UNMAP ); + &xor_val_result,DMA_PREP_INTERRUPT );if (!tx) {dev_err (dev,"Self-test zero prep failed\n" ); err = -ENODEV ;
@@ -1389,9 +1385,7 @@ static int ioat_xor_val_self_test(struct ioatdma_device *device) DMA_TO_DEVICE); tx = dma->device_prep_dma_xor_val (dma_chan, dma_srcs,IOAT_NUM_SRC_TEST +1 ,PAGE_SIZE , - &xor_val_result,DMA_PREP_INTERRUPT | -DMA_COMPL_SKIP_SRC_UNMAP | -DMA_COMPL_SKIP_DEST_UNMAP ); + &xor_val_result,DMA_PREP_INTERRUPT );if (!tx) {dev_err (dev,"Self-test 2nd zero prep failed\n" ); err = -ENODEV ;
drivers/media/platform/m2m-deinterlace.c +1 -2
@@ -341,8 +341,7 @@ static void deinterlace_issue_dma(struct deinterlace_ctx *ctx, int op, ctx->xt->dir =DMA_MEM_TO_MEM ; ctx->xt->src_sgl = false; ctx->xt->dst_sgl = true; - flags =DMA_CTRL_ACK |DMA_PREP_INTERRUPT | -DMA_COMPL_SKIP_DEST_UNMAP |DMA_COMPL_SKIP_SRC_UNMAP ; + flags =DMA_CTRL_ACK |DMA_PREP_INTERRUPT ; tx = dmadev->device_prep_interleaved_dma (chan, ctx->xt, flags);if (tx ==NULL ) {
drivers/media/platform/timblogiw.c +1 -1
@@ -565,7 +565,7 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) desc =dmaengine_prep_slave_sg (fh->chan, buf->sg, sg_elems,DMA_DEV_TO_MEM , -DMA_PREP_INTERRUPT |DMA_COMPL_SKIP_SRC_UNMAP ); +DMA_PREP_INTERRUPT );if (!desc) {spin_lock_irq (&fh->queue_lock);list_del_init (&vb->queue);
drivers/misc/carma/carma-fpga.c +1 -2
@@ -631,8 +631,7 @@ static int data_submit_dma(struct fpga_device *priv, struct data_buf *buf)struct dma_async_tx_descriptor *tx;dma_cookie_t cookie;dma_addr_t dst, src; -unsigned long dma_flags =DMA_COMPL_SKIP_DEST_UNMAP | -DMA_COMPL_SKIP_SRC_UNMAP ; +unsigned long dma_flags =0 ; dst_sg = buf->vb.sglist; dst_nents = buf->vb.sglen;
drivers/mtd/nand/atmel_nand.c +1 -2
@@ -375,8 +375,7 @@ static int atmel_nand_dma_op(struct mtd_info *mtd, void *buf, int len, dma_dev = host->dma_chan->device; - flags =DMA_CTRL_ACK |DMA_PREP_INTERRUPT |DMA_COMPL_SKIP_SRC_UNMAP | -DMA_COMPL_SKIP_DEST_UNMAP ; + flags =DMA_CTRL_ACK |DMA_PREP_INTERRUPT ; phys_addr =dma_map_single (dma_dev->dev, p, len, dir);if (dma_mapping_error (dma_dev->dev, phys_addr)) {
drivers/mtd/nand/fsmc_nand.c +0 -2
@@ -573,8 +573,6 @@ static int dma_xfer(struct fsmc_nand_data *host, void *buffer, int len, dma_dev = chan->device; dma_addr =dma_map_single (dma_dev->dev, buffer, len, direction); - flags |=DMA_COMPL_SKIP_SRC_UNMAP |DMA_COMPL_SKIP_DEST_UNMAP ; -if (direction ==DMA_TO_DEVICE ) { dma_src = dma_addr; dma_dst = host->data_pa;
drivers/net/ethernet/micrel/ks8842.c +2 -4
@@ -459,8 +459,7 @@ static int ks8842_tx_frame_dma(struct sk_buff *skb, struct net_device *netdev)sg_dma_len (&ctl->sg) +=4 -sg_dma_len (&ctl->sg) %4 ; ctl->adesc =dmaengine_prep_slave_sg (ctl->chan, - &ctl->sg,1 ,DMA_MEM_TO_DEV , -DMA_PREP_INTERRUPT |DMA_COMPL_SKIP_SRC_UNMAP ); + &ctl->sg,1 ,DMA_MEM_TO_DEV ,DMA_PREP_INTERRUPT );if (!ctl->adesc)return NETDEV_TX_BUSY ;
@@ -571,8 +570,7 @@ static int __ks8842_start_new_rx_dma(struct net_device *netdev)sg_dma_len (sg) =DMA_BUFFER_SIZE ; ctl->adesc =dmaengine_prep_slave_sg (ctl->chan, - sg,1 ,DMA_DEV_TO_MEM , -DMA_PREP_INTERRUPT |DMA_COMPL_SKIP_SRC_UNMAP ); + sg,1 ,DMA_DEV_TO_MEM ,DMA_PREP_INTERRUPT );if (!ctl->adesc) goto out;
drivers/ntb/ntb_transport.c +1 -2
@@ -1072,8 +1072,7 @@ static void ntb_async_rx(struct ntb_queue_entry *entry, void *offset, unmap->from_cnt =1 ; - flags =DMA_COMPL_SKIP_SRC_UNMAP |DMA_COMPL_SKIP_DEST_UNMAP | -DMA_PREP_INTERRUPT ; + flags =DMA_PREP_INTERRUPT ; txd = device->device_prep_dma_memcpy (chan, unmap->addr[1 ], unmap->addr[0 ], len, flags);if (!txd)
drivers/spi/spi-dw-mid.c +2 -2
@@ -150,7 +150,7 @@ static int mid_spi_dma_transfer(struct dw_spi *dws, int cs_change) &dws->tx_sgl,1 ,DMA_MEM_TO_DEV , - DMA_PREP_INTERRUPT | DMA_COMPL_SKIP_DEST_UNMAP); + DMA_PREP_INTERRUPT); txdesc->callback = dw_spi_dma_done; txdesc->callback_param = dws;
@@ -173,7 +173,7 @@ static int mid_spi_dma_transfer(struct dw_spi *dws, int cs_change) &dws->rx_sgl,1 ,DMA_DEV_TO_MEM , - DMA_PREP_INTERRUPT | DMA_COMPL_SKIP_DEST_UNMAP); + DMA_PREP_INTERRUPT); rxdesc->callback = dw_spi_dma_done; rxdesc->callback_param = dws;
include/linux/dmaengine.h +4 -14
@@ -171,12 +171,6 @@ struct dma_interleaved_template {* @DMA_CTRL_ACK - if clear, the descriptor cannot be reused until the client * acknowledges receipt, i.e. has has a chance to establish any dependency * chains -* @DMA_COMPL_SKIP_SRC_UNMAP - set to disable dma-unmapping the source buffer(s) -* @DMA_COMPL_SKIP_DEST_UNMAP - set to disable dma-unmapping the destination(s) -* @DMA_COMPL_SRC_UNMAP_SINGLE - set to do the source dma-unmapping as single -* (if not set, do the source dma-unmapping as page) -* @DMA_COMPL_DEST_UNMAP_SINGLE - set to do the destination dma-unmapping as single -* (if not set, do the destination dma-unmapping as page) * @DMA_PREP_PQ_DISABLE_P - prevent generation of P while generating Q * @DMA_PREP_PQ_DISABLE_Q - prevent generation of Q while generating P * @DMA_PREP_CONTINUE - indicate to a driver that it is reusing buffers as
@@ -188,14 +182,10 @@ struct dma_interleaved_template {enum dma_ctrl_flags {DMA_PREP_INTERRUPT = (1 <<0 ),DMA_CTRL_ACK = (1 <<1 ), -DMA_COMPL_SKIP_SRC_UNMAP = (1 <<2 ), -DMA_COMPL_SKIP_DEST_UNMAP = (1 <<3 ), -DMA_COMPL_SRC_UNMAP_SINGLE = (1 <<4 ), -DMA_COMPL_DEST_UNMAP_SINGLE = (1 <<5 ), -DMA_PREP_PQ_DISABLE_P = (1 <<6 ), -DMA_PREP_PQ_DISABLE_Q = (1 <<7 ), -DMA_PREP_CONTINUE = (1 <<8 ), -DMA_PREP_FENCE = (1 <<9 ), +DMA_PREP_PQ_DISABLE_P = (1 <<2 ), +DMA_PREP_PQ_DISABLE_Q = (1 <<3 ), +DMA_PREP_CONTINUE = (1 <<4 ), +DMA_PREP_FENCE = (1 <<5 ), };/**
Re: [PATCH v2 13/13] dmaengine: remove DMA unmap flags
Quoted 8 lines · Dan Williams
From: Bartlomiej Zolnierkiewicz <[email protected]>
Remove no longer needed DMA unmap flags:
-DMA_COMPL_SKIP_SRC_UNMAP
-DMA_COMPL_SKIP_DEST_UNMAP
-DMA_COMPL_SRC_UNMAP_SINGLE
-DMA_COMPL_DEST_UNMAP_SINGLE
Quoted 6 lines
Cc Viresh Kumar <[email protected]>Cc Tejun Heo <[email protected]>Cc Vinod Koul <[email protected]>Cc Mauro Carvalho Chehab <[email protected]>Cc David Woodhouse <[email protected]>Cc Jon Mason <[email protected]>
For NTB relevant parts
Quoted 374 lines
Cc Mark Brown <[email protected]>Cc Tomasz Figa <[email protected]>Cc Dave Jiang <[email protected]>Signed-off-by Bartlomiej Zolnierkiewicz <[email protected]>Signed-off-by Kyungmin Park <[email protected]>Signed-off-by Dan Williams <[email protected]>---
Resend to:
1/ add it to the new dmaengine patchwork
2/ cc maintainers of affected drivers
3/ fixup some mail addressescrypto/async_tx/async_memcpy.c | 3 +-- crypto/async_tx/async_pq.c | 1 - crypto/async_tx/async_raid6_recov.c | 8 ++------ crypto/async_tx/async_xor.c | 6 ++---- drivers/ata/pata_arasan_cf.c | 3 +-- drivers/dma/dmaengine.c | 3 +-- drivers/dma/dmatest.c | 3 +-- drivers/dma/ioat/dma.c | 3 +-- drivers/dma/ioat/dma_v3.c | 12 +++--------- drivers/media/platform/m2m-deinterlace.c | 3 +-- drivers/media/platform/timblogiw.c | 2 +- drivers/misc/carma/carma-fpga.c | 3 +-- drivers/mtd/nand/atmel_nand.c | 3 +-- drivers/mtd/nand/fsmc_nand.c | 2 -- drivers/net/ethernet/micrel/ks8842.c | 6 ++---- drivers/ntb/ntb_transport.c | 3 +-- drivers/spi/spi-dw-mid.c | 4 ++-- include/linux/dmaengine.h | 18 ++++-------------- 18 files changed, 25 insertions(+), 61 deletions(-)crypto/async_tx/async_memcpy.c +1
-2@@ -56,8 +56,7 @@ async_memcpy(struct page *dest, struct page *src, unsigned int dest_offset, unmap =dmaengine_get_unmap_data (device->dev,2 ,GFP_NOIO );if (unmap &&is_dma_copy_aligned (device, src_offset, dest_offset, len)) { -unsigned long dma_prep_flags =DMA_COMPL_SKIP_SRC_UNMAP | -DMA_COMPL_SKIP_DEST_UNMAP ; +unsigned long dma_prep_flags =0 ;if (submit->cb_fn) dma_prep_flags |=DMA_PREP_INTERRUPT ;crypto/async_tx/async_pq.c +0
-1@@ -62,7 +62,6 @@ do_async_gen_syndrome(struct dma_chan *chan,dma_addr_t dma_dest[2 ];int src_off =0 ; - dma_flags |=DMA_COMPL_SKIP_SRC_UNMAP |DMA_COMPL_SKIP_DEST_UNMAP ;if (submit->flags &ASYNC_TX_FENCE ) dma_flags |=DMA_PREP_FENCE ;crypto/async_tx/async_raid6_recov.c +2
-6@@ -47,9 +47,7 @@ async_sum_product(struct page *dest, struct page **srcs, unsigned char *coef,struct device *dev = dma->dev;dma_addr_t pq[2 ];struct dma_async_tx_descriptor *tx; -enum dma_ctrl_flags dma_flags =DMA_COMPL_SKIP_SRC_UNMAP | -DMA_COMPL_SKIP_DEST_UNMAP | -DMA_PREP_PQ_DISABLE_P ; +enum dma_ctrl_flags dma_flags =DMA_PREP_PQ_DISABLE_P ;if (submit->flags &ASYNC_TX_FENCE ) dma_flags |=DMA_PREP_FENCE ;@@ -113,9 +111,7 @@ async_mult(struct page *dest, struct page *src, u8 coef, size_t len,dma_addr_t dma_dest[2 ];struct device *dev = dma->dev;struct dma_async_tx_descriptor *tx; -enum dma_ctrl_flags dma_flags =DMA_COMPL_SKIP_SRC_UNMAP | -DMA_COMPL_SKIP_DEST_UNMAP | -DMA_PREP_PQ_DISABLE_P ; +enum dma_ctrl_flags dma_flags =DMA_PREP_PQ_DISABLE_P ;if (submit->flags &ASYNC_TX_FENCE ) dma_flags |=DMA_PREP_FENCE ;crypto/async_tx/async_xor.c +2
-4@@ -41,7 +41,7 @@ do_async_xor(struct dma_chan *chan, struct dmaengine_unmap_data *unmap,dma_async_tx_callback cb_fn_orig = submit->cb_fn;void *cb_param_orig = submit->cb_param;enum async_tx_flags flags_orig = submit->flags; -enum dma_ctrl_flags dma_flags; +enum dma_ctrl_flags dma_flags =0 ;int src_cnt = unmap->to_cnt;int xor_src_cnt;dma_addr_t dma_dest = unmap->addr[unmap->to_cnt];@@ -55,7 +55,6 @@ do_async_xor(struct dma_chan *chan, struct dmaengine_unmap_data *unmap,/* if we are submitting additional xors, leave the chain open * and clear the callback parameters */ - dma_flags =DMA_COMPL_SKIP_SRC_UNMAP |DMA_COMPL_SKIP_DEST_UNMAP ;if (src_cnt > xor_src_cnt) { submit->flags &= ~ASYNC_TX_ACK ; submit->flags |=ASYNC_TX_FENCE ;@@ -284,8 +283,7 @@ async_xor_val(struct page *dest, struct page **src_list, unsigned int offset,if (unmap && src_cnt <= device->max_xor &&is_dma_xor_aligned (device, offset,0 , len)) { -unsigned long dma_prep_flags =DMA_COMPL_SKIP_SRC_UNMAP | -DMA_COMPL_SKIP_DEST_UNMAP ; +unsigned long dma_prep_flags =0 ;int i;pr_debug ("%s: (async) len: %zu\n" , __func__, len);drivers/ata/pata_arasan_cf.c +1
-2@@ -396,8 +396,7 @@ dma_xfer(struct arasan_cf_dev *acdev, dma_addr_t src, dma_addr_t dest, u32 len)struct dma_async_tx_descriptor *tx;struct dma_chan *chan = acdev->dma_chan;dma_cookie_t cookie; -unsigned long flags =DMA_PREP_INTERRUPT |DMA_COMPL_SKIP_SRC_UNMAP | -DMA_COMPL_SKIP_DEST_UNMAP ; +unsigned long flags =DMA_PREP_INTERRUPT ;int ret =0 ; tx = chan->device->device_prep_dma_memcpy (chan, dest, src, len, flags);drivers/dma/dmaengine.c +1
-2@@ -1065,8 +1065,7 @@ dma_async_memcpy_pg_to_pg(struct dma_chan *chan, struct page *dest_pg, unmap->addr[1 ] =dma_map_page (dev->dev, dest_pg, dest_off, len,DMA_FROM_DEVICE ); unmap->len = len; - flags =DMA_CTRL_ACK |DMA_COMPL_SKIP_SRC_UNMAP | -DMA_COMPL_SKIP_DEST_UNMAP ; + flags =DMA_CTRL_ACK ; tx = dev->device_prep_dma_memcpy (chan, unmap->addr[1 ], unmap->addr[0 ], len, flags);drivers/dma/dmatest.c +1
-2@@ -599,8 +599,7 @@ static int dmatest_func(void *data)/* * src and dst buffers are freed by ourselves below */ - flags =DMA_CTRL_ACK |DMA_PREP_INTERRUPT | -DMA_COMPL_SKIP_SRC_UNMAP |DMA_COMPL_SKIP_DEST_UNMAP ; + flags =DMA_CTRL_ACK |DMA_PREP_INTERRUPT ;while (!kthread_should_stop () && !(params->iterations && total_tests >= params->iterations)) {drivers/dma/ioat/dma.c +1
-2@@ -818,8 +818,7 @@ int ioat_dma_self_test(struct ioatdma_device *device) dma_src =dma_map_single (dev, src,IOAT_TEST_SIZE ,DMA_TO_DEVICE ); dma_dest =dma_map_single (dev, dest,IOAT_TEST_SIZE ,DMA_FROM_DEVICE ); - flags =DMA_COMPL_SKIP_SRC_UNMAP |DMA_COMPL_SKIP_DEST_UNMAP | -DMA_PREP_INTERRUPT ; + flags =DMA_PREP_INTERRUPT ; tx = device->common.device_prep_dma_memcpy (dma_chan, dma_dest, dma_src,IOAT_TEST_SIZE , flags);if (!tx) {drivers/dma/ioat/dma_v3.c +3
-9@@ -1279,9 +1279,7 @@ static int ioat_xor_val_self_test(struct ioatdma_device *device) DMA_TO_DEVICE); tx = dma->device_prep_dma_xor (dma_chan, dest_dma, dma_srcs,IOAT_NUM_SRC_TEST ,PAGE_SIZE , -DMA_PREP_INTERRUPT | -DMA_COMPL_SKIP_SRC_UNMAP | -DMA_COMPL_SKIP_DEST_UNMAP ); +DMA_PREP_INTERRUPT );if (!tx) {dev_err (dev,"Self-test xor prep failed\n" );@@ -1342,9 +1340,7 @@ static int ioat_xor_val_self_test(struct ioatdma_device *device) DMA_TO_DEVICE); tx = dma->device_prep_dma_xor_val (dma_chan, dma_srcs,IOAT_NUM_SRC_TEST +1 ,PAGE_SIZE , - &xor_val_result,DMA_PREP_INTERRUPT | -DMA_COMPL_SKIP_SRC_UNMAP | -DMA_COMPL_SKIP_DEST_UNMAP ); + &xor_val_result,DMA_PREP_INTERRUPT );if (!tx) {dev_err (dev,"Self-test zero prep failed\n" ); err = -ENODEV ;@@ -1389,9 +1385,7 @@ static int ioat_xor_val_self_test(struct ioatdma_device *device) DMA_TO_DEVICE); tx = dma->device_prep_dma_xor_val (dma_chan, dma_srcs,IOAT_NUM_SRC_TEST +1 ,PAGE_SIZE , - &xor_val_result,DMA_PREP_INTERRUPT | -DMA_COMPL_SKIP_SRC_UNMAP | -DMA_COMPL_SKIP_DEST_UNMAP ); + &xor_val_result,DMA_PREP_INTERRUPT );if (!tx) {dev_err (dev,"Self-test 2nd zero prep failed\n" ); err = -ENODEV ;drivers/media/platform/m2m-deinterlace.c +1
-2@@ -341,8 +341,7 @@ static void deinterlace_issue_dma(struct deinterlace_ctx *ctx, int op, ctx->xt->dir =DMA_MEM_TO_MEM ; ctx->xt->src_sgl = false; ctx->xt->dst_sgl = true; - flags =DMA_CTRL_ACK |DMA_PREP_INTERRUPT | -DMA_COMPL_SKIP_DEST_UNMAP |DMA_COMPL_SKIP_SRC_UNMAP ; + flags =DMA_CTRL_ACK |DMA_PREP_INTERRUPT ; tx = dmadev->device_prep_interleaved_dma (chan, ctx->xt, flags);if (tx ==NULL ) {drivers/media/platform/timblogiw.c +1
-1@@ -565,7 +565,7 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) desc =dmaengine_prep_slave_sg (fh->chan, buf->sg, sg_elems,DMA_DEV_TO_MEM , -DMA_PREP_INTERRUPT |DMA_COMPL_SKIP_SRC_UNMAP ); +DMA_PREP_INTERRUPT );if (!desc) {spin_lock_irq (&fh->queue_lock);list_del_init (&vb->queue);drivers/misc/carma/carma-fpga.c +1
-2@@ -631,8 +631,7 @@ static int data_submit_dma(struct fpga_device *priv, struct data_buf *buf)struct dma_async_tx_descriptor *tx;dma_cookie_t cookie;dma_addr_t dst, src; -unsigned long dma_flags =DMA_COMPL_SKIP_DEST_UNMAP | -DMA_COMPL_SKIP_SRC_UNMAP ; +unsigned long dma_flags =0 ; dst_sg = buf->vb.sglist; dst_nents = buf->vb.sglen;drivers/mtd/nand/atmel_nand.c +1
-2@@ -375,8 +375,7 @@ static int atmel_nand_dma_op(struct mtd_info *mtd, void *buf, int len, dma_dev = host->dma_chan->device; - flags =DMA_CTRL_ACK |DMA_PREP_INTERRUPT |DMA_COMPL_SKIP_SRC_UNMAP | -DMA_COMPL_SKIP_DEST_UNMAP ; + flags =DMA_CTRL_ACK |DMA_PREP_INTERRUPT ; phys_addr =dma_map_single (dma_dev->dev, p, len, dir);if (dma_mapping_error (dma_dev->dev, phys_addr)) {drivers/mtd/nand/fsmc_nand.c +0
-2@@ -573,8 +573,6 @@ static int dma_xfer(struct fsmc_nand_data *host, void *buffer, int len, dma_dev = chan->device; dma_addr =dma_map_single (dma_dev->dev, buffer, len, direction); - flags |=DMA_COMPL_SKIP_SRC_UNMAP |DMA_COMPL_SKIP_DEST_UNMAP ; -if (direction ==DMA_TO_DEVICE ) { dma_src = dma_addr; dma_dst = host->data_pa;drivers/net/ethernet/micrel/ks8842.c +2
-4@@ -459,8 +459,7 @@ static int ks8842_tx_frame_dma(struct sk_buff *skb, struct net_device *netdev)sg_dma_len (&ctl->sg) +=4 -sg_dma_len (&ctl->sg) %4 ; ctl->adesc =dmaengine_prep_slave_sg (ctl->chan, - &ctl->sg,1 ,DMA_MEM_TO_DEV , -DMA_PREP_INTERRUPT |DMA_COMPL_SKIP_SRC_UNMAP ); + &ctl->sg,1 ,DMA_MEM_TO_DEV ,DMA_PREP_INTERRUPT );if (!ctl->adesc)return NETDEV_TX_BUSY ;@@ -571,8 +570,7 @@ static int __ks8842_start_new_rx_dma(struct net_device *netdev)sg_dma_len (sg) =DMA_BUFFER_SIZE ; ctl->adesc =dmaengine_prep_slave_sg (ctl->chan, - sg,1 ,DMA_DEV_TO_MEM , -DMA_PREP_INTERRUPT |DMA_COMPL_SKIP_SRC_UNMAP ); + sg,1 ,DMA_DEV_TO_MEM ,DMA_PREP_INTERRUPT );if (!ctl->adesc) goto out;drivers/ntb/ntb_transport.c +1
-2@@ -1072,8 +1072,7 @@ static void ntb_async_rx(struct ntb_queue_entry *entry, void *offset, unmap->from_cnt =1 ; - flags =DMA_COMPL_SKIP_SRC_UNMAP |DMA_COMPL_SKIP_DEST_UNMAP | -DMA_PREP_INTERRUPT ; + flags =DMA_PREP_INTERRUPT ; txd = device->device_prep_dma_memcpy (chan, unmap->addr[1 ], unmap->addr[0 ], len, flags);if (!txd)drivers/spi/spi-dw-mid.c +2
-2@@ -150,7 +150,7 @@ static int mid_spi_dma_transfer(struct dw_spi *dws, int cs_change) &dws->tx_sgl,1 ,DMA_MEM_TO_DEV , - DMA_PREP_INTERRUPT | DMA_COMPL_SKIP_DEST_UNMAP); + DMA_PREP_INTERRUPT); txdesc->callback = dw_spi_dma_done; txdesc->callback_param = dws;@@ -173,7 +173,7 @@ static int mid_spi_dma_transfer(struct dw_spi *dws, int cs_change) &dws->rx_sgl,1 ,DMA_DEV_TO_MEM , - DMA_PREP_INTERRUPT | DMA_COMPL_SKIP_DEST_UNMAP); + DMA_PREP_INTERRUPT); rxdesc->callback = dw_spi_dma_done; rxdesc->callback_param = dws;include/linux/dmaengine.h +4
-14@@ -171,12 +171,6 @@ struct dma_interleaved_template {* @DMA_CTRL_ACK - if clear, the descriptor cannot be reused until the client * acknowledges receipt, i.e. has has a chance to establish any dependency * chains -* @DMA_COMPL_SKIP_SRC_UNMAP - set to disable dma-unmapping the source buffer(s) -* @DMA_COMPL_SKIP_DEST_UNMAP - set to disable dma-unmapping the destination(s) -* @DMA_COMPL_SRC_UNMAP_SINGLE - set to do the source dma-unmapping as single -* (if not set, do the source dma-unmapping as page) -* @DMA_COMPL_DEST_UNMAP_SINGLE - set to do the destination dma-unmapping as single -* (if not set, do the destination dma-unmapping as page) * @DMA_PREP_PQ_DISABLE_P - prevent generation of P while generating Q * @DMA_PREP_PQ_DISABLE_Q - prevent generation of Q while generating P * @DMA_PREP_CONTINUE - indicate to a driver that it is reusing buffers as @@ -188,14 +182,10 @@ struct dma_interleaved_template {enum dma_ctrl_flags {DMA_PREP_INTERRUPT = (1 <<0 ),DMA_CTRL_ACK = (1 <<1 ), -DMA_COMPL_SKIP_SRC_UNMAP = (1 <<2 ), -DMA_COMPL_SKIP_DEST_UNMAP = (1 <<3 ), -DMA_COMPL_SRC_UNMAP_SINGLE = (1 <<4 ), -DMA_COMPL_DEST_UNMAP_SINGLE = (1 <<5 ), -DMA_PREP_PQ_DISABLE_P = (1 <<6 ), -DMA_PREP_PQ_DISABLE_Q = (1 <<7 ), -DMA_PREP_CONTINUE = (1 <<8 ), -DMA_PREP_FENCE = (1 <<9 ), +DMA_PREP_PQ_DISABLE_P = (1 <<2 ), +DMA_PREP_PQ_DISABLE_Q = (1 <<3 ), +DMA_PREP_CONTINUE = (1 <<4 ), +DMA_PREP_FENCE = (1 <<5 ), };/**
Re: [PATCH v2 13/13] dmaengine: remove DMA unmap flags
In reply to Dan WilliamsQuoted 7 lines · Dan Williams
From: Bartlomiej Zolnierkiewicz <[email protected]>
Remove no longer needed DMA unmap flags:
-DMA_COMPL_SKIP_SRC_UNMAP
-DMA_COMPL_SKIP_DEST_UNMAP
-DMA_COMPL_SRC_UNMAP_SINGLE
-DMA_COMPL_DEST_UNMAP_SINGLE