From: Vignesh Raghavendra Date: Thu, 17 Sep 2020 11:23:08 +0000 (+0530) Subject: mtd: cfi_mtd: Use DMA for reads X-Git-Url: http://git.dujemihanovic.xyz/img/sics.gif?a=commitdiff_plain;h=3f891a103c5c90c186a5a0b1584dfa39e8688b8f;p=u-boot.git mtd: cfi_mtd: Use DMA for reads 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 Reviewed-by: Stefan Roese --- 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 +#include #include #include @@ -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;