From 8d53a07ee6031596466a02169712ed2324e8a077 Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Thu, 20 Mar 2025 16:41:14 +0000 Subject: [PATCH] dmaengine: dw-axi-dmac: Fix alignment checks Remove a bogus memory alignment check - transfers will be run bytewise if needed - and add a check that the overall length is multiple of the register size, otherwise there is residue. See: https://github.com/raspberrypi/linux/issues/6733 Signed-off-by: Phil Elwell --- drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) --- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c +++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c @@ -750,11 +750,6 @@ static int dw_axi_dma_set_hw_desc(struct mem_width = __ffs(data_width | mem_addr | len); - if (!IS_ALIGNED(mem_addr, 4)) { - dev_err(chan->chip->dev, "invalid buffer alignment\n"); - return -EINVAL; - } - /* Use a reasonable upper limit otherwise residue reporting granularity grows large */ mem_burst_msize = axi_dma_encode_msize(16); @@ -799,6 +794,11 @@ static int dw_axi_dma_set_hw_desc(struct return -EINVAL; } + if (len % (1 << reg_width)) { + dev_err_ratelimited(chan->chip->dev, "length %ld not aligned to device width %d\n", len, 1 << reg_width); + return -EINVAL; + } + if (block_ts > axi_block_ts) return -EINVAL;