Commit afde3be1 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Linus Torvalds

dmatest: check for dma mapping error

The kernel emits a warning if CONFIG_DMA_API_DEBUG=y:

  WARNING: at lib/dma-debug.c:933 check_unmap+0x5d6/0x6ac()
  dw_dmac dw_dmac.0: DMA-API: device driver failed to check map error[device address=0x0000000035698305] [size=14365 bytes] [mapped as single]

Fix this by adding the required checking of the dma_map_single() return
value.
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 632fd283
...@@ -367,14 +367,34 @@ static int dmatest_func(void *data) ...@@ -367,14 +367,34 @@ static int dmatest_func(void *data)
dma_srcs[i] = dma_map_single(dev->dev, buf, len, dma_srcs[i] = dma_map_single(dev->dev, buf, len,
DMA_TO_DEVICE); DMA_TO_DEVICE);
ret = dma_mapping_error(dev->dev, dma_srcs[i]);
if (ret) {
unmap_src(dev->dev, dma_srcs, len, i);
pr_warn("%s: #%u: mapping error %d with "
"src_off=0x%x len=0x%x\n",
thread_name, total_tests - 1, ret,
src_off, len);
failed_tests++;
continue;
}
} }
/* map with DMA_BIDIRECTIONAL to force writeback/invalidate */ /* map with DMA_BIDIRECTIONAL to force writeback/invalidate */
for (i = 0; i < dst_cnt; i++) { for (i = 0; i < dst_cnt; i++) {
dma_dsts[i] = dma_map_single(dev->dev, thread->dsts[i], dma_dsts[i] = dma_map_single(dev->dev, thread->dsts[i],
test_buf_size, test_buf_size,
DMA_BIDIRECTIONAL); DMA_BIDIRECTIONAL);
ret = dma_mapping_error(dev->dev, dma_dsts[i]);
if (ret) {
unmap_src(dev->dev, dma_srcs, len, src_cnt);
unmap_dst(dev->dev, dma_dsts, test_buf_size, i);
pr_warn("%s: #%u: mapping error %d with "
"dst_off=0x%x len=0x%x\n",
thread_name, total_tests - 1, ret,
dst_off, test_buf_size);
failed_tests++;
continue;
}
} }
if (thread->type == DMA_MEMCPY) if (thread->type == DMA_MEMCPY)
tx = dev->device_prep_dma_memcpy(chan, tx = dev->device_prep_dma_memcpy(chan,
......
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