Skip to content

Commit 5c094d4

Browse files
andreamerellovinodkoul
authored andcommitted
dmaengine: xilinx_dma: in axidma slave_sg and dma_cyclic mode align split descriptors
Whenever a single or cyclic transaction is prepared, the driver could eventually split it over several SG descriptors in order to deal with the HW maximum transfer length. This could end up in DMA operations starting from a misaligned address. This seems fatal for the HW if DRE (Data Realignment Engine) is not enabled. This patch eventually adjusts the transfer size in order to make sure all operations start from an aligned address. Cc: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com> Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Reviewed-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com> Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 616f0f8 commit 5c094d4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

drivers/dma/xilinx/xilinx_dma.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,15 @@ static int xilinx_dma_calc_copysize(struct xilinx_dma_chan *chan,
977977
copy = min_t(size_t, size - done,
978978
chan->xdev->max_buffer_len);
979979

980+
if ((copy + done < size) &&
981+
chan->xdev->common.copy_align) {
982+
/*
983+
* If this is not the last descriptor, make sure
984+
* the next one will be properly aligned
985+
*/
986+
copy = rounddown(copy,
987+
(1 << chan->xdev->common.copy_align));
988+
}
980989
return copy;
981990
}
982991

0 commit comments

Comments
 (0)