[PATCH 0/2] mtd: cfi_mtd: Add DMA support for reads

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH 0/2] mtd: cfi_mtd: Add DMA support for reads

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

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

--
2.28.0

Reply | Threaded
Open this post in threaded view
|

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

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.

Signed-off-by: Vignesh Raghavendra <[hidden email]>
---
 drivers/dma/dma-uclass.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/dma-uclass.c b/drivers/dma/dma-uclass.c
index 8cbb364042..50403148d6 100644
--- a/drivers/dma/dma-uclass.c
+++ b/drivers/dma/dma-uclass.c
@@ -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;
  }
 
--
2.28.0

Reply | Threaded
Open this post in threaded view
|

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

Vignesh Raghavendra
In reply to this post by 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.

Signed-off-by: Vignesh Raghavendra <[hidden email]>
---
 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

Reply | Threaded
Open this post in threaded view
|

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

Stefan Roese
In reply to this post by Vignesh Raghavendra
On 17.09.20 13:23, Vignesh Raghavendra wrote:
> Caller would need gracefully handle failures of dma_get_device(),
> therefore reduce pr_err() to pr_debug() when DMA device is not found.
>
> Signed-off-by: Vignesh Raghavendra <[hidden email]>

Reviewed-by: Stefan Roese <[hidden email]>

Thanks,
Stefan

> ---
>   drivers/dma/dma-uclass.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/dma/dma-uclass.c b/drivers/dma/dma-uclass.c
> index 8cbb364042..50403148d6 100644
> --- a/drivers/dma/dma-uclass.c
> +++ b/drivers/dma/dma-uclass.c
> @@ -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

--
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: [hidden email]
Reply | Threaded
Open this post in threaded view
|

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

Stefan Roese
In reply to this post by Vignesh Raghavendra
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 <[hidden email]>

Reviewed-by: Stefan Roese <[hidden email]>

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

--
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: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 0/2] mtd: cfi_mtd: Add DMA support for reads

Vignesh Raghavendra
In reply to this post by Vignesh Raghavendra
Hi Stefan

On 9/17/20 4:53 PM, Vignesh Raghavendra wrote:

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

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

Regards
Vignesh
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 0/2] mtd: cfi_mtd: Add DMA support for reads

Stefan Roese
Hi Vignesh,

On 05.10.20 20:42, Vignesh Raghavendra wrote:

> Hi Stefan
>
> On 9/17/20 4:53 PM, Vignesh Raghavendra wrote:
>> 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(-)
>>
>
> 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
Reply | Threaded
Open this post in threaded view
|

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

Stefan Roese
In reply to this post by Vignesh Raghavendra
On 17.09.20 13:23, Vignesh Raghavendra wrote:
> Caller would need gracefully handle failures of dma_get_device(),
> therefore reduce pr_err() to pr_debug() when DMA device is not found.
>
> Signed-off-by: Vignesh Raghavendra <[hidden email]>

Applied to u-boot-cfi-flash/master

Thanks,
Stefan

> ---
>   drivers/dma/dma-uclass.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/dma/dma-uclass.c b/drivers/dma/dma-uclass.c
> index 8cbb364042..50403148d6 100644
> --- a/drivers/dma/dma-uclass.c
> +++ b/drivers/dma/dma-uclass.c
> @@ -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

--
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: [hidden email]
Reply | Threaded
Open this post in threaded view
|

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

Stefan Roese
In reply to this post by Vignesh Raghavendra
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 <[hidden email]>

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

--
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: [hidden email]