aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/dma/mv_xor.c
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2008-12-08 15:46:00 -0500
committerDan Williams <dan.j.williams@intel.com>2008-12-08 15:46:00 -0500
commita06d568f7c5e40e34ea64881842deb8f4382babf (patch)
tree15b38b4652705b7c58bd89052c81ab91ca94cc4a /drivers/dma/mv_xor.c
parentb0b42b16ff2b90f17bc1a4308366c9beba4b276e (diff)
async_xor: dma_map destination DMA_BIDIRECTIONAL
Mapping the destination multiple times is a misuse of the dma-api. Since the destination may be reused as a source, ensure that it is only mapped once and that it is mapped bidirectionally. This appears to add ugliness on the unmap side in that it always reads back the destination address from the descriptor, but gcc can determine that dma_unmap is a nop and not emit the code that calculates its arguments. Cc: <stable@kernel.org> Cc: Saeed Bishara <saeed@marvell.com> Acked-by: Yuri Tikhonov <yur@emcraft.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/dma/mv_xor.c')
-rw-r--r--drivers/dma/mv_xor.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/drivers/dma/mv_xor.c b/drivers/dma/mv_xor.c
index 0328da020a10..bcda17426411 100644
--- a/drivers/dma/mv_xor.c
+++ b/drivers/dma/mv_xor.c
@@ -311,17 +311,26 @@ mv_xor_run_tx_complete_actions(struct mv_xor_desc_slot *desc,
311 enum dma_ctrl_flags flags = desc->async_tx.flags; 311 enum dma_ctrl_flags flags = desc->async_tx.flags;
312 u32 src_cnt; 312 u32 src_cnt;
313 dma_addr_t addr; 313 dma_addr_t addr;
314 dma_addr_t dest;
314 315
316 src_cnt = unmap->unmap_src_cnt;
317 dest = mv_desc_get_dest_addr(unmap);
315 if (!(flags & DMA_COMPL_SKIP_DEST_UNMAP)) { 318 if (!(flags & DMA_COMPL_SKIP_DEST_UNMAP)) {
316 addr = mv_desc_get_dest_addr(unmap); 319 enum dma_data_direction dir;
317 dma_unmap_page(dev, addr, len, DMA_FROM_DEVICE); 320
321 if (src_cnt > 1) /* is xor ? */
322 dir = DMA_BIDIRECTIONAL;
323 else
324 dir = DMA_FROM_DEVICE;
325 dma_unmap_page(dev, dest, len, dir);
318 } 326 }
319 327
320 if (!(flags & DMA_COMPL_SKIP_SRC_UNMAP)) { 328 if (!(flags & DMA_COMPL_SKIP_SRC_UNMAP)) {
321 src_cnt = unmap->unmap_src_cnt;
322 while (src_cnt--) { 329 while (src_cnt--) {
323 addr = mv_desc_get_src_addr(unmap, 330 addr = mv_desc_get_src_addr(unmap,
324 src_cnt); 331 src_cnt);
332 if (addr == dest)
333 continue;
325 dma_unmap_page(dev, addr, len, 334 dma_unmap_page(dev, addr, len,
326 DMA_TO_DEVICE); 335 DMA_TO_DEVICE);
327 } 336 }