stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dmaengine: dw-edma: Fix scatter-gather address calculation
@ 2020-08-13 14:14 Gustavo Pimentel
  2020-08-25 11:07 ` Vinod Koul
  0 siblings, 1 reply; 2+ messages in thread
From: Gustavo Pimentel @ 2020-08-13 14:14 UTC (permalink / raw)
  To: vkoul, dmaengine; +Cc: Gustavo Pimentel, Joao Pinto, stable

Fix the source and destination physical address calculation of a
peripheral device on scatter-gather implementation.

This issue manifested during tests using a 64 bits architecture system.
The abnormal behavior wasn't visible before due to all previous tests
were done using 32 bits architecture system, that masked his effect.

Fixes: e63d79d1ffcd ("dmaengine: Add Synopsys eDMA IP core driver")

Cc: Joao Pinto <jpinto@synopsys.com>
Cc: stable@vger.kernel.org
Signed-off-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
---
 drivers/dma/dw-edma/dw-edma-core.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/dw-edma/dw-edma-core.c b/drivers/dma/dw-edma/dw-edma-core.c
index ed430ad..b971505 100644
--- a/drivers/dma/dw-edma/dw-edma-core.c
+++ b/drivers/dma/dw-edma/dw-edma-core.c
@@ -405,7 +405,7 @@ dw_edma_device_transfer(struct dw_edma_transfer *xfer)
 			if (xfer->cyclic) {
 				burst->dar = xfer->xfer.cyclic.paddr;
 			} else {
-				burst->dar = sg_dma_address(sg);
+				burst->dar = dst_addr;
 				/* Unlike the typical assumption by other
 				 * drivers/IPs the peripheral memory isn't
 				 * a FIFO memory, in this case, it's a
@@ -413,14 +413,13 @@ dw_edma_device_transfer(struct dw_edma_transfer *xfer)
 				 * and destination addresses are increased
 				 * by the same portion (data length)
 				 */
-				src_addr += sg_dma_len(sg);
 			}
 		} else {
 			burst->dar = dst_addr;
 			if (xfer->cyclic) {
 				burst->sar = xfer->xfer.cyclic.paddr;
 			} else {
-				burst->sar = sg_dma_address(sg);
+				burst->sar = src_addr;
 				/* Unlike the typical assumption by other
 				 * drivers/IPs the peripheral memory isn't
 				 * a FIFO memory, in this case, it's a
@@ -428,12 +427,14 @@ dw_edma_device_transfer(struct dw_edma_transfer *xfer)
 				 * and destination addresses are increased
 				 * by the same portion (data length)
 				 */
-				dst_addr += sg_dma_len(sg);
 			}
 		}
 
-		if (!xfer->cyclic)
+		if (!xfer->cyclic) {
+			src_addr += sg_dma_len(sg);
+			dst_addr += sg_dma_len(sg);
 			sg = sg_next(sg);
+		}
 	}
 
 	return vchan_tx_prep(&chan->vc, &desc->vd, xfer->flags);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] dmaengine: dw-edma: Fix scatter-gather address calculation
  2020-08-13 14:14 [PATCH] dmaengine: dw-edma: Fix scatter-gather address calculation Gustavo Pimentel
@ 2020-08-25 11:07 ` Vinod Koul
  0 siblings, 0 replies; 2+ messages in thread
From: Vinod Koul @ 2020-08-25 11:07 UTC (permalink / raw)
  To: Gustavo Pimentel; +Cc: dmaengine, Joao Pinto, stable

On 13-08-20, 16:14, Gustavo Pimentel wrote:
> Fix the source and destination physical address calculation of a
> peripheral device on scatter-gather implementation.
> 
> This issue manifested during tests using a 64 bits architecture system.
> The abnormal behavior wasn't visible before due to all previous tests
> were done using 32 bits architecture system, that masked his effect.

Applied, thanks

> 
> Fixes: e63d79d1ffcd ("dmaengine: Add Synopsys eDMA IP core driver")
> 

Dont leave empty line here

> Cc: Joao Pinto <jpinto@synopsys.com>
> Cc: stable@vger.kernel.org
> Signed-off-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
> ---
>  drivers/dma/dw-edma/dw-edma-core.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/dma/dw-edma/dw-edma-core.c b/drivers/dma/dw-edma/dw-edma-core.c
> index ed430ad..b971505 100644
> --- a/drivers/dma/dw-edma/dw-edma-core.c
> +++ b/drivers/dma/dw-edma/dw-edma-core.c
> @@ -405,7 +405,7 @@ dw_edma_device_transfer(struct dw_edma_transfer *xfer)
>  			if (xfer->cyclic) {
>  				burst->dar = xfer->xfer.cyclic.paddr;
>  			} else {
> -				burst->dar = sg_dma_address(sg);
> +				burst->dar = dst_addr;
>  				/* Unlike the typical assumption by other
>  				 * drivers/IPs the peripheral memory isn't
>  				 * a FIFO memory, in this case, it's a
> @@ -413,14 +413,13 @@ dw_edma_device_transfer(struct dw_edma_transfer *xfer)
>  				 * and destination addresses are increased
>  				 * by the same portion (data length)
>  				 */
> -				src_addr += sg_dma_len(sg);
>  			}
>  		} else {
>  			burst->dar = dst_addr;
>  			if (xfer->cyclic) {
>  				burst->sar = xfer->xfer.cyclic.paddr;
>  			} else {
> -				burst->sar = sg_dma_address(sg);
> +				burst->sar = src_addr;
>  				/* Unlike the typical assumption by other
>  				 * drivers/IPs the peripheral memory isn't
>  				 * a FIFO memory, in this case, it's a
> @@ -428,12 +427,14 @@ dw_edma_device_transfer(struct dw_edma_transfer *xfer)
>  				 * and destination addresses are increased
>  				 * by the same portion (data length)
>  				 */
> -				dst_addr += sg_dma_len(sg);
>  			}
>  		}
>  
> -		if (!xfer->cyclic)
> +		if (!xfer->cyclic) {
> +			src_addr += sg_dma_len(sg);
> +			dst_addr += sg_dma_len(sg);
>  			sg = sg_next(sg);
> +		}
>  	}
>  
>  	return vchan_tx_prep(&chan->vc, &desc->vd, xfer->flags);
> -- 
> 2.7.4

-- 
~Vinod

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-08-25 11:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-13 14:14 [PATCH] dmaengine: dw-edma: Fix scatter-gather address calculation Gustavo Pimentel
2020-08-25 11:07 ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).