Skip to contentSkip to conversation

configs: Disable LMB and BDI for tools-only

PATCH In review Marek Vasut 4 participants 48 messages Aug 15, 2021 – Sep 4, 2021 2 messages not in the archive

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

PATCH 1/14 configs: Disable LMB and BDI for tools-only

These two options are useless for tools-only build, since they pull in LMB support which is only useful in a running U-Boot.

Cc Simon Glass <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tom Rini <[email protected]>
---
 configs/tools-only_defconfig | 2 ++
 1 file changed, 2 insertions(+)
configs/tools-only_defconfig +2 -0
index f54bc1802c..edfefd5475 100644
@@ -5,6 +5,7 @@ CONFIG_ANDROID_BOOT_IMAGE=y
 CONFIG_FIT=y
 CONFIG_FIT_SIGNATURE=y
 CONFIG_MISC_INIT_F=y
+# CONFIG_CMD_BDI is not set
 # CONFIG_CMD_BOOTD is not set
 # CONFIG_CMD_BOOTM is not set
 # CONFIG_CMD_ELF is not set
@@ -30,3 +31,4 @@ CONFIG_SYSRESET=y
 # CONFIG_VIRTIO_PCI is not set
 # CONFIG_VIRTIO_SANDBOX is not set
 # CONFIG_EFI_LOADER is not set
+# CONFIG_LMB is not set
Signature · 1 line
2.30.2
#1 lore raw

PATCH 2/14 lmb: Use CONFIG_LMB_*_REGIONS only if they are defined

The CONFIG_LMB_*_REGIONS are defined only if CONFIG_LMB is enabled, protect access to those two config options to avoid undefined macro errors.

Cc Simon Glass <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tom Rini <[email protected]>
---
 include/lmb.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/lmb.h +2 -2
