Skip to contentSkip to conversation

mtd: cfi_mtd: Add DMA support for reads

PATCH New Vignesh Raghavendra 2 participants 9 messages Sep 17, 2020 – Oct 8, 2020

Subsystems (2)
lore
Share & tools
lore

Vignesh Raghavendra

author maintainer
#0 lore raw

cover mtd: cfi_mtd: Add DMA support for reads

This series adds DMA support to read from memory mapped CFI flashes

First patch reduces noise from DMA APIs
Second patch adds DMA support for cfi_mtd.

Tested on J721e that has CFI compliant HyperFlash

Vignesh Raghavendra (2):
dma: Reduce error level when DMA channel type does not exist
mtd: cfi_mtd: Use DMA for reads

 drivers/dma/dma-uclass.c | 4 ++--
 drivers/mtd/cfi_mtd.c    | 4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)
Signature · 1 line
2.28.0
author maintainer
#1 lore raw

PATCH 1/2 dma: Reduce error level when DMA channel type does not exist

Caller would need gracefully handle failures of dma_get_device(), therefore reduce pr_err() to pr_debug() when DMA device is not found.

---
 drivers/dma/dma-uclass.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/dma/dma-uclass.c +2 -2
index 8cbb364042..50403148d6 100644
@@ -219,8 +219,8 @@ int dma_get_device(u32 transfer_type, struct udevice **devp)
 	}
 
 	if (!dev) {
-		pr_err("No DMA device found that supports %x type\n",
-		      transfer_type);
+		pr_debug("No DMA device found that supports %x type\n",
+			 transfer_type);
 		return -EPROTONOSUPPORT;
 	}
 
Signature · 1 line
2.28.0
#2 lore raw

PATCH 1/2 dma: Reduce error level when DMA channel type does not exist

Quoted 4 lines · Vignesh Raghavendra

Caller would need gracefully handle failures of dma_get_device(), therefore reduce pr_err() to pr_debug() when DMA device is not found.

Thanks,
Stefan

Quoted 10 lines
---
  drivers/dma/dma-uclass.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/dma/dma-uclass.c +0 -0
index 8cbb364042..50403148d6 100644

drivers/dma/dma-uclass.c int dma_get_device(u32 transfer_type, struct udevice **devp) · line 226

Quoted 10 lines
drivers/dma/dma-uclass.c +2 -2
@@ -219,8 +219,8 @@ int dma_get_device(u32 transfer_type, struct udevice **devp)
  	}
 
  	if (!dev) {
-		pr_err("No DMA device found that supports %x type\n",
-		      transfer_type);
+		pr_debug("No DMA device found that supports %x type\n",
+			 transfer_type);
  		return -EPROTONOSUPPORT;
  	}
 

Viele Gr??e,
Stefan

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de
#3 lore raw

PATCH 1/2 dma: Reduce error level when DMA channel type does not exist

In reply to Vignesh Raghavendra
Quoted 4 lines · Vignesh Raghavendra

Caller would need gracefully handle failures of dma_get_device(), therefore reduce pr_err() to pr_debug() when DMA device is not found.

Applied to u-boot-cfi-flash/master

Thanks,
Stefan

Quoted 10 lines
---
  drivers/dma/dma-uclass.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/dma/dma-uclass.c +0 -0
index 8cbb364042..50403148d6 100644

drivers/dma/dma-uclass.c int dma_get_device(u32 transfer_type, struct udevice **devp) · line 226

Quoted 10 lines
drivers/dma/dma-uclass.c +2 -2
@@ -219,8 +219,8 @@ int dma_get_device(u32 transfer_type, struct udevice **devp)
  	}
 
  	if (!dev) {
-		pr_err("No DMA device found that supports %x type\n",
-		      transfer_type);
+		pr_debug("No DMA device found that supports %x type\n",
+			 transfer_type);
  		return -EPROTONOSUPPORT;
  	}
 

