Skip to content

Commit 5156463

Browse files
stroeseVinod Koul
authored andcommitted
dmaengine: mv_xor: Fix incorrect offset in dma_map_page()
Upon booting, I occasionally spotted some BUGs triggered by the internal DMA test routine executed upon driver probing. This was detected by SLUB_DEBUG ("Freechain corrupt" or "Redzone overwritten"). Tracking this down located a problem in passing 0 as offset in dma_map_page(). As kmalloc, especially when used with SLUB_DEBUG, may return a non page aligned address. This patch fixes this issue by passing the correct offset in dma_map_page(). Tested on a custom Armada XP board. Signed-off-by: Stefan Roese <[email protected]> Cc: Thomas Petazzoni <[email protected]> Cc: Gregory CLEMENT <[email protected]> Cc: Marcin Wojtas <[email protected]> Signed-off-by: Vinod Koul <[email protected]>
1 parent 9295c41 commit 5156463

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/dma/mv_xor.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -703,8 +703,9 @@ static int mv_chan_memcpy_self_test(struct mv_xor_chan *mv_chan)
703703
goto free_resources;
704704
}
705705

706-
src_dma = dma_map_page(dma_chan->device->dev, virt_to_page(src), 0,
707-
PAGE_SIZE, DMA_TO_DEVICE);
706+
src_dma = dma_map_page(dma_chan->device->dev, virt_to_page(src),
707+
(size_t)src & ~PAGE_MASK, PAGE_SIZE,
708+
DMA_TO_DEVICE);
708709
unmap->addr[0] = src_dma;
709710

710711
ret = dma_mapping_error(dma_chan->device->dev, src_dma);
@@ -714,8 +715,9 @@ static int mv_chan_memcpy_self_test(struct mv_xor_chan *mv_chan)
714715
}
715716
unmap->to_cnt = 1;
716717

717-
dest_dma = dma_map_page(dma_chan->device->dev, virt_to_page(dest), 0,
718-
PAGE_SIZE, DMA_FROM_DEVICE);
718+
dest_dma = dma_map_page(dma_chan->device->dev, virt_to_page(dest),
719+
(size_t)dest & ~PAGE_MASK, PAGE_SIZE,
720+
DMA_FROM_DEVICE);
719721
unmap->addr[1] = dest_dma;
720722

721723
ret = dma_mapping_error(dma_chan->device->dev, dest_dma);

0 commit comments

Comments
 (0)