mtd: cfi_mtd: Use DMA for reads
authorVignesh Raghavendra <vigneshr@ti.com>
Thu, 17 Sep 2020 11:23:08 +0000 (16:53 +0530)
committerStefan Roese <sr@denx.de>
Thu, 8 Oct 2020 07:04:41 +0000 (09:04 +0200)
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>
drivers/mtd/cfi_mtd.c

index a5bb096..78293ca 100644 (file)
@@ -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;