History

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.

Andy Shevchenko committed 13 years ago

Commit afde3be1 parent 632fd281 file · +21 −1Browse files

Unified · Split

drivers/dma/dmatest.c+21−1
@@ -367,15 +367,35 @@ static int dmatest_func(void *data) · 366 unmodified lines
367367
368368 dma_srcs[i] = dma_map_single(dev->dev, buf, len,
369369 DMA_TO_DEVICE);
370+ ret = dma_mapping_error(dev->dev, dma_srcs[i]);
371+ if (ret) {
372+ unmap_src(dev->dev, dma_srcs, len, i);
373+ pr_warn("%s: #%u: mapping error %d with "
374+ "src_off=0x%x len=0x%x\n",
375+ thread_name, total_tests - 1, ret,
376+ src_off, len);
377+ failed_tests++;
378+ continue;
379+ }
370380 }
371381 /* map with DMA_BIDIRECTIONAL to force writeback/invalidate */
372382 for (i = 0; i < dst_cnt; i++) {
373383 dma_dsts[i] = dma_map_single(dev->dev, thread->dsts[i],
374384 test_buf_size,
375385 DMA_BIDIRECTIONAL);
386+ ret = dma_mapping_error(dev->dev, dma_dsts[i]);
387+ if (ret) {
388+ unmap_src(dev->dev, dma_srcs, len, src_cnt);
389+ unmap_dst(dev->dev, dma_dsts, test_buf_size, i);
390+ pr_warn("%s: #%u: mapping error %d with "
391+ "dst_off=0x%x len=0x%x\n",
392+ thread_name, total_tests - 1, ret,
393+ dst_off, test_buf_size);
394+ failed_tests++;
395+ continue;
396+ }
376397 }
377398
378−
379399 if (thread->type == DMA_MEMCPY)
380400 tx = dev->device_prep_dma_memcpy(chan,
381401 dma_dsts[0] + dst_off,