From 8995a86cd6fa6e189c03a638da4a8ef9755d3738 Mon Sep 17 00:00:00 2001 From: Vignesh Raghavendra Date: Thu, 17 Sep 2020 16:53:07 +0530 Subject: [PATCH 1/3] 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. Signed-off-by: Vignesh Raghavendra Reviewed-by: Stefan Roese --- 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; } From 3f891a103c5c90c186a5a0b1584dfa39e8688b8f Mon Sep 17 00:00:00 2001 From: Vignesh Raghavendra Date: Thu, 17 Sep 2020 16:53:08 +0530 Subject: [PATCH 2/3] 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 --- 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 +#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; From 492b9917c684bbfd42479e049c00b1e502f8b53f Mon Sep 17 00:00:00 2001 From: Andre Przywara Date: Thu, 24 Sep 2020 00:22:04 +0100 Subject: [PATCH 3/3] cfi_flash: Fix devicetree address determination The cfi-flash driver uses an open-coded version of the generic algorithm to decode and translate multiple frames of a "reg" property. This starts off the wrong foot by using the address-cells and size-cells properties of *this* very node, and not of the parent. This somewhat happened to work back when we were using a wrong default size of 2, but broke about a year ago with commit 0ba41ce1b781 ("libfdt: return correct value if #size-cells property is not present"). Instead of fixing the reinvented wheel, just use the generic function that does all of this properly. This fixes U-Boot on QEMU (-arm64), which was crashing due to decoding a wrong flash base address: DRAM: 1 GiB Flash: "Synchronous Abort" handler, esr 0x96000044 elr: 00000000000211dc lr : 00000000000211b0 (reloc) elr: 000000007ff5e1dc lr : 000000007ff5e1b0 x0 : 00000000000000f0 x1 : 000000007ff5e1d8 x2 : 000000007edfbc48 x3 : 0000000000000000 x4 : 0000000000000000 x5 : 00000000000000f0 x6 : 000000007edfbc2c x7 : 0000000000000000 x8 : 000000007ffd8d70 x9 : 000000000000000c x10: 0400000000000003 x11: 0000000000000055 ^^^^^^^^^^^^^^^^ Signed-off-by: Andre Przywara Reviewed-by: Stefan Roese --- drivers/mtd/cfi_flash.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c index b7289ba539..9e3a652f44 100644 --- a/drivers/mtd/cfi_flash.c +++ b/drivers/mtd/cfi_flash.c @@ -2468,29 +2468,17 @@ unsigned long flash_init(void) #ifdef CONFIG_CFI_FLASH /* for driver model */ static int cfi_flash_probe(struct udevice *dev) { - const fdt32_t *cell; - int addrc, sizec; - int len, idx; + fdt_addr_t addr; + int idx; - addrc = dev_read_addr_cells(dev); - sizec = dev_read_size_cells(dev); - - /* decode regs; there may be multiple reg tuples. */ - cell = dev_read_prop(dev, "reg", &len); - if (!cell) - return -ENOENT; - idx = 0; - len /= sizeof(fdt32_t); - while (idx < len) { - phys_addr_t addr; - - addr = dev_translate_address(dev, cell + idx); + for (idx = 0; idx < CFI_MAX_FLASH_BANKS; idx++) { + addr = dev_read_addr_index(dev, idx); + if (addr == FDT_ADDR_T_NONE) + break; flash_info[cfi_flash_num_flash_banks].dev = dev; flash_info[cfi_flash_num_flash_banks].base = addr; cfi_flash_num_flash_banks++; - - idx += addrc + sizec; } gd->bd->bi_flashstart = flash_info[0].base;