Skip to contentSkip to conversation

imx: convert to DM_SERIAL

PATCH In review Peng Fan (OSS) 7 participants 43 messages Nov 7, 2022 – Feb 1, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover imx: convert to DM_SERIAL

From: Peng Fan <[email protected]>

This patchset is to convert mx6ull/z_evk, mx6sl[l]evk, mx6sxsbareauto, mx6sabreauto, mx6sabresd to DM_SERIAL

Patch 1 is a fix found when testing mx6sllevk

Peng Fan (11):
imx: implement get_effective_memsize
imx: mx6ull_14x14_evk: select DM_SERIAL
imx: mx6ulz: select DM_SERIAL
imx: mx6ull/z_14x14_evk: clean up UART iomux
imx: mx6sllevk: correct pmic name
imx: mx6sllevk: select DM_SERIAL
imx: mx6slevk: select DM_SERIAL
imx: mx6ul_evk: select DM_SERIAL
imx: mx6sxsabreauto: select DM_SERIAL
imx: mx6sabreauto_defconfig: select DM_SERIAL
imx: mx6sabresd: select DM_SERIAL

 arch/arm/dts/imx6sll-evk-u-boot.dtsi           |  8 ++++++++
 arch/arm/dts/imx6sx-sabreauto-u-boot.dtsi      |  4 ++++
 arch/arm/dts/imx6ull-14x14-evk-u-boot.dtsi     |  8 ++++++++
 arch/arm/dts/imx6ulz-14x14-evk-u-boot.dtsi     |  8 ++++++++
 arch/arm/mach-imx/cache.c                      | 14 ++++++++++++++
 board/freescale/mx6sllevk/mx6sllevk.c          | 18 +-----------------
 .../freescale/mx6sxsabreauto/mx6sxsabreauto.c  | 16 ----------------
 board/freescale/mx6ullevk/mx6ullevk.c          | 16 ----------------
 configs/mx6sabreauto_defconfig                 |  1 +
 configs/mx6sabresd_defconfig                   |  1 +
 configs/mx6slevk_defconfig                     |  1 +
 configs/mx6slevk_spinor_defconfig              |  1 +
 configs/mx6slevk_spl_defconfig                 |  1 +
 configs/mx6sllevk_defconfig                    |  1 +
 configs/mx6sllevk_plugin_defconfig             |  1 +
 configs/mx6sxsabreauto_defconfig               |  1 +
 configs/mx6ul_14x14_evk_defconfig              |  1 +
 configs/mx6ul_9x9_evk_defconfig                |  1 +
 configs/mx6ull_14x14_evk_defconfig             |  1 +
 configs/mx6ull_14x14_evk_plugin_defconfig      |  1 +
 configs/mx6ulz_14x14_evk_defconfig             |  1 +
 21 files changed, 56 insertions(+), 49 deletions(-)
 create mode 100644 arch/arm/dts/imx6sll-evk-u-boot.dtsi
 create mode 100644 arch/arm/dts/imx6ull-14x14-evk-u-boot.dtsi
 create mode 100644 arch/arm/dts/imx6ulz-14x14-evk-u-boot.dtsi
Signature · 1 line
2.36.0
#1 lore raw

PATCH 1/11 imx: implement get_effective_memsize

From: Peng Fan <[email protected]>

To i.MX6/7 which has 2GB memory, the upper 4KB cut off, will cause the top 1MB not mapped as normal memory, because ARMV7-A use section mapping. So implement i.MX6/7 specific get_effective_memsize to fix the issue.

Fixes 777aaaa706bc("common/memsize.c: Fix get_effective_memsize() to check for overflow")
---
 arch/arm/mach-imx/cache.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
arch/arm/mach-imx/cache.c +14 -0
index ab9b621a2a6..69a085abee7 100644
@@ -7,10 +7,24 @@
 #include <cpu_func.h>
 #include <asm/armv7.h>
 #include <asm/cache.h>
+#include <asm/global_data.h>
 #include <asm/pl310.h>
 #include <asm/io.h>
 #include <asm/mach-imx/sys_proto.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
