Skip to content

Commit 46c321b

Browse files
pelwellpopcornmix
authored andcommitted
dmaengine: dw-axi-dmac: Allow client-chosen width
For devices where transfer lengths are not known upfront, there is a danger when the destination is wider than the source that partial words can be lost at the end of a transfer. Ideally the controller would be able to flush the residue, but it can't - it's not even possible to tell that there is any. Instead, allow the client driver to avoid the problem by setting a smaller width. Signed-off-by: Phil Elwell <phil@raspberrypi.com>
1 parent cb27b17 commit 46c321b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,18 @@ static int dw_axi_dma_set_hw_desc(struct axi_dma_chan *chan,
771771
case DMA_DEV_TO_MEM:
772772
reg_burst_msize = axi_dma_encode_msize(chan->config.src_maxburst);
773773
reg_width = __ffs(chan->config.src_addr_width);
774+
/*
775+
* For devices where transfer lengths are not known upfront,
776+
* there is a danger when the destination is wider than the
777+
* source that partial words can be lost at the end of a transfer.
778+
* Ideally the controller would be able to flush the residue, but
779+
* it can't - it's not even possible to tell that there is any.
780+
* Instead, allow the client driver to avoid the problem by setting
781+
* a smaller width.
782+
*/
783+
if (chan->config.dst_addr_width &&
784+
(chan->config.dst_addr_width < mem_width))
785+
mem_width = chan->config.dst_addr_width;
774786
device_addr = phys_to_dma(chan->chip->dev, chan->config.src_addr);
775787
ctllo = reg_width << CH_CTL_L_SRC_WIDTH_POS |
776788
mem_width << CH_CTL_L_DST_WIDTH_POS |

0 commit comments

Comments
 (0)