Skip to content

Commit a2fa911

Browse files
committed
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 <[email protected]>
1 parent 8346446 commit a2fa911

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
@@ -724,6 +724,18 @@ static int dw_axi_dma_set_hw_desc(struct axi_dma_chan *chan,
724724
case DMA_DEV_TO_MEM:
725725
reg_burst_msize = axi_dma_encode_msize(chan->config.src_maxburst);
726726
reg_width = __ffs(chan->config.src_addr_width);
727+
/*
728+
* For devices where transfer lengths are not known upfront,
729+
* there is a danger when the destination is wider than the
730+
* source that partial words can be lost at the end of a transfer.
731+
* Ideally the controller would be able to flush the residue, but
732+
* it can't - it's not even possible to tell that there is any.
733+
* Instead, allow the client driver to avoid the problem by setting
734+
* a smaller width.
735+
*/
736+
if (chan->config.dst_addr_width &&
737+
(chan->config.dst_addr_width < mem_width))
738+
mem_width = chan->config.dst_addr_width;
727739
device_addr = phys_to_dma(chan->chip->dev, chan->config.src_addr);
728740
ctllo = reg_width << CH_CTL_L_SRC_WIDTH_POS |
729741
mem_width << CH_CTL_L_DST_WIDTH_POS |

0 commit comments

Comments
 (0)