index 3c4afdf9f0..fa1474a360 100644
@@ -44,7 +44,7 @@ struct lmb_property {
 struct lmb_region {
 	unsigned long cnt;
 	unsigned long max;
-#if IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
+#if IS_ENABLED(CONFIG_LMB) && IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
 	struct lmb_property region[CONFIG_LMB_MAX_REGIONS];
 #else
 	struct lmb_property *region;
@@ -67,7 +67,7 @@ struct lmb_region {
 struct lmb {
 	struct lmb_region memory;
 	struct lmb_region reserved;
-#if !IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
+#if IS_ENABLED(CONFIG_LMB) && !IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
 	struct lmb_property memory_regions[CONFIG_LMB_MEMORY_REGIONS];
 	struct lmb_property reserved_regions[CONFIG_LMB_RESERVED_REGIONS];
 #endif
Signature · 1 line
2.30.2
#2 lore raw

Re: [PATCH 02/14] lmb: Use CONFIG_LMB_*_REGIONS only if they are defined

Quoted 26 lines · Marek Vasut

The CONFIG_LMB_*_REGIONS are defined only if CONFIG_LMB is enabled, protect access to those two config options to avoid undefined macro errors.

Cc Simon Glass <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tom Rini <[email protected]>
---
 include/lmb.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/lmb.h +1 -1
index 3c4afdf9f0..fa1474a360 100644
@@ -44,7 +44,7 @@ struct lmb_property {
 struct lmb_region {
 	unsigned long cnt;
 	unsigned long max;
-#if IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
+#if IS_ENABLED(CONFIG_LMB) && IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
 	struct lmb_property region[CONFIG_LMB_MAX_REGIONS];
 #else
 	struct lmb_property *region;

include/lmb.h struct lmb_region { · line 73

Quoted 8 lines
include/lmb.h +1 -1
@@ -67,7 +67,7 @@ struct lmb_region {
 struct lmb {
 	struct lmb_region memory;
 	struct lmb_region reserved;
-#if !IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
+#if IS_ENABLED(CONFIG_LMB) && !IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
 	struct lmb_property memory_regions[CONFIG_LMB_MEMORY_REGIONS];
 	struct lmb_property reserved_regions[CONFIG_LMB_RESERVED_REGIONS];
 #endif

We shouldn't need this at all. LMB and LMB_USE_MAX_REGIONS are both in Kconfig and have the dependencies expressed that way.

Signature · 1 line
Tom
#3 lore raw

Re: [PATCH 02/14] lmb: Use CONFIG_LMB_*_REGIONS only if they are defined

Quoted 31 lines · Tom Rini
Quoted 29 lines · Marek Vasut

The CONFIG_LMB_*_REGIONS are defined only if CONFIG_LMB is enabled, protect access to those two config options to avoid undefined macro errors.

Cc Simon Glass <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tom Rini <[email protected]>
---
  include/lmb.h | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
include/lmb.h +1 -1
index 3c4afdf9f0..fa1474a360 100644
@@ -44,7 +44,7 @@ struct lmb_property {
  struct lmb_region {
  	unsigned long cnt;
  	unsigned long max;
-#if IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
+#if IS_ENABLED(CONFIG_LMB) && IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
  	struct lmb_property region[CONFIG_LMB_MAX_REGIONS];
  #else
  	struct lmb_property *region;
@@ -67,7 +67,7 @@ struct lmb_region {
  struct lmb {
  	struct lmb_region memory;
  	struct lmb_region reserved;
Quoted 8 lines

include/lmb.h struct lmb_region { · line 73

Quoted 5 lines
include/lmb.h +1 -1
-#if !IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
+#if IS_ENABLED(CONFIG_LMB) && !IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
  	struct lmb_property memory_regions[CONFIG_LMB_MEMORY_REGIONS];
  	struct lmb_property reserved_regions[CONFIG_LMB_RESERVED_REGIONS];
  #endif

We shouldn't need this at all. LMB and LMB_USE_MAX_REGIONS are both in Kconfig and have the dependencies expressed that way.

However, CONFIG_LMB_MEMORY_REGIONS and CONFIG_LMB_RESERVED_REGIONS may be undefined if CONFIG_LMB and !CONFIG_LMB_USE_MAX_REGIONS . They are four different symbols.

#4 lore raw

Re: [PATCH 02/14] lmb: Use CONFIG_LMB_*_REGIONS only if they are defined

Quoted 15 lines · Marek Vasut
Quoted 14 lines · Tom Rini
Quoted 12 lines · Marek Vasut

The CONFIG_LMB_*_REGIONS are defined only if CONFIG_LMB is enabled, protect access to those two config options to avoid undefined macro errors.

Cc Simon Glass <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tom Rini <[email protected]>
---
  include/lmb.h | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 10 lines
Quoted 10 lines

include/lmb.h struct lmb_property { · line 47

Quoted 10 lines
include/lmb.h +1 -1
index 3c4afdf9f0..fa1474a360 100644
@@ -44,7 +44,7 @@ struct lmb_property {
  struct lmb_region {
  	unsigned long cnt;
  	unsigned long max;
-#if IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
+#if IS_ENABLED(CONFIG_LMB) && IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)

This doesn't make sense to me, still. You cannot enable CONFIG_LMB_USE_MAX_REGIONS without CONFIG_LMB as the former depends on the latter in Kconfig.

Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
include/lmb.h +0 -0
  	struct lmb_property region[CONFIG_LMB_MAX_REGIONS];
  #else
  	struct lmb_property *region;
@@ -67,7 +67,7 @@ struct lmb_region {
  struct lmb {
  	struct lmb_region memory;
  	struct lmb_region reserved;
Quoted 8 lines

include/lmb.h struct lmb_region { · line 73

Quoted 5 lines
include/lmb.h +1 -1
-#if !IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
+#if IS_ENABLED(CONFIG_LMB) && !IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
  	struct lmb_property memory_regions[CONFIG_LMB_MEMORY_REGIONS];
  	struct lmb_property reserved_regions[CONFIG_LMB_RESERVED_REGIONS];
  #endif

We shouldn't need this at all. LMB and LMB_USE_MAX_REGIONS are both in Kconfig and have the dependencies expressed that way.

Quoted 3 lines

However, CONFIG_LMB_MEMORY_REGIONS and CONFIG_LMB_RESERVED_REGIONS may be undefined if CONFIG_LMB and !CONFIG_LMB_USE_MAX_REGIONS . They are four different symbols.

I'm still not seeing it, sorry. Is there some case where we're trying to access a struct lmb without CONFIG_LMB enabled?

Signature · 1 line
Tom
#5 lore raw

Re: [PATCH 02/14] lmb: Use CONFIG_LMB_*_REGIONS only if they are defined

Quoted 47 lines · Tom Rini
Quoted 15 lines · Marek Vasut
Quoted 14 lines · Tom Rini
Quoted 12 lines · Marek Vasut

The CONFIG_LMB_*_REGIONS are defined only if CONFIG_LMB is enabled, protect access to those two config options to avoid undefined macro errors.

Cc Simon Glass <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tom Rini <[email protected]>
---
   include/lmb.h | 4 ++--
   1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 10 lines
Quoted 10 lines

include/lmb.h struct lmb_property { · line 47

Quoted 10 lines
include/lmb.h +1 -1
index 3c4afdf9f0..fa1474a360 100644
@@ -44,7 +44,7 @@ struct lmb_property {
   struct lmb_region {
   	unsigned long cnt;
   	unsigned long max;
-#if IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
+#if IS_ENABLED(CONFIG_LMB) && IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)

This doesn't make sense to me, still. You cannot enable CONFIG_LMB_USE_MAX_REGIONS without CONFIG_LMB as the former depends on the latter in Kconfig.

Quoted 16 lines
Quoted 15 lines

include/lmb.h struct lmb_region { · line 73

Quoted 12 lines
include/lmb.h +1 -1
   	struct lmb_property region[CONFIG_LMB_MAX_REGIONS];
   #else
   	struct lmb_property *region;
@@ -67,7 +67,7 @@ struct lmb_region {
   struct lmb {
   	struct lmb_region memory;
   	struct lmb_region reserved;
-#if !IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
+#if IS_ENABLED(CONFIG_LMB) && !IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
   	struct lmb_property memory_regions[CONFIG_LMB_MEMORY_REGIONS];
   	struct lmb_property reserved_regions[CONFIG_LMB_RESERVED_REGIONS];
   #endif

We shouldn't need this at all. LMB and LMB_USE_MAX_REGIONS are both in Kconfig and have the dependencies expressed that way.

Quoted 7 lines
Quoted 3 lines

However, CONFIG_LMB_MEMORY_REGIONS and CONFIG_LMB_RESERVED_REGIONS may be undefined if CONFIG_LMB and !CONFIG_LMB_USE_MAX_REGIONS . They are four different symbols.

I'm still not seeing it, sorry. Is there some case where we're trying to access a struct lmb without CONFIG_LMB enabled?

See build failure
https://source.denx.de/u-boot/custodians/u-boot-sh/-/jobs/315331

#6 lore raw

Re: [PATCH 02/14] lmb: Use CONFIG_LMB_*_REGIONS only if they are defined

Quoted 52 lines · Marek Vasut
Quoted 51 lines · Tom Rini
Quoted 15 lines · Marek Vasut
Quoted 14 lines · Tom Rini
Quoted 12 lines · Marek Vasut

The CONFIG_LMB_*_REGIONS are defined only if CONFIG_LMB is enabled, protect access to those two config options to avoid undefined macro errors.

Cc Simon Glass <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tom Rini <[email protected]>
---
   include/lmb.h | 4 ++--
   1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 10 lines
Quoted 10 lines

include/lmb.h struct lmb_property { · line 47

Quoted 10 lines
include/lmb.h +1 -1
index 3c4afdf9f0..fa1474a360 100644
@@ -44,7 +44,7 @@ struct lmb_property {
   struct lmb_region {
   	unsigned long cnt;
   	unsigned long max;
-#if IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
+#if IS_ENABLED(CONFIG_LMB) && IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)

This doesn't make sense to me, still. You cannot enable CONFIG_LMB_USE_MAX_REGIONS without CONFIG_LMB as the former depends on the latter in Kconfig.

Quoted 19 lines
Quoted 7 lines
Quoted 7 lines
include/lmb.h +0 -0
   	struct lmb_property region[CONFIG_LMB_MAX_REGIONS];
   #else
   	struct lmb_property *region;
@@ -67,7 +67,7 @@ struct lmb_region {
   struct lmb {
   	struct lmb_region memory;
   	struct lmb_region reserved;
Quoted 8 lines

include/lmb.h struct lmb_region { · line 73

Quoted 5 lines
include/lmb.h +1 -1
-#if !IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
+#if IS_ENABLED(CONFIG_LMB) && !IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
   	struct lmb_property memory_regions[CONFIG_LMB_MEMORY_REGIONS];
   	struct lmb_property reserved_regions[CONFIG_LMB_RESERVED_REGIONS];
   #endif

We shouldn't need this at all. LMB and LMB_USE_MAX_REGIONS are both in Kconfig and have the dependencies expressed that way.

However, CONFIG_LMB_MEMORY_REGIONS and CONFIG_LMB_RESERVED_REGIONS may be undefined if CONFIG_LMB and !CONFIG_LMB_USE_MAX_REGIONS . They are four different symbols.

Quoted 6 lines
Quoted 3 lines

I'm still not seeing it, sorry. Is there some case where we're trying to access a struct lmb without CONFIG_LMB enabled?

See build failure
https://source.denx.de/u-boot/custodians/u-boot-sh/-/jobs/315331

Ah, progress. Drop <lmb.h> from <image.h> since we already have a forward declaration of struct lmb? But it's not failing without this series too, so what's changing?

Signature · 1 line
Tom
#7 lore raw

Re: [PATCH 02/14] lmb: Use CONFIG_LMB_*_REGIONS only if they are defined

Quoted 57 lines · Tom Rini
Quoted 56 lines · Marek Vasut
Quoted 54 lines · Tom Rini
Quoted 15 lines · Marek Vasut
Quoted 14 lines · Tom Rini
Quoted 12 lines · Marek Vasut

The CONFIG_LMB_*_REGIONS are defined only if CONFIG_LMB is enabled, protect access to those two config options to avoid undefined macro errors.

Cc Simon Glass <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tom Rini <[email protected]>
---
    include/lmb.h | 4 ++--
    1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 10 lines
Quoted 10 lines

include/lmb.h struct lmb_property { · line 47

Quoted 10 lines
include/lmb.h +1 -1
index 3c4afdf9f0..fa1474a360 100644
@@ -44,7 +44,7 @@ struct lmb_property {
    struct lmb_region {
    	unsigned long cnt;
    	unsigned long max;
-#if IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
+#if IS_ENABLED(CONFIG_LMB) && IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)

This doesn't make sense to me, still. You cannot enable CONFIG_LMB_USE_MAX_REGIONS without CONFIG_LMB as the former depends on the latter in Kconfig.

Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
include/lmb.h +0 -0
    	struct lmb_property region[CONFIG_LMB_MAX_REGIONS];
    #else
    	struct lmb_property *region;
@@ -67,7 +67,7 @@ struct lmb_region {
    struct lmb {
    	struct lmb_region memory;
    	struct lmb_region reserved;
Quoted 8 lines

include/lmb.h struct lmb_region { · line 73

Quoted 5 lines
include/lmb.h +1 -1
-#if !IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
+#if IS_ENABLED(CONFIG_LMB) && !IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
    	struct lmb_property memory_regions[CONFIG_LMB_MEMORY_REGIONS];
    	struct lmb_property reserved_regions[CONFIG_LMB_RESERVED_REGIONS];
    #endif

We shouldn't need this at all. LMB and LMB_USE_MAX_REGIONS are both in Kconfig and have the dependencies expressed that way.

Quoted 3 lines

However, CONFIG_LMB_MEMORY_REGIONS and CONFIG_LMB_RESERVED_REGIONS may be undefined if CONFIG_LMB and !CONFIG_LMB_USE_MAX_REGIONS . They are four different symbols.

I'm still not seeing it, sorry. Is there some case where we're trying to access a struct lmb without CONFIG_LMB enabled?

Quoted 6 lines
Quoted 2 lines

See build failure
https://source.denx.de/u-boot/custodians/u-boot-sh/-/jobs/315331

Ah, progress. Drop <lmb.h> from <image.h> since we already have a forward declaration of struct lmb? But it's not failing without this series too, so what's changing?

See 01/14 in this series.

#8 lore raw

Re: [PATCH 02/14] lmb: Use CONFIG_LMB_*_REGIONS only if they are defined

Quoted 58 lines · Marek Vasut
Quoted 57 lines · Tom Rini
Quoted 56 lines · Marek Vasut
Quoted 54 lines · Tom Rini
Quoted 15 lines · Marek Vasut
Quoted 14 lines · Tom Rini
Quoted 12 lines · Marek Vasut

The CONFIG_LMB_*_REGIONS are defined only if CONFIG_LMB is enabled, protect access to those two config options to avoid undefined macro errors.

Cc Simon Glass <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tom Rini <[email protected]>
---
    include/lmb.h | 4 ++--
    1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 10 lines
Quoted 10 lines

include/lmb.h struct lmb_property { · line 47

Quoted 10 lines
include/lmb.h +1 -1
index 3c4afdf9f0..fa1474a360 100644
@@ -44,7 +44,7 @@ struct lmb_property {
    struct lmb_region {
    	unsigned long cnt;
    	unsigned long max;
-#if IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
+#if IS_ENABLED(CONFIG_LMB) && IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)

This doesn't make sense to me, still. You cannot enable CONFIG_LMB_USE_MAX_REGIONS without CONFIG_LMB as the former depends on the latter in Kconfig.

Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
include/lmb.h +0 -0
    	struct lmb_property region[CONFIG_LMB_MAX_REGIONS];
    #else
    	struct lmb_property *region;
@@ -67,7 +67,7 @@ struct lmb_region {
    struct lmb {
    	struct lmb_region memory;
    	struct lmb_region reserved;
Quoted 8 lines

include/lmb.h struct lmb_region { · line 73

Quoted 5 lines
include/lmb.h +1 -1
-#if !IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
+#if IS_ENABLED(CONFIG_LMB) && !IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
    	struct lmb_property memory_regions[CONFIG_LMB_MEMORY_REGIONS];
    	struct lmb_property reserved_regions[CONFIG_LMB_RESERVED_REGIONS];
    #endif

We shouldn't need this at all. LMB and LMB_USE_MAX_REGIONS are both in Kconfig and have the dependencies expressed that way.

Quoted 3 lines

However, CONFIG_LMB_MEMORY_REGIONS and CONFIG_LMB_RESERVED_REGIONS may be undefined if CONFIG_LMB and !CONFIG_LMB_USE_MAX_REGIONS . They are four different symbols.

I'm still not seeing it, sorry. Is there some case where we're trying to access a struct lmb without CONFIG_LMB enabled?

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

See build failure
https://source.denx.de/u-boot/custodians/u-boot-sh/-/jobs/315331

Ah, progress. Drop <lmb.h> from <image.h> since we already have a forward declaration of struct lmb? But it's not failing without this series too, so what's changing?

See 01/14 in this series.

Ah, so drop 1/14 then.

Signature · 1 line
Tom
#9 lore raw

Re: [PATCH 02/14] lmb: Use CONFIG_LMB_*_REGIONS only if they are defined

Quoted 62 lines · Tom Rini
Quoted 61 lines · Marek Vasut
Quoted 60 lines · Tom Rini
Quoted 58 lines · Marek Vasut
Quoted 47 lines · Tom Rini
Quoted 15 lines · Marek Vasut
Quoted 14 lines · Tom Rini
Quoted 12 lines · Marek Vasut

The CONFIG_LMB_*_REGIONS are defined only if CONFIG_LMB is enabled, protect access to those two config options to avoid undefined macro errors.

Cc Simon Glass <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tom Rini <[email protected]>
---
     include/lmb.h | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 10 lines
Quoted 10 lines

include/lmb.h struct lmb_property { · line 47

Quoted 10 lines
include/lmb.h +1 -1
index 3c4afdf9f0..fa1474a360 100644
@@ -44,7 +44,7 @@ struct lmb_property {
     struct lmb_region {
     	unsigned long cnt;
     	unsigned long max;
-#if IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
+#if IS_ENABLED(CONFIG_LMB) && IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)

This doesn't make sense to me, still. You cannot enable CONFIG_LMB_USE_MAX_REGIONS without CONFIG_LMB as the former depends on the latter in Kconfig.

Quoted 16 lines
Quoted 15 lines

include/lmb.h struct lmb_region { · line 73

Quoted 12 lines
include/lmb.h +1 -1
     	struct lmb_property region[CONFIG_LMB_MAX_REGIONS];
     #else
     	struct lmb_property *region;
@@ -67,7 +67,7 @@ struct lmb_region {
     struct lmb {
     	struct lmb_region memory;
     	struct lmb_region reserved;
-#if !IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
+#if IS_ENABLED(CONFIG_LMB) && !IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
     	struct lmb_property memory_regions[CONFIG_LMB_MEMORY_REGIONS];
     	struct lmb_property reserved_regions[CONFIG_LMB_RESERVED_REGIONS];
     #endif

We shouldn't need this at all. LMB and LMB_USE_MAX_REGIONS are both in Kconfig and have the dependencies expressed that way.

Quoted 7 lines
Quoted 3 lines

However, CONFIG_LMB_MEMORY_REGIONS and CONFIG_LMB_RESERVED_REGIONS may be undefined if CONFIG_LMB and !CONFIG_LMB_USE_MAX_REGIONS . They are four different symbols.

I'm still not seeing it, sorry. Is there some case where we're trying to access a struct lmb without CONFIG_LMB enabled?

See build failure
https://source.denx.de/u-boot/custodians/u-boot-sh/-/jobs/315331

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Ah, progress. Drop <lmb.h> from <image.h> since we already have a forward declaration of struct lmb? But it's not failing without this series too, so what's changing?

See 01/14 in this series.

Ah, so drop 1/14 then.

Why ? That patch is correct.

#10 lore raw

Re: [PATCH 02/14] lmb: Use CONFIG_LMB_*_REGIONS only if they are defined

Quoted 67 lines · Marek Vasut
Quoted 66 lines · Tom Rini
Quoted 65 lines · Marek Vasut
Quoted 63 lines · Tom Rini
Quoted 52 lines · Marek Vasut
Quoted 51 lines · Tom Rini
Quoted 15 lines · Marek Vasut
Quoted 14 lines · Tom Rini
Quoted 12 lines · Marek Vasut

The CONFIG_LMB_*_REGIONS are defined only if CONFIG_LMB is enabled, protect access to those two config options to avoid undefined macro errors.

Cc Simon Glass <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tom Rini <[email protected]>
---
     include/lmb.h | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 10 lines
Quoted 10 lines

include/lmb.h struct lmb_property { · line 47

Quoted 10 lines
include/lmb.h +1 -1
index 3c4afdf9f0..fa1474a360 100644
@@ -44,7 +44,7 @@ struct lmb_property {
     struct lmb_region {
     	unsigned long cnt;
     	unsigned long max;
-#if IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
+#if IS_ENABLED(CONFIG_LMB) && IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)

This doesn't make sense to me, still. You cannot enable CONFIG_LMB_USE_MAX_REGIONS without CONFIG_LMB as the former depends on the latter in Kconfig.

Quoted 19 lines
Quoted 7 lines
Quoted 7 lines
include/lmb.h +0 -0
     	struct lmb_property region[CONFIG_LMB_MAX_REGIONS];
     #else
     	struct lmb_property *region;
@@ -67,7 +67,7 @@ struct lmb_region {
     struct lmb {
     	struct lmb_region memory;
     	struct lmb_region reserved;
Quoted 8 lines

include/lmb.h struct lmb_region { · line 73

Quoted 5 lines
include/lmb.h +1 -1
-#if !IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
+#if IS_ENABLED(CONFIG_LMB) && !IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
     	struct lmb_property memory_regions[CONFIG_LMB_MEMORY_REGIONS];
     	struct lmb_property reserved_regions[CONFIG_LMB_RESERVED_REGIONS];
     #endif

We shouldn't need this at all. LMB and LMB_USE_MAX_REGIONS are both in Kconfig and have the dependencies expressed that way.

However, CONFIG_LMB_MEMORY_REGIONS and CONFIG_LMB_RESERVED_REGIONS may be undefined if CONFIG_LMB and !CONFIG_LMB_USE_MAX_REGIONS . They are four different symbols.

Quoted 6 lines
Quoted 3 lines

I'm still not seeing it, sorry. Is there some case where we're trying to access a struct lmb without CONFIG_LMB enabled?

See build failure
https://source.denx.de/u-boot/custodians/u-boot-sh/-/jobs/315331

Ah, progress. Drop <lmb.h> from <image.h> since we already have a forward declaration of struct lmb? But it's not failing without this series too, so what's changing?

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

See 01/14 in this series.

Ah, so drop 1/14 then.

Why ? That patch is correct.

It's not quite right, 1/14 and then 2/14 are papering over the fact that lmb.h, and it's including headers / files, need to be cleaned up so that we don't need to have redundant tests in the header.

Signature · 1 line
Tom
#11 lore raw

Re: [PATCH 02/14] lmb: Use CONFIG_LMB_*_REGIONS only if they are defined

Quoted 70 lines · Tom Rini
Quoted 69 lines · Marek Vasut
Quoted 68 lines · Tom Rini
Quoted 66 lines · Marek Vasut
Quoted 57 lines · Tom Rini
Quoted 56 lines · Marek Vasut
Quoted 54 lines · Tom Rini
Quoted 15 lines · Marek Vasut
Quoted 14 lines · Tom Rini
Quoted 12 lines · Marek Vasut

The CONFIG_LMB_*_REGIONS are defined only if CONFIG_LMB is enabled, protect access to those two config options to avoid undefined macro errors.

Cc Simon Glass <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tom Rini <[email protected]>
---
      include/lmb.h | 4 ++--
      1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 10 lines
Quoted 10 lines

include/lmb.h struct lmb_property { · line 47

Quoted 10 lines
include/lmb.h +1 -1
index 3c4afdf9f0..fa1474a360 100644
@@ -44,7 +44,7 @@ struct lmb_property {
      struct lmb_region {
      	unsigned long cnt;
      	unsigned long max;
-#if IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
+#if IS_ENABLED(CONFIG_LMB) && IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)

This doesn't make sense to me, still. You cannot enable CONFIG_LMB_USE_MAX_REGIONS without CONFIG_LMB as the former depends on the latter in Kconfig.

Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
include/lmb.h +0 -0
      	struct lmb_property region[CONFIG_LMB_MAX_REGIONS];
      #else
      	struct lmb_property *region;
@@ -67,7 +67,7 @@ struct lmb_region {
      struct lmb {
      	struct lmb_region memory;
      	struct lmb_region reserved;
Quoted 8 lines

include/lmb.h struct lmb_region { · line 73

Quoted 5 lines
include/lmb.h +1 -1
-#if !IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
+#if IS_ENABLED(CONFIG_LMB) && !IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
      	struct lmb_property memory_regions[CONFIG_LMB_MEMORY_REGIONS];
      	struct lmb_property reserved_regions[CONFIG_LMB_RESERVED_REGIONS];
      #endif

We shouldn't need this at all. LMB and LMB_USE_MAX_REGIONS are both in Kconfig and have the dependencies expressed that way.

Quoted 3 lines

However, CONFIG_LMB_MEMORY_REGIONS and CONFIG_LMB_RESERVED_REGIONS may be undefined if CONFIG_LMB and !CONFIG_LMB_USE_MAX_REGIONS . They are four different symbols.

I'm still not seeing it, sorry. Is there some case where we're trying to access a struct lmb without CONFIG_LMB enabled?

Quoted 6 lines
Quoted 2 lines

See build failure
https://source.denx.de/u-boot/custodians/u-boot-sh/-/jobs/315331

Ah, progress. Drop <lmb.h> from <image.h> since we already have a forward declaration of struct lmb? But it's not failing without this series too, so what's changing?

See 01/14 in this series.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Ah, so drop 1/14 then.

Why ? That patch is correct.

It's not quite right, 1/14 and then 2/14 are papering over the fact that lmb.h, and it's including headers / files, need to be cleaned up so that we don't need to have redundant tests in the header.

1/14 disables LMB and CMD_BDI for tools build, we do not need those, so 1/14 is correct.

What kind of cleanup of lmb.h do you have in mind ?

#12 lore raw

Re: [PATCH 02/14] lmb: Use CONFIG_LMB_*_REGIONS only if they are defined

Quoted 73 lines · Marek Vasut
Quoted 72 lines · Tom Rini
Quoted 71 lines · Marek Vasut
Quoted 69 lines · Tom Rini
Quoted 58 lines · Marek Vasut
Quoted 57 lines · Tom Rini
Quoted 56 lines · Marek Vasut
Quoted 54 lines · Tom Rini
Quoted 15 lines · Marek Vasut
Quoted 14 lines · Tom Rini
Quoted 12 lines · Marek Vasut

The CONFIG_LMB_*_REGIONS are defined only if CONFIG_LMB is enabled, protect access to those two config options to avoid undefined macro errors.

Cc Simon Glass <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tom Rini <[email protected]>
---
      include/lmb.h | 4 ++--
      1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 10 lines
Quoted 10 lines

include/lmb.h struct lmb_property { · line 47

Quoted 10 lines
include/lmb.h +1 -1
index 3c4afdf9f0..fa1474a360 100644
@@ -44,7 +44,7 @@ struct lmb_property {
      struct lmb_region {
      	unsigned long cnt;
      	unsigned long max;
-#if IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
+#if IS_ENABLED(CONFIG_LMB) && IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)

This doesn't make sense to me, still. You cannot enable CONFIG_LMB_USE_MAX_REGIONS without CONFIG_LMB as the former depends on the latter in Kconfig.

Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
include/lmb.h +0 -0
      	struct lmb_property region[CONFIG_LMB_MAX_REGIONS];
      #else
      	struct lmb_property *region;
@@ -67,7 +67,7 @@ struct lmb_region {
      struct lmb {
      	struct lmb_region memory;
      	struct lmb_region reserved;
Quoted 8 lines

include/lmb.h struct lmb_region { · line 73

Quoted 5 lines
include/lmb.h +1 -1
-#if !IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
+#if IS_ENABLED(CONFIG_LMB) && !IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
      	struct lmb_property memory_regions[CONFIG_LMB_MEMORY_REGIONS];
      	struct lmb_property reserved_regions[CONFIG_LMB_RESERVED_REGIONS];
      #endif

We shouldn't need this at all. LMB and LMB_USE_MAX_REGIONS are both in Kconfig and have the dependencies expressed that way.

Quoted 3 lines

However, CONFIG_LMB_MEMORY_REGIONS and CONFIG_LMB_RESERVED_REGIONS may be undefined if CONFIG_LMB and !CONFIG_LMB_USE_MAX_REGIONS . They are four different symbols.

I'm still not seeing it, sorry. Is there some case where we're trying to access a struct lmb without CONFIG_LMB enabled?

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

See build failure
https://source.denx.de/u-boot/custodians/u-boot-sh/-/jobs/315331

Ah, progress. Drop <lmb.h> from <image.h> since we already have a forward declaration of struct lmb? But it's not failing without this series too, so what's changing?

See 01/14 in this series.

Ah, so drop 1/14 then.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Why ? That patch is correct.

It's not quite right, 1/14 and then 2/14 are papering over the fact that lmb.h, and it's including headers / files, need to be cleaned up so that we don't need to have redundant tests in the header.

1/14 disables LMB and CMD_BDI for tools build, we do not need those, so 1/14 is correct.

We don't need to build u-boot at all for tools-only, only the tools-only build target. It's just annoying to exclude the tools-only_defconfig from "sandbox" in CI.

Quoted 1 line

What kind of cleanup of lmb.h do you have in mind ?

Remove it from include/image.h and fix any fall-out from that of files that got <lmb.h> indirectly when they needed it directly instead.

Signature · 1 line
Tom
#13 lore raw

Re: [PATCH 02/14] lmb: Use CONFIG_LMB_*_REGIONS only if they are defined

Quoted 80 lines · Tom Rini
Quoted 79 lines · Marek Vasut
Quoted 77 lines · Tom Rini
Quoted 67 lines · Marek Vasut
Quoted 66 lines · Tom Rini
Quoted 65 lines · Marek Vasut
Quoted 63 lines · Tom Rini
Quoted 52 lines · Marek Vasut
Quoted 51 lines · Tom Rini
Quoted 15 lines · Marek Vasut
Quoted 14 lines · Tom Rini
Quoted 12 lines · Marek Vasut

The CONFIG_LMB_*_REGIONS are defined only if CONFIG_LMB is enabled, protect access to those two config options to avoid undefined macro errors.

Cc Simon Glass <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tom Rini <[email protected]>
---
       include/lmb.h | 4 ++--
       1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 10 lines
Quoted 10 lines

include/lmb.h struct lmb_property { · line 47

Quoted 10 lines
include/lmb.h +1 -1
index 3c4afdf9f0..fa1474a360 100644
@@ -44,7 +44,7 @@ struct lmb_property {
       struct lmb_region {
       	unsigned long cnt;
       	unsigned long max;
-#if IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
+#if IS_ENABLED(CONFIG_LMB) && IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)

This doesn't make sense to me, still. You cannot enable CONFIG_LMB_USE_MAX_REGIONS without CONFIG_LMB as the former depends on the latter in Kconfig.

Quoted 19 lines
Quoted 7 lines
Quoted 7 lines
include/lmb.h +0 -0
       	struct lmb_property region[CONFIG_LMB_MAX_REGIONS];
       #else
       	struct lmb_property *region;
@@ -67,7 +67,7 @@ struct lmb_region {
       struct lmb {
       	struct lmb_region memory;
       	struct lmb_region reserved;
Quoted 8 lines

include/lmb.h struct lmb_region { · line 73

Quoted 5 lines
include/lmb.h +1 -1
-#if !IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
+#if IS_ENABLED(CONFIG_LMB) && !IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
       	struct lmb_property memory_regions[CONFIG_LMB_MEMORY_REGIONS];
       	struct lmb_property reserved_regions[CONFIG_LMB_RESERVED_REGIONS];
       #endif

We shouldn't need this at all. LMB and LMB_USE_MAX_REGIONS are both in Kconfig and have the dependencies expressed that way.

However, CONFIG_LMB_MEMORY_REGIONS and CONFIG_LMB_RESERVED_REGIONS may be undefined if CONFIG_LMB and !CONFIG_LMB_USE_MAX_REGIONS . They are four different symbols.

Quoted 6 lines
Quoted 3 lines

I'm still not seeing it, sorry. Is there some case where we're trying to access a struct lmb without CONFIG_LMB enabled?

See build failure
https://source.denx.de/u-boot/custodians/u-boot-sh/-/jobs/315331

Ah, progress. Drop <lmb.h> from <image.h> since we already have a forward declaration of struct lmb? But it's not failing without this series too, so what's changing?

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

See 01/14 in this series.

Ah, so drop 1/14 then.

Why ? That patch is correct.

It's not quite right, 1/14 and then 2/14 are papering over the fact that lmb.h, and it's including headers / files, need to be cleaned up so that we don't need to have redundant tests in the header.

Quoted 6 lines
Quoted 2 lines

1/14 disables LMB and CMD_BDI for tools build, we do not need those, so 1/14 is correct.

We don't need to build u-boot at all for tools-only, only the tools-only build target. It's just annoying to exclude the tools-only_defconfig from "sandbox" in CI.

So, what exactly is the problem with that 01/14 ? Please elaborate, I believe the patch is correct.

Quoted 4 lines
Quoted 1 line

What kind of cleanup of lmb.h do you have in mind ?

Remove it from include/image.h and fix any fall-out from that of files that got <lmb.h> indirectly when they needed it directly instead.

Uh ... that is likely for a separate series, and a big one.

#14 lore raw

Re: [PATCH 02/14] lmb: Use CONFIG_LMB_*_REGIONS only if they are defined

Quoted 84 lines · Marek Vasut
Quoted 83 lines · Tom Rini
Quoted 81 lines · Marek Vasut
Quoted 70 lines · Tom Rini
Quoted 69 lines · Marek Vasut
Quoted 68 lines · Tom Rini
Quoted 66 lines · Marek Vasut
Quoted 57 lines · Tom Rini
Quoted 56 lines · Marek Vasut
Quoted 54 lines · Tom Rini
Quoted 15 lines · Marek Vasut
Quoted 14 lines · Tom Rini
Quoted 12 lines · Marek Vasut

The CONFIG_LMB_*_REGIONS are defined only if CONFIG_LMB is enabled,
protect access to those two config options to avoid undefined macro
errors.

Signed-off-by: Marek Vasut <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Simon Goldschmidt <[email protected]>
Cc: Tom Rini <[email protected]>
---
include/lmb.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

diff --git a/include/lmb.h b/include/lmb.h
index 3c4afdf9f0..fa1474a360 100644
--- a/include/lmb.h
+++ b/include/lmb.h
@@ -44,7 +44,7 @@ struct lmb_property {
struct lmb_region {
unsigned long cnt;
unsigned long max;
-#if IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
+#if IS_ENABLED(CONFIG_LMB) && IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)

This doesn't make sense to me, still. You cannot enable CONFIG_LMB_USE_MAX_REGIONS without CONFIG_LMB as the former depends on the latter in Kconfig.

Quoted 16 lines
Quoted 7 lines
Quoted 7 lines

struct lmb_property region[CONFIG_LMB_MAX_REGIONS];
#else
struct lmb_property *region;
@@ -67,7 +67,7 @@ struct lmb_region {
struct lmb {
struct lmb_region memory;
struct lmb_region reserved;

Quoted 8 lines
Quoted 5 lines

-#if !IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
+#if IS_ENABLED(CONFIG_LMB) && !IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
struct lmb_property memory_regions[CONFIG_LMB_MEMORY_REGIONS];
struct lmb_property reserved_regions[CONFIG_LMB_RESERVED_REGIONS];
#endif

We shouldn't need this at all. LMB and LMB_USE_MAX_REGIONS are both in Kconfig and have the dependencies expressed that way.

Quoted 3 lines

However, CONFIG_LMB_MEMORY_REGIONS and CONFIG_LMB_RESERVED_REGIONS may be undefined if CONFIG_LMB and !CONFIG_LMB_USE_MAX_REGIONS . They are four different symbols.

I'm still not seeing it, sorry. Is there some case where we're trying to access a struct lmb without CONFIG_LMB enabled?

Quoted 6 lines
Quoted 2 lines

See build failure
https://source.denx.de/u-boot/custodians/u-boot-sh/-/jobs/315331

Ah, progress. Drop <lmb.h> from <image.h> since we already have a forward declaration of struct lmb? But it's not failing without this series too, so what's changing?

See 01/14 in this series.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Ah, so drop 1/14 then.

Why ? That patch is correct.

It's not quite right, 1/14 and then 2/14 are papering over the fact that lmb.h, and it's including headers / files, need to be cleaned up so that we don't need to have redundant tests in the header.

1/14 disables LMB and CMD_BDI for tools build, we do not need those, so 1/14 is correct.

Quoted 6 lines
Quoted 3 lines

We don't need to build u-boot at all for tools-only, only the tools-only build target. It's just annoying to exclude the tools-only_defconfig from "sandbox" in CI.

So, what exactly is the problem with that 01/14 ? Please elaborate, I believe the patch is correct.

You disable LMB in a target that's only building "all" in CI because wasn't ever worth adding ",sandbox" to the all other arches job until perhaps now.

Disabling LMB in tools-only_defconfig then exposes that <lmb.h> can only be included safely when CONFIG_LMB is set.

Adding / extending an #if test in code for something that's already checked for in Kconfig is bad. We spent so much time already removing and shrinking #if tests in the code.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

What kind of cleanup of lmb.h do you have in mind ?

Remove it from include/image.h and fix any fall-out from that of files that got <lmb.h> indirectly when they needed it directly instead.

Uh ... that is likely for a separate series, and a big one.

Honestly, checking again, I'm not sure LMB=n is valid, ever. That's how we keep our running U-Boot from being trivially overwritten and a huge number of security issues from being re-opened.

At this point, I think you should rework things to stop making CONFIG_LMB be optional, it should be a def_bool y.

Signature · 1 line
Tom
#15 lore raw

Re: [PATCH 02/14] lmb: Use CONFIG_LMB_*_REGIONS only if they are defined

Quoted 96 lines · Tom Rini
Quoted 84 lines · Marek Vasut
Quoted 83 lines · Tom Rini
Quoted 81 lines · Marek Vasut
Quoted 70 lines · Tom Rini
Quoted 69 lines · Marek Vasut
Quoted 68 lines · Tom Rini
Quoted 66 lines · Marek Vasut
Quoted 57 lines · Tom Rini
Quoted 56 lines · Marek Vasut
Quoted 54 lines · Tom Rini
Quoted 15 lines · Marek Vasut
Quoted 14 lines · Tom Rini

On Sun, Aug 15, 2021 at 08:13:02PM +0200, Marek Vasut wrote:

The CONFIG_LMB_*_REGIONS are defined only if CONFIG_LMB is enabled,
protect access to those two config options to avoid undefined macro
errors.

Signed-off-by: Marek Vasut <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Simon Goldschmidt <[email protected]>
Cc: Tom Rini <[email protected]>
---
include/lmb.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

Quoted 10 lines
Quoted 10 lines

diff --git a/include/lmb.h b/include/lmb.h
index 3c4afdf9f0..fa1474a360 100644
--- a/include/lmb.h
+++ b/include/lmb.h
@@ -44,7 +44,7 @@ struct lmb_property {
struct lmb_region {
unsigned long cnt;
unsigned long max;
-#if IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
+#if IS_ENABLED(CONFIG_LMB) && IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)

This doesn't make sense to me, still. You cannot enable CONFIG_LMB_USE_MAX_REGIONS without CONFIG_LMB as the former depends on the latter in Kconfig.

Quoted 16 lines
Quoted 15 lines

struct lmb_property region[CONFIG_LMB_MAX_REGIONS];
#else
struct lmb_property *region;
@@ -67,7 +67,7 @@ struct lmb_region {
struct lmb {
struct lmb_region memory;
struct lmb_region reserved;
-#if !IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
+#if IS_ENABLED(CONFIG_LMB) && !IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
struct lmb_property memory_regions[CONFIG_LMB_MEMORY_REGIONS];
struct lmb_property reserved_regions[CONFIG_LMB_RESERVED_REGIONS];
#endif

We shouldn't need this at all. LMB and LMB_USE_MAX_REGIONS are both in
Kconfig and have the dependencies expressed that way.

Quoted 3 lines

However, CONFIG_LMB_MEMORY_REGIONS and CONFIG_LMB_RESERVED_REGIONS may be undefined if CONFIG_LMB and !CONFIG_LMB_USE_MAX_REGIONS . They are four different symbols.

I'm still not seeing it, sorry. Is there some case where we're trying to access a struct lmb without CONFIG_LMB enabled?

Quoted 6 lines
Quoted 2 lines

See build failure
https://source.denx.de/u-boot/custodians/u-boot-sh/-/jobs/315331

Ah, progress. Drop <lmb.h> from <image.h> since we already have a forward declaration of struct lmb? But it's not failing without this series too, so what's changing?

See 01/14 in this series.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Ah, so drop 1/14 then.

Why ? That patch is correct.

It's not quite right, 1/14 and then 2/14 are papering over the fact that lmb.h, and it's including headers / files, need to be cleaned up so that we don't need to have redundant tests in the header.

1/14 disables LMB and CMD_BDI for tools build, we do not need those, so 1/14 is correct.

Quoted 6 lines
Quoted 3 lines

We don't need to build u-boot at all for tools-only, only the tools-only build target. It's just annoying to exclude the tools-only_defconfig from "sandbox" in CI.

So, what exactly is the problem with that 01/14 ? Please elaborate, I believe the patch is correct.

You disable LMB in a target that's only building "all" in CI because wasn't ever worth adding ",sandbox" to the all other arches job until perhaps now.

Quoted 6 lines

Disabling LMB in tools-only_defconfig then exposes that <lmb.h> can only be included safely when CONFIG_LMB is set.

Adding / extending an #if test in code for something that's already checked for in Kconfig is bad. We spent so much time already removing and shrinking #if tests in the code.

So, the patch is correct, the headers need further clean up.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

What kind of cleanup of lmb.h do you have in mind ?

Remove it from include/image.h and fix any fall-out from that of files that got <lmb.h> indirectly when they needed it directly instead.

Uh ... that is likely for a separate series, and a big one.

Honestly, checking again, I'm not sure LMB=n is valid, ever.

Why wouldn't it be ? For tools, LMB=n is perfectly valid.

Quoted 3 lines

That's how
we keep our running U-Boot from being trivially overwritten and a huge number of security issues from being re-opened.

Tools are not running U-Boot.

Quoted 2 lines

At this point, I think you should rework things to stop making CONFIG_LMB be optional, it should be a def_bool y.

I disagree, see above.

#16 lore raw

Re: [PATCH 02/14] lmb: Use CONFIG_LMB_*_REGIONS only if they are defined

Quoted 97 lines · Marek Vasut
Quoted 96 lines · Tom Rini
Quoted 84 lines · Marek Vasut
Quoted 83 lines · Tom Rini
Quoted 81 lines · Marek Vasut
Quoted 70 lines · Tom Rini
Quoted 69 lines · Marek Vasut
Quoted 68 lines · Tom Rini
Quoted 66 lines · Marek Vasut
Quoted 57 lines · Tom Rini
Quoted 56 lines · Marek Vasut
Quoted 54 lines · Tom Rini
Quoted 25 lines · Marek Vasut

On 8/15/21 9:47 PM, Tom Rini wrote:
On Sun, Aug 15, 2021 at 08:13:02PM +0200, Marek Vasut wrote:

The CONFIG_LMB_*_REGIONS are defined only if CONFIG_LMB is enabled,
protect access to those two config options to avoid undefined macro
errors.

Signed-off-by: Marek Vasut <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Simon Goldschmidt <[email protected]>
Cc: Tom Rini <[email protected]>
---
include/lmb.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/lmb.h b/include/lmb.h
index 3c4afdf9f0..fa1474a360 100644
--- a/include/lmb.h
+++ b/include/lmb.h
@@ -44,7 +44,7 @@ struct lmb_property {
struct lmb_region {
unsigned long cnt;
unsigned long max;
-#if IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
+#if IS_ENABLED(CONFIG_LMB) && IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)

This doesn't make sense to me, still. You cannot enable CONFIG_LMB_USE_MAX_REGIONS without CONFIG_LMB as the former depends on the latter in Kconfig.

Quoted 19 lines

struct lmb_property region[CONFIG_LMB_MAX_REGIONS];
#else
struct lmb_property *region;
@@ -67,7 +67,7 @@ struct lmb_region {
struct lmb {
struct lmb_region memory;
struct lmb_region reserved;
-#if !IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
+#if IS_ENABLED(CONFIG_LMB) && !IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
struct lmb_property memory_regions[CONFIG_LMB_MEMORY_REGIONS];
struct lmb_property reserved_regions[CONFIG_LMB_RESERVED_REGIONS];
#endif

We shouldn't need this at all. LMB and LMB_USE_MAX_REGIONS are both in
Kconfig and have the dependencies expressed that way.

However, CONFIG_LMB_MEMORY_REGIONS and CONFIG_LMB_RESERVED_REGIONS may be
undefined if CONFIG_LMB and !CONFIG_LMB_USE_MAX_REGIONS . They are four
different symbols.

I'm still not seeing it, sorry. Is there some case where we're trying to access a struct lmb without CONFIG_LMB enabled?

Quoted 6 lines
Quoted 2 lines

See build failure
https://source.denx.de/u-boot/custodians/u-boot-sh/-/jobs/315331

Ah, progress. Drop <lmb.h> from <image.h> since we already have a forward declaration of struct lmb? But it's not failing without this series too, so what's changing?

See 01/14 in this series.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Ah, so drop 1/14 then.

Why ? That patch is correct.

It's not quite right, 1/14 and then 2/14 are papering over the fact that lmb.h, and it's including headers / files, need to be cleaned up so that we don't need to have redundant tests in the header.

1/14 disables LMB and CMD_BDI for tools build, we do not need those, so 1/14 is correct.

Quoted 6 lines
Quoted 3 lines

We don't need to build u-boot at all for tools-only, only the tools-only build target. It's just annoying to exclude the tools-only_defconfig from "sandbox" in CI.

So, what exactly is the problem with that 01/14 ? Please elaborate, I believe the patch is correct.

You disable LMB in a target that's only building "all" in CI because wasn't ever worth adding ",sandbox" to the all other arches job until perhaps now.

Quoted 8 lines
Quoted 6 lines

Disabling LMB in tools-only_defconfig then exposes that <lmb.h> can only be included safely when CONFIG_LMB is set.

Adding / extending an #if test in code for something that's already checked for in Kconfig is bad. We spent so much time already removing and shrinking #if tests in the code.

So, the patch is correct, the headers need further clean up.

No, it's not. The first patch is wrong because disabling CONFIG_LMB is invalid. The second patch is conceptually wrong because if we're enforcing a check in C for a dependency that's enforced in Kconfig, we have another problem to investigate. Which I did, LMB is non-optional.

Quoted 10 lines
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

What kind of cleanup of lmb.h do you have in mind ?

Remove it from include/image.h and fix any fall-out from that of files that got <lmb.h> indirectly when they needed it directly instead.

Uh ... that is likely for a separate series, and a big one.

Honestly, checking again, I'm not sure LMB=n is valid, ever.

Why wouldn't it be ? For tools, LMB=n is perfectly valid.

Because it's never valid to disable LMB, LMB is what protects the running U-Boot.

It's nonsense to build u-boot on tools-only_defconfig but we don't have a way currently to remove "u-boot" from the all target. Maybe once a few more of the hard/tricky CONFIG symbols get migrated to Kconfig we can then set tools-only_defconfig to NOT build u-boot at all.

Quoted 10 lines
Quoted 3 lines

That's how
we keep our running U-Boot from being trivially overwritten and a huge number of security issues from being re-opened.

Tools are not running U-Boot.

Quoted 2 lines

At this point, I think you should rework things to stop making CONFIG_LMB be optional, it should be a def_bool y.

I disagree, see above.

The only reason "tools-only_defconfig" builds a useless u-boot binary today is in CI where it would be more work than it's worth to make CI exclude that from the build list. But if you want to just do that instead, I'll also accept adding -x tools-only to the azure/gitlab jobs that build all other architectures, as tools-only is tested in its own build job, for it's only valid build target.

Signature · 1 line
Tom
#17 lore raw

Re: [PATCH 02/14] lmb: Use CONFIG_LMB_*_REGIONS only if they are defined

On 8/30/21 2:01 PM, Tom Rini wrote:

[...]

Quoted 45 lines
Quoted 45 lines
Quoted 45 lines
Quoted 31 lines
Quoted 31 lines
Quoted 30 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 19 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines

We shouldn't need this at all. LMB and LMB_USE_MAX_REGIONS are both in
Kconfig and have the dependencies expressed that way.

However, CONFIG_LMB_MEMORY_REGIONS and CONFIG_LMB_RESERVED_REGIONS may be
undefined if CONFIG_LMB and !CONFIG_LMB_USE_MAX_REGIONS . They are four
different symbols.

I'm still not seeing it, sorry. Is there some case where we're trying
to access a struct lmb without CONFIG_LMB enabled?

Quoted 6 lines
Quoted 2 lines

See build failure
https://source.denx.de/u-boot/custodians/u-boot-sh/-/jobs/315331

Ah, progress. Drop <lmb.h> from <image.h> since we already have a forward declaration of struct lmb? But it's not failing without this series too, so what's changing?

See 01/14 in this series.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Ah, so drop 1/14 then.

Why ? That patch is correct.

It's not quite right, 1/14 and then 2/14 are papering over the fact that lmb.h, and it's including headers / files, need to be cleaned up so that we don't need to have redundant tests in the header.

1/14 disables LMB and CMD_BDI for tools build, we do not need those, so 1/14 is correct.

Quoted 6 lines
Quoted 3 lines

We don't need to build u-boot at all for tools-only, only the tools-only build target. It's just annoying to exclude the tools-only_defconfig from "sandbox" in CI.

So, what exactly is the problem with that 01/14 ? Please elaborate, I believe the patch is correct.

You disable LMB in a target that's only building "all" in CI because wasn't ever worth adding ",sandbox" to the all other arches job until perhaps now.

Disabling LMB in tools-only_defconfig then exposes that <lmb.h> can only be included safely when CONFIG_LMB is set.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Adding / extending an #if test in code for something that's already checked for in Kconfig is bad. We spent so much time already removing and shrinking #if tests in the code.

So, the patch is correct, the headers need further clean up.

No, it's not. The first patch is wrong because disabling CONFIG_LMB is invalid.

Please explain why the patch disabling LMB support for tools-only build is invalid. I disagree with this statement, LMB support in tools-only build is useless, because LMB protects parts of running U-Boot from being overwritten.

Quoted 3 lines

The second patch is conceptually wrong because if we're enforcing a check in C for a dependency that's enforced in Kconfig, we have another problem to investigate. Which I did, LMB is non-optional.

Please explain why is LMB non-optional ? I disagree. LMB for tools-only build is useless, hence it should not be enabled.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 1 line

What kind of cleanup of lmb.h do you have in mind ?

Remove it from include/image.h and fix any fall-out from that of files that got <lmb.h> indirectly when they needed it directly instead.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Uh ... that is likely for a separate series, and a big one.

Honestly, checking again, I'm not sure LMB=n is valid, ever.

Why wouldn't it be ? For tools, LMB=n is perfectly valid.

Because it's never valid to disable LMB, LMB is what protects the running U-Boot.

We are talking about tools-only build here, not running U-Boot.

Quoted 14 lines

It's nonsense to build u-boot on tools-only_defconfig but we don't have a way currently to remove "u-boot" from the all target. Maybe once a few more of the hard/tricky CONFIG symbols get migrated to Kconfig we can then set tools-only_defconfig to NOT build u-boot at all.

Quoted 9 lines
Quoted 3 lines

That's how
we keep our running U-Boot from being trivially overwritten and a huge number of security issues from being re-opened.

Tools are not running U-Boot.

Quoted 2 lines

At this point, I think you should rework things to stop making CONFIG_LMB be optional, it should be a def_bool y.

Quoted 8 lines
Quoted 1 line

I disagree, see above.

The only reason "tools-only_defconfig" builds a useless u-boot binary today is in CI where it would be more work than it's worth to make CI exclude that from the build list. But if you want to just do that instead, I'll also accept adding -x tools-only to the azure/gitlab jobs that build all other architectures, as tools-only is tested in its own build job, for it's only valid build target.

The tools-only build is also used elsewhere, to build just that, tools.

[...]

#18 lore raw

Re: [PATCH 02/14] lmb: Use CONFIG_LMB_*_REGIONS only if they are defined

Quoted 102 lines · Marek Vasut

On 8/30/21 2:01 PM, Tom Rini wrote:

[...]

Quoted 45 lines
Quoted 45 lines
Quoted 45 lines
Quoted 31 lines
Quoted 31 lines
Quoted 30 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 19 lines
Quoted 11 lines
Quoted 11 lines

We shouldn't need this at all. LMB and LMB_USE_MAX_REGIONS are both in
Kconfig and have the dependencies expressed that way.

However, CONFIG_LMB_MEMORY_REGIONS and CONFIG_LMB_RESERVED_REGIONS may be
undefined if CONFIG_LMB and !CONFIG_LMB_USE_MAX_REGIONS . They are four
different symbols.

I'm still not seeing it, sorry. Is there some case where we're trying
to access a struct lmb without CONFIG_LMB enabled?

Quoted 6 lines
Quoted 2 lines

See build failure
https://source.denx.de/u-boot/custodians/u-boot-sh/-/jobs/315331

Ah, progress. Drop <lmb.h> from <image.h> since we already have a forward declaration of struct lmb? But it's not failing without this series too, so what's changing?

See 01/14 in this series.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Ah, so drop 1/14 then.

Why ? That patch is correct.

It's not quite right, 1/14 and then 2/14 are papering over the fact that lmb.h, and it's including headers / files, need to be cleaned up so that we don't need to have redundant tests in the header.

1/14 disables LMB and CMD_BDI for tools build, we do not need those, so 1/14 is correct.

Quoted 6 lines
Quoted 3 lines

We don't need to build u-boot at all for tools-only, only the tools-only build target. It's just annoying to exclude the tools-only_defconfig from "sandbox" in CI.

So, what exactly is the problem with that 01/14 ? Please elaborate, I believe the patch is correct.

You disable LMB in a target that's only building "all" in CI because wasn't ever worth adding ",sandbox" to the all other arches job until perhaps now.

Disabling LMB in tools-only_defconfig then exposes that <lmb.h> can only be included safely when CONFIG_LMB is set.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Adding / extending an #if test in code for something that's already checked for in Kconfig is bad. We spent so much time already removing and shrinking #if tests in the code.

So, the patch is correct, the headers need further clean up.

No, it's not. The first patch is wrong because disabling CONFIG_LMB is invalid.

Please explain why the patch disabling LMB support for tools-only build is invalid. I disagree with this statement, LMB support in tools-only build is useless, because LMB protects parts of running U-Boot from being overwritten.

Quoted 3 lines

The second patch is conceptually wrong because if we're enforcing a check in C for a dependency that's enforced in Kconfig, we have another problem to investigate. Which I did, LMB is non-optional.

Please explain why is LMB non-optional ? I disagree. LMB for tools-only build is useless, hence it should not be enabled.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 1 line

What kind of cleanup of lmb.h do you have in mind ?

Remove it from include/image.h and fix any fall-out from that of files that got <lmb.h> indirectly when they needed it directly instead.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Uh ... that is likely for a separate series, and a big one.

Honestly, checking again, I'm not sure LMB=n is valid, ever.

Why wouldn't it be ? For tools, LMB=n is perfectly valid.

Because it's never valid to disable LMB, LMB is what protects the running U-Boot.

We are talking about tools-only build here, not running U-Boot.

Quoted 16 lines

It's nonsense to build u-boot on tools-only_defconfig but we don't have a way currently to remove "u-boot" from the all target. Maybe once a few more of the hard/tricky CONFIG symbols get migrated to Kconfig we can then set tools-only_defconfig to NOT build u-boot at all.

Quoted 10 lines
Quoted 3 lines

That's how
we keep our running U-Boot from being trivially overwritten and a huge number of security issues from being re-opened.

Tools are not running U-Boot.

Quoted 2 lines

At this point, I think you should rework things to stop making CONFIG_LMB be optional, it should be a def_bool y.

I disagree, see above.

Quoted 8 lines
Quoted 6 lines

The only reason "tools-only_defconfig" builds a useless u-boot binary today is in CI where it would be more work than it's worth to make CI exclude that from the build list. But if you want to just do that instead, I'll also accept adding -x tools-only to the azure/gitlab jobs that build all other architectures, as tools-only is tested in its own build job, for it's only valid build target.

The tools-only build is also used elsewhere, to build just that, tools.

I've repeatedly explained myself and what I'm looking for in v2 of this series. I will summarize one last time. The "tools-only_defconfig" is for tools, only. Building anything other than the "tools-only" target isn't useful. In U-Boot itself, LMB is required as that is how we prevent a number of CVEs from being trivial to exploit. v2 of this series needs to drop patches 1 and 2 of v1 of this series. It can further do any of:
1. Nothing else.
2. Add tools-only to the exclude list in the "build everything else" CI job.
3. Make CONFIG_LMB be def_bool y.

Signature · 1 line
Tom
#19 lore raw

Re: [PATCH 02/14] lmb: Use CONFIG_LMB_*_REGIONS only if they are defined

On 9/4/21 4:10 PM, Tom Rini wrote:
[...]

Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines

At this point, I think you should rework things to stop making CONFIG_LMB be optional, it should be a def_bool y.

I disagree, see above.

Quoted 8 lines
Quoted 6 lines

The only reason "tools-only_defconfig" builds a useless u-boot binary today is in CI where it would be more work than it's worth to make CI exclude that from the build list. But if you want to just do that instead, I'll also accept adding -x tools-only to the azure/gitlab jobs that build all other architectures, as tools-only is tested in its own build job, for it's only valid build target.

The tools-only build is also used elsewhere, to build just that, tools.

Quoted 11 lines

I've repeatedly explained myself and what I'm looking for in v2 of this series. I will summarize one last time. The "tools-only_defconfig" is for tools, only. Building anything other than the "tools-only" target isn't useful. In U-Boot itself, LMB is required as that is how we prevent a number of CVEs from being trivial to exploit. v2 of this series needs to drop patches 1 and 2 of v1 of this series. It can further do any of:
1. Nothing else.
2. Add tools-only to the exclude list in the "build everything else" CI job.
3. Make CONFIG_LMB be def_bool y.

If tools-only is for tools, only, then why should it enable LMB ? The tools are userspace tools, they do not need LMB, and so LMB can be disabled.

This is the part which is unclear to me.

#20 lore raw

Re: [PATCH 02/14] lmb: Use CONFIG_LMB_*_REGIONS only if they are defined

Quoted 29 lines · Marek Vasut

On 9/4/21 4:10 PM, Tom Rini wrote:
[...]

Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines

At this point, I think you should rework things to stop making CONFIG_LMB be optional, it should be a def_bool y.

I disagree, see above.

Quoted 8 lines
Quoted 6 lines

The only reason "tools-only_defconfig" builds a useless u-boot binary today is in CI where it would be more work than it's worth to make CI exclude that from the build list. But if you want to just do that instead, I'll also accept adding -x tools-only to the azure/gitlab jobs that build all other architectures, as tools-only is tested in its own build job, for it's only valid build target.

The tools-only build is also used elsewhere, to build just that, tools.

Quoted 11 lines

I've repeatedly explained myself and what I'm looking for in v2 of this series. I will summarize one last time. The "tools-only_defconfig" is for tools, only. Building anything other than the "tools-only" target isn't useful. In U-Boot itself, LMB is required as that is how we prevent a number of CVEs from being trivial to exploit. v2 of this series needs to drop patches 1 and 2 of v1 of this series. It can further do any of:
1. Nothing else.
2. Add tools-only to the exclude list in the "build everything else" CI job.
3. Make CONFIG_LMB be def_bool y.

Quoted 5 lines

If tools-only is for tools, only, then why should it enable LMB ? The tools are userspace tools, they do not need LMB, and so LMB can be disabled.

This is the part which is unclear to me.

I don't know why it's unclear to you at this point, sorry.

Signature · 1 line
Tom
#21 lore raw

Re: [PATCH 02/14] lmb: Use CONFIG_LMB_*_REGIONS only if they are defined

Quoted 30 lines · Tom Rini
Quoted 29 lines · Marek Vasut

On 9/4/21 4:10 PM, Tom Rini wrote:
[...]

Quoted 25 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines

At this point, I think you should rework things to stop making CONFIG_LMB be optional, it should be a def_bool y.

I disagree, see above.

Quoted 8 lines
Quoted 6 lines

The only reason "tools-only_defconfig" builds a useless u-boot binary today is in CI where it would be more work than it's worth to make CI exclude that from the build list. But if you want to just do that instead, I'll also accept adding -x tools-only to the azure/gitlab jobs that build all other architectures, as tools-only is tested in its own build job, for it's only valid build target.

The tools-only build is also used elsewhere, to build just that, tools.

I've repeatedly explained myself and what I'm looking for in v2 of this series. I will summarize one last time. The "tools-only_defconfig" is for tools, only. Building anything other than the "tools-only" target isn't useful. In U-Boot itself, LMB is required as that is how we prevent a number of CVEs from being trivial to exploit. v2 of this series needs to drop patches 1 and 2 of v1 of this series. It can further do any of:
1. Nothing else.
2. Add tools-only to the exclude list in the "build everything else" CI job.
3. Make CONFIG_LMB be def_bool y.

Quoted 7 lines
Quoted 5 lines

If tools-only is for tools, only, then why should it enable LMB ? The tools are userspace tools, they do not need LMB, and so LMB can be disabled.

This is the part which is unclear to me.

I don't know why it's unclear to you at this point, sorry.

Well why exactly does a userspace program require LMB enabled ? What does LMB protect in there ? obviously not U-Boot.

#22 lore raw

Re: [PATCH 02/14] lmb: Use CONFIG_LMB_*_REGIONS only if they are defined

Quoted 35 lines · Marek Vasut
Quoted 34 lines · Tom Rini
Quoted 33 lines · Marek Vasut

On 9/4/21 4:10 PM, Tom Rini wrote:
[...]

Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines

At this point, I think you should rework things to stop making CONFIG_LMB be optional, it should be a def_bool y.

I disagree, see above.

Quoted 8 lines
Quoted 6 lines

The only reason "tools-only_defconfig" builds a useless u-boot binary today is in CI where it would be more work than it's worth to make CI exclude that from the build list. But if you want to just do that instead, I'll also accept adding -x tools-only to the azure/gitlab jobs that build all other architectures, as tools-only is tested in its own build job, for it's only valid build target.

The tools-only build is also used elsewhere, to build just that, tools.

Quoted 11 lines

I've repeatedly explained myself and what I'm looking for in v2 of this series. I will summarize one last time. The "tools-only_defconfig" is for tools, only. Building anything other than the "tools-only" target isn't useful. In U-Boot itself, LMB is required as that is how we prevent a number of CVEs from being trivial to exploit. v2 of this series needs to drop patches 1 and 2 of v1 of this series. It can further do any of:
1. Nothing else.
2. Add tools-only to the exclude list in the "build everything else" CI job.
3. Make CONFIG_LMB be def_bool y.

If tools-only is for tools, only, then why should it enable LMB ? The tools are userspace tools, they do not need LMB, and so LMB can be disabled.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

This is the part which is unclear to me.

I don't know why it's unclear to you at this point, sorry.

Well why exactly does a userspace program require LMB enabled ? What does LMB protect in there ? obviously not U-Boot.

I feel like you've lost the thread.

Signature · 1 line
Tom
#23 lore raw

Re: [PATCH 02/14] lmb: Use CONFIG_LMB_*_REGIONS only if they are defined

Quoted 36 lines · Tom Rini
Quoted 35 lines · Marek Vasut
Quoted 34 lines · Tom Rini
Quoted 33 lines · Marek Vasut

On 9/4/21 4:10 PM, Tom Rini wrote:
[...]

Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines

At this point, I think you should rework things to stop making CONFIG_LMB be optional, it should be a def_bool y.

I disagree, see above.

Quoted 8 lines
Quoted 6 lines

The only reason "tools-only_defconfig" builds a useless u-boot binary today is in CI where it would be more work than it's worth to make CI exclude that from the build list. But if you want to just do that instead, I'll also accept adding -x tools-only to the azure/gitlab jobs that build all other architectures, as tools-only is tested in its own build job, for it's only valid build target.

The tools-only build is also used elsewhere, to build just that, tools.

Quoted 11 lines

I've repeatedly explained myself and what I'm looking for in v2 of this series. I will summarize one last time. The "tools-only_defconfig" is for tools, only. Building anything other than the "tools-only" target isn't useful. In U-Boot itself, LMB is required as that is how we prevent a number of CVEs from being trivial to exploit. v2 of this series needs to drop patches 1 and 2 of v1 of this series. It can further do any of:
1. Nothing else.
2. Add tools-only to the exclude list in the "build everything else" CI job.
3. Make CONFIG_LMB be def_bool y.

If tools-only is for tools, only, then why should it enable LMB ? The tools are userspace tools, they do not need LMB, and so LMB can be disabled.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

This is the part which is unclear to me.

I don't know why it's unclear to you at this point, sorry.

Well why exactly does a userspace program require LMB enabled ? What does LMB protect in there ? obviously not U-Boot.

I feel like you've lost the thread.

Can you please answer my questions above ?

This is exactly what patch 1/14 is about -- disable LMB for tools build, because it is useless for tools build.

#24 lore raw

Re: [PATCH 02/14] lmb: Use CONFIG_LMB_*_REGIONS only if they are defined

[trimming the CC list]

Quoted 39 lines · Marek Vasut
Quoted 38 lines · Tom Rini
Quoted 37 lines · Marek Vasut
Quoted 36 lines · Tom Rini
Quoted 34 lines · Marek Vasut

On 9/4/21 4:10 PM, Tom Rini wrote:
[...]

Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines

At this point, I think you should rework things to stop making CONFIG_LMB be optional, it should be a def_bool y.

I disagree, see above.

Quoted 8 lines
Quoted 6 lines

The only reason "tools-only_defconfig" builds a useless u-boot binary today is in CI where it would be more work than it's worth to make CI exclude that from the build list. But if you want to just do that instead, I'll also accept adding -x tools-only to the azure/gitlab jobs that build all other architectures, as tools-only is tested in its own build job, for it's only valid build target.

The tools-only build is also used elsewhere, to build just that, tools.

Quoted 11 lines

I've repeatedly explained myself and what I'm looking for in v2 of this series. I will summarize one last time. The "tools-only_defconfig" is for tools, only. Building anything other than the "tools-only" target isn't useful. In U-Boot itself, LMB is required as that is how we prevent a number of CVEs from being trivial to exploit. v2 of this series needs to drop patches 1 and 2 of v1 of this series. It can further do any of:
1. Nothing else.
2. Add tools-only to the exclude list in the "build everything else" CI job.
3. Make CONFIG_LMB be def_bool y.

If tools-only is for tools, only, then why should it enable LMB ? The tools are userspace tools, they do not need LMB, and so LMB can be disabled.

This is the part which is unclear to me.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

I don't know why it's unclear to you at this point, sorry.

Well why exactly does a userspace program require LMB enabled ? What does LMB protect in there ? obviously not U-Boot.

I feel like you've lost the thread.

Can you please answer my questions above ?

I have.

Signature · 1 line
Tom
#25 lore raw

Re: [PATCH 02/14] lmb: Use CONFIG_LMB_*_REGIONS only if they are defined

Quoted 44 lines · Tom Rini

[trimming the CC list]

Quoted 41 lines · Marek Vasut
Quoted 40 lines · Tom Rini
Quoted 39 lines · Marek Vasut
Quoted 37 lines · Tom Rini
Quoted 29 lines · Marek Vasut

On 9/4/21 4:10 PM, Tom Rini wrote:
[...]

Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines

At this point, I think you should rework things to stop making CONFIG_LMB be optional, it should be a def_bool y.

I disagree, see above.

Quoted 8 lines
Quoted 6 lines

The only reason "tools-only_defconfig" builds a useless u-boot binary today is in CI where it would be more work than it's worth to make CI exclude that from the build list. But if you want to just do that instead, I'll also accept adding -x tools-only to the azure/gitlab jobs that build all other architectures, as tools-only is tested in its own build job, for it's only valid build target.

The tools-only build is also used elsewhere, to build just that, tools.

Quoted 11 lines

I've repeatedly explained myself and what I'm looking for in v2 of this series. I will summarize one last time. The "tools-only_defconfig" is for tools, only. Building anything other than the "tools-only" target isn't useful. In U-Boot itself, LMB is required as that is how we prevent a number of CVEs from being trivial to exploit. v2 of this series needs to drop patches 1 and 2 of v1 of this series. It can further do any of:
1. Nothing else.
2. Add tools-only to the exclude list in the "build everything else" CI job.
3. Make CONFIG_LMB be def_bool y.

Quoted 5 lines

If tools-only is for tools, only, then why should it enable LMB ? The tools are userspace tools, they do not need LMB, and so LMB can be disabled.

This is the part which is unclear to me.

I don't know why it's unclear to you at this point, sorry.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Well why exactly does a userspace program require LMB enabled ? What does LMB protect in there ? obviously not U-Boot.

I feel like you've lost the thread.

Can you please answer my questions above ?

I have.

This attitude is not helpful. Please answer my questions, if necessary please reiterate, otherwise this discussion cannot be resolved and will only lead to frustration.

#26 lore raw

Re: [PATCH 02/14] lmb: Use CONFIG_LMB_*_REGIONS only if they are defined

Quoted 50 lines · Marek Vasut
Quoted 49 lines · Tom Rini

[trimming the CC list]

Quoted 46 lines · Marek Vasut
Quoted 44 lines · Tom Rini
Quoted 35 lines · Marek Vasut
Quoted 34 lines · Tom Rini
Quoted 33 lines · Marek Vasut

On 9/4/21 4:10 PM, Tom Rini wrote:
[...]

Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines

At this point, I think you should rework things to stop making CONFIG_LMB be optional, it should be a def_bool y.

I disagree, see above.

Quoted 8 lines
Quoted 6 lines

The only reason "tools-only_defconfig" builds a useless u-boot binary today is in CI where it would be more work than it's worth to make CI exclude that from the build list. But if you want to just do that instead, I'll also accept adding -x tools-only to the azure/gitlab jobs that build all other architectures, as tools-only is tested in its own build job, for it's only valid build target.

The tools-only build is also used elsewhere, to build just that, tools.

Quoted 11 lines

I've repeatedly explained myself and what I'm looking for in v2 of this series. I will summarize one last time. The "tools-only_defconfig" is for tools, only. Building anything other than the "tools-only" target isn't useful. In U-Boot itself, LMB is required as that is how we prevent a number of CVEs from being trivial to exploit. v2 of this series needs to drop patches 1 and 2 of v1 of this series. It can further do any of:
1. Nothing else.
2. Add tools-only to the exclude list in the "build everything else" CI job.
3. Make CONFIG_LMB be def_bool y.

If tools-only is for tools, only, then why should it enable LMB ? The tools are userspace tools, they do not need LMB, and so LMB can be disabled.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

This is the part which is unclear to me.

I don't know why it's unclear to you at this point, sorry.

Well why exactly does a userspace program require LMB enabled ? What does LMB protect in there ? obviously not U-Boot.

I feel like you've lost the thread.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Can you please answer my questions above ?

I have.

This attitude is not helpful. Please answer my questions, if necessary please reiterate, otherwise this discussion cannot be resolved and will only lead to frustration.

One last time then. The only reason tools-only_defconfig is ever built for a target other than "tools-only" is because CI does not exclude it from the world build stage. You can fix this by doing option #2 still quoted above.

The only CONFIG options that are at all valid for "tools-only" and so the host tools related, are LOCALVERSION (which is why there's a tools-only defconfig at all) and now TOOLS_LIBCRYPTO. Nothing else at all should matter as the tools should always be the same. So your point about "what does userspace need LMB for" is irrelevant. The host tools should need NO option be enabled/disabled.

Further, "disabling FOO breaks the build" means we need to investigate what the correct resolution is. In this case, LMB needs to be def_bool y. This is option #3 above. Why does u-boot-as-sandbox need LMB? Because that's how we ensure that the tests that check for overlap fail as expected.

Finally, you can just drop the first two patches and call me too stubborn. This is option #1 above.

Signature · 1 line
Tom
#27 lore raw

PATCH 3/14 lmb: Always compile arch_lmb_reserve() into U-Boot on arm

In reply to Marek Vasut

The arch_lmb_reserve() is called by lib/lmb.c lmb_reserve_common() even if CMD_BOOT{I,M,Z} is not enabled. However, the arm32/arm64 variant of arch_lmb_reserve() is only compiled in if CMD_BOOT{I,M,Z} is enabled.

This currently does not trigger build error, because there is an empty weak implementation of arch_lmb_reserve(), however that is not the function that should be used on arm32/arm64.

Fix this by moving the arch_lmb_reserve() implementation into common code and always compile it in.

Cc Simon Glass <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tom Rini <[email protected]>
---
 arch/arm/lib/bootm.c | 45 --------------------------------------------
 arch/arm/lib/stack.c | 45 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+), 45 deletions(-)
arch/arm/lib/bootm.c +0 -45
index f60ee3a7e6..dd6a69315a 100644
@@ -16,7 +16,6 @@
 #include <command.h>
 #include <cpu_func.h>
 #include <dm.h>
-#include <lmb.h>
 #include <log.h>
 #include <asm/global_data.h>
 #include <dm/root.h>
@@ -43,50 +42,6 @@ DECLARE_GLOBAL_DATA_PTR;
 
 static struct tag *params;
 
-static ulong get_sp(void)
-{
-	ulong ret;
-
-	asm("mov %0, sp" : "=r"(ret) : );
-	return ret;
-}
-
-void arch_lmb_reserve(struct lmb *lmb)
-{
-	ulong sp, bank_end;
-	int bank;
-
-	/*
-	 * Booting a (Linux) kernel image
-	 *
-	 * Allocate space for command line and board info - the
-	 * address should be as high as possible within the reach of
-	 * the kernel (see CONFIG_SYS_BOOTMAPSZ settings), but in unused
-	 * memory, which means far enough below the current stack
-	 * pointer.
-	 */
-	sp = get_sp();
-	debug("## Current stack ends at 0x%08lx ", sp);
-
-	/* adjust sp by 4K to be safe */
-	sp -= 4096;
-	for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
-		if (!gd->bd->bi_dram[bank].size ||
-		    sp < gd->bd->bi_dram[bank].start)
-			continue;
-		/* Watch out for RAM at end of address space! */
-		bank_end = gd->bd->bi_dram[bank].start +
-			gd->bd->bi_dram[bank].size - 1;
-		if (sp > bank_end)
-			continue;
-		if (bank_end > gd->ram_top)
-			bank_end = gd->ram_top - 1;
-
-		lmb_reserve(lmb, sp, bank_end - sp + 1);
-		break;
-	}
-}
-
 __weak void board_quiesce_devices(void)
 {
 }
arch/arm/lib/stack.c +45 -0

54 lines not on this page · raw message

Signature · 1 line
2.30.2
Reviewed-by on v1 3/14
#28 lore raw

Re: [PATCH 03/14] lmb: Always compile arch_lmb_reserve() into U-Boot on arm

Quoted 8 lines · Marek Vasut

The arch_lmb_reserve() is called by lib/lmb.c lmb_reserve_common() even if CMD_BOOT{I,M,Z} is not enabled. However, the arm32/arm64 variant of arch_lmb_reserve() is only compiled in if CMD_BOOT{I,M,Z} is enabled.

This currently does not trigger build error, because there is an empty weak implementation of arch_lmb_reserve(), however that is not the function that should be used on arm32/arm64.

Quoted 7 lines

Fix this by moving the arch_lmb_reserve() implementation into common code and always compile it in.

Cc Simon Glass <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tom Rini <[email protected]>
Signature · 1 line
Tom
#29 lore raw

PATCH 4/14 lmb: Always compile arch_lmb_reserve() into U-Boot on arc

In reply to Marek Vasut

The arch_lmb_reserve() is called by lib/lmb.c lmb_reserve_common() even if CMD_BOOTM is not enabled. However, the arc variant of arch_lmb_reserve() is only compiled in if CMD_BOOTM is enabled.

This currently does not trigger build error, because there is an empty weak implementation of arch_lmb_reserve(), however that is not the function that should be used on ar.

Fix this by moving the arch_lmb_reserve() implementation into common code and always compile it in.

Cc Simon Glass <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tom Rini <[email protected]>
---
 arch/arc/lib/bootm.c | 30 ------------------------------
 arch/arc/lib/cache.c | 30 ++++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 30 deletions(-)
arch/arc/lib/bootm.c +0 -30
index 8a8d394a5f..41408c2b46 100644
@@ -8,42 +8,12 @@
 #include <env.h>
 #include <image.h>
 #include <irq_func.h>
-#include <lmb.h>
 #include <log.h>
 #include <asm/cache.h>
 #include <asm/global_data.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static ulong get_sp(void)
-{
-	ulong ret;
-
-	asm("mov %0, sp" : "=r"(ret) : );
-	return ret;
-}
-
-void arch_lmb_reserve(struct lmb *lmb)
-{
-	ulong sp;
-
-	/*
-	 * Booting a (Linux) kernel image
-	 *
-	 * Allocate space for command line and board info - the
-	 * address should be as high as possible within the reach of
-	 * the kernel (see CONFIG_SYS_BOOTMAPSZ settings), but in unused
-	 * memory, which means far enough below the current stack
-	 * pointer.
-	 */
-	sp = get_sp();
-	debug("## Current stack ends at 0x%08lx ", sp);
-
-	/* adjust sp by 4K to be safe */
-	sp -= 4096;
-	lmb_reserve(lmb, sp, (CONFIG_SYS_SDRAM_BASE + gd->ram_size - sp));
-}
-
 static int cleanup_before_linux(void)
 {
 	disable_interrupts();
arch/arc/lib/cache.c +30 -0
index f807cd83d6..4ba180482c 100644
@@ -11,6 +11,7 @@
 #include <linux/compiler.h>
 #include <linux/kernel.h>
 #include <linux/log2.h>
+#include <lmb.h>
 #include <asm/arcregs.h>
 #include <asm/arc-bcr.h>
 #include <asm/cache.h>
@@ -820,3 +821,32 @@ void sync_n_cleanup_cache_all(void)
 
 	__ic_entire_invalidate();
 }
+
+static ulong get_sp(void)
+{
+	ulong ret;
+
+	asm("mov %0, sp" : "=r"(ret) : );
+	return ret;
+}
+
+void arch_lmb_reserve(struct lmb *lmb)
+{
+	ulong sp;
+
+	/*
+	 * Booting a (Linux) kernel image
+	 *
+	 * Allocate space for command line and board info - the
+	 * address should be as high as possible within the reach of
+	 * the kernel (see CONFIG_SYS_BOOTMAPSZ settings), but in unused
+	 * memory, which means far enough below the current stack
+	 * pointer.
+	 */
+	sp = get_sp();
+	debug("## Current stack ends at 0x%08lx ", sp);
+
+	/* adjust sp by 4K to be safe */
+	sp -= 4096;
+	lmb_reserve(lmb, sp, (CONFIG_SYS_SDRAM_BASE + gd->ram_size - sp));
+}
Signature · 1 line
2.30.2
#30 lore raw

PATCH 5/14 lmb: Add generic arch_lmb_reserve_generic()

In reply to Marek Vasut

The arc/arm/m68k/microblaze/mips/ppc arch_lmb_reserve() implementations are all mostly the same, except for a couple of details. Implement a generic arch_lmb_reserve_generic() function which can be parametrized enough to cater for those differences between architectures. This can also be parametrized enough so it can handle cases where U-Boot is not relocated to the end of DRAM e.g. because there is some other reserved memory past U-Boot (e.g. unmovable firmware for coprocessor), it is not relocated at all, and other such use cases.

Cc Alexey Brodkin <[email protected]>
Cc Angelo Dureghello <[email protected]>
Cc Daniel Schwierzeck <[email protected]>
Cc Eugeniy Paltsev <[email protected]>
Cc Hai Pham <[email protected]>
Cc Michal Simek <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 include/lmb.h |  1 +
 lib/lmb.c     | 39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)
include/lmb.h +1 -0
index fa1474a360..deca551ee7 100644
@@ -122,6 +122,7 @@ lmb_size_bytes(struct lmb_region *type, unsigned long region_nr)
 
 void board_lmb_reserve(struct lmb *lmb);
 void arch_lmb_reserve(struct lmb *lmb);
+void arch_lmb_reserve_generic(struct lmb *lmb, ulong sp, ulong end, ulong align);
 
 /* Low level functions */
 
lib/lmb.c +39 -0
index 7bd1255f7a..fed3c341a7 100644
@@ -12,6 +12,10 @@
 #include <log.h>
 #include <malloc.h>
 
+#include <asm/global_data.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
 #define LMB_ALLOC_ANYWHERE	0
 
 static void lmb_dump_region(struct lmb_region *rgn, char *name)
@@ -113,6 +117,41 @@ void lmb_init(struct lmb *lmb)
 	lmb->reserved.cnt = 0;
 }
 
+void arch_lmb_reserve_generic(struct lmb *lmb, ulong sp, ulong end, ulong align)
+{
+	ulong bank_end;
+	int bank;
+
+	/*
+	 * Booting a (Linux) kernel image
+	 *
+	 * Allocate space for command line and board info - the
+	 * address should be as high as possible within the reach of
+	 * the kernel (see CONFIG_SYS_BOOTMAPSZ settings), but in unused
+	 * memory, which means far enough below the current stack
+	 * pointer.
+	 */
+	debug("## Current stack ends at 0x%08lx ", sp);
+
+	/* adjust sp by 4K to be safe */
+	sp -= align;
+	for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
+		if (!gd->bd->bi_dram[bank].size ||
+		    sp < gd->bd->bi_dram[bank].start)
+			continue;
+		/* Watch out for RAM at end of address space! */
+		bank_end = gd->bd->bi_dram[bank].start +
+			gd->bd->bi_dram[bank].size - 1;
+		if (sp > bank_end)
+			continue;
+		if (bank_end > end)
+			bank_end = end - 1;
+
+		lmb_reserve(lmb, sp, bank_end - sp + 1);
+		break;
+	}
+}
+
 static void lmb_reserve_common(struct lmb *lmb, void *fdt_blob)
 {
 	arch_lmb_reserve(lmb);
Signature · 1 line
2.30.2
#31 lore raw

Re: [PATCH 05/14] lmb: Add generic arch_lmb_reserve_generic()

Quoted 8 lines · Marek Vasut

The arc/arm/m68k/microblaze/mips/ppc arch_lmb_reserve() implementations are all mostly the same, except for a couple of details. Implement a generic arch_lmb_reserve_generic() function which can be parametrized enough to cater for those differences between architectures. This can also be parametrized enough so it can handle cases where U-Boot is not relocated to the end of DRAM e.g. because there is some other reserved memory past U-Boot (e.g. unmovable firmware for coprocessor), it is not relocated at all, and other such use cases.

[snip]

Quoted 4 lines
lib/lmb.c +4 -0
+void arch_lmb_reserve_generic(struct lmb *lmb, ulong sp, ulong end, ulong align)
+{
+	ulong bank_end;
+	int bank;

lib/lmb.c void lmb_init(struct lmb *lmb) · line 133

Quoted 10 lines
lib/lmb.c +10 -0
+
+	/*
+	 * Booting a (Linux) kernel image
+	 *
+	 * Allocate space for command line and board info - the
+	 * address should be as high as possible within the reach of
+	 * the kernel (see CONFIG_SYS_BOOTMAPSZ settings), but in unused
+	 * memory, which means far enough below the current stack
+	 * pointer.
+	 */

This comment is wrong, and we need to fix it, rather than continue to perpetuate it.

Signature · 1 line
Tom
#32 lore raw

PATCH 6/14 lmb: Switch to generic arch_lmb_reserve_generic()

In reply to Marek Vasut

Switch arc/arm/m68k/microblaze/mips/ppc arch_lmb_reserve() to arch_lmb_reserve_generic().

Cc Alexey Brodkin <[email protected]>
Cc Angelo Dureghello <[email protected]>
Cc Daniel Schwierzeck <[email protected]>
Cc Eugeniy Paltsev <[email protected]>
Cc Hai Pham <[email protected]>
Cc Michal Simek <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 arch/arc/lib/cache.c        | 18 +-----------------
 arch/arm/lib/stack.c        | 33 +--------------------------------
 arch/m68k/lib/bootm.c       | 18 +-----------------
 arch/microblaze/lib/bootm.c | 28 +---------------------------
 arch/mips/lib/bootm.c       |  9 +--------
 arch/powerpc/lib/bootm.c    | 18 ++----------------
 6 files changed, 7 insertions(+), 117 deletions(-)
arch/arc/lib/cache.c +1 -17
index 4ba180482c..4c696cb53a 100644
@@ -832,21 +832,5 @@ static ulong get_sp(void)
 
 void arch_lmb_reserve(struct lmb *lmb)
 {
-	ulong sp;
-
-	/*
-	 * Booting a (Linux) kernel image
-	 *
-	 * Allocate space for command line and board info - the
-	 * address should be as high as possible within the reach of
-	 * the kernel (see CONFIG_SYS_BOOTMAPSZ settings), but in unused
-	 * memory, which means far enough below the current stack
-	 * pointer.
-	 */
-	sp = get_sp();
-	debug("## Current stack ends at 0x%08lx ", sp);
-
-	/* adjust sp by 4K to be safe */
-	sp -= 4096;
-	lmb_reserve(lmb, sp, (CONFIG_SYS_SDRAM_BASE + gd->ram_size - sp));
+	arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 4096);
 }
arch/arm/lib/stack.c +1 -32
index 3f961f4454..52d9f15298 100644
@@ -45,36 +45,5 @@ static ulong get_sp(void)
 
 void arch_lmb_reserve(struct lmb *lmb)
 {
-	ulong sp, bank_end;
-	int bank;
-
-	/*
-	 * Booting a (Linux) kernel image
-	 *
-	 * Allocate space for command line and board info - the
-	 * address should be as high as possible within the reach of
-	 * the kernel (see CONFIG_SYS_BOOTMAPSZ settings), but in unused
-	 * memory, which means far enough below the current stack
-	 * pointer.
-	 */
-	sp = get_sp();
-	debug("## Current stack ends at 0x%08lx ", sp);
-
-	/* adjust sp by 4K to be safe */
-	sp -= 4096;
-	for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
-		if (!gd->bd->bi_dram[bank].size ||
-		    sp < gd->bd->bi_dram[bank].start)
-			continue;
-		/* Watch out for RAM at end of address space! */
-		bank_end = gd->bd->bi_dram[bank].start +
-			gd->bd->bi_dram[bank].size - 1;
-		if (sp > bank_end)
-			continue;
-		if (bank_end > gd->ram_top)
-			bank_end = gd->ram_top - 1;
-
-		lmb_reserve(lmb, sp, bank_end - sp + 1);
-		break;
-	}
+	arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 4096);
 }
arch/m68k/lib/bootm.c +1 -17
index 51a6f93858..27729db67e 100644
@@ -32,23 +32,7 @@ static void set_clocks_in_mhz (struct bd_info *kbd);
 
 void arch_lmb_reserve(struct lmb *lmb)
 {
-	ulong sp;
-
-	/*
-	 * Booting a (Linux) kernel image
-	 *
-	 * Allocate space for command line and board info - the
-	 * address should be as high as possible within the reach of
-	 * the kernel (see CONFIG_SYS_BOOTMAPSZ settings), but in unused
-	 * memory, which means far enough below the current stack
-	 * pointer.
-	 */
-	sp = get_sp();
-	debug ("## Current stack ends at 0x%08lx ", sp);
-
-	/* adjust sp by 1K to be safe */
-	sp -= 1024;
-	lmb_reserve(lmb, sp, (CONFIG_SYS_SDRAM_BASE + gd->ram_size - sp));
+	arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 1024);
 }
 
 int do_bootm_linux(int flag, int argc, char *const argv[],
arch/microblaze/lib/bootm.c +1 -27
index 6695ac63c7..3a6da6e29f 100644
@@ -34,33 +34,7 @@ static ulong get_sp(void)
 
 void arch_lmb_reserve(struct lmb *lmb)
 {
-	ulong sp, bank_end;
-	int bank;
-
-	/*
-	 * Booting a (Linux) kernel image
-	 *
-	 * Allocate space for command line and board info - the
-	 * address should be as high as possible within the reach of
-	 * the kernel (see CONFIG_SYS_BOOTMAPSZ settings), but in unused
-	 * memory, which means far enough below the current stack
-	 * pointer.
-	 */
-	sp = get_sp();
-	debug("## Current stack ends at 0x%08lx ", sp);
-
-	/* adjust sp by 4K to be safe */
-	sp -= 4096;
-	for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
-		if (sp < gd->bd->bi_dram[bank].start)
-			continue;
-		bank_end = gd->bd->bi_dram[bank].start +
-			gd->bd->bi_dram[bank].size;
-		if (sp >= bank_end)
-			continue;
-		lmb_reserve(lmb, sp, bank_end - sp);
-		break;
-	}
+	arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 4096);
 }
 
 static void boot_jump_linux(bootm_headers_t *images, int flag)
arch/mips/lib/bootm.c +1 -8
index fde90fced4..cab8da4860 100644
@@ -39,14 +39,7 @@ static ulong arch_get_sp(void)
 
 void arch_lmb_reserve(struct lmb *lmb)
 {
-	ulong sp;
-
-	sp = arch_get_sp();
-	debug("## Current stack ends at 0x%08lx\n", sp);
-
-	/* adjust sp by 4K to be safe */
-	sp -= 4096;
-	lmb_reserve(lmb, sp, gd->ram_top - sp);
+	arch_lmb_reserve_generic(lmb, arch_get_sp(), gd->ram_top, 4096);
 }
 
 static void linux_cmdline_init(void)
arch/powerpc/lib/bootm.c +2 -16
index 31c17b5bb3..8d65047aa4 100644
@@ -119,7 +119,7 @@ static void boot_jump_linux(bootm_headers_t *images)
 void arch_lmb_reserve(struct lmb *lmb)
 {
 	phys_size_t bootm_size;
-	ulong size, sp, bootmap_base;
+	ulong size, bootmap_base;
 
 	bootmap_base = env_get_bootm_low();
 	bootm_size = env_get_bootm_size();
@@ -141,21 +141,7 @@ void arch_lmb_reserve(struct lmb *lmb)
 		lmb_reserve(lmb, base, bootm_size - size);
 	}
 
-	/*
-	 * Booting a (Linux) kernel image
-	 *
-	 * Allocate space for command line and board info - the
-	 * address should be as high as possible within the reach of
-	 * the kernel (see CONFIG_SYS_BOOTMAPSZ settings), but in unused
-	 * memory, which means far enough below the current stack
-	 * pointer.
-	 */
-	sp = get_sp();
-	debug("## Current stack ends at 0x%08lx\n", sp);
-
-	/* adjust sp by 4K to be safe */
-	sp -= 4096;
-	lmb_reserve(lmb, sp, (CONFIG_SYS_SDRAM_BASE + get_effective_memsize() - sp));
+	arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 4096);
 
 #ifdef CONFIG_MP
 	cpu_mp_lmb_reserve(lmb);
Signature · 1 line
2.30.2
Reviewed-by on v1 6/14
#33 lore raw

Re: [PATCH 06/14] lmb: Switch to generic arch_lmb_reserve_generic()

Quoted 13 lines · Marek Vasut

Switch arc/arm/m68k/microblaze/mips/ppc arch_lmb_reserve() to arch_lmb_reserve_generic().

Cc Alexey Brodkin <[email protected]>
Cc Angelo Dureghello <[email protected]>
Cc Daniel Schwierzeck <[email protected]>
Cc Eugeniy Paltsev <[email protected]>
Cc Hai Pham <[email protected]>
Cc Michal Simek <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Signature · 1 line
Tom
#34 lore raw

PATCH 7/14 lmb: nios2: Add arch_lmb_reserve()

In reply to Marek Vasut

Add arch_lmb_reserve() implemented using arch_lmb_reserve_generic(). It is rather likely this architecture also needs to cover U-Boot with LMB before booting Linux.

Cc Simon Goldschmidt <[email protected]>
Cc Thomas Chou <[email protected]>
Cc Tom Rini <[email protected]>
---
 arch/nios2/lib/bootm.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/nios2/lib/bootm.c +16 -0
index 5037467151..3cb59bd977 100644
@@ -10,6 +10,9 @@
 #include <image.h>
 #include <irq_func.h>
 #include <log.h>
+#include <asm/global_data.h>
+
+DECLARE_GLOBAL_DATA_PTR;
 
 #define NIOS_MAGIC 0x534f494e /* enable command line and initrd passing */
 
@@ -60,3 +63,16 @@ int do_bootm_linux(int flag, int argc, char *const argv[],
 
 	return 1;
 }
+
+static ulong get_sp(void)
+{
+	ulong ret;
+
+	asm("mov %0, sp" : "=r"(ret) : );
+	return ret;
+}
+
+void arch_lmb_reserve(struct lmb *lmb)
+{
+	arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 4096);
+}
Signature · 1 line
2.30.2
#35 lore raw

PATCH 8/14 lmb: nds32: Add arch_lmb_reserve()

In reply to Marek Vasut

Add arch_lmb_reserve() implemented using arch_lmb_reserve_generic(). It is rather likely this architecture also needs to cover U-Boot with LMB before booting Linux.

Cc Rick Chen <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tom Rini <[email protected]>
---
 arch/nds32/lib/bootm.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
arch/nds32/lib/bootm.c +13 -0
index 4cb0f530ae..a7c8978f23 100644
@@ -245,3 +245,16 @@ static void setup_end_tag(struct bd_info *bd)
 }
 
 #endif /* CONFIG_SETUP_MEMORY_TAGS || CONFIG_CMDLINE_TAG || CONFIG_INITRD_TAG */
+
+static ulong get_sp(void)
+{
+	ulong ret;
+
+	asm("move %0, $sp" : "=r"(ret) : );
+	return ret;
+}
+
+void arch_lmb_reserve(struct lmb *lmb)
+{
+	arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 4096);
+}
Signature · 1 line
2.30.2

A message that is not in the archive (sent off-list or not yet received): HK0PR03MB2994783DDC460B69CDE74093C1CE9@HK0PR03MB2994.apcprd03.prod.outlook.com

Reviewed-by
#37 lore raw

Re: [PATCH 08/14] lmb: nds32: Add arch_lmb_reserve()

Quoted 9 lines

From: Marek Vasut <[email protected]>
Sent: Monday, August 16, 2021 2:13 AM
To: [email protected]
Cc: Marek Vasut <[email protected]>; Rick Jian-Zhi Chen(陳建志) <[email protected]>; Simon Goldschmidt <[email protected]>; Tom Rini <[email protected]>
Subject: [PATCH 08/14] lmb: nds32: Add arch_lmb_reserve()

Add arch_lmb_reserve() implemented using arch_lmb_reserve_generic().
It is rather likely this architecture also needs to cover U-Boot with LMB before booting Linux.

Quoted 7 lines
Cc Rick Chen <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tom Rini <[email protected]>
---
 arch/nds32/lib/bootm.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
#38 lore raw

PATCH 9/14 lmb: riscv: Add arch_lmb_reserve()

In reply to Marek Vasut

Add arch_lmb_reserve() implemented using arch_lmb_reserve_generic(). It is rather likely this architecture also needs to cover U-Boot with LMB before booting Linux.

Cc Atish Patra <[email protected]>
Cc Rick Chen <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tom Rini <[email protected]>
---
 arch/riscv/lib/bootm.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
arch/riscv/lib/bootm.c +13 -0
index 8dd1820540..ff1bdf7131 100644
@@ -135,3 +135,16 @@ int do_bootm_vxworks(int flag, int argc, char *const argv[],
 {
 	return do_bootm_linux(flag, argc, argv, images);
 }
+
+static ulong get_sp(void)
+{
+	ulong ret;
+
+	asm("mv %0, sp" : "=r"(ret) : );
+	return ret;
+}
+
+void arch_lmb_reserve(struct lmb *lmb)
+{
+	arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 4096);
+}
Signature · 1 line
2.30.2

A message that is not in the archive (sent off-list or not yet received): HK0PR03MB2994629C8CC69189EDF64C00C1CE9@HK0PR03MB2994.apcprd03.prod.outlook.com

Reviewed-by
#40 lore raw

Re: [PATCH 09/14] lmb: riscv: Add arch_lmb_reserve()

Quoted 15 lines

From: Marek Vasut <[email protected]>
Sent: Monday, August 16, 2021 2:13 AM
To: [email protected]
Cc: Marek Vasut <[email protected]>; Atish Patra <[email protected]>; Leo Yu-Chi Liang(梁育齊) <[email protected]>; Rick Jian-Zhi Chen(陳建志) <[email protected]>; Simon Goldschmidt <[email protected]>; Tom Rini <[email protected]>
Subject: [PATCH 09/14] lmb: riscv: Add arch_lmb_reserve()

Add arch_lmb_reserve() implemented using arch_lmb_reserve_generic().
It is rather likely this architecture also needs to cover U-Boot with LMB before booting Linux.

Cc Atish Patra <[email protected]>
Cc Rick Chen <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tom Rini <[email protected]>
Quoted 3 lines
---
 arch/riscv/lib/bootm.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
#41 lore raw

PATCH 10/14 lmb: sh: Add arch_lmb_reserve()

In reply to Marek Vasut

Add arch_lmb_reserve() implemented using arch_lmb_reserve_generic(). This architecture also needs to cover U-Boot with LMB before booting Linux.

Cc Simon Goldschmidt <[email protected]>
Cc Tom Rini <[email protected]>
---
 arch/sh/lib/bootm.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/sh/lib/bootm.c +16 -0
index dc94f83785..9b71424dfe 100644
@@ -12,8 +12,11 @@
 #include <env.h>
 #include <image.h>
 #include <asm/byteorder.h>
+#include <asm/global_data.h>
 #include <asm/zimage.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 #ifdef CONFIG_SYS_DEBUG
 static void hexdump(unsigned char *buf, int len)
 {
@@ -111,3 +114,16 @@ int do_bootm_linux(int flag, int argc, char *const argv[],
 	/* does not return */
 	return 1;
 }
+
+static ulong get_sp(void)
+{
+	ulong ret;
+
+	asm("mov r15, %0" : "=r"(ret) : );
+	return ret;
+}
+
+void arch_lmb_reserve(struct lmb *lmb)
+{
+	arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 4096);
+}
Signature · 1 line
2.30.2
#42 lore raw

PATCH 11/14 lmb: xtensa: Add arch_lmb_reserve()

In reply to Marek Vasut

Add arch_lmb_reserve() implemented using arch_lmb_reserve_generic(). It is rather likely this architecture also needs to cover U-Boot with LMB before booting Linux.

Cc Chris Zankel <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tom Rini <[email protected]>
---
 arch/xtensa/lib/bootm.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/xtensa/lib/bootm.c +12 -0
index bb1e2886ab..277af18168 100644
@@ -197,3 +197,15 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
 	return 1;
 }
 
+static ulong get_sp(void)
+{
+	ulong ret;
+
+	asm("mov %0, a1" : "=r"(ret) : );
+	return ret;
+}
+
+void arch_lmb_reserve(struct lmb *lmb)
+{
+	arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 4096);
+}
Signature · 1 line
2.30.2
#43 lore raw

PATCH 12/14 lmb: x86: Add arch_lmb_reserve()

In reply to Marek Vasut

Add arch_lmb_reserve() implemented using arch_lmb_reserve_generic(). It is rather likely this architecture also needs to cover U-Boot with LMB before booting Linux.

Cc Simon Glass <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tom Rini <[email protected]>
---
 arch/x86/lib/bootm.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
arch/x86/lib/bootm.c +18 -0
index 733dd71257..667e5e689e 100644
@@ -223,3 +223,21 @@ int do_bootm_linux(int flag, int argc, char *const argv[],
 
 	return boot_jump_linux(images);
 }
+
+static ulong get_sp(void)
+{
+	ulong ret;
+
+#if CONFIG_IS_ENABLED(X86_64)
+	ret = gd->start_addr_sp;
+#else
+	asm("mov %%esp, %0" : "=r"(ret) : );
+#endif
+
+	return ret;
+}
+
+void arch_lmb_reserve(struct lmb *lmb)
+{
+	arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 4096);
+}
Signature · 1 line
2.30.2
#44 lore raw

PATCH 13/14 lmb: Mark arch_lmb_reserve() as weak symbol

In reply to Marek Vasut

Mark arch_lmb_reserve() weak on architecture level, so it can be overridden if necessary. This might be necessary if there is some sort of architectural exception where e.g. more LMB areas have to be reserved.

Note that sandbox now needs an empty implementation of arch_lmb_reserve().

Cc Alexey Brodkin <[email protected]>
Cc Angelo Dureghello <[email protected]>
Cc Daniel Schwierzeck <[email protected]>
Cc Eugeniy Paltsev <[email protected]>
Cc Hai Pham <[email protected]>
Cc Michal Simek <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 arch/arc/lib/cache.c        | 2 +-
 arch/arm/lib/stack.c        | 2 +-
 arch/m68k/lib/bootm.c       | 2 +-
 arch/microblaze/lib/bootm.c | 2 +-
 arch/mips/lib/bootm.c       | 2 +-
 arch/powerpc/lib/bootm.c    | 2 +-
 arch/riscv/lib/bootm.c      | 2 +-
 arch/sandbox/lib/bootm.c    | 5 +++++
 arch/sh/lib/bootm.c         | 2 +-
 arch/x86/lib/bootm.c        | 2 +-
 arch/xtensa/lib/bootm.c     | 2 +-
 lib/lmb.c                   | 5 -----
 12 files changed, 15 insertions(+), 15 deletions(-)
arch/arc/lib/cache.c +1 -1
index 4c696cb53a..23bca1fffc 100644
@@ -830,7 +830,7 @@ static ulong get_sp(void)
 	return ret;
 }
 
-void arch_lmb_reserve(struct lmb *lmb)
+__weak void arch_lmb_reserve(struct lmb *lmb)
 {
 	arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 4096);
 }
arch/arm/lib/stack.c +1 -1
index 52d9f15298..93a69a1688 100644
@@ -43,7 +43,7 @@ static ulong get_sp(void)
 	return ret;
 }
 
-void arch_lmb_reserve(struct lmb *lmb)
+__weak void arch_lmb_reserve(struct lmb *lmb)
 {
 	arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 4096);
 }
arch/m68k/lib/bootm.c +1 -1
index 27729db67e..fb4784187a 100644
@@ -30,7 +30,7 @@ DECLARE_GLOBAL_DATA_PTR;
 static ulong get_sp (void);
 static void set_clocks_in_mhz (struct bd_info *kbd);
 
-void arch_lmb_reserve(struct lmb *lmb)
+__weak void arch_lmb_reserve(struct lmb *lmb)
 {
 	arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 1024);
 }
arch/microblaze/lib/bootm.c +1 -1
index 3a6da6e29f..2621770082 100644
@@ -32,7 +32,7 @@ static ulong get_sp(void)
 	return ret;
 }
 
-void arch_lmb_reserve(struct lmb *lmb)
+__weak void arch_lmb_reserve(struct lmb *lmb)
 {
 	arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 4096);
 }
arch/mips/lib/bootm.c +1 -1
index cab8da4860..57873f200b 100644
@@ -37,7 +37,7 @@ static ulong arch_get_sp(void)
 	return ret;
 }
 
-void arch_lmb_reserve(struct lmb *lmb)
+__weak void arch_lmb_reserve(struct lmb *lmb)
 {
 	arch_lmb_reserve_generic(lmb, arch_get_sp(), gd->ram_top, 4096);
 }
arch/powerpc/lib/bootm.c +1 -1
index 8d65047aa4..482bacdfe6 100644
@@ -116,7 +116,7 @@ static void boot_jump_linux(bootm_headers_t *images)
 	return ;
 }
 
-void arch_lmb_reserve(struct lmb *lmb)
+__weak void arch_lmb_reserve(struct lmb *lmb)
 {
 	phys_size_t bootm_size;
 	ulong size, bootmap_base;
arch/riscv/lib/bootm.c +1 -1
index ff1bdf7131..377c77b909 100644
@@ -144,7 +144,7 @@ static ulong get_sp(void)
 	return ret;
 }
 
-void arch_lmb_reserve(struct lmb *lmb)
+__weak void arch_lmb_reserve(struct lmb *lmb)
 {
 	arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 4096);
 }
arch/sandbox/lib/bootm.c +5 -0
index d1d460b84a..17c02fc9f7 100644
@@ -61,3 +61,8 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
 
 	return 0;
 }
+
+void arch_lmb_reserve(struct lmb *lmb)
+{
+	/* do nothing */
+}
arch/sh/lib/bootm.c +1 -1
index 9b71424dfe..ec4a74b43c 100644
@@ -123,7 +123,7 @@ static ulong get_sp(void)
 	return ret;
 }
 
-void arch_lmb_reserve(struct lmb *lmb)
+__weak void arch_lmb_reserve(struct lmb *lmb)
 {
 	arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 4096);
 }
arch/x86/lib/bootm.c +1 -1
index 667e5e689e..b46411d93d 100644
@@ -237,7 +237,7 @@ static ulong get_sp(void)
 	return ret;
 }
 
-void arch_lmb_reserve(struct lmb *lmb)
+__weak void arch_lmb_reserve(struct lmb *lmb)
 {
 	arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 4096);
 }
arch/xtensa/lib/bootm.c +1 -1
index 277af18168..a8ad62aa54 100644
@@ -205,7 +205,7 @@ static ulong get_sp(void)
 	return ret;
 }
 
-void arch_lmb_reserve(struct lmb *lmb)
+__weak void arch_lmb_reserve(struct lmb *lmb)
 {
 	arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 4096);
 }
lib/lmb.c +0 -5
index fed3c341a7..00498944a0 100644
@@ -504,8 +504,3 @@ __weak void board_lmb_reserve(struct lmb *lmb)
 {
 	/* please define platform specific board_lmb_reserve() */
 }
-
-__weak void arch_lmb_reserve(struct lmb *lmb)
-{
-	/* please define platform specific arch_lmb_reserve() */
-}
Signature · 1 line
2.30.2
#45 lore raw

Re: [PATCH 13/14] lmb: Mark arch_lmb_reserve() as weak symbol

Quoted 7 lines · Marek Vasut

Mark arch_lmb_reserve() weak on architecture level, so it can be overridden if necessary. This might be necessary if there is some sort of architectural exception where e.g. more LMB areas have to be reserved.

Note that sandbox now needs an empty implementation of arch_lmb_reserve().

I'm not sure we need this. We have the arch and board call-outs, and I've already addressed the imx example. I really want to see how this works on the I believe you've said rcar example.

Signature · 1 line
Tom
#46 lore raw

Re: [PATCH 13/14] lmb: Mark arch_lmb_reserve() as weak symbol

Quoted 7 lines · Tom Rini
Quoted 5 lines · Marek Vasut

Mark arch_lmb_reserve() weak on architecture level, so it can be overridden if necessary. This might be necessary if there is some sort of architectural exception where e.g. more LMB areas have to be reserved.

Quoted 6 lines
Quoted 2 lines

Note that sandbox now needs an empty implementation of arch_lmb_reserve().

I'm not sure we need this. We have the arch and board call-outs, and I've already addressed the imx example. I really want to see how this works on the I believe you've said rcar example.

Since they disable relocation in the bsp too, gd->ram_top would be replaced by fixed value there. I can skip this patch for now.

#47 lore raw

Re: [PATCH 13/14] lmb: Mark arch_lmb_reserve() as weak symbol

Quoted 11 lines · Marek Vasut
Quoted 10 lines · Tom Rini
Quoted 7 lines · Marek Vasut

Mark arch_lmb_reserve() weak on architecture level, so it can be overridden if necessary. This might be necessary if there is some sort of architectural exception where e.g. more LMB areas have to be reserved.

Note that sandbox now needs an empty implementation of arch_lmb_reserve().

Quoted 6 lines
Quoted 3 lines

I'm not sure we need this. We have the arch and board call-outs, and I've already addressed the imx example. I really want to see how this works on the I believe you've said rcar example.

Since they disable relocation in the bsp too, gd->ram_top would be replaced by fixed value there. I can skip this patch for now.

OK.

Signature · 1 line
Tom
#48 lore raw

PATCH 14/14 lmb: Switch imx board_lmb_reserve() to arch_lmb_reserve()

In reply to Marek Vasut

This function is clearly architecture specific code, not board specific code. The only difference from the generic arm arch_lmb_reserve() is the extra reservation of 16k of memory below the stack bottom, rather than the default 4k. Switch this from board_lmb_reserve() to arch_lmb_reserve() and use arch_lmb_reserve_generic() with 16k stack reservation parameter instead of replicating older version of arch_lmb_reserve() here.

Cc Alexey Brodkin <[email protected]>
Cc Angelo Dureghello <[email protected]>
Cc Daniel Schwierzeck <[email protected]>
Cc Eugeniy Paltsev <[email protected]>
Cc Hai Pham <[email protected]>
Cc Michal Simek <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 arch/arm/mach-imx/misc.c | 21 ++-------------------
 1 file changed, 2 insertions(+), 19 deletions(-)
arch/arm/mach-imx/misc.c +2 -19
index d82efa7f8f..529601156f 100644
@@ -86,24 +86,7 @@ static ulong get_sp(void)
 	return ret;
 }
 
-void board_lmb_reserve(struct lmb *lmb)
+void arch_lmb_reserve(struct lmb *lmb)
 {
-	ulong sp, bank_end;
-	int bank;
-
-	sp = get_sp();
-	debug("## Current stack ends at 0x%08lx ", sp);
-
-	/* adjust sp by 16K to be safe */
-	sp -= 4096 << 2;
-	for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
-		if (sp < gd->bd->bi_dram[bank].start)
-			continue;
-		bank_end = gd->bd->bi_dram[bank].start +
-			gd->bd->bi_dram[bank].size;
-		if (sp >= bank_end)
-			continue;
-		lmb_reserve(lmb, sp, bank_end - sp);
-		break;
-	}
+	arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 16384);
 }
Signature · 1 line
2.30.2
#49 lore raw

Re: [PATCH 14/14] lmb: Switch imx board_lmb_reserve() to arch_lmb_reserve()

Quoted 43 lines · Marek Vasut

This function is clearly architecture specific code, not board specific code. The only difference from the generic arm arch_lmb_reserve() is the extra reservation of 16k of memory below the stack bottom, rather than the default 4k. Switch this from board_lmb_reserve() to arch_lmb_reserve() and use arch_lmb_reserve_generic() with 16k stack reservation parameter instead of replicating older version of arch_lmb_reserve() here.

Cc Alexey Brodkin <[email protected]>
Cc Angelo Dureghello <[email protected]>
Cc Daniel Schwierzeck <[email protected]>
Cc Eugeniy Paltsev <[email protected]>
Cc Hai Pham <[email protected]>
Cc Michal Simek <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 arch/arm/mach-imx/misc.c | 21 ++-------------------
 1 file changed, 2 insertions(+), 19 deletions(-)
arch/arm/mach-imx/misc.c +1 -11
index d82efa7f8f..529601156f 100644
@@ -86,24 +86,7 @@ static ulong get_sp(void)
 	return ret;
 }
 
-void board_lmb_reserve(struct lmb *lmb)
+void arch_lmb_reserve(struct lmb *lmb)
 {
-	ulong sp, bank_end;
-	int bank;
-
-	sp = get_sp();
-	debug("## Current stack ends at 0x%08lx ", sp);
-
-	/* adjust sp by 16K to be safe */
-	sp -= 4096 << 2;
-	for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
-		if (sp < gd->bd->bi_dram[bank].start)

arch/arm/mach-imx/misc.c static ulong get_sp(void) · line 92

Quoted 10 lines
arch/arm/mach-imx/misc.c +1 -8
-			continue;
-		bank_end = gd->bd->bi_dram[bank].start +
-			gd->bd->bi_dram[bank].size;
-		if (sp >= bank_end)
-			continue;
-		lmb_reserve(lmb, sp, bank_end - sp);
-		break;
-	}
+	arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 16384);
 }

As I previously said, this should be the generic ARM one. And arguably all device-tree using architectures should give themselves more headroom here, based on the additional context we got. Calling the iMX entry the arch one is wrong. If we don't want to address the general problem more, we should keep this as a board one that reserves an additional 12KiB.

Signature · 1 line
Tom