Viele Gr??e,
Stefan

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de
author maintainer
#4 lore raw

PATCH 2/2 mtd: cfi_mtd: Use DMA for reads

In reply to Vignesh Raghavendra

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.

---
 drivers/mtd/cfi_mtd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mtd/cfi_mtd.c +3 -1
index a5bb0962e5..78293caa2f 100644
@@ -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;
Signature · 1 line
2.28.0
#5 lore raw

PATCH 2/2 mtd: cfi_mtd: Use DMA for reads

Quoted 7 lines · Vignesh Raghavendra

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.

Thanks,
Stefan

Quoted 18 lines
---
  drivers/mtd/cfi_mtd.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mtd/cfi_mtd.c +1 -0
index a5bb0962e5..78293caa2f 100644
@@ -6,6 +6,7 @@
   */
 
  #include <common.h>
+#include <dma.h>
  #include <flash.h>
  #include <malloc.h>
 

drivers/mtd/cfi_mtd.c static int cfi_mtd_read(struct mtd_info *mtd, loff_t from, size_t len, · line 78

Quoted 9 lines
drivers/mtd/cfi_mtd.c +2 -1
@@ -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

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de
#6 lore raw

PATCH 2/2 mtd: cfi_mtd: Use DMA for reads

In reply to Vignesh Raghavendra
Quoted 7 lines · Vignesh Raghavendra

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.

Applied to u-boot-cfi-flash/master

Thanks,
Stefan

Quoted 18 lines
---
  drivers/mtd/cfi_mtd.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mtd/cfi_mtd.c +1 -0
index a5bb0962e5..78293caa2f 100644
@@ -6,6 +6,7 @@
   */
 
  #include <common.h>
+#include <dma.h>
  #include <flash.h>
  #include <malloc.h>
 

drivers/mtd/cfi_mtd.c static int cfi_mtd_read(struct mtd_info *mtd, loff_t from, size_t len, · line 78

Quoted 9 lines
drivers/mtd/cfi_mtd.c +2 -1
@@ -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

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de
author maintainer
#7 lore raw

cover mtd: cfi_mtd: Add DMA support for reads

In reply to Vignesh Raghavendra

Hi Stefan

Quoted 7 lines · Vignesh Raghavendra

This series adds DMA support to read from memory mapped CFI flashes

First patch reduces noise from DMA APIs
Second patch adds DMA support for cfi_mtd.

Tested on J721e that has CFI compliant HyperFlash

Quoted 8 lines

Vignesh Raghavendra (2):
dma: Reduce error level when DMA channel type does not exist
mtd: cfi_mtd: Use DMA for reads

 drivers/dma/dma-uclass.c | 4 ++--
 drivers/mtd/cfi_mtd.c    | 4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)

Do you plan to pick up this series via CFI Flash? Or should I ask Tom to pull it in? Thanks!

Regards
Vignesh

#8 lore raw

cover mtd: cfi_mtd: Add DMA support for reads

Hi Vignesh,

Quoted 14 lines · Vignesh Raghavendra

Hi Stefan

Quoted 11 lines · Vignesh Raghavendra

This series adds DMA support to read from memory mapped CFI flashes

First patch reduces noise from DMA APIs
Second patch adds DMA support for cfi_mtd.

Tested on J721e that has CFI compliant HyperFlash

Vignesh Raghavendra (2):
dma: Reduce error level when DMA channel type does not exist
mtd: cfi_mtd: Use DMA for reads

Quoted 7 lines
Quoted 4 lines
  drivers/dma/dma-uclass.c | 4 ++--
  drivers/mtd/cfi_mtd.c    | 4 +++-
  2 files changed, 5 insertions(+), 3 deletions(-)

Do you plan to pick up this series via CFI Flash? Or should I ask Tom to pull it in? Thanks!

I'll pull this patchset soon via the CFI tree.

Thanks,
Stefan