diff mbox series

[2/2] mtd: cfi_mtd: Use DMA for reads

Message ID 20200917112308.7736-3-vigneshr@ti.com
State Awaiting Upstream
Delegated to: Stefan Roese
Headers show
Series mtd: cfi_mtd: Add DMA support for reads | expand

Commit Message

Vignesh Raghavendra Sept. 17, 2020, 11:23 a.m. UTC
When possible use DMA for reading from CFI flash, this provides upto 5x
improvement in read performance with high speed CFI compliant flashes
like HyperFlash.

Code will gracefully fallback to CPU copy when DMA is unavailable.

Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
---
 drivers/mtd/cfi_mtd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Stefan Roese Sept. 23, 2020, 6:59 a.m. UTC | #1
On 17.09.20 13:23, Vignesh Raghavendra wrote:
> When possible use DMA for reading from CFI flash, this provides upto 5x
> improvement in read performance with high speed CFI compliant flashes
> like HyperFlash.
> 
> Code will gracefully fallback to CPU copy when DMA is unavailable.
> 
> Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

> ---
>   drivers/mtd/cfi_mtd.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/cfi_mtd.c b/drivers/mtd/cfi_mtd.c
> index a5bb0962e5..78293caa2f 100644
> --- a/drivers/mtd/cfi_mtd.c
> +++ b/drivers/mtd/cfi_mtd.c
> @@ -6,6 +6,7 @@
>    */
>   
>   #include <common.h>
> +#include <dma.h>
>   #include <flash.h>
>   #include <malloc.h>
>   
> @@ -70,7 +71,8 @@ static int cfi_mtd_read(struct mtd_info *mtd, loff_t from, size_t len,
>   	flash_info_t *fi = mtd->priv;
>   	u_char *f = (u_char*)(fi->start[0]) + from;
>   
> -	memcpy(buf, f, len);
> +	if (dma_memcpy(buf, f, len) < 0)
> +		memcpy(buf, f, len);
>   	*retlen = len;
>   
>   	return 0;
> 


Viele Grüße,
Stefan
Stefan Roese Oct. 8, 2020, 7:08 a.m. UTC | #2
On 17.09.20 13:23, Vignesh Raghavendra wrote:
> When possible use DMA for reading from CFI flash, this provides upto 5x
> improvement in read performance with high speed CFI compliant flashes
> like HyperFlash.
> 
> Code will gracefully fallback to CPU copy when DMA is unavailable.
> 
> Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>

Applied to u-boot-cfi-flash/master

Thanks,
Stefan

> ---
>   drivers/mtd/cfi_mtd.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/cfi_mtd.c b/drivers/mtd/cfi_mtd.c
> index a5bb0962e5..78293caa2f 100644
> --- a/drivers/mtd/cfi_mtd.c
> +++ b/drivers/mtd/cfi_mtd.c
> @@ -6,6 +6,7 @@
>    */
>   
>   #include <common.h>
> +#include <dma.h>
>   #include <flash.h>
>   #include <malloc.h>
>   
> @@ -70,7 +71,8 @@ static int cfi_mtd_read(struct mtd_info *mtd, loff_t from, size_t len,
>   	flash_info_t *fi = mtd->priv;
>   	u_char *f = (u_char*)(fi->start[0]) + from;
>   
> -	memcpy(buf, f, len);
> +	if (dma_memcpy(buf, f, len) < 0)
> +		memcpy(buf, f, len);
>   	*retlen = len;
>   
>   	return 0;
> 


Viele Grüße,
Stefan
diff mbox series

Patch

diff --git a/drivers/mtd/cfi_mtd.c b/drivers/mtd/cfi_mtd.c
index a5bb0962e5..78293caa2f 100644
--- a/drivers/mtd/cfi_mtd.c
+++ b/drivers/mtd/cfi_mtd.c
@@ -6,6 +6,7 @@ 
  */
 
 #include <common.h>
+#include <dma.h>
 #include <flash.h>
 #include <malloc.h>
 
@@ -70,7 +71,8 @@  static int cfi_mtd_read(struct mtd_info *mtd, loff_t from, size_t len,
 	flash_info_t *fi = mtd->priv;
 	u_char *f = (u_char*)(fi->start[0]) + from;
 
-	memcpy(buf, f, len);
+	if (dma_memcpy(buf, f, len) < 0)
+		memcpy(buf, f, len);
 	*retlen = len;
 
 	return 0;