Commit 632fd283 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Linus Torvalds

dmatest: implement two helpers to unmap dma memory

The unmap_src() and unmap_dst() will be used later as well.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Cc: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 0f34c400
...@@ -228,6 +228,20 @@ static void dmatest_callback(void *arg) ...@@ -228,6 +228,20 @@ static void dmatest_callback(void *arg)
wake_up_all(done->wait); wake_up_all(done->wait);
} }
static inline void unmap_src(struct device *dev, dma_addr_t *addr, size_t len,
unsigned int count)
{
while (count--)
dma_unmap_single(dev, addr[count], len, DMA_TO_DEVICE);
}
static inline void unmap_dst(struct device *dev, dma_addr_t *addr, size_t len,
unsigned int count)
{
while (count--)
dma_unmap_single(dev, addr[count], len, DMA_BIDIRECTIONAL);
}
/* /*
* This function repeatedly tests DMA transfers of various lengths and * This function repeatedly tests DMA transfers of various lengths and
* offsets for a given operation type until it is told to exit by * offsets for a given operation type until it is told to exit by
...@@ -383,13 +397,8 @@ static int dmatest_func(void *data) ...@@ -383,13 +397,8 @@ static int dmatest_func(void *data)
} }
if (!tx) { if (!tx) {
for (i = 0; i < src_cnt; i++) unmap_src(dev->dev, dma_srcs, len, src_cnt);
dma_unmap_single(dev->dev, dma_srcs[i], len, unmap_dst(dev->dev, dma_dsts, test_buf_size, dst_cnt);
DMA_TO_DEVICE);
for (i = 0; i < dst_cnt; i++)
dma_unmap_single(dev->dev, dma_dsts[i],
test_buf_size,
DMA_BIDIRECTIONAL);
pr_warning("%s: #%u: prep error with src_off=0x%x " pr_warning("%s: #%u: prep error with src_off=0x%x "
"dst_off=0x%x len=0x%x\n", "dst_off=0x%x len=0x%x\n",
thread_name, total_tests - 1, thread_name, total_tests - 1,
...@@ -443,9 +452,7 @@ static int dmatest_func(void *data) ...@@ -443,9 +452,7 @@ static int dmatest_func(void *data)
} }
/* Unmap by myself (see DMA_COMPL_SKIP_DEST_UNMAP above) */ /* Unmap by myself (see DMA_COMPL_SKIP_DEST_UNMAP above) */
for (i = 0; i < dst_cnt; i++) unmap_dst(dev->dev, dma_dsts, test_buf_size, dst_cnt);
dma_unmap_single(dev->dev, dma_dsts[i], test_buf_size,
DMA_BIDIRECTIONAL);
error_count = 0; error_count = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment