Collect information about the memory-margin in each phase which uses
this feature. Update the 'vbe state' command to show it.

Signed-off-by: Simon Glass <s...@chromium.org>
---

(no changes since v1)

 cmd/vbe.c              |  8 ++++++--
 common/spl/spl_reloc.c | 12 ++++++++++++
 include/vbe.h          |  3 +++
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/cmd/vbe.c b/cmd/vbe.c
index 186f6e6860d..02d224ad286 100644
--- a/cmd/vbe.c
+++ b/cmd/vbe.c
@@ -92,9 +92,13 @@ static int do_vbe_state(struct cmd_tbl *cmdtp, int flag, int 
argc,
 
        printf("Phases:");
        for (i = PHASE_NONE; i < PHASE_COUNT; i++) {
-               if (handoff->phases & (1 << i))
-                       printf(" %s", xpl_name(i));
+               if (handoff->phases & (1 << i)) {
+                       int margin = handoff->reloc_margin[i];
 
+                       printf(" %s", xpl_name(i));
+                       if (margin)
+                               printf(" (margin %x) ", margin);
+               }
        }
        if (!handoff->phases)
                printf(" (none)");
diff --git a/common/spl/spl_reloc.c b/common/spl/spl_reloc.c
index 216c0f36623..6bfc75bc484 100644
--- a/common/spl/spl_reloc.c
+++ b/common/spl/spl_reloc.c
@@ -4,11 +4,13 @@
  * Written by Simon Glass <s...@chromium.org>
  */
 
+#include <bloblist.h>
 #include <gzip.h>
 #include <image.h>
 #include <log.h>
 #include <mapmem.h>
 #include <spl.h>
+#include <vbe.h>
 #include <asm/global_data.h>
 #include <asm/io.h>
 #include <asm/sections.h>
@@ -58,6 +60,16 @@ static int setup_layout(struct spl_image_info *image, ulong 
*addrp)
        buf_size = rcode_base - base;
        uint need_size = image->size + image->fdt_size;
        margin = buf_size - need_size;
+
+       if (CONFIG_IS_ENABLED(BLOBLIST)) {
+               struct vbe_handoff *handoff;
+
+               handoff = bloblist_find(BLOBLISTT_VBE,
+                                       sizeof(struct vbe_handoff));
+               if (handoff)
+                       handoff->reloc_margin[xpl_phase()] = margin;
+       }
+
        log_debug("spl_reloc %s->%s: margin%s%lx limit %lx fdt_size %lx base 
%lx avail %x image %x fdt %lx need %x\n",
                  xpl_name(xpl_phase()), xpl_name(xpl_phase() + 1),
                  margin >= 0 ? " " : " -", abs(margin), limit, fdt_size, base,
diff --git a/include/vbe.h b/include/vbe.h
index 61bfa0e557d..84a996cdf7f 100644
--- a/include/vbe.h
+++ b/include/vbe.h
@@ -11,6 +11,7 @@
 #define __VBE_H
 
 #include <linux/types.h>
+#include <spl.h>
 
 /**
  * enum vbe_phase_t - current phase of VBE
@@ -47,12 +48,14 @@ enum vbe_pick_t {
  * @size: Size of the area containing the FIT
  * @phases: Indicates which phases used the VBE bootmeth (1 << PHASE_...)
  * @pick: Indicates which firmware pick was used (enum vbe_pick_t)
+ * @reloc_margin: Indicates the number of bytes of margin coming into this 
phase
  */
 struct vbe_handoff {
        ulong offset;
        ulong size;
        u8 phases;
        u8 pick;
+       int reloc_margin[PHASE_COUNT];
 };
 
 /**
-- 
2.43.0

Reply via email to