+phys_size_t get_effective_memsize(void)
+{
+#ifndef CONFIG_MAX_MEM_MAPPED
+	return gd->ram_size;
+#else
+	/* limit stack to what we can reasonable map */
+	return ((gd->ram_size > CONFIG_MAX_MEM_MAPPED) ?
+		CONFIG_MAX_MEM_MAPPED : gd->ram_size);
+#endif
+}
+
 void enable_ca7_smp(void)
 {
 	u32 val;
Signature · 1 line
2.36.0
#2 lore raw

Re: [PATCH 01/11] imx: implement get_effective_memsize

Quoted 9 lines · On Monday 07 November 2022 16:00:06 Peng Fan (OSS) wrote:

From: Peng Fan <[email protected]>

To i.MX6/7 which has 2GB memory, the upper 4KB cut off, will cause the top 1MB not mapped as normal memory, because ARMV7-A use section mapping. So implement i.MX6/7 specific get_effective_memsize to fix the issue.

Fixes 777aaaa706bc("common/memsize.c: Fix get_effective_memsize() to check for overflow")

Should not just configuring CONFIG_MAX_MEM_MAPPED properly avoid that issue?

Quoted 36 lines
---
 arch/arm/mach-imx/cache.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
arch/arm/mach-imx/cache.c +14 -0
index ab9b621a2a6..69a085abee7 100644
@@ -7,10 +7,24 @@
 #include <cpu_func.h>
 #include <asm/armv7.h>
 #include <asm/cache.h>
+#include <asm/global_data.h>
 #include <asm/pl310.h>
 #include <asm/io.h>
 #include <asm/mach-imx/sys_proto.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
+phys_size_t get_effective_memsize(void)
+{
+#ifndef CONFIG_MAX_MEM_MAPPED
+	return gd->ram_size;
+#else
+	/* limit stack to what we can reasonable map */
+	return ((gd->ram_size > CONFIG_MAX_MEM_MAPPED) ?
+		CONFIG_MAX_MEM_MAPPED : gd->ram_size);
+#endif
+}
+
 void enable_ca7_smp(void)
 {
 	u32 val;
Signature · 1 line
2.36.0
author
#3 lore raw

Re: [PATCH 01/11] imx: implement get_effective_memsize

Quoted 8 lines · Pali Rohár
Quoted 7 lines · On Monday 07 November 2022 16:00:06 Peng Fan (OSS) wrote:

From: Peng Fan <[email protected]>

To i.MX6/7 which has 2GB memory, the upper 4KB cut off, will cause the top 1MB not mapped as normal memory, because ARMV7-A use section mapping. So implement i.MX6/7 specific get_effective_memsize to fix the issue.

Quoted 4 lines
Quoted 2 lines
Fixes 777aaaa706bc("common/memsize.c: Fix get_effective_memsize() to check for overflow")

Should not just configuring CONFIG_MAX_MEM_MAPPED properly avoid that issue?

No, unless I decrease PHYS_SDRAM_SIZE.

Regards,
Peng.

Quoted 37 lines
Quoted 37 lines
---
  arch/arm/mach-imx/cache.c | 14 ++++++++++++++
  1 file changed, 14 insertions(+)
arch/arm/mach-imx/cache.c +14 -0
index ab9b621a2a6..69a085abee7 100644
@@ -7,10 +7,24 @@
  #include <cpu_func.h>
  #include <asm/armv7.h>
  #include <asm/cache.h>
+#include <asm/global_data.h>
  #include <asm/pl310.h>
  #include <asm/io.h>
  #include <asm/mach-imx/sys_proto.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
+phys_size_t get_effective_memsize(void)
+{
+#ifndef CONFIG_MAX_MEM_MAPPED
+	return gd->ram_size;
+#else
+	/* limit stack to what we can reasonable map */
+	return ((gd->ram_size > CONFIG_MAX_MEM_MAPPED) ?
+		CONFIG_MAX_MEM_MAPPED : gd->ram_size);
+#endif
+}
+
  void enable_ca7_smp(void)
  {
  	u32 val;
Signature · 1 line
2.36.0
#4 lore raw

Re: [PATCH 01/11] imx: implement get_effective_memsize

Quoted 9 lines · On Tuesday 08 November 2022 09:38:01 Peng Fan wrote:
Quoted 8 lines · Pali Rohár
Quoted 7 lines · On Monday 07 November 2022 16:00:06 Peng Fan (OSS) wrote:

From: Peng Fan <[email protected]>

To i.MX6/7 which has 2GB memory, the upper 4KB cut off, will cause the top 1MB not mapped as normal memory, because ARMV7-A use section mapping. So implement i.MX6/7 specific get_effective_memsize to fix the issue.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Fixes 777aaaa706bc("common/memsize.c: Fix get_effective_memsize() to check for overflow")

Should not just configuring CONFIG_MAX_MEM_MAPPED properly avoid that issue?

No, unless I decrease PHYS_SDRAM_SIZE.

So, what is the issue? I just do not see what happens after 777aaaa706bc that RAM size is calculated incorrectly in your case. I did not catch the description from commit message. What are your gd->ram_size and CONFIG_MAX_MEM_MAPPED values that current code does not work?

Quoted 39 lines

Regards,
Peng.

Quoted 36 lines
Quoted 36 lines
---
  arch/arm/mach-imx/cache.c | 14 ++++++++++++++
  1 file changed, 14 insertions(+)
arch/arm/mach-imx/cache.c +14 -0
index ab9b621a2a6..69a085abee7 100644
@@ -7,10 +7,24 @@
  #include <cpu_func.h>
  #include <asm/armv7.h>
  #include <asm/cache.h>
+#include <asm/global_data.h>
  #include <asm/pl310.h>
  #include <asm/io.h>
  #include <asm/mach-imx/sys_proto.h>
+DECLARE_GLOBAL_DATA_PTR;
+
+phys_size_t get_effective_memsize(void)
+{
+#ifndef CONFIG_MAX_MEM_MAPPED
+	return gd->ram_size;
+#else
+	/* limit stack to what we can reasonable map */
+	return ((gd->ram_size > CONFIG_MAX_MEM_MAPPED) ?
+		CONFIG_MAX_MEM_MAPPED : gd->ram_size);
+#endif
+}
+
  void enable_ca7_smp(void)
  {
  	u32 val;
Signature · 1 line
2.36.0
#5 lore raw

RE: [PATCH 01/11] imx: implement get_effective_memsize

Quoted 17 lines

Subject: Re: [PATCH 01/11] imx: implement get_effective_memsize

Quoted 9 lines · On Tuesday 08 November 2022 09:38:01 Peng Fan wrote:
Quoted 8 lines · Pali Rohár
Quoted 7 lines · On Monday 07 November 2022 16:00:06 Peng Fan (OSS) wrote:

From: Peng Fan <[email protected]>

To i.MX6/7 which has 2GB memory, the upper 4KB cut off, will cause the top 1MB not mapped as normal memory, because ARMV7-A use section mapping. So implement i.MX6/7 specific get_effective_memsize to fix the issue.

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Fixes 777aaaa706bc("common/memsize.c: Fix get_effective_memsize()

to check for overflow")

Should not just configuring CONFIG_MAX_MEM_MAPPED properly avoid

Quoted 8 lines

that issue?

Quoted 2 lines

No, unless I decrease PHYS_SDRAM_SIZE.

So, what is the issue? I just do not see what happens after 777aaaa706bc that RAM size is calculated incorrectly in your case. I did not catch the description from commit message. What are your gd->ram_size and CONFIG_MAX_MEM_MAPPED values that current code does not work?

The base is 2GB, the size is 2GB. With CONFIG_MAX_MEM_MAPPED, the ram_size already decreased by 4KB.

Regards,
Peng.

Quoted 37 lines
Quoted 37 lines

Regards,
Peng.

Quoted 33 lines
Quoted 33 lines
---
  arch/arm/mach-imx/cache.c | 14 ++++++++++++++
  1 file changed, 14 insertions(+)
arch/arm/mach-imx/cache.c +11 -1
index ab9b621a2a6..69a085abee7 100644
@@ -7,10 +7,24 @@
  #include <cpu_func.h>
  #include <asm/armv7.h>
  #include <asm/cache.h>
+#include <asm/global_data.h>
  #include <asm/pl310.h>
  #include <asm/io.h>
  #include <asm/mach-imx/sys_proto.h>
+DECLARE_GLOBAL_DATA_PTR;
+
+phys_size_t get_effective_memsize(void) { #ifndef
+CONFIG_MAX_MEM_MAPPED
+	return gd->ram_size;
+#else
+	/* limit stack to what we can reasonable map */
+	return ((gd->ram_size > CONFIG_MAX_MEM_MAPPED) ?
+		CONFIG_MAX_MEM_MAPPED : gd->ram_size); #endif }
+
  void enable_ca7_smp(void)
  {
  	u32 val;
--

2.36.0

#6 lore raw

Re: [PATCH 01/11] imx: implement get_effective_memsize

Quoted 21 lines · On Tuesday 08 November 2022 07:56:59 Peng Fan wrote:
Quoted 21 lines

Subject: Re: [PATCH 01/11] imx: implement get_effective_memsize

Quoted 9 lines · On Tuesday 08 November 2022 09:38:01 Peng Fan wrote:
Quoted 8 lines · Pali Rohár
Quoted 7 lines · On Monday 07 November 2022 16:00:06 Peng Fan (OSS) wrote:

From: Peng Fan <[email protected]>

To i.MX6/7 which has 2GB memory, the upper 4KB cut off, will cause the top 1MB not mapped as normal memory, because ARMV7-A use section mapping. So implement i.MX6/7 specific get_effective_memsize to fix the issue.

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Fixes 777aaaa706bc("common/memsize.c: Fix get_effective_memsize()

to check for overflow")

Should not just configuring CONFIG_MAX_MEM_MAPPED properly avoid

that issue?

Quoted 2 lines

No, unless I decrease PHYS_SDRAM_SIZE.

Quoted 7 lines
Quoted 4 lines

So, what is the issue? I just do not see what happens after 777aaaa706bc that RAM size is calculated incorrectly in your case. I did not catch the description from commit message. What are your gd->ram_size and CONFIG_MAX_MEM_MAPPED values that current code does not work?

The base is 2GB, the size is 2GB. With CONFIG_MAX_MEM_MAPPED, the ram_size already decreased by 4KB.

If base is 2GB and size is 2GB then ram_top is 4GB which cannot be represented in 32-bit phys_size_t type and hence some of other u-boot functions use 0 as ram_top. Mentioned commit tries to fix this issue. I guess that you have some other hidden problem and my change just showed implication of that. Could you check how is gd->ram_top configured with and without this change?

Quoted 40 lines

Regards,
Peng.

Quoted 37 lines
Quoted 37 lines

Regards,
Peng.

Quoted 33 lines
Quoted 33 lines
---
  arch/arm/mach-imx/cache.c | 14 ++++++++++++++
  1 file changed, 14 insertions(+)
arch/arm/mach-imx/cache.c +11 -1
index ab9b621a2a6..69a085abee7 100644
@@ -7,10 +7,24 @@
  #include <cpu_func.h>
  #include <asm/armv7.h>
  #include <asm/cache.h>
+#include <asm/global_data.h>
  #include <asm/pl310.h>
  #include <asm/io.h>
  #include <asm/mach-imx/sys_proto.h>
+DECLARE_GLOBAL_DATA_PTR;
+
+phys_size_t get_effective_memsize(void) { #ifndef
+CONFIG_MAX_MEM_MAPPED
+	return gd->ram_size;
+#else
+	/* limit stack to what we can reasonable map */
+	return ((gd->ram_size > CONFIG_MAX_MEM_MAPPED) ?
+		CONFIG_MAX_MEM_MAPPED : gd->ram_size); #endif }
+
  void enable_ca7_smp(void)
  {
  	u32 val;
--

2.36.0

author
#7 lore raw

Re: [PATCH 01/11] imx: implement get_effective_memsize

Quoted 27 lines · Pali Rohár
Quoted 26 lines · On Tuesday 08 November 2022 07:56:59 Peng Fan wrote:
Quoted 25 lines

Subject: Re: [PATCH 01/11] imx: implement get_effective_memsize

Quoted 9 lines · On Tuesday 08 November 2022 09:38:01 Peng Fan wrote:
Quoted 8 lines · Pali Rohár
Quoted 7 lines · On Monday 07 November 2022 16:00:06 Peng Fan (OSS) wrote:

From: Peng Fan <[email protected]>

To i.MX6/7 which has 2GB memory, the upper 4KB cut off, will cause the top 1MB not mapped as normal memory, because ARMV7-A use section mapping. So implement i.MX6/7 specific get_effective_memsize to fix the issue.

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Fixes 777aaaa706bc("common/memsize.c: Fix get_effective_memsize()

to check for overflow")

Should not just configuring CONFIG_MAX_MEM_MAPPED properly avoid

that issue?

Quoted 2 lines

No, unless I decrease PHYS_SDRAM_SIZE.

So, what is the issue? I just do not see what happens after 777aaaa706bc that RAM size is calculated incorrectly in your case. I did not catch the description from commit message. What are your gd->ram_size and CONFIG_MAX_MEM_MAPPED values that current code does not work?

Quoted 8 lines
Quoted 2 lines

The base is 2GB, the size is 2GB. With CONFIG_MAX_MEM_MAPPED, the ram_size already decreased by 4KB.

If base is 2GB and size is 2GB then ram_top is 4GB which cannot be represented in 32-bit phys_size_t type and hence some of other u-boot functions use 0 as ram_top. Mentioned commit tries to fix this issue. I guess that you have some other hidden problem and my change just showed implication of that.

The issue is with higher 4KB cut off, the MMU mapping will cut off
1MB or 2MB(section mapping), so after MMU enabled, the PC instruction will not able to fetch instruction in the higher 1MB area because of U-Boot relocated to top of DRAM.

Regards,
Peng.

Could you check how is gd->ram_top

Quoted 42 lines

configured with and without this change?

Quoted 40 lines

Regards,
Peng.

Quoted 37 lines
Quoted 37 lines

Regards,
Peng.

Quoted 33 lines
Quoted 33 lines
---
   arch/arm/mach-imx/cache.c | 14 ++++++++++++++
   1 file changed, 14 insertions(+)
arch/arm/mach-imx/cache.c +11 -1
index ab9b621a2a6..69a085abee7 100644
@@ -7,10 +7,24 @@
   #include <cpu_func.h>
   #include <asm/armv7.h>
   #include <asm/cache.h>
+#include <asm/global_data.h>
   #include <asm/pl310.h>
   #include <asm/io.h>
   #include <asm/mach-imx/sys_proto.h>
+DECLARE_GLOBAL_DATA_PTR;
+
+phys_size_t get_effective_memsize(void) { #ifndef
+CONFIG_MAX_MEM_MAPPED
+	return gd->ram_size;
+#else
+	/* limit stack to what we can reasonable map */
+	return ((gd->ram_size > CONFIG_MAX_MEM_MAPPED) ?
+		CONFIG_MAX_MEM_MAPPED : gd->ram_size); #endif }
+
   void enable_ca7_smp(void)
   {
   	u32 val;
--

2.36.0

#8 lore raw

Re: [PATCH 01/11] imx: implement get_effective_memsize

Quoted 37 lines · On Wednesday 09 November 2022 09:48:53 Peng Fan wrote:
Quoted 27 lines · Pali Rohár
Quoted 26 lines · On Tuesday 08 November 2022 07:56:59 Peng Fan wrote:
Quoted 25 lines

Subject: Re: [PATCH 01/11] imx: implement get_effective_memsize

Quoted 9 lines · On Tuesday 08 November 2022 09:38:01 Peng Fan wrote:
Quoted 8 lines · Pali Rohár
Quoted 7 lines · On Monday 07 November 2022 16:00:06 Peng Fan (OSS) wrote:

From: Peng Fan <[email protected]>

To i.MX6/7 which has 2GB memory, the upper 4KB cut off, will cause the top 1MB not mapped as normal memory, because ARMV7-A use section mapping. So implement i.MX6/7 specific get_effective_memsize to fix the issue.

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Fixes 777aaaa706bc("common/memsize.c: Fix get_effective_memsize()

to check for overflow")

Should not just configuring CONFIG_MAX_MEM_MAPPED properly avoid

that issue?

Quoted 2 lines

No, unless I decrease PHYS_SDRAM_SIZE.

So, what is the issue? I just do not see what happens after 777aaaa706bc that RAM size is calculated incorrectly in your case. I did not catch the description from commit message. What are your gd->ram_size and CONFIG_MAX_MEM_MAPPED values that current code does not work?

Quoted 8 lines
Quoted 2 lines

The base is 2GB, the size is 2GB. With CONFIG_MAX_MEM_MAPPED, the ram_size already decreased by 4KB.

If base is 2GB and size is 2GB then ram_top is 4GB which cannot be represented in 32-bit phys_size_t type and hence some of other u-boot functions use 0 as ram_top. Mentioned commit tries to fix this issue. I guess that you have some other hidden problem and my change just showed implication of that.

Quoted 5 lines

The issue is with higher 4KB cut off, the MMU mapping will cut off 1MB or 2MB(section mapping), so after MMU enabled, the PC instruction will not able to fetch instruction in the higher 1MB area because of U-Boot relocated to
top of DRAM.

But it is not possible to represent whole 4GB of RAM size in 32-bit phys_size_t type. So some cut-off for this storage is required.

Quoted 5 lines

Regards,
Peng.

Could you check how is gd->ram_top

Quoted 1 line

configured with and without this change?

Could you check this?

Quoted 40 lines
Quoted 40 lines
Quoted 40 lines

Regards,
Peng.

Quoted 37 lines
Quoted 37 lines

Regards,
Peng.

Quoted 33 lines
Quoted 33 lines
---
   arch/arm/mach-imx/cache.c | 14 ++++++++++++++
   1 file changed, 14 insertions(+)
arch/arm/mach-imx/cache.c +11 -1
index ab9b621a2a6..69a085abee7 100644
@@ -7,10 +7,24 @@
   #include <cpu_func.h>
   #include <asm/armv7.h>
   #include <asm/cache.h>
+#include <asm/global_data.h>
   #include <asm/pl310.h>
   #include <asm/io.h>
   #include <asm/mach-imx/sys_proto.h>
+DECLARE_GLOBAL_DATA_PTR;
+
+phys_size_t get_effective_memsize(void) { #ifndef
+CONFIG_MAX_MEM_MAPPED
+	return gd->ram_size;
+#else
+	/* limit stack to what we can reasonable map */
+	return ((gd->ram_size > CONFIG_MAX_MEM_MAPPED) ?
+		CONFIG_MAX_MEM_MAPPED : gd->ram_size); #endif }
+
   void enable_ca7_smp(void)
   {
   	u32 val;
--

2.36.0

author
#9 lore raw

Re: [PATCH 01/11] imx: implement get_effective_memsize

Quoted 38 lines · Pali Rohár
Quoted 37 lines · On Wednesday 09 November 2022 09:48:53 Peng Fan wrote:
Quoted 35 lines · Pali Rohár
Quoted 21 lines · On Tuesday 08 November 2022 07:56:59 Peng Fan wrote:
Quoted 21 lines

Subject: Re: [PATCH 01/11] imx: implement get_effective_memsize

Quoted 9 lines · On Tuesday 08 November 2022 09:38:01 Peng Fan wrote:
Quoted 8 lines · Pali Rohár
Quoted 7 lines · On Monday 07 November 2022 16:00:06 Peng Fan (OSS) wrote:

From: Peng Fan <[email protected]>

To i.MX6/7 which has 2GB memory, the upper 4KB cut off, will cause the top 1MB not mapped as normal memory, because ARMV7-A use section mapping. So implement i.MX6/7 specific get_effective_memsize to fix the issue.

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Fixes 777aaaa706bc("common/memsize.c: Fix get_effective_memsize()

to check for overflow")

Should not just configuring CONFIG_MAX_MEM_MAPPED properly avoid

that issue?

Quoted 2 lines

No, unless I decrease PHYS_SDRAM_SIZE.

Quoted 7 lines
Quoted 4 lines

So, what is the issue? I just do not see what happens after 777aaaa706bc that RAM size is calculated incorrectly in your case. I did not catch the description from commit message. What are your gd->ram_size and CONFIG_MAX_MEM_MAPPED values that current code does not work?

The base is 2GB, the size is 2GB. With CONFIG_MAX_MEM_MAPPED, the ram_size already decreased by 4KB.

If base is 2GB and size is 2GB then ram_top is 4GB which cannot be represented in 32-bit phys_size_t type and hence some of other u-boot functions use 0 as ram_top. Mentioned commit tries to fix this issue. I guess that you have some other hidden problem and my change just showed implication of that.

Quoted 8 lines
Quoted 5 lines

The issue is with higher 4KB cut off, the MMU mapping will cut off 1MB or 2MB(section mapping), so after MMU enabled, the PC instruction will not able to fetch instruction in the higher 1MB area because of U-Boot relocated to
top of DRAM.

But it is not possible to represent whole 4GB of RAM size in 32-bit phys_size_t type. So some cut-off for this storage is required.

I understand this. But this means I have to reserve the higher 2MB section because of the 4KB cut off.

Even the ram_top is 0 in my case, it does not matter. The relocaddr is unsigned long, when reserve other memory, it will back to the high address.

Regards,
Peng.

Quoted 49 lines
Quoted 6 lines

Regards,
Peng.

Could you check how is gd->ram_top

Quoted 1 line

configured with and without this change?

Could you check this?

Quoted 40 lines
Quoted 40 lines
Quoted 40 lines

Regards,
Peng.

Quoted 37 lines
Quoted 37 lines

Regards,
Peng.

Quoted 33 lines
Quoted 33 lines
---
    arch/arm/mach-imx/cache.c | 14 ++++++++++++++
    1 file changed, 14 insertions(+)
arch/arm/mach-imx/cache.c +11 -1
index ab9b621a2a6..69a085abee7 100644
@@ -7,10 +7,24 @@
    #include <cpu_func.h>
    #include <asm/armv7.h>
    #include <asm/cache.h>
+#include <asm/global_data.h>
    #include <asm/pl310.h>
    #include <asm/io.h>
    #include <asm/mach-imx/sys_proto.h>
+DECLARE_GLOBAL_DATA_PTR;
+
+phys_size_t get_effective_memsize(void) { #ifndef
+CONFIG_MAX_MEM_MAPPED
+	return gd->ram_size;
+#else
+	/* limit stack to what we can reasonable map */
+	return ((gd->ram_size > CONFIG_MAX_MEM_MAPPED) ?
+		CONFIG_MAX_MEM_MAPPED : gd->ram_size); #endif }
+
    void enable_ca7_smp(void)
    {
    	u32 val;
--

2.36.0

#10 lore raw

Re: [PATCH 01/11] imx: implement get_effective_memsize

Quoted 48 lines · On Tuesday 15 November 2022 11:06:23 Peng Fan wrote:
Quoted 38 lines · Pali Rohár
Quoted 37 lines · On Wednesday 09 November 2022 09:48:53 Peng Fan wrote:
Quoted 35 lines · Pali Rohár
Quoted 21 lines · On Tuesday 08 November 2022 07:56:59 Peng Fan wrote:
Quoted 21 lines

Subject: Re: [PATCH 01/11] imx: implement get_effective_memsize

Quoted 9 lines · On Tuesday 08 November 2022 09:38:01 Peng Fan wrote:
Quoted 8 lines · Pali Rohár
Quoted 7 lines · On Monday 07 November 2022 16:00:06 Peng Fan (OSS) wrote:

From: Peng Fan <[email protected]>

To i.MX6/7 which has 2GB memory, the upper 4KB cut off, will cause the top 1MB not mapped as normal memory, because ARMV7-A use section mapping. So implement i.MX6/7 specific get_effective_memsize to fix the issue.

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Fixes 777aaaa706bc("common/memsize.c: Fix get_effective_memsize()

to check for overflow")

Should not just configuring CONFIG_MAX_MEM_MAPPED properly avoid

that issue?

Quoted 2 lines

No, unless I decrease PHYS_SDRAM_SIZE.

Quoted 7 lines
Quoted 4 lines

So, what is the issue? I just do not see what happens after 777aaaa706bc that RAM size is calculated incorrectly in your case. I did not catch the description from commit message. What are your gd->ram_size and CONFIG_MAX_MEM_MAPPED values that current code does not work?

The base is 2GB, the size is 2GB. With CONFIG_MAX_MEM_MAPPED, the ram_size already decreased by 4KB.

If base is 2GB and size is 2GB then ram_top is 4GB which cannot be represented in 32-bit phys_size_t type and hence some of other u-boot functions use 0 as ram_top. Mentioned commit tries to fix this issue. I guess that you have some other hidden problem and my change just showed implication of that.

Quoted 8 lines
Quoted 5 lines

The issue is with higher 4KB cut off, the MMU mapping will cut off 1MB or 2MB(section mapping), so after MMU enabled, the PC instruction will not able to fetch instruction in the higher 1MB area because of U-Boot relocated to
top of DRAM.

But it is not possible to represent whole 4GB of RAM size in 32-bit phys_size_t type. So some cut-off for this storage is required.

Quoted 6 lines

I understand this. But this means I have to reserve the higher 2MB section because of the 4KB cut off.

Even the ram_top is 0 in my case, it does not matter. The relocaddr is unsigned long, when reserve other memory, it will back to the high address.

Well, zero ram_top did not work, that is why I introduced that commit. Better to cut off 4kB/2MB of RAM size and have working u-boot, as having issues with reserving parts of RAM.

Quoted 52 lines

Regards,
Peng.

Quoted 49 lines
Quoted 6 lines

Regards,
Peng.

Could you check how is gd->ram_top

Quoted 1 line

configured with and without this change?

Could you check this?

Quoted 40 lines
Quoted 40 lines
Quoted 40 lines

Regards,
Peng.

Quoted 37 lines
Quoted 37 lines

Regards,
Peng.

Quoted 33 lines
Quoted 33 lines
---
    arch/arm/mach-imx/cache.c | 14 ++++++++++++++
    1 file changed, 14 insertions(+)
arch/arm/mach-imx/cache.c +11 -1
index ab9b621a2a6..69a085abee7 100644
@@ -7,10 +7,24 @@
    #include <cpu_func.h>
    #include <asm/armv7.h>
    #include <asm/cache.h>
+#include <asm/global_data.h>
    #include <asm/pl310.h>
    #include <asm/io.h>
    #include <asm/mach-imx/sys_proto.h>
+DECLARE_GLOBAL_DATA_PTR;
+
+phys_size_t get_effective_memsize(void) { #ifndef
+CONFIG_MAX_MEM_MAPPED
+	return gd->ram_size;
+#else
+	/* limit stack to what we can reasonable map */
+	return ((gd->ram_size > CONFIG_MAX_MEM_MAPPED) ?
+		CONFIG_MAX_MEM_MAPPED : gd->ram_size); #endif }
+
    void enable_ca7_smp(void)
    {
    	u32 val;
--

2.36.0

author
#11 lore raw

Re: [PATCH 01/11] imx: implement get_effective_memsize

Quoted 52 lines · Pali Rohár
Quoted 51 lines · On Tuesday 15 November 2022 11:06:23 Peng Fan wrote:
Quoted 38 lines · Pali Rohár
Quoted 37 lines · On Wednesday 09 November 2022 09:48:53 Peng Fan wrote:
Quoted 35 lines · Pali Rohár
Quoted 21 lines · On Tuesday 08 November 2022 07:56:59 Peng Fan wrote:
Quoted 21 lines

Subject: Re: [PATCH 01/11] imx: implement get_effective_memsize

Quoted 9 lines · On Tuesday 08 November 2022 09:38:01 Peng Fan wrote:
Quoted 8 lines · Pali Rohár
Quoted 7 lines · On Monday 07 November 2022 16:00:06 Peng Fan (OSS) wrote:

From: Peng Fan <[email protected]>

To i.MX6/7 which has 2GB memory, the upper 4KB cut off, will cause the top 1MB not mapped as normal memory, because ARMV7-A use section mapping. So implement i.MX6/7 specific get_effective_memsize to fix the issue.

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Fixes 777aaaa706bc("common/memsize.c: Fix get_effective_memsize()

to check for overflow")

Should not just configuring CONFIG_MAX_MEM_MAPPED properly avoid

that issue?

Quoted 2 lines

No, unless I decrease PHYS_SDRAM_SIZE.

Quoted 7 lines
Quoted 4 lines

So, what is the issue? I just do not see what happens after 777aaaa706bc that RAM size is calculated incorrectly in your case. I did not catch the description from commit message. What are your gd->ram_size and CONFIG_MAX_MEM_MAPPED values that current code does not work?

The base is 2GB, the size is 2GB. With CONFIG_MAX_MEM_MAPPED, the ram_size already decreased by 4KB.

If base is 2GB and size is 2GB then ram_top is 4GB which cannot be represented in 32-bit phys_size_t type and hence some of other u-boot functions use 0 as ram_top. Mentioned commit tries to fix this issue. I guess that you have some other hidden problem and my change just showed implication of that.

Quoted 8 lines
Quoted 5 lines

The issue is with higher 4KB cut off, the MMU mapping will cut off 1MB or 2MB(section mapping), so after MMU enabled, the PC instruction will not able to fetch instruction in the higher 1MB area because of U-Boot relocated to
top of DRAM.

But it is not possible to represent whole 4GB of RAM size in 32-bit phys_size_t type. So some cut-off for this storage is required.

I understand this. But this means I have to reserve the higher 2MB section because of the 4KB cut off.

Quoted 7 lines
Quoted 3 lines

Even the ram_top is 0 in my case, it does not matter. The relocaddr is unsigned long, when reserve other memory, it will back to the high address.

Well, zero ram_top did not work, that is why I introduced that commit. Better to cut off 4kB/2MB of RAM size and have working u-boot, as having issues with reserving parts of RAM.

But it worked before, right? Is there any changes that cause ram_top as 0 not work?

Thanks,
Peng.

Quoted 53 lines
Quoted 53 lines

Regards,
Peng.

Quoted 49 lines
Quoted 6 lines

Regards,
Peng.

Could you check how is gd->ram_top

Quoted 1 line

configured with and without this change?

Could you check this?

Quoted 40 lines
Quoted 40 lines
Quoted 40 lines

Regards,
Peng.

Quoted 37 lines
Quoted 37 lines

Regards,
Peng.

Quoted 33 lines
Quoted 33 lines
---
     arch/arm/mach-imx/cache.c | 14 ++++++++++++++
     1 file changed, 14 insertions(+)
arch/arm/mach-imx/cache.c +11 -1
index ab9b621a2a6..69a085abee7 100644
@@ -7,10 +7,24 @@
     #include <cpu_func.h>
     #include <asm/armv7.h>
     #include <asm/cache.h>
+#include <asm/global_data.h>
     #include <asm/pl310.h>
     #include <asm/io.h>
     #include <asm/mach-imx/sys_proto.h>
+DECLARE_GLOBAL_DATA_PTR;
+
+phys_size_t get_effective_memsize(void) { #ifndef
+CONFIG_MAX_MEM_MAPPED
+	return gd->ram_size;
+#else
+	/* limit stack to what we can reasonable map */
+	return ((gd->ram_size > CONFIG_MAX_MEM_MAPPED) ?
+		CONFIG_MAX_MEM_MAPPED : gd->ram_size); #endif }
+
     void enable_ca7_smp(void)
     {
     	u32 val;
--

2.36.0

#12 lore raw

Re: [PATCH 01/11] imx: implement get_effective_memsize

Quoted 57 lines · On Tuesday 15 November 2022 16:28:20 Peng Fan wrote:
Quoted 56 lines · Pali Rohár
Quoted 54 lines · On Tuesday 15 November 2022 11:06:23 Peng Fan wrote:
Quoted 38 lines · Pali Rohár
Quoted 37 lines · On Wednesday 09 November 2022 09:48:53 Peng Fan wrote:
Quoted 35 lines · Pali Rohár
Quoted 21 lines · On Tuesday 08 November 2022 07:56:59 Peng Fan wrote:
Quoted 21 lines

Subject: Re: [PATCH 01/11] imx: implement get_effective_memsize

Quoted 9 lines · On Tuesday 08 November 2022 09:38:01 Peng Fan wrote:
Quoted 8 lines · Pali Rohár
Quoted 7 lines · On Monday 07 November 2022 16:00:06 Peng Fan (OSS) wrote:

From: Peng Fan <[email protected]>

To i.MX6/7 which has 2GB memory, the upper 4KB cut off, will cause the top 1MB not mapped as normal memory, because ARMV7-A use section mapping. So implement i.MX6/7 specific get_effective_memsize to fix the issue.

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Fixes 777aaaa706bc("common/memsize.c: Fix get_effective_memsize()

to check for overflow")

Should not just configuring CONFIG_MAX_MEM_MAPPED properly avoid

that issue?

Quoted 2 lines

No, unless I decrease PHYS_SDRAM_SIZE.

Quoted 7 lines
Quoted 4 lines

So, what is the issue? I just do not see what happens after 777aaaa706bc that RAM size is calculated incorrectly in your case. I did not catch the description from commit message. What are your gd->ram_size and CONFIG_MAX_MEM_MAPPED values that current code does not work?

The base is 2GB, the size is 2GB. With CONFIG_MAX_MEM_MAPPED, the ram_size already decreased by 4KB.

If base is 2GB and size is 2GB then ram_top is 4GB which cannot be represented in 32-bit phys_size_t type and hence some of other u-boot functions use 0 as ram_top. Mentioned commit tries to fix this issue. I guess that you have some other hidden problem and my change just showed implication of that.

Quoted 8 lines
Quoted 5 lines

The issue is with higher 4KB cut off, the MMU mapping will cut off 1MB or 2MB(section mapping), so after MMU enabled, the PC instruction will not able to fetch instruction in the higher 1MB area because of U-Boot relocated to
top of DRAM.

But it is not possible to represent whole 4GB of RAM size in 32-bit phys_size_t type. So some cut-off for this storage is required.

I understand this. But this means I have to reserve the higher 2MB section because of the 4KB cut off.

Even the ram_top is 0 in my case, it does not matter. The relocaddr is unsigned long, when reserve other memory, it will back to the high address.

Quoted 6 lines
Quoted 3 lines

Well, zero ram_top did not work, that is why I introduced that commit. Better to cut off 4kB/2MB of RAM size and have working u-boot, as having issues with reserving parts of RAM.

But it worked before, right? Is there any changes that cause ram_top as 0 not work?

It did not work, u-boot at that time hanged during reserving memory space.

Quoted 55 lines

Thanks,
Peng.

Quoted 53 lines
Quoted 53 lines

Regards,
Peng.

Quoted 49 lines
Quoted 6 lines

Regards,
Peng.

Could you check how is gd->ram_top

Quoted 1 line

configured with and without this change?

Could you check this?

Quoted 40 lines
Quoted 40 lines
Quoted 40 lines

Regards,
Peng.

Quoted 37 lines
Quoted 37 lines

Regards,
Peng.

Quoted 33 lines
Quoted 33 lines
---
     arch/arm/mach-imx/cache.c | 14 ++++++++++++++
     1 file changed, 14 insertions(+)
arch/arm/mach-imx/cache.c +11 -1
index ab9b621a2a6..69a085abee7 100644
@@ -7,10 +7,24 @@
     #include <cpu_func.h>
     #include <asm/armv7.h>
     #include <asm/cache.h>
+#include <asm/global_data.h>
     #include <asm/pl310.h>
     #include <asm/io.h>
     #include <asm/mach-imx/sys_proto.h>
+DECLARE_GLOBAL_DATA_PTR;
+
+phys_size_t get_effective_memsize(void) { #ifndef
+CONFIG_MAX_MEM_MAPPED
+	return gd->ram_size;
+#else
+	/* limit stack to what we can reasonable map */
+	return ((gd->ram_size > CONFIG_MAX_MEM_MAPPED) ?
+		CONFIG_MAX_MEM_MAPPED : gd->ram_size); #endif }
+
     void enable_ca7_smp(void)
     {
     	u32 val;
--

2.36.0

author
#13 lore raw

Re: [PATCH 01/11] imx: implement get_effective_memsize

In reply to Pali Rohár

+Tom

Quoted 38 lines · Pali Rohár
Quoted 37 lines · On Wednesday 09 November 2022 09:48:53 Peng Fan wrote:
Quoted 35 lines · Pali Rohár
Quoted 21 lines · On Tuesday 08 November 2022 07:56:59 Peng Fan wrote:
Quoted 21 lines

Subject: Re: [PATCH 01/11] imx: implement get_effective_memsize

Quoted 9 lines · On Tuesday 08 November 2022 09:38:01 Peng Fan wrote:
Quoted 8 lines · Pali Rohár
Quoted 7 lines · On Monday 07 November 2022 16:00:06 Peng Fan (OSS) wrote:

From: Peng Fan <[email protected]>

To i.MX6/7 which has 2GB memory, the upper 4KB cut off, will cause the top 1MB not mapped as normal memory, because ARMV7-A use section mapping. So implement i.MX6/7 specific get_effective_memsize to fix the issue.

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Fixes 777aaaa706bc("common/memsize.c: Fix get_effective_memsize()

to check for overflow")

Should not just configuring CONFIG_MAX_MEM_MAPPED properly avoid

that issue?

Quoted 2 lines

No, unless I decrease PHYS_SDRAM_SIZE.

Quoted 7 lines
Quoted 4 lines

So, what is the issue? I just do not see what happens after 777aaaa706bc that RAM size is calculated incorrectly in your case. I did not catch the description from commit message. What are your gd->ram_size and CONFIG_MAX_MEM_MAPPED values that current code does not work?

The base is 2GB, the size is 2GB. With CONFIG_MAX_MEM_MAPPED, the ram_size already decreased by 4KB.

If base is 2GB and size is 2GB then ram_top is 4GB which cannot be represented in 32-bit phys_size_t type and hence some of other u-boot functions use 0 as ram_top. Mentioned commit tries to fix this issue. I guess that you have some other hidden problem and my change just showed implication of that.

Quoted 8 lines
Quoted 5 lines

The issue is with higher 4KB cut off, the MMU mapping will cut off 1MB or 2MB(section mapping), so after MMU enabled, the PC instruction will not able to fetch instruction in the higher 1MB area because of U-Boot relocated to
top of DRAM.

But it is not possible to represent whole 4GB of RAM size in 32-bit phys_size_t type. So some cut-off for this storage is required.

With your commit
Ram size: 80000000
Ram top: FFFFF000

Your patch would break all i.MX6/7 boards that 2GB memory with base starts at 0x80000000.

After apply this patch, It works, even if RAM top is 0.
Ram size: 80000000
Ram top: 00000000
full log below:
U-Boot 2022.10-00346-gd80f7fc140a-dirty (Nov 16 2022 - 11:24:56 +0800)

initcall: 8780f549
U-Boot code: 87800000 -> 878562BC  BSS: -> 8785D998
initcall: 8780f43d
initcall: 87801fe1
CPU:   Freescale i.MX6SLL rev1.0 at 792MHz
CPU:   Commercial temperature grade (0C to 95C)
Reset cause: POR
initcall: 8780fb21
Model: Freescale i.MX6SLL EVK Board
Board: MX6SLL EVK
initcall: 8780f5b9
initcall: 8780f5a9
DRAM:  initcall: 8780356d
initcall: 8780f87d
Monitor len: 0005D998
Ram size: 80000000
Ram top: 00000000
initcall: 8780f429
initcall: 87801d17
initcall: 8780f5eb
initcall: 8780f5ef
initcall: 8780f501
Reserving 374k for U-Boot at: fff92000
initcall: 8780f611
Reserving 16392k for malloc() at: fef90000
initcall: 8780f56d

Reserving 68 Bytes for Board Info at: fef8ffb0
initcall: 8780f63d
Reserving 248 Bytes for Global Data at: fef8feb0
initcall: 8780f669
Reserving 25600 Bytes for FDT at: fef89ab0
initcall: 8780f5f3
initcall: 8780f5f7
initcall: 8780f607
initcall: 8780f8e1
initcall: 8780f441
initcall: 8780f6c1

RAM Configuration:
Bank #0: 80000000 2 GiB

DRAM: 2 GiB
initcall: 8780f8f3
initcall: 8780f4ed
New Stack Pointer is: fef89a90
initcall: 8780f45b
initcall: 8780f5fb
initcall: 8780f5ff
initcall: 8780f48d
Relocation Offset is: 78792000
Relocating to fff92000, new gd at fef8feb0, sp at fef89a90

initcall: 8780f60b
initcall: 8780f5e3
Core:  74 devices, 16 uclasses, devicetree: separate
MMC:   FSL_SDHC: 0, FSL_SDHC: 2

Loading Environment from MMC... MMC: no card present *** Warning - No block device, using default environment

In:    serial@2020000
Out:   serial@2020000
Err:   serial@2020000
Net:   No ethernet found.
Hit any key to stop autoboot:  0
Quoted 49 lines
Quoted 6 lines

Regards,
Peng.

Could you check how is gd->ram_top

Quoted 1 line

configured with and without this change?

Could you check this?

Quoted 40 lines
Quoted 40 lines
Quoted 40 lines

Regards,
Peng.

Quoted 37 lines
Quoted 37 lines

Regards,
Peng.

Quoted 33 lines
Quoted 33 lines
---
    arch/arm/mach-imx/cache.c | 14 ++++++++++++++
    1 file changed, 14 insertions(+)
arch/arm/mach-imx/cache.c +11 -1
index ab9b621a2a6..69a085abee7 100644
@@ -7,10 +7,24 @@
    #include <cpu_func.h>
    #include <asm/armv7.h>
    #include <asm/cache.h>
+#include <asm/global_data.h>
    #include <asm/pl310.h>
    #include <asm/io.h>
    #include <asm/mach-imx/sys_proto.h>
+DECLARE_GLOBAL_DATA_PTR;
+
+phys_size_t get_effective_memsize(void) { #ifndef
+CONFIG_MAX_MEM_MAPPED
+	return gd->ram_size;
+#else
+	/* limit stack to what we can reasonable map */
+	return ((gd->ram_size > CONFIG_MAX_MEM_MAPPED) ?
+		CONFIG_MAX_MEM_MAPPED : gd->ram_size); #endif }
+
    void enable_ca7_smp(void)
    {
    	u32 val;
--

2.36.0

#14 lore raw

Re: [PATCH 01/11] imx: implement get_effective_memsize

Hi Peng,

please find one late comment from me below...

Quoted 48 lines · Peng Fan

+Tom

Quoted 44 lines · Pali Rohár
Quoted 42 lines · On Wednesday 09 November 2022 09:48:53 Peng Fan wrote:
Quoted 27 lines · Pali Rohár
Quoted 26 lines · On Tuesday 08 November 2022 07:56:59 Peng Fan wrote:
Quoted 25 lines

Subject: Re: [PATCH 01/11] imx: implement get_effective_memsize

Quoted 9 lines · On Tuesday 08 November 2022 09:38:01 Peng Fan wrote:
Quoted 8 lines · Pali Rohár
Quoted 7 lines · On Monday 07 November 2022 16:00:06 Peng Fan (OSS) wrote:

From: Peng Fan <[email protected]>

To i.MX6/7 which has 2GB memory, the upper 4KB cut off, will cause the top 1MB not mapped as normal memory, because ARMV7-A use section mapping. So implement i.MX6/7 specific get_effective_memsize to fix the issue.

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Fixes 777aaaa706bc("common/memsize.c: Fix get_effective_memsize()

to check for overflow")

Should not just configuring CONFIG_MAX_MEM_MAPPED properly avoid

that issue?

Quoted 2 lines

No, unless I decrease PHYS_SDRAM_SIZE.

So, what is the issue? I just do not see what happens after 777aaaa706bc that RAM size is calculated incorrectly in your case. I did not catch the description from commit message. What are your gd->ram_size and CONFIG_MAX_MEM_MAPPED values that current code does not work?

Quoted 8 lines
Quoted 2 lines

The base is 2GB, the size is 2GB. With CONFIG_MAX_MEM_MAPPED, the ram_size already decreased by 4KB.

If base is 2GB and size is 2GB then ram_top is 4GB which cannot be represented in 32-bit phys_size_t type and hence some of other u-boot functions use 0 as ram_top. Mentioned commit tries to fix this issue. I guess that you have some other hidden problem and my change just showed implication of that.

The issue is with higher 4KB cut off, the MMU mapping will cut off 1MB or 2MB(section mapping), so after MMU enabled, the PC instruction will not able to fetch instruction in the higher 1MB area because of U-Boot relocated to
top of DRAM.

Quoted 6 lines
Quoted 2 lines

But it is not possible to represent whole 4GB of RAM size in 32-bit phys_size_t type. So some cut-off for this storage is required.

With your commit
Ram size: 80000000
Ram top: FFFFF000

Looks good to me.

Quoted 2 lines

Your patch would break all i.MX6/7 boards that 2GB memory with base starts at 0x80000000.

Why is this the case?

Quoted 3 lines

After apply this patch, It works, even if RAM top is 0. Ram size: 80000000
Ram top: 00000000

Ughhh. This looks broken to me. Address 0x0000.0000 is a valid address and points to 0! In this case the code just seems to work (as seen below) as 0 is wrapped around since it's a 32bit value.

Quoted 18 lines

full log below:
U-Boot 2022.10-00346-gd80f7fc140a-dirty (Nov 16 2022 - 11:24:56 +0800)

initcall: 8780f549
U-Boot code: 87800000 -> 878562BC  BSS: -> 8785D998
initcall: 8780f43d
initcall: 87801fe1
CPU:   Freescale i.MX6SLL rev1.0 at 792MHz CPU:   Commercial temperature grade (0C to 95C) Reset cause: POR
initcall: 8780fb21
Model: Freescale i.MX6SLL EVK Board
Board: MX6SLL EVK
initcall: 8780f5b9
initcall: 8780f5a9
DRAM:  initcall: 8780356d
initcall: 8780f87d
Monitor len: 0005D998

Quoted 8 lines

Ram size: 80000000
Ram top: 00000000
initcall: 8780f429
initcall: 87801d17
initcall: 8780f5eb
initcall: 8780f5ef
initcall: 8780f501
Reserving 374k for U-Boot at: fff92000

Here we've got the wrap around.

So why does it not work with the Pali's original code leading to a ram-top of 0xFFFFF000? Where does it fail? Could you please post this bootlog as well?

Thanks,
Stefan

Quoted 83 lines

initcall: 8780f611
Reserving 16392k for malloc() at: fef90000
initcall: 8780f56d
Reserving 68 Bytes for Board Info at: fef8ffb0
initcall: 8780f63d
Reserving 248 Bytes for Global Data at: fef8feb0
initcall: 8780f669
Reserving 25600 Bytes for FDT at: fef89ab0
initcall: 8780f5f3
initcall: 8780f5f7
initcall: 8780f607
initcall: 8780f8e1
initcall: 8780f441
initcall: 8780f6c1

RAM Configuration:
Bank #0: 80000000 2 GiB

DRAM:  2 GiB
initcall: 8780f8f3
initcall: 8780f4ed
New Stack Pointer is: fef89a90
initcall: 8780f45b
initcall: 8780f5fb
initcall: 8780f5ff
initcall: 8780f48d
Relocation Offset is: 78792000
Relocating to fff92000, new gd at fef8feb0, sp at fef89a90
initcall: 8780f60b
initcall: 8780f5e3
Core:  74 devices, 16 uclasses, devicetree: separate MMC:   FSL_SDHC: 0, FSL_SDHC: 2
Loading Environment from MMC... MMC: no card present *** Warning - No block device, using default environment

In:    serial@2020000
Out:   serial@2020000
Err:   serial@2020000
Net:   No ethernet found.
Hit any key to stop autoboot:  0

Quoted 41 lines
Quoted 6 lines

Regards,
Peng.

Could you check how is gd->ram_top

Quoted 1 line

configured with and without this change?

Could you check this?

Quoted 32 lines
Quoted 32 lines
Quoted 32 lines

Regards,
Peng.

Quoted 29 lines
Quoted 29 lines

Regards,
Peng.

Quoted 25 lines
Quoted 25 lines

---
    arch/arm/mach-imx/cache.c | 14 ++++++++++++++

    1 file changed, 14 insertions(+)
arch/arm/mach-imx/cache.c +9 -0
index ab9b621a2a6..69a085abee7 100644
@@ -7,10 +7,24 @@
     #include <cpu_func.h>
     #include <asm/armv7.h>
     #include <asm/cache.h>
+#include <asm/global_data.h>
     #include <asm/pl310.h>
     #include <asm/io.h>
     #include <asm/mach-imx/sys_proto.h>
+DECLARE_GLOBAL_DATA_PTR;
+
+phys_size_t get_effective_memsize(void) { #ifndef
+CONFIG_MAX_MEM_MAPPED
+    return gd->ram_size;
+#else
+    /* limit stack to what we can reasonable map */
+    return ((gd->ram_size > CONFIG_MAX_MEM_MAPPED) ?
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
arch/arm/mach-imx/cache.c +2 -0
+        CONFIG_MAX_MEM_MAPPED : gd->ram_size); #endif }
+
     void enable_ca7_smp(void)
     {
         u32 val;
Signature · 1 line
2.36.0

Viele Grüße,
Stefan Roese

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: [email protected]
author
#15 lore raw

Re: [PATCH 01/11] imx: implement get_effective_memsize

Hi Stefan,

Quoted 105 lines · Stefan Roese

Hi Peng,

please find one late comment from me below...

Quoted 51 lines · Peng Fan

+Tom

Quoted 47 lines · Pali Rohár
Quoted 45 lines · On Wednesday 09 November 2022 09:48:53 Peng Fan wrote:
Quoted 29 lines · Pali Rohár
Quoted 28 lines · On Tuesday 08 November 2022 07:56:59 Peng Fan wrote:
Quoted 27 lines

Subject: Re: [PATCH 01/11] imx: implement get_effective_memsize

Quoted 9 lines · On Tuesday 08 November 2022 09:38:01 Peng Fan wrote:
Quoted 8 lines · Pali Rohár
Quoted 7 lines · On Monday 07 November 2022 16:00:06 Peng Fan (OSS) wrote:

From: Peng Fan <[email protected]>

To i.MX6/7 which has 2GB memory, the upper 4KB cut off, will cause the top 1MB not mapped as normal memory, because ARMV7-A use section mapping. So implement i.MX6/7 specific get_effective_memsize to fix the issue.

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Fixes 777aaaa706bc("common/memsize.c: Fix get_effective_memsize()

to check for overflow")

Should not just configuring CONFIG_MAX_MEM_MAPPED properly avoid

that issue?

Quoted 2 lines

No, unless I decrease PHYS_SDRAM_SIZE.

So, what is the issue? I just do not see what happens after 777aaaa706bc
that RAM size is calculated incorrectly in your case. I did not catch the
description from commit message. What are your gd->ram_size and CONFIG_MAX_MEM_MAPPED values that current code does not work?

Quoted 8 lines
Quoted 2 lines

The base is 2GB, the size is 2GB. With CONFIG_MAX_MEM_MAPPED, the ram_size already decreased by 4KB.

If base is 2GB and size is 2GB then ram_top is 4GB which cannot be represented in 32-bit phys_size_t type and hence some of other u-boot functions use 0 as ram_top. Mentioned commit tries to fix this issue. I guess that you have some other hidden problem and my change just showed implication of that.

The issue is with higher 4KB cut off, the MMU mapping will cut off 1MB or 2MB(section mapping), so after MMU enabled, the PC instruction will
not able to fetch instruction in the higher 1MB area because of U-Boot relocated to
top of DRAM.

Quoted 6 lines
Quoted 2 lines

But it is not possible to represent whole 4GB of RAM size in 32-bit phys_size_t type. So some cut-off for this storage is required.

With your commit
Ram size: 80000000
Ram top: FFFFF000

Looks good to me.

Quoted 2 lines

Your patch would break all i.MX6/7 boards that 2GB memory with base starts at 0x80000000.

Why is this the case?

Quoted 3 lines

After apply this patch, It works, even if RAM top is 0. Ram size: 80000000
Ram top: 00000000

Ughhh. This looks broken to me. Address 0x0000.0000 is a valid address and points to 0! In this case the code just seems to work (as seen below) as 0 is wrapped around since it's a 32bit value.

Quoted 18 lines

full log below:
U-Boot 2022.10-00346-gd80f7fc140a-dirty (Nov 16 2022 - 11:24:56 +0800)

initcall: 8780f549
U-Boot code: 87800000 -> 878562BC  BSS: -> 8785D998
initcall: 8780f43d
initcall: 87801fe1
CPU:   Freescale i.MX6SLL rev1.0 at 792MHz CPU:   Commercial temperature grade (0C to 95C) Reset cause: POR
initcall: 8780fb21
Model: Freescale i.MX6SLL EVK Board
Board: MX6SLL EVK
initcall: 8780f5b9
initcall: 8780f5a9
DRAM:  initcall: 8780356d
initcall: 8780f87d
Monitor len: 0005D998

Quoted 8 lines

Ram size: 80000000
Ram top: 00000000
initcall: 8780f429
initcall: 87801d17
initcall: 8780f5eb
initcall: 8780f5ef
initcall: 8780f501
Reserving 374k for U-Boot at: fff92000

Quoted 5 lines

Here we've got the wrap around.

So why does it not work with the Pali's original code leading to a ram-top of 0xFFFFF000? Where does it fail? Could you please post this bootlog as well?

Not has board at hand for now.

0xFFFFF000 only has the top 4KB cut-off, but when we set up MMU mapping, we use section mapping, so the top 1MB will be cut off when do the mmu mapping.

        for (i = bd->bi_dram[bank].start >> MMU_SECTION_SHIFT;
             i < (bd->bi_dram[bank].start >> MMU_SECTION_SHIFT) +
                 (bd->bi_dram[bank].size >> MMU_SECTION_SHIFT);
             i++)
                set_section_dcache(i, DCACHE_DEFAULT_OPTION);

Then the code/data between 0xFF000000 - 0xFFFFF000 are not mapped, cause boot hang.

Thanks,
Peng.

Quoted 99 lines

Thanks,
Stefan

Quoted 83 lines

initcall: 8780f611
Reserving 16392k for malloc() at: fef90000
initcall: 8780f56d
Reserving 68 Bytes for Board Info at: fef8ffb0
initcall: 8780f63d
Reserving 248 Bytes for Global Data at: fef8feb0
initcall: 8780f669
Reserving 25600 Bytes for FDT at: fef89ab0
initcall: 8780f5f3
initcall: 8780f5f7
initcall: 8780f607
initcall: 8780f8e1
initcall: 8780f441
initcall: 8780f6c1

RAM Configuration:
Bank #0: 80000000 2 GiB

DRAM:  2 GiB
initcall: 8780f8f3
initcall: 8780f4ed
New Stack Pointer is: fef89a90
initcall: 8780f45b
initcall: 8780f5fb
initcall: 8780f5ff
initcall: 8780f48d
Relocation Offset is: 78792000
Relocating to fff92000, new gd at fef8feb0, sp at fef89a90
initcall: 8780f60b
initcall: 8780f5e3
Core:  74 devices, 16 uclasses, devicetree: separate MMC:   FSL_SDHC: 0, FSL_SDHC: 2
Loading Environment from MMC... MMC: no card present *** Warning - No block device, using default environment

In:    serial@2020000
Out:   serial@2020000
Err:   serial@2020000
Net:   No ethernet found.
Hit any key to stop autoboot:  0

Quoted 41 lines
Quoted 6 lines

Regards,
Peng.

Could you check how is gd->ram_top

Quoted 1 line

configured with and without this change?

Could you check this?

Quoted 32 lines
Quoted 32 lines
Quoted 32 lines

Regards,
Peng.

Quoted 29 lines
Quoted 29 lines

Regards,
Peng.

Quoted 25 lines
Quoted 25 lines
---
     arch/arm/mach-imx/cache.c | 14 ++++++++++++++
     1 file changed, 14 insertions(+)
arch/arm/mach-imx/cache.c +9 -0
index ab9b621a2a6..69a085abee7 100644
@@ -7,10 +7,24 @@
     #include <cpu_func.h>
     #include <asm/armv7.h>
     #include <asm/cache.h>
+#include <asm/global_data.h>
     #include <asm/pl310.h>
     #include <asm/io.h>
     #include <asm/mach-imx/sys_proto.h>
+DECLARE_GLOBAL_DATA_PTR;
+
+phys_size_t get_effective_memsize(void) { #ifndef
+CONFIG_MAX_MEM_MAPPED
+    return gd->ram_size;
+#else
+    /* limit stack to what we can reasonable map */
+    return ((gd->ram_size > CONFIG_MAX_MEM_MAPPED) ?
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
arch/arm/mach-imx/cache.c +2 -0
+        CONFIG_MAX_MEM_MAPPED : gd->ram_size); #endif }
+
     void enable_ca7_smp(void)
     {
         u32 val;
Signature · 1 line
2.36.0

Viele Grüße,
Stefan Roese

reviewer
#16 lore raw

Re: [PATCH 01/11] imx: implement get_effective_memsize

In reply to Peng Fan (OSS)

Hi Peng,

Quoted 9 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

To i.MX6/7 which has 2GB memory, the upper 4KB cut off, will cause the top 1MB not mapped as normal memory, because ARMV7-A use section mapping. So implement i.MX6/7 specific get_effective_memsize to fix the issue.

Fixes 777aaaa706bc("common/memsize.c: Fix get_effective_memsize() to check for overflow")

This commit has been reverted in master for non-Power PC platforms:

commit d1f4b090dd17ee11373859f2c91af94bf254af7a

Author: Pali Rohár <[email protected]>
Date:   Sat Jan 7 22:55:26 2023 +0100

common/memsize.c: Check for overflow in get_effective_memsize()
only for mpc85xx

This reverts commit 777aaaa706bc ("common/memsize.c: Fix get_effective_memsize() to check for overflow") for non-mpc85xx platforms.

The changes to this generic function, which is intended to help with 32bit platforms with large amounts of memory has unintended side effects (which in turn lead to boot failures) on other platforms which were previously functional.

For now do overflow check only for powerpc mpc85xx platform. It is needed to prevent crashing of P1/P2 boards with 4GB DDR module in 32-bit mode.

Fixes 777aaaa706bc ("common/memsize.c: Fix

get_effective_memsize() to check for overflow")

Can this patch be discarded then?

I just noticed that Stefano applied it to u-boot-imx master-next branch.

#17 lore raw

Re: [PATCH 01/11] imx: implement get_effective_memsize

Quoted 33 lines · Fabio Estevam

Hi Peng,

Quoted 9 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

To i.MX6/7 which has 2GB memory, the upper 4KB cut off, will cause the top 1MB not mapped as normal memory, because ARMV7-A use section mapping. So implement i.MX6/7 specific get_effective_memsize to fix the issue.

Fixes 777aaaa706bc("common/memsize.c: Fix get_effective_memsize() to check for overflow")

This commit has been reverted in master for non-Power PC platforms:

commit d1f4b090dd17ee11373859f2c91af94bf254af7a

Author: Pali Rohár <[email protected]>
Date:   Sat Jan 7 22:55:26 2023 +0100

common/memsize.c: Check for overflow in get_effective_memsize()
only for mpc85xx

This reverts commit 777aaaa706bc ("common/memsize.c: Fix get_effective_memsize() to check for overflow") for non-mpc85xx platforms.

The changes to this generic function, which is intended to help with 32bit platforms with large amounts of memory has unintended side effects (which in turn lead to boot failures) on other platforms which were previously functional.

For now do overflow check only for powerpc mpc85xx platform. It is needed to prevent crashing of P1/P2 boards with 4GB DDR module in 32-bit mode.

Quoted 7 lines
Fixes 777aaaa706bc ("common/memsize.c: Fix

get_effective_memsize() to check for overflow")

Can this patch be discarded then?

I just noticed that Stefano applied it to u-boot-imx master-next branch.

Yes, it is in test - I could let it out for the moment, waiting for Peng's answer.

Regards,
Stefano

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,        Managing Director: Erika Unter
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================
author
#18 lore raw

Re: [PATCH 01/11] imx: implement get_effective_memsize

Quoted 38 lines · Stefano Babic
Quoted 37 lines · Fabio Estevam

Hi Peng,

Quoted 9 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

To i.MX6/7 which has 2GB memory, the upper 4KB cut off, will cause the top 1MB not mapped as normal memory, because ARMV7-A use section mapping. So implement i.MX6/7 specific get_effective_memsize to fix the issue.

Fixes 777aaaa706bc("common/memsize.c: Fix get_effective_memsize() to check for overflow")

This commit has been reverted in master for non-Power PC platforms:

commit d1f4b090dd17ee11373859f2c91af94bf254af7a
Author: Pali Rohár <[email protected]>
Date:   Sat Jan 7 22:55:26 2023 +0100

     common/memsize.c: Check for overflow in get_effective_memsize() only for mpc85xx

     This reverts commit 777aaaa706bc ("common/memsize.c: Fix get_effective_memsize() to check for overflow") for non-mpc85xx platforms.

     The changes to this generic function, which is intended to help with 32bit platforms with large amounts of memory has unintended side effects (which in turn lead to boot failures) on other platforms which were previously functional.

     For now do overflow check only for powerpc mpc85xx platform. It is needed to prevent crashing of P1/P2 boards with 4GB DDR module in 32-bit mode.

Fixes 777aaaa706bc ("common/memsize.c: Fix

get_effective_memsize() to check for overflow")

Quoted 6 lines
Quoted 3 lines

Can this patch be discarded then?

I just noticed that Stefano applied it to u-boot-imx master-next branch.

Yes, it is in test - I could let it out for the moment, waiting for Peng's answer.

Yes, this patch could dropped, since the common code already has fix.

Thanks,
Peng.

Quoted 4 lines

Regards,
Stefano

#19 lore raw

PATCH 2/11 imx: mx6ull_14x14_evk: select DM_SERIAL

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

Select DM_SERIAL

---
 configs/mx6ull_14x14_evk_defconfig        | 1 +
 configs/mx6ull_14x14_evk_plugin_defconfig | 1 +
 2 files changed, 2 insertions(+)
configs/mx6ull_14x14_evk_defconfig +1 -0
index 65db621f156..b13918c2699 100644
@@ -59,6 +59,7 @@ CONFIG_PINCTRL_IMX6=y
 CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
configs/mx6ull_14x14_evk_plugin_defconfig +1 -0
index 55ddd7eabbd..e601056d277 100644
@@ -58,6 +58,7 @@ CONFIG_MII=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX6=y
 CONFIG_DM_REGULATOR=y
+CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
Signature · 1 line
2.36.0
#20 lore raw

PATCH 2/11 imx: mx6ull_14x14_evk: select DM_SERIAL

Quoted 3 lines

From: Peng Fan <[email protected]>
Select DM_SERIAL

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,        Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================
#21 lore raw

PATCH 3/11 imx: mx6ulz: select DM_SERIAL

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

Select DM_SERIAL

---
 configs/mx6ulz_14x14_evk_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/mx6ulz_14x14_evk_defconfig +1 -0
index 0c1b442b682..2df2ccd2681 100644
@@ -48,6 +48,7 @@ CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX6=y
 CONFIG_DM_REGULATOR=y
+CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
Signature · 1 line
2.36.0
#22 lore raw

PATCH 3/11 imx: mx6ulz: select DM_SERIAL

Quoted 3 lines

From: Peng Fan <[email protected]>
Select DM_SERIAL

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,        Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================
#23 lore raw

PATCH 4/11 imx: mx6ull/z_14x14_evk: clean up UART iomux

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

After DM_SERIAL, and set pinctrl_uart1 as pre-reloc, no need initialize iomux at board file.

---
 arch/arm/dts/imx6ull-14x14-evk-u-boot.dtsi |  8 ++++++++
 arch/arm/dts/imx6ulz-14x14-evk-u-boot.dtsi |  8 ++++++++
 board/freescale/mx6ullevk/mx6ullevk.c      | 16 ----------------
 3 files changed, 16 insertions(+), 16 deletions(-)
 create mode 100644 arch/arm/dts/imx6ull-14x14-evk-u-boot.dtsi
 create mode 100644 arch/arm/dts/imx6ulz-14x14-evk-u-boot.dtsi
arch/arm/dts/imx6ull-14x14-evk-u-boot.dtsi new file +8 -0
new file mode 100644
index 00000000000..d283e815e6a
@@ -0,0 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2022 NXP
+ */
+
+&pinctrl_uart1 {
+	u-boot,dm-pre-reloc;
+};
arch/arm/dts/imx6ulz-14x14-evk-u-boot.dtsi new file +8 -0
new file mode 100644
index 00000000000..d283e815e6a
@@ -0,0 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2022 NXP
+ */
+
+&pinctrl_uart1 {
+	u-boot,dm-pre-reloc;
+};
board/freescale/mx6ullevk/mx6ullevk.c +0 -16
index 86c11c7bd3a..87bdbe51c6d 100644
@@ -24,10 +24,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#define UART_PAD_CTRL  (PAD_CTL_PKE | PAD_CTL_PUE |		\
-	PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED |		\
-	PAD_CTL_DSE_40ohm   | PAD_CTL_SRE_FAST  | PAD_CTL_HYS)
-
 int dram_init(void)
 {
 	gd->ram_size = imx_ddr_size();
@@ -35,16 +31,6 @@ int dram_init(void)
 	return 0;
 }
 
-static iomux_v3_cfg_t const uart1_pads[] = {
-	MX6_PAD_UART1_TX_DATA__UART1_DCE_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
-	MX6_PAD_UART1_RX_DATA__UART1_DCE_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
-};
-
-static void setup_iomux_uart(void)
-{
-	imx_iomux_v3_setup_multiple_pads(uart1_pads, ARRAY_SIZE(uart1_pads));
-}
-
 int board_mmc_get_env_dev(int devno)
 {
 	return devno;
@@ -57,8 +43,6 @@ int mmc_map_to_kernel_blk(int devno)
 
 int board_early_init_f(void)
 {
-	setup_iomux_uart();
-
 	return 0;
 }
 
Signature · 1 line
2.36.0
#24 lore raw

Re: [PATCH 04/11] imx: mx6ull/z_14x14_evk: clean up UART iomux

Quoted 76 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

After DM_SERIAL, and set pinctrl_uart1 as pre-reloc, no need initialize iomux at board file.

---
 arch/arm/dts/imx6ull-14x14-evk-u-boot.dtsi |  8 ++++++++
 arch/arm/dts/imx6ulz-14x14-evk-u-boot.dtsi |  8 ++++++++
 board/freescale/mx6ullevk/mx6ullevk.c      | 16 ----------------
 3 files changed, 16 insertions(+), 16 deletions(-)
 create mode 100644 arch/arm/dts/imx6ull-14x14-evk-u-boot.dtsi
 create mode 100644 arch/arm/dts/imx6ulz-14x14-evk-u-boot.dtsi
arch/arm/dts/imx6ull-14x14-evk-u-boot.dtsi new file +8 -0
new file mode 100644
index 00000000000..d283e815e6a
@@ -0,0 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2022 NXP
+ */
+
+&pinctrl_uart1 {
+       u-boot,dm-pre-reloc;
+};
arch/arm/dts/imx6ulz-14x14-evk-u-boot.dtsi new file +8 -0
new file mode 100644
index 00000000000..d283e815e6a
@@ -0,0 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2022 NXP
+ */
+
+&pinctrl_uart1 {
+       u-boot,dm-pre-reloc;
+};
board/freescale/mx6ullevk/mx6ullevk.c +0 -14
index 86c11c7bd3a..87bdbe51c6d 100644
@@ -24,10 +24,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#define UART_PAD_CTRL  (PAD_CTL_PKE | PAD_CTL_PUE |            \
-       PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED |               \
-       PAD_CTL_DSE_40ohm   | PAD_CTL_SRE_FAST  | PAD_CTL_HYS)
-
 int dram_init(void)
 {
        gd->ram_size = imx_ddr_size();
@@ -35,16 +31,6 @@ int dram_init(void)
        return 0;
 }
 
-static iomux_v3_cfg_t const uart1_pads[] = {
-       MX6_PAD_UART1_TX_DATA__UART1_DCE_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
-       MX6_PAD_UART1_RX_DATA__UART1_DCE_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
-};
-
-static void setup_iomux_uart(void)
-{
-       imx_iomux_v3_setup_multiple_pads(uart1_pads, ARRAY_SIZE(uart1_pads));
-}
-
 int board_mmc_get_env_dev(int devno)
 {
        return devno;

board/freescale/mx6ullevk/mx6ullevk.c int mmc_map_to_kernel_blk(int devno) · line 47

Quoted 7 lines
board/freescale/mx6ullevk/mx6ullevk.c +0 -2
@@ -57,8 +43,6 @@ int mmc_map_to_kernel_blk(int devno)
 
 int board_early_init_f(void)
 {
-       setup_iomux_uart();
-
        return 0;
 }

Can you not just drop the entire board_early_init_f function and also the matching CONFIG_BOARD_EARLY_INIT_F=y option too?

#25 lore raw

PATCH 4/11 imx: mx6ull/z_14x14_evk: clean up UART iomux

In reply to Peng Fan (OSS)
Quoted 4 lines

From: Peng Fan <[email protected]>
After DM_SERIAL, and set pinctrl_uart1 as pre-reloc, no need initialize iomux at board file.

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,        Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================
#26 lore raw

PATCH 5/11 imx: mx6sllevk: correct pmic name

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

The prefix 0 has been dropped in dts, so correct in board file

---
 board/freescale/mx6sllevk/mx6sllevk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
board/freescale/mx6sllevk/mx6sllevk.c +1 -1
index b4fddafe640..d9574623300 100644
@@ -58,7 +58,7 @@ int power_init_board(void)
 	u32 switch_num = 6;
 	u32 offset = PFUZE100_SW1CMODE;
 
-	ret = pmic_get("pfuze100@08", &dev);
+	ret = pmic_get("pfuze100@8", &dev);
 	if (ret == -ENODEV)
 		return 0;
 
Signature · 1 line
2.36.0
#27 lore raw

PATCH 5/11 imx: mx6sllevk: correct pmic name

Quoted 3 lines

From: Peng Fan <[email protected]>
The prefix 0 has been dropped in dts, so correct in board file

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,        Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================
#28 lore raw

PATCH 6/11 imx: mx6sllevk: select DM_SERIAL

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

Select DM_SERIAL

---
 arch/arm/dts/imx6sll-evk-u-boot.dtsi  |  8 ++++++++
 board/freescale/mx6sllevk/mx6sllevk.c | 16 ----------------
 configs/mx6sllevk_defconfig           |  1 +
 configs/mx6sllevk_plugin_defconfig    |  1 +
 4 files changed, 10 insertions(+), 16 deletions(-)
 create mode 100644 arch/arm/dts/imx6sll-evk-u-boot.dtsi
arch/arm/dts/imx6sll-evk-u-boot.dtsi new file +8 -0
new file mode 100644
index 00000000000..14d0b58949a
@@ -0,0 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2019, 2021 NXP
+ */
+
+&pinctrl_uart1 {
+	u-boot,dm-pre-reloc;
+};
board/freescale/mx6sllevk/mx6sllevk.c +0 -16
index d9574623300..10a00095aff 100644
@@ -24,10 +24,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#define UART_PAD_CTRL  (PAD_CTL_PKE | PAD_CTL_PUE |		\
-	PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED |		\
-	PAD_CTL_DSE_40ohm   | PAD_CTL_SRE_FAST  | PAD_CTL_HYS)
-
 int dram_init(void)
 {
 	gd->ram_size = imx_ddr_size();
@@ -35,20 +31,10 @@ int dram_init(void)
 	return 0;
 }
 
-static iomux_v3_cfg_t const uart1_pads[] = {
-	MX6_PAD_UART1_TXD__UART1_DCE_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
-	MX6_PAD_UART1_RXD__UART1_DCE_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
-};
-
 static iomux_v3_cfg_t const wdog_pads[] = {
 	MX6_PAD_WDOG_B__WDOG1_B | MUX_PAD_CTRL(NO_PAD_CTRL),
 };
 
-static void setup_iomux_uart(void)
-{
-	imx_iomux_v3_setup_multiple_pads(uart1_pads, ARRAY_SIZE(uart1_pads));
-}
-
 #ifdef CONFIG_DM_PMIC_PFUZE100
 int power_init_board(void)
 {
@@ -94,8 +80,6 @@ int power_init_board(void)
 
 int board_early_init_f(void)
 {
-	setup_iomux_uart();
-
 	return 0;
 }
 
configs/mx6sllevk_defconfig +1 -0
index 39a15ae830e..ea46071626a 100644
@@ -51,6 +51,7 @@ CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_PFUZE100=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_IMX_THERMAL=y
 CONFIG_USB=y
configs/mx6sllevk_plugin_defconfig +1 -0
index 47d82540aca..885dda716c1 100644
@@ -52,6 +52,7 @@ CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_PFUZE100=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_IMX_THERMAL=y
 CONFIG_USB=y
Signature · 1 line
2.36.0
#29 lore raw

PATCH 6/11 imx: mx6sllevk: select DM_SERIAL

Quoted 3 lines

From: Peng Fan <[email protected]>
Select DM_SERIAL

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,        Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================
#30 lore raw

PATCH 7/11 imx: mx6slevk: select DM_SERIAL

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

Select DM_SERIAL

---
 configs/mx6slevk_defconfig        | 1 +
 configs/mx6slevk_spinor_defconfig | 1 +
 configs/mx6slevk_spl_defconfig    | 1 +
 3 files changed, 3 insertions(+)
configs/mx6slevk_defconfig +1 -0
index 018df1bbfaf..3dba1b357e1 100644
@@ -59,6 +59,7 @@ CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_PFUZE100=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
configs/mx6slevk_spinor_defconfig +1 -0
index 5351d03510d..c970271dae8 100644
@@ -59,6 +59,7 @@ CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_PFUZE100=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
configs/mx6slevk_spl_defconfig +1 -0
index 85dc039347e..4863c729097 100644
@@ -74,6 +74,7 @@ CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_PFUZE100=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
Signature · 1 line
2.36.0
#31 lore raw

PATCH 7/11 imx: mx6slevk: select DM_SERIAL

Quoted 3 lines

From: Peng Fan <[email protected]>
Select DM_SERIAL

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,        Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================
#32 lore raw

PATCH 8/11 imx: mx6ul_evk: select DM_SERIAL

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

Select DM_SERIAL

---
 configs/mx6ul_14x14_evk_defconfig | 1 +
 configs/mx6ul_9x9_evk_defconfig   | 1 +
 2 files changed, 2 insertions(+)
configs/mx6ul_14x14_evk_defconfig +1 -0
index 1f1bff1e0c7..bd7b4211c76 100644
@@ -85,6 +85,7 @@ CONFIG_PINCTRL_IMX6=y
 CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
configs/mx6ul_9x9_evk_defconfig +1 -0
index 0b9c1003cdc..8bc7bf4f5e5 100644
@@ -80,6 +80,7 @@ CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_PFUZE100=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
Signature · 1 line
2.36.0
#33 lore raw

PATCH 8/11 imx: mx6ul_evk: select DM_SERIAL

Quoted 3 lines

From: Peng Fan <[email protected]>
Select DM_SERIAL

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,        Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================
#34 lore raw

PATCH 9/11 imx: mx6sxsabreauto: select DM_SERIAL

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

Select DM_SERIAL

---
 arch/arm/dts/imx6sx-sabreauto-u-boot.dtsi       |  4 ++++
 board/freescale/mx6sxsabreauto/mx6sxsabreauto.c | 16 ----------------
 configs/mx6sxsabreauto_defconfig                |  1 +
 3 files changed, 5 insertions(+), 16 deletions(-)
arch/arm/dts/imx6sx-sabreauto-u-boot.dtsi +4 -0
index 549461df71e..7812aa34ee1 100644
@@ -14,3 +14,7 @@
 		compatible = "jedec,spi-nor";
 	};
 };
+
+&pinctrl_uart1 {
+	u-boot,dm-pre-reloc;
+};
board/freescale/mx6sxsabreauto/mx6sxsabreauto.c +0 -16
index 7340a344023..c7fe11fff0b 100644
@@ -33,10 +33,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#define UART_PAD_CTRL  (PAD_CTL_PKE | PAD_CTL_PUE |		\
-	PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED |		\
-	PAD_CTL_DSE_40ohm   | PAD_CTL_SRE_FAST  | PAD_CTL_HYS)
-
 #define ENET_PAD_CTRL  (PAD_CTL_PUS_100K_UP | PAD_CTL_PUE |     \
 	PAD_CTL_SPEED_HIGH   |                                   \
 	PAD_CTL_DSE_48ohm   | PAD_CTL_SRE_FAST)
@@ -59,11 +55,6 @@ int dram_init(void)
 	return 0;
 }
 
-static iomux_v3_cfg_t const uart1_pads[] = {
-	MX6_PAD_GPIO1_IO04__UART1_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
-	MX6_PAD_GPIO1_IO05__UART1_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
-};
-
 static iomux_v3_cfg_t const fec2_pads[] = {
 	MX6_PAD_ENET1_MDC__ENET2_MDC | MUX_PAD_CTRL(ENET_PAD_CTRL),
 	MX6_PAD_ENET1_MDIO__ENET2_MDIO | MUX_PAD_CTRL(ENET_PAD_CTRL),
@@ -81,11 +72,6 @@ static iomux_v3_cfg_t const fec2_pads[] = {
 	MX6_PAD_RGMII2_TXC__ENET2_RGMII_TXC | MUX_PAD_CTRL(ENET_PAD_CTRL),
 };
 
-static void setup_iomux_uart(void)
-{
-	imx_iomux_v3_setup_multiple_pads(uart1_pads, ARRAY_SIZE(uart1_pads));
-}
-
 static int setup_fec(void)
 {
 	struct iomuxc *iomuxc_regs = (struct iomuxc *)IOMUXC_BASE_ADDR;
@@ -216,8 +202,6 @@ int board_ehci_hcd_init(int port)
 
 int board_early_init_f(void)
 {
-	setup_iomux_uart();
-
 	return 0;
 }
 
configs/mx6sxsabreauto_defconfig +1 -0
index 78780a8c706..3e8ba780929 100644
@@ -64,6 +64,7 @@ CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_PFUZE100=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
Signature · 1 line
2.36.0
#35 lore raw

PATCH 9/11 imx: mx6sxsabreauto: select DM_SERIAL

Quoted 3 lines

From: Peng Fan <[email protected]>
Select DM_SERIAL

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,        Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================
#36 lore raw

PATCH 10/11 imx: mx6sabreauto_defconfig: select DM_SERIAL

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

Select DM_SERIAL

---
 configs/mx6sabreauto_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/mx6sabreauto_defconfig +1 -0
index bf6aff8e48e..2566f2a97fc 100644
@@ -96,6 +96,7 @@ CONFIG_PINCTRL_IMX6=y
 CONFIG_POWER_LEGACY=y
 CONFIG_DM_REGULATOR=y
 CONFIG_POWER_I2C=y
+CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
Signature · 1 line
2.36.0
#37 lore raw

PATCH 10/11 imx: mx6sabreauto_defconfig: select DM_SERIAL

Quoted 3 lines

From: Peng Fan <[email protected]>
Select DM_SERIAL

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,        Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================
#38 lore raw

PATCH 11/11 imx: mx6sabresd: select DM_SERIAL

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

Select DM_SERIAL

---
 configs/mx6sabresd_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/mx6sabresd_defconfig +1 -0
index 26cee0eae60..43c668ce5af 100644
@@ -104,6 +104,7 @@ CONFIG_POWER_LEGACY=y
 CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_POWER_I2C=y
+CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
Signature · 1 line
2.36.0
reviewer
#39 lore raw

Re: [PATCH 11/11] imx: mx6sabresd: select DM_SERIAL

Hi Peng,

Quoted 4 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

Select DM_SERIAL

When converting to DM_SERIAL, please also remove setup_iomux_uart() from the board code.

author
#40 lore raw

Re: [PATCH 11/11] imx: mx6sabresd: select DM_SERIAL

Quoted 10 lines · Fabio Estevam

Hi Peng,

Quoted 4 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

Select DM_SERIAL

When converting to DM_SERIAL, please also remove setup_iomux_uart() from the board code.

No, the SPL not use DM_SERIAL. For mx6sabresd, it supports 3 boards, limited SRAM made is hard to enable the DM feature.

Thanks,
Peng.

reviewer
#41 lore raw

Re: [PATCH 11/11] imx: mx6sabresd: select DM_SERIAL

Hi Peng,

Quoted 3 lines · Peng Fan

No, the SPL not use DM_SERIAL. For mx6sabresd, it supports 3 boards, limited SRAM made is hard to enable the DM feature.

setup_iomux_uart() is not called in SPL. It is called inside U-Boot proper.

#42 lore raw

PATCH 11/11 imx: mx6sabresd: select DM_SERIAL

In reply to Peng Fan (OSS)
Quoted 3 lines

From: Peng Fan <[email protected]>
Select DM_SERIAL

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,        Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================