dmaengine: sprd: Fix block length overflow [Linux 5.2]

dmaengine: sprd: Fix block length overflow [Linux 5.2]

This Linux kernel change "dmaengine: sprd: Fix block length overflow" is included in the Linux 5.2 release. This change is authored by Eric Long <eric.long [at] unisoc.com> on Mon May 6 15:28:31 2019 +0800. The commit for this change in Linux stable tree is 89d03b3 (patch).

dmaengine: sprd: Fix block length overflow

The maximum value of block length is 0xffff, so if the configured transfer length
is more than 0xffff, that will cause block length overflow to lead a configuration
error.

Thus we can set block length as the maximum burst length to avoid this issue, since
the maximum burst length will not be a big value which is more than 0xffff.

Signed-off-by: Eric Long <[email protected]>
Signed-off-by: Baolin Wang <[email protected]>
Signed-off-by: Vinod Koul <[email protected]>

There are 2 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/dma/sprd-dma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c
index 0f92e60..a01c232 100644
--- a/drivers/dma/sprd-dma.c
+++ b/drivers/dma/sprd-dma.c
@@ -778,7 +778,7 @@ static int sprd_dma_fill_desc(struct dma_chan *chan,
    temp |= slave_cfg->src_maxburst & SPRD_DMA_FRG_LEN_MASK;
    hw->frg_len = temp;

-   hw->blk_len = len & SPRD_DMA_BLK_LEN_MASK;
+   hw->blk_len = slave_cfg->src_maxburst & SPRD_DMA_BLK_LEN_MASK;
    hw->trsc_len = len & SPRD_DMA_TRSC_LEN_MASK;

    temp = (dst_step & SPRD_DMA_TRSF_STEP_MASK) << SPRD_DMA_DEST_TRSF_STEP_OFFSET;

Leave a Reply

Your email address will not be published. Required fields are marked *