public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Vignesh Raghavendra <vigneshr@ti.com>
To: u-boot@lists.denx.de
Subject: [PATCH 2/2] mtd: cfi_mtd: Use DMA for reads
Date: Thu, 17 Sep 2020 16:53:08 +0530	[thread overview]
Message-ID: <20200917112308.7736-3-vigneshr@ti.com> (raw)
In-Reply-To: <20200917112308.7736-1-vigneshr@ti.com>

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(-)

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;
-- 
2.28.0

  parent reply	other threads:[~2020-09-17 11:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-17 11:23 [PATCH 0/2] mtd: cfi_mtd: Add DMA support for reads Vignesh Raghavendra
2020-09-17 11:23 ` [PATCH 1/2] dma: Reduce error level when DMA channel type does not exist Vignesh Raghavendra
2020-09-23  6:58   ` Stefan Roese
2020-10-08  7:08   ` Stefan Roese
2020-09-17 11:23 ` Vignesh Raghavendra [this message]
2020-09-23  6:59   ` [PATCH 2/2] mtd: cfi_mtd: Use DMA for reads Stefan Roese
2020-10-08  7:08   ` Stefan Roese
2020-10-05 18:42 ` [PATCH 0/2] mtd: cfi_mtd: Add DMA support " Vignesh Raghavendra
2020-10-07  4:55   ` Stefan Roese

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200917112308.7736-3-vigneshr@ti.com \
    --to=vigneshr@ti.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox