Skip to contentSkip to conversation

spl: fit: handle mmc read to sram case in rockchip SoCs

PATCH New Kever Yang 3 participants 5 messages Mar 29, 2019 – Apr 2, 2019

lore
Share & tools
lore

Kever Yang

author
#0 lore raw

PATCH 1/1 spl: fit: handle mmc read to sram case in rockchip SoCs

Rockchip fit image with atf may have firmware for sram, so the fit driver need to read data from mmc to sram, but Rockchip mmc controller does not support this data path, we have to read into ddr first and then copy it to sram.

---

 common/spl/spl_fit.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
common/spl/spl_fit.c +10 -0
index c9bfe0cc8a..5c5b58f69d 100644
@@ -9,6 +9,7 @@
 #include <fpga.h>
 #include <image.h>
 #include <linux/libfdt.h>
+#include <malloc.h>
 #include <spl.h>
 
 #ifndef CONFIG_SYS_BOOTM_LEN
@@ -215,6 +216,15 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
 			return -ENOENT;
 
 		load_ptr = (load_addr + align_len) & ~align_len;
+#if  defined(CONFIG_ROCKCHIP_RK3399) || defined(CONFIG_ROCKCHIP_RK3368)
+		/*
+		 * Rockchip SOC's mmc controller does not support read data
+		 * from mmc to sram, we have to read to sdram first, and then
+		 * copy to sram.
+		 */
+		if ((load_ptr & 0xffff0000) != CONFIG_SYS_SDRAM_BASE)
+			load_ptr = (ulong)memalign(ARCH_DMA_MINALIGN, len);
+#endif
 		length = len;
 
 		overhead = get_aligned_image_overhead(info, offset);
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/1 spl: fit: handle mmc read to sram case in rockchip SoCs

Quoted 25 lines · Kever Yang

Rockchip fit image with atf may have firmware for sram, so the fit driver need to read data from mmc to sram, but Rockchip mmc controller does not support this data path, we have to read into ddr first and then copy it to sram.

---

  common/spl/spl_fit.c | 10 ++++++++++
  1 file changed, 10 insertions(+)
common/spl/spl_fit.c +1 -0
index c9bfe0cc8a..5c5b58f69d 100644
@@ -9,6 +9,7 @@
  #include <fpga.h>
  #include <image.h>
  #include <linux/libfdt.h>
+#include <malloc.h>
  #include <spl.h>
 
  #ifndef CONFIG_SYS_BOOTM_LEN

common/spl/spl_fit.c static int spl_load_fit_image(struct spl_load_info *info, ulong sector, · line 219

Quoted 4 lines
common/spl/spl_fit.c +1 -0
@@ -215,6 +216,15 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
  			return -ENOENT;
 
  		load_ptr = (load_addr + align_len) & ~align_len;
+#if  defined(CONFIG_ROCKCHIP_RK3399) || defined(CONFIG_ROCKCHIP_RK3368)

This looks hacky. I don't think we should clutter platform independent code with platform dependent ifdefs. You're totally violating code abstraction here.

Regards,
Simon

Quoted 12 lines
common/spl/spl_fit.c +8 -0
+		/*
+		 * Rockchip SOC's mmc controller does not support read data
+		 * from mmc to sram, we have to read to sdram first, and then
+		 * copy to sram.
+		 */
+		if ((load_ptr & 0xffff0000) != CONFIG_SYS_SDRAM_BASE)
+			load_ptr = (ulong)memalign(ARCH_DMA_MINALIGN, len);
+#endif
  		length = len;
 
  		overhead = get_aligned_image_overhead(info, offset);
author
#2 lore raw

PATCH 1/1 spl: fit: handle mmc read to sram case in rockchip SoCs

Hi Simon,

Quoted 27 lines · Simon Goldschmidt
Quoted 24 lines · Kever Yang

Rockchip fit image with atf may have firmware for sram, so the fit driver need to read data from mmc to sram, but Rockchip mmc controller does not support this data path, we have to read into ddr first and then copy it to sram.

---

  common/spl/spl_fit.c | 10 ++++++++++

  1 file changed, 10 insertions(+)
common/spl/spl_fit.c +1 -0
index c9bfe0cc8a..5c5b58f69d 100644
@@ -9,6 +9,7 @@
   #include <fpga.h>
   #include <image.h>
   #include <linux/libfdt.h>
+#include <malloc.h>
   #include <spl.h>
     #ifndef CONFIG_SYS_BOOTM_LEN
@@ -215,6 +216,15 @@ static int spl_load_fit_image(struct
Quoted 9 lines

common/spl/spl_fit.c static int spl_load_fit_image(struct spl_load_info *info, ulong sector, · line 219

Quoted 4 lines
common/spl/spl_fit.c +1 -0
 spl_load_info *info, ulong sector,
               return -ENOENT;
             load_ptr = (load_addr + align_len) & ~align_len;
+#if  defined(CONFIG_ROCKCHIP_RK3399) || defined(CONFIG_ROCKCHIP_RK3368)

This looks hacky. I don't think we should clutter platform independent code with platform dependent ifdefs. You're totally violating code abstraction here.

Thanks for your comment, I know this looks hacky, could you share you idea about how to implement this better?
We do need this to make things work.

Thanks,
- Kever

Quoted 15 lines

Regards,
Simon

Quoted 11 lines
common/spl/spl_fit.c +8 -0
+        /*
+         * Rockchip SOC's mmc controller does not support read data
+         * from mmc to sram, we have to read to sdram first, and then
+         * copy to sram.
+         */
+        if ((load_ptr & 0xffff0000) != CONFIG_SYS_SDRAM_BASE)
+            load_ptr = (ulong)memalign(ARCH_DMA_MINALIGN, len);
+#endif
           length = len;
             overhead = get_aligned_image_overhead(info, offset);
 
#3 lore raw

PATCH 1/1 spl: fit: handle mmc read to sram case in rockchip SoCs

Kever,

Quoted 43 lines · Kever Yang

Hi Simon,

Quoted 27 lines · Simon Goldschmidt
Quoted 24 lines · Kever Yang

Rockchip fit image with atf may have firmware for sram, so the fit driver need to read data from mmc to sram, but Rockchip mmc controller does not support this data path, we have to read into ddr first and then copy it to sram.

---

  common/spl/spl_fit.c | 10 ++++++++++
  1 file changed, 10 insertions(+)
common/spl/spl_fit.c +1 -0
index c9bfe0cc8a..5c5b58f69d 100644
@@ -9,6 +9,7 @@
  #include <fpga.h>
  #include <image.h>
  #include <linux/libfdt.h>
+#include <malloc.h>
  #include <spl.h>
    #ifndef CONFIG_SYS_BOOTM_LEN
@@ -215,6 +216,15 @@ static int spl_load_fit_image(struct
Quoted 9 lines

common/spl/spl_fit.c static int spl_load_fit_image(struct spl_load_info *info, ulong sector, · line 219

Quoted 4 lines
common/spl/spl_fit.c +1 -0
 spl_load_info *info, ulong sector,
              return -ENOENT;
            load_ptr = (load_addr + align_len) & ~align_len;
+#if  defined(CONFIG_ROCKCHIP_RK3399) || defined(CONFIG_ROCKCHIP_RK3368)

This looks hacky. I don't think we should clutter platform independent code with platform dependent ifdefs. You're totally violating code abstraction here.

Quoted 3 lines

Thanks for your comment, I know this looks hacky, could you share you idea about how to implement this better?
We do need this to make things work.

A more appropriate way would be to leverage the bounce buffers in the SD/MMC drivers and to make sure that the 0xffff0000 memory region is not allocated as a DMA-able target address via bounce buffers.

Note that this is the same issue that I had highlighted about a year and a half ago and that we ended up working around by loading the PMU firmware into DRAM, pass the info about the loadables to ATF as part of the FDT, and finally have ATF relocate the loadables to INTMEM.

Quoted 24 lines

Thanks,
- Kever

Quoted 15 lines

Regards,
Simon

Quoted 11 lines
common/spl/spl_fit.c +8 -0
+        /*
+         * Rockchip SOC's mmc controller does not support read data
+         * from mmc to sram, we have to read to sdram first, and then
+         * copy to sram.
+         */
+        if ((load_ptr & 0xffff0000) != CONFIG_SYS_SDRAM_BASE)
+            load_ptr = (ulong)memalign(ARCH_DMA_MINALIGN, len);
+#endif
          length = len;
            overhead = get_aligned_image_overhead(info, offset);
 

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

author
#4 lore raw

PATCH 1/1 spl: fit: handle mmc read to sram case in rockchip SoCs

Hi Philipp,

Quoted 52 lines · Philipp Tomsich

Kever,

Quoted 46 lines

On 30.03.2019, at 02:43, Kever Yang <[email protected] <mailto:[email protected]>> wrote:

Hi Simon,

Quoted 29 lines · Simon Goldschmidt
Quoted 26 lines · Kever Yang

Rockchip fit image with atf may have firmware for sram, so the fit driver need to read data from mmc to sram, but Rockchip mmc controller does not support this data path, we have to read into ddr first and then copy it to sram.

<mailto:[email protected]>>
---

  common/spl/spl_fit.c | 10 ++++++++++

  1 file changed, 10 insertions(+)
common/spl/spl_fit.c +1 -0
index c9bfe0cc8a..5c5b58f69d 100644
@@ -9,6 +9,7 @@
   #include <fpga.h>
   #include <image.h>
   #include <linux/libfdt.h>
+#include <malloc.h>
   #include <spl.h>
     #ifndef CONFIG_SYS_BOOTM_LEN
@@ -215,6 +216,15 @@ static int spl_load_fit_image(struct
 spl_load_info *info, ulong sector,
Quoted 9 lines

common/spl/spl_fit.c static int spl_load_fit_image(struct spl_load_info *info, ulong sector,

Quoted 4 lines
common/spl/spl_fit.c +1 -0
               return -ENOENT;
             load_ptr = (load_addr + align_len) & ~align_len;
+#if  defined(CONFIG_ROCKCHIP_RK3399) ||
 defined(CONFIG_ROCKCHIP_RK3368)

This looks hacky. I don't think we should clutter platform independent code with platform dependent ifdefs. You're totally violating code abstraction here.

Quoted 3 lines

Thanks for your comment, I know this looks hacky, could you share you idea about how to implement this better?
We do need this to make things work.

Quoted 5 lines

A more appropriate way would be to leverage the bounce buffers in the SD/MMC
drivers and to make sure that the 0xffff0000 memory region is not allocated as a
DMA-able target address via bounce buffers.

Bounce buffer is a good idea, I have implement it and send to patch to the list, thanks
very much.

This patch can be drop.

Thanks,
- Kever

Quoted 33 lines

Note that this is the same issue that I had highlighted about a year and a half ago
and that we ended up working around by loading the PMU firmware into DRAM, pass the info about the loadables to ATF as part of the FDT, and finally have ATF
relocate the loadables to INTMEM.

Quoted 24 lines

Thanks,
- Kever

Quoted 15 lines

Regards,
Simon

Quoted 11 lines
common/spl/spl_fit.c +8 -0
+        /*
+         * Rockchip SOC's mmc controller does not support read data
+         * from mmc to sram, we have to read to sdram first, and then
+         * copy to sram.
+         */
+        if ((load_ptr & 0xffff0000) != CONFIG_SYS_SDRAM_BASE)
+            load_ptr = (ulong)memalign(ARCH_DMA_MINALIGN, len);
+#endif
           length = len;
             overhead = get_aligned_image_overhead(info, offset);

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de <mailto:[email protected]>
https://lists.denx.de/listinfo/u-boot