x86: Improve support for chain-loading U-Boot
cover x86: Improve support for chain-loading U-Boot
This little series adds a few checks into the code to allow better operation when booting a build from a previous-state loader such as coreboot.
At present we have a 'coreboot' target, but sometimes it is useful to boot a bare-metal target, such as coral, from coreboot. That allows comparison of operation between the bare metal version doing all the init itself and relying on coreboot for some init.
Simon Glass (5):
x86: fsp: Allow skipping init code when chain loading
x86: apl: Skip init code when chain loading
x86: cpu: Skip init code when chain loading
dm: Avoid initing built-in devices when chain loading
pci: Avoid auto-config when chain loading
arch/x86/cpu/apollolake/fsp_s.c | 2 ++ arch/x86/cpu/cpu.c | 4 +++- arch/x86/cpu/i386/interrupt.c | 3 +++ arch/x86/lib/fsp/fsp_dram.c | 8 ++++++++ arch/x86/lib/fsp/fsp_graphics.c | 3 +++ arch/x86/lib/fsp2/fsp_dram.c | 10 ++++++++++ arch/x86/lib/fsp2/fsp_init.c | 2 +- arch/x86/lib/init_helpers.c | 3 +++ common/board_r.c | 3 +++ drivers/pci/pci-uclass.c | 4 ++-- 10 files changed, 38 insertions(+), 4 deletions(-)
Signature · 1 line
2.24.1.735.g03f4e72817-goog
PATCH 1/5 x86: fsp: Allow skipping init code when chain loading
When U-Boot is no the first-stage bootloader much of this code is not needed and can break booting. Add checks for this to the FSP code.
Rather than checking for the amount of available SDRAM, just use 1GB in this situation, which should be safe. Using 2GB may run into a memory hole on some SoCs.
---
arch/x86/lib/fsp/fsp_dram.c | 8 ++++++++ arch/x86/lib/fsp/fsp_graphics.c | 3 +++ arch/x86/lib/fsp2/fsp_dram.c | 10 ++++++++++ arch/x86/lib/fsp2/fsp_init.c | 2 +- 4 files changed, 22 insertions(+), 1 deletion(-)
arch/x86/lib/fsp/fsp_dram.c +8 -0
@@ -44,6 +44,14 @@ int dram_init_banksize(void)phys_addr_t low_end;uint bank; +if (!ll_boot_init ()) { + gd->bd->bi_dram[0 ].start =0 ; + gd->bd->bi_dram[0 ].size = gd->ram_size; + +mtrr_add_request (MTRR_TYPE_WRBACK ,0 , gd->ram_size); +return 0 ; + } + low_end =0 ; for (bank = 1, hdr = gd->arch.hob_list; bank < CONFIG_NR_DRAM_BANKS && !end_of_hob(hdr);
arch/x86/lib/fsp/fsp_graphics.c +3 -0
@@ -78,6 +78,9 @@ static int fsp_video_probe(struct udevice *dev)struct vesa_mode_info *vesa = &mode_info.vesa;int ret; +if (!ll_boot_init ()) +return 0 ; +printf ("Video: " );/* Initialize vesa_mode_info structure */
arch/x86/lib/fsp2/fsp_dram.c +10 -0
@@ -12,11 +12,18 @@#include <asm/fsp/fsp_support.h> #include <asm/fsp2/fsp_api.h> #include <asm/fsp2/fsp_internal.h> +#include <linux/sizes.h> int dram_init (void ) {int ret; +if (!ll_boot_init ()) { +/* Use a small and safe amount of 1GB */ + gd->ram_size =SZ_1G ; + +return 0 ; + }if (spl_phase () ==PHASE_SPL ) {#ifdef CONFIG_HAVE_ACPI_RESUME bool s3wake = gd->arch.prev_sleep_state ==ACPI_S3 ;
@@ -68,6 +75,9 @@ int dram_init(void)ulong board_get_usable_ram_top (ulong total_size) { +if (!ll_boot_init ()) +return gd->ram_size; +#if CONFIG_IS_ENABLED (HANDOFF )struct spl_handoff *ho = gd->spl_handoff;
arch/x86/lib/fsp2/fsp_init.c +1 -1
@@ -23,7 +23,7 @@ int arch_cpu_init_dm(void)int ret;/* Make sure pads are set up early in U-Boot */ -if (spl_phase () !=PHASE_BOARD_F ) +if (!ll_boot_init () ||spl_phase () !=PHASE_BOARD_F )return 0 ;/* Probe all pinctrl devices to set up the pads */
Signature · 1 line
2.24.1.735.g03f4e72817-goog
PATCH 1/5 x86: fsp: Allow skipping init code when chain loading
Hi Simon,
Quoted 23 lines · Simon Glass
When U-Boot is no the first-stage bootloader much of this code is not needed and can break booting. Add checks for this to the FSP code.
Rather than checking for the amount of available SDRAM, just use 1GB in this situation, which should be safe. Using 2GB may run into a memory hole on some SoCs.
Signed-off-by Simon Glass <[email protected]>---
arch/x86/lib/fsp/fsp_dram.c | 8 ++++++++ arch/x86/lib/fsp/fsp_graphics.c | 3 +++ arch/x86/lib/fsp2/fsp_dram.c | 10 ++++++++++ arch/x86/lib/fsp2/fsp_init.c | 2 +- 4 files changed, 22 insertions(+), 1 deletion(-)arch/x86/lib/fsp/fsp_dram.c +0
-0@@ -44,6 +44,14 @@ int dram_init_banksize(void)phys_addr_t low_end;
arch/x86/lib/fsp/fsp_dram.c int dram_init_banksize(void) · line 54
Quoted 10 lines
arch/x86/lib/fsp/fsp_dram.c +8
-0uint bank; +if (!ll_boot_init ()) { + gd->bd->bi_dram[0 ].start =0 ; + gd->bd->bi_dram[0 ].size = gd->ram_size; + +mtrr_add_request (MTRR_TYPE_WRBACK ,0 , gd->ram_size); +return 0 ; + } +
I wonder why this change is needed. When booting from other bootloader, this dram_init_banksize() will not be called, no?
Quoted 8 lines
arch/x86/lib/fsp/fsp_dram.c +0
-0low_end =0 ; for (bank = 1, hdr = gd->arch.hob_list; bank < CONFIG_NR_DRAM_BANKS && !end_of_hob(hdr);arch/x86/lib/fsp/fsp_graphics.c +0
-0
arch/x86/lib/fsp/fsp_graphics.c static int fsp_video_probe(struct udevice *dev) · line 83
Quoted 6 lines
arch/x86/lib/fsp/fsp_graphics.c +3
-0@@ -78,6 +78,9 @@ static int fsp_video_probe(struct udevice *dev)struct vesa_mode_info *vesa = &mode_info.vesa;int ret; +if (!ll_boot_init ()) +return 0 ; +
the same question as above
Quoted 11 lines
arch/x86/lib/fsp/fsp_graphics.c +0
-0printf ("Video: " );/* Initialize vesa_mode_info structure */ arch/x86/lib/fsp2/fsp_dram.c +0
-0@@ -12,11 +12,18 @@#include <asm/fsp/fsp_support.h> #include <asm/fsp2/fsp_api.h> #include <asm/fsp2/fsp_internal.h>
arch/x86/lib/fsp2/fsp_dram.c line 24
Quoted 10 lines
arch/x86/lib/fsp2/fsp_dram.c +5
-0+#include <linux/sizes.h> int dram_init (void ) {int ret; +if (!ll_boot_init ()) { +/* Use a small and safe amount of 1GB */ + gd->ram_size =SZ_1G ; +
ditto. Maybe we should explain on what configuration ll_boot_init() is set to true / false?
Quoted 20 lines
arch/x86/lib/fsp2/fsp_dram.c +5
-0+return 0 ; + }if (spl_phase () ==PHASE_SPL ) {#ifdef CONFIG_HAVE_ACPI_RESUME bool s3wake = gd->arch.prev_sleep_state ==ACPI_S3 ;@@ -68,6 +75,9 @@ int dram_init(void)ulong board_get_usable_ram_top (ulong total_size) { +if (!ll_boot_init ()) +return gd->ram_size; +#if CONFIG_IS_ENABLED (HANDOFF )struct spl_handoff *ho = gd->spl_handoff;arch/x86/lib/fsp2/fsp_init.c +0
-0
arch/x86/lib/fsp2/fsp_init.c int arch_cpu_init_dm(void)
Quoted 9 lines
arch/x86/lib/fsp2/fsp_init.c +1
-2@@ -23,7 +23,7 @@ int arch_cpu_init_dm(void)int ret;/* Make sure pads are set up early in U-Boot */ -if (spl_phase () !=PHASE_BOARD_F ) +if (!ll_boot_init () ||spl_phase () !=PHASE_BOARD_F )return 0 ;/* Probe all pinctrl devices to set up the pads */ --
Regards,
Bin
PATCH 1/5 x86: fsp: Allow skipping init code when chain loading
Hi Bin,
Quoted 29 lines · Bin Meng
Hi Simon,
Quoted 25 lines · Simon Glass
When U-Boot is no the first-stage bootloader much of this code is not needed and can break booting. Add checks for this to the FSP code.
Rather than checking for the amount of available SDRAM, just use 1GB in this situation, which should be safe. Using 2GB may run into a memory hole on some SoCs.
Signed-off-by Simon Glass <[email protected]>---
arch/x86/lib/fsp/fsp_dram.c | 8 ++++++++ arch/x86/lib/fsp/fsp_graphics.c | 3 +++ arch/x86/lib/fsp2/fsp_dram.c | 10 ++++++++++ arch/x86/lib/fsp2/fsp_init.c | 2 +- 4 files changed, 22 insertions(+), 1 deletion(-)arch/x86/lib/fsp/fsp_dram.c +0
-0@@ -44,6 +44,14 @@ int dram_init_banksize(void)phys_addr_t low_end;uint bank;
Quoted 11 lines
arch/x86/lib/fsp/fsp_dram.c int dram_init_banksize(void) · line 54
Quoted 8 lines
arch/x86/lib/fsp/fsp_dram.c +8
-0+if (!ll_boot_init ()) { + gd->bd->bi_dram[0 ].start =0 ; + gd->bd->bi_dram[0 ].size = gd->ram_size; + +mtrr_add_request (MTRR_TYPE_WRBACK ,0 , gd->ram_size); +return 0 ; + } +I wonder why this change is needed. When booting from other bootloader, this
dram_init_banksize()will not be called, no?
How about this:
It is useful to be able to boot the same x86 image on a device with or without a first-stage bootloader. For example, with chromebook_coral, it is helpful for testing to be able to boot the same U-Boot (complete with FSP) on bare metal and from coreboot. It allows checking of things like CPU speed, comparing registers, ACPI tables and the like.
The idea is to change ll_boot_init() to false, and rebuild without changing anything else.
Regards,
Simon
PATCH 1/5 x86: fsp: Allow skipping init code when chain loading
Hi Simon,
Quoted 47 lines · Simon Glass
Hi Bin,
Quoted 29 lines · Bin Meng
Hi Simon,
Quoted 25 lines · Simon Glass
When U-Boot is no the first-stage bootloader much of this code is not needed and can break booting. Add checks for this to the FSP code.
Rather than checking for the amount of available SDRAM, just use 1GB in this situation, which should be safe. Using 2GB may run into a memory hole on some SoCs.
Signed-off-by Simon Glass <[email protected]>---
arch/x86/lib/fsp/fsp_dram.c | 8 ++++++++ arch/x86/lib/fsp/fsp_graphics.c | 3 +++ arch/x86/lib/fsp2/fsp_dram.c | 10 ++++++++++ arch/x86/lib/fsp2/fsp_init.c | 2 +- 4 files changed, 22 insertions(+), 1 deletion(-)arch/x86/lib/fsp/fsp_dram.c +0
-0@@ -44,6 +44,14 @@ int dram_init_banksize(void)phys_addr_t low_end;uint bank;Quoted 11 lines
arch/x86/lib/fsp/fsp_dram.c int dram_init_banksize(void) · line 54
Quoted 8 lines
arch/x86/lib/fsp/fsp_dram.c +8
-0+if (!ll_boot_init ()) { + gd->bd->bi_dram[0 ].start =0 ; + gd->bd->bi_dram[0 ].size = gd->ram_size; + +mtrr_add_request (MTRR_TYPE_WRBACK ,0 , gd->ram_size); +return 0 ; + } +I wonder why this change is needed. When booting from other bootloader, this
dram_init_banksize()will not be called, no?How about this:
Quoted 8 lines
It is useful to be able to boot the same x86 image on a device with or without a first-stage bootloader. For example, with
chromebook_coral, it is helpful for testing to be able to boot the same U-Boot (complete with FSP) on bare metal and from coreboot. It allows checking of things like CPU speed, comparing registers, ACPI tables and the like.The idea is to change
ll_boot_init()to false, and rebuild without changing anything else.
This sounds like for a debugging purpose, instead of a supported configuration. So when we boot from previous bootloader, we really should use its configuration, for the coreboot case, coreboot-x86_defconfig should be used, and we can compare the registers, ACPI tables in that configuration, instead of "hacking" current U-Boot codes like in this series.
Regards,
Bin
PATCH 1/5 x86: fsp: Allow skipping init code when chain loading
Hi Bin,
Quoted 60 lines · Bin Meng
Hi Simon,
Quoted 47 lines · Simon Glass
Hi Bin,
Quoted 29 lines · Bin Meng
Hi Simon,
Quoted 25 lines · Simon Glass
When U-Boot is no the first-stage bootloader much of this code is not needed and can break booting. Add checks for this to the FSP code.
Rather than checking for the amount of available SDRAM, just use 1GB in this situation, which should be safe. Using 2GB may run into a memory hole on some SoCs.
Signed-off-by Simon Glass <[email protected]>---
arch/x86/lib/fsp/fsp_dram.c | 8 ++++++++ arch/x86/lib/fsp/fsp_graphics.c | 3 +++ arch/x86/lib/fsp2/fsp_dram.c | 10 ++++++++++ arch/x86/lib/fsp2/fsp_init.c | 2 +- 4 files changed, 22 insertions(+), 1 deletion(-)arch/x86/lib/fsp/fsp_dram.c +0
-0@@ -44,6 +44,14 @@ int dram_init_banksize(void)phys_addr_t low_end;uint bank;Quoted 11 lines
arch/x86/lib/fsp/fsp_dram.c int dram_init_banksize(void) · line 54
Quoted 8 lines
arch/x86/lib/fsp/fsp_dram.c +8
-0+if (!ll_boot_init ()) { + gd->bd->bi_dram[0 ].start =0 ; + gd->bd->bi_dram[0 ].size = gd->ram_size; + +mtrr_add_request (MTRR_TYPE_WRBACK ,0 , gd->ram_size); +return 0 ; + } +I wonder why this change is needed. When booting from other bootloader, this
dram_init_banksize()will not be called, no?How about this:
Quoted 8 lines
It is useful to be able to boot the same x86 image on a device with or without a first-stage bootloader. For example, with
chromebook_coral, it is helpful for testing to be able to boot the same U-Boot (complete with FSP) on bare metal and from coreboot. It allows checking of things like CPU speed, comparing registers, ACPI tables and the like.The idea is to change
ll_boot_init()to false, and rebuild without changing anything else.
Quoted 6 lines
This sounds like for a debugging purpose, instead of a supported configuration. So when we boot from previous bootloader, we really should use its configuration, for the coreboot case, coreboot-x86_defconfig should be used, and we can compare the registers, ACPI tables in that configuration, instead of "hacking" current U-Boot codes like in this series.
Well the problem is then that we cannot boot the same image with or without coreboot. Also there are various of device-tree things in coral that we need for the laptop to work properly. My idea is to detect coreboot and set ll_boot_init() dynamically if needed.
Regards,
Simon
PATCH 1/5 x86: fsp: Allow skipping init code when chain loading
Hi Simon,
Quoted 71 lines · Simon Glass
Hi Bin,
Quoted 60 lines · Bin Meng
Hi Simon,
Quoted 47 lines · Simon Glass
Hi Bin,
Quoted 29 lines · Bin Meng
Hi Simon,
Quoted 25 lines · Simon Glass
When U-Boot is no the first-stage bootloader much of this code is not needed and can break booting. Add checks for this to the FSP code.
Rather than checking for the amount of available SDRAM, just use 1GB in this situation, which should be safe. Using 2GB may run into a memory hole on some SoCs.
Signed-off-by Simon Glass <[email protected]>---
arch/x86/lib/fsp/fsp_dram.c | 8 ++++++++ arch/x86/lib/fsp/fsp_graphics.c | 3 +++ arch/x86/lib/fsp2/fsp_dram.c | 10 ++++++++++ arch/x86/lib/fsp2/fsp_init.c | 2 +- 4 files changed, 22 insertions(+), 1 deletion(-)arch/x86/lib/fsp/fsp_dram.c +0
-0@@ -44,6 +44,14 @@ int dram_init_banksize(void)phys_addr_t low_end;uint bank;Quoted 11 lines
arch/x86/lib/fsp/fsp_dram.c int dram_init_banksize(void) · line 54
Quoted 8 lines
arch/x86/lib/fsp/fsp_dram.c +8
-0+if (!ll_boot_init ()) { + gd->bd->bi_dram[0 ].start =0 ; + gd->bd->bi_dram[0 ].size = gd->ram_size; + +mtrr_add_request (MTRR_TYPE_WRBACK ,0 , gd->ram_size); +return 0 ; + } +I wonder why this change is needed. When booting from other bootloader, this
dram_init_banksize()will not be called, no?How about this:
Quoted 8 lines
It is useful to be able to boot the same x86 image on a device with or without a first-stage bootloader. For example, with
chromebook_coral, it is helpful for testing to be able to boot the same U-Boot (complete with FSP) on bare metal and from coreboot. It allows checking of things like CPU speed, comparing registers, ACPI tables and the like.The idea is to change
ll_boot_init()to false, and rebuild without changing anything else.Quoted 6 lines
This sounds like for a debugging purpose, instead of a supported configuration. So when we boot from previous bootloader, we really should use its configuration, for the coreboot case, coreboot-x86_defconfig should be used, and we can compare the registers, ACPI tables in that configuration, instead of "hacking" current U-Boot codes like in this series.
Quoted 4 lines
Well the problem is then that we cannot boot the same image with or without coreboot. Also there are various of device-tree things in coral that we need for the laptop to work properly. My idea is to detect coreboot and set
ll_boot_init()dynamically if needed.
If so, why should we keep coreboot_defconfig for U-Boot as a supported target?
I am more interested in what you proposed here: "detect coreboot and set ll_boot_init() dynamically if needed." The name ll_boot_init() does not sound great. It's written like a function call but actually it is a macro for true/false. Can we do something in the gd->flags to indicate we are booting from previous stage bootloaders instead of relying on ll_boot_init()?
Regards,
Bin
PATCH 1/5 x86: fsp: Allow skipping init code when chain loading
Hi Bin,
Quoted 80 lines · Bin Meng
Hi Simon,
Quoted 71 lines · Simon Glass
Hi Bin,
Quoted 60 lines · Bin Meng
Hi Simon,
Quoted 47 lines · Simon Glass
Hi Bin,
Quoted 29 lines · Bin Meng
Hi Simon,
Quoted 25 lines · Simon Glass
When U-Boot is no the first-stage bootloader much of this code is not needed and can break booting. Add checks for this to the FSP code.
Rather than checking for the amount of available SDRAM, just use 1GB in this situation, which should be safe. Using 2GB may run into a memory hole on some SoCs.
Signed-off-by Simon Glass <[email protected]>---
arch/x86/lib/fsp/fsp_dram.c | 8 ++++++++ arch/x86/lib/fsp/fsp_graphics.c | 3 +++ arch/x86/lib/fsp2/fsp_dram.c | 10 ++++++++++ arch/x86/lib/fsp2/fsp_init.c | 2 +- 4 files changed, 22 insertions(+), 1 deletion(-)arch/x86/lib/fsp/fsp_dram.c +0
-0@@ -44,6 +44,14 @@ int dram_init_banksize(void)phys_addr_t low_end;uint bank;Quoted 11 lines
arch/x86/lib/fsp/fsp_dram.c int dram_init_banksize(void) · line 54
Quoted 8 lines
arch/x86/lib/fsp/fsp_dram.c +8
-0+if (!ll_boot_init ()) { + gd->bd->bi_dram[0 ].start =0 ; + gd->bd->bi_dram[0 ].size = gd->ram_size; + +mtrr_add_request (MTRR_TYPE_WRBACK ,0 , gd->ram_size); +return 0 ; + } +I wonder why this change is needed. When booting from other bootloader, this
dram_init_banksize()will not be called, no?How about this:
Quoted 8 lines
It is useful to be able to boot the same x86 image on a device with or without a first-stage bootloader. For example, with
chromebook_coral, it is helpful for testing to be able to boot the same U-Boot (complete with FSP) on bare metal and from coreboot. It allows checking of things like CPU speed, comparing registers, ACPI tables and the like.The idea is to change
ll_boot_init()to false, and rebuild without changing anything else.Quoted 6 lines
This sounds like for a debugging purpose, instead of a supported configuration. So when we boot from previous bootloader, we really should use its configuration, for the coreboot case, coreboot-x86_defconfig should be used, and we can compare the registers, ACPI tables in that configuration, instead of "hacking" current U-Boot codes like in this series.
Quoted 4 lines
Well the problem is then that we cannot boot the same image with or without coreboot. Also there are various of device-tree things in coral that we need for the laptop to work properly. My idea is to detect coreboot and set
ll_boot_init()dynamically if needed.
Quoted 8 lines
If so, why should we keep
coreboot_defconfigfor U-Boot as a supported target?I am more interested in what you proposed here: "detect coreboot and set
ll_boot_init()dynamically if needed." The namell_boot_init()does not sound great. It's written like a function call but actually it is a macro for true/false. Can we do something in thegd->flagsto indicate we are booting from previous stage bootloaders instead of relying onll_boot_init()?
That sounds like a good idea, although at present it is statically configured. But we don't really care about code size here I think.
Regards,
Simon
PATCH 2/5 x86: apl: Skip init code when chain loading
In reply to Simon GlassWhen U-Boot is not the first-stage bootloader the FSP-S init must be skipped. Update it to add a check.
---
arch/x86/cpu/apollolake/fsp_s.c | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/cpu/apollolake/fsp_s.c +2 -0
@@ -623,6 +623,8 @@ int arch_fsp_init_r(void)struct udevice *dev, *itss;int ret; +if (!ll_boot_init ()) +return 0 ;/* * This must be called before any devices are probed. Put any probing * into arch_fsps_preinit() above.
Signature · 1 line
2.24.1.735.g03f4e72817-goog
PATCH 3/5 x86: cpu: Skip init code when chain loading
In reply to Simon GlassWhen U-Boot is not the first-stage bootloader the interrupt and cache init must be skipped, as well as init for various peripherals. Update the code to add checks for this.
---
arch/x86/cpu/cpu.c | 4 +++- arch/x86/cpu/i386/interrupt.c | 3 +++ arch/x86/lib/init_helpers.c | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-)
arch/x86/cpu/cpu.c +3 -1
@@ -238,8 +238,10 @@ int cpu_init_r(void)struct udevice *dev;int ret; -if (!ll_boot_init ()) +if (!ll_boot_init ()) { +uclass_first_device (UCLASS_PCI , &dev);return 0 ; + } ret =x86_init_cpus ();if (ret)
arch/x86/cpu/i386/interrupt.c +3 -0
@@ -261,6 +261,9 @@ int interrupt_init(void)struct udevice *dev;int ret; +if (!ll_boot_init ()) +return 0 ; +/* Try to set up the interrupt router, but don't require one */ ret =uclass_first_device_err (UCLASS_IRQ , &dev);if (ret && ret != -ENODEV )
arch/x86/lib/init_helpers.c +3 -0
@@ -30,6 +30,9 @@ int init_cache_f_r(void)return ret; } +if (!ll_boot_init ()) +return 0 ; +/* Initialise the CPU cache(s) */ return init_cache (); }
Signature · 1 line
2.24.1.735.g03f4e72817-goog
PATCH 3/5 x86: cpu: Skip init code when chain loading
Hi Simon,
Quoted 34 lines · Simon Glass
When U-Boot is not the first-stage bootloader the interrupt and cache init must be skipped, as well as init for various peripherals. Update the code to add checks for this.
Signed-off-by Simon Glass <[email protected]>---
arch/x86/cpu/cpu.c | 4 +++- arch/x86/cpu/i386/interrupt.c | 3 +++ arch/x86/lib/init_helpers.c | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-)arch/x86/cpu/cpu.c +3
-1@@ -238,8 +238,10 @@ int cpu_init_r(void)struct udevice *dev;int ret; -if (!ll_boot_init ()) +if (!ll_boot_init ()) { +uclass_first_device (UCLASS_PCI , &dev);return 0 ; + } ret =x86_init_cpus ();if (ret)arch/x86/cpu/i386/interrupt.c +0
-0
arch/x86/cpu/i386/interrupt.c int interrupt_init(void) · line 266
Quoted 6 lines
arch/x86/cpu/i386/interrupt.c +3
-0@@ -261,6 +261,9 @@ int interrupt_init(void)struct udevice *dev;int ret; +if (!ll_boot_init ()) +return 0 ; +
If you scroll down a little bit in this function, you see there is already a ll_boot_init() check. We need some consolidation here.
arch/x86/lib/init_helpers.c int init_cache_f_r(void) · line 34
Quoted 13 lines
arch/x86/cpu/i386/interrupt.c +0
-0/* Try to set up the interrupt router, but don't require one */ ret =uclass_first_device_err (UCLASS_IRQ , &dev);if (ret && ret != -ENODEV )arch/x86/lib/init_helpers.c +2
-0@@ -30,6 +30,9 @@ int init_cache_f_r(void)return ret; } +if (!ll_boot_init ()) +return 0 ;
I am not convinced that we should add the ll_boot_init() check here. This function already has a do_mtrr variable that is based on the config options.
arch/x86/lib/init_helpers.c int init_cache_f_r(void) · line 38
Quoted 4 lines
arch/x86/lib/init_helpers.c +1
-0+/* Initialise the CPU cache(s) */ return init_cache (); }
Regards,
Bin
PATCH 3/5 x86: cpu: Skip init code when chain loading
Hi Bin,
Quoted 59 lines · Bin Meng
Hi Simon,
Quoted 34 lines · Simon Glass
When U-Boot is not the first-stage bootloader the interrupt and cache init must be skipped, as well as init for various peripherals. Update the code to add checks for this.
Signed-off-by Simon Glass <[email protected]>---
arch/x86/cpu/cpu.c | 4 +++- arch/x86/cpu/i386/interrupt.c | 3 +++ arch/x86/lib/init_helpers.c | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-)arch/x86/cpu/cpu.c +3
-1@@ -238,8 +238,10 @@ int cpu_init_r(void)struct udevice *dev;int ret; -if (!ll_boot_init ()) +if (!ll_boot_init ()) { +uclass_first_device (UCLASS_PCI , &dev);return 0 ; + } ret =x86_init_cpus ();if (ret)arch/x86/cpu/i386/interrupt.c +0
-0arch/x86/cpu/i386/interrupt.c int interrupt_init(void) · line 266
Quoted 6 lines
arch/x86/cpu/i386/interrupt.c +3
-0@@ -261,6 +261,9 @@ int interrupt_init(void)struct udevice *dev;int ret; +if (!ll_boot_init ()) +return 0 ; +If you scroll down a little bit in this function, you see there is already a
ll_boot_init()check. We need some consolidation here.Quoted 11 lines
arch/x86/cpu/i386/interrupt.c +0
-0/* Try to set up the interrupt router, but don't require one */ ret =uclass_first_device_err (UCLASS_IRQ , &dev);if (ret && ret != -ENODEV )arch/x86/lib/init_helpers.c +0
-0@@ -30,6 +30,9 @@ int init_cache_f_r(void)return ret; }
Quoted 6 lines
arch/x86/lib/init_helpers.c int init_cache_f_r(void) · line 34
Quoted 2 lines
arch/x86/lib/init_helpers.c +2
-0+if (!ll_boot_init ()) +return 0 ;I am not convinced that we should add the
ll_boot_init()check here. This function already has ado_mtrrvariable that is based on the config options.
Yes but as per my other explanation, we are not using those config options. The idea is to boot an image as close as possible to the bare-metal one.
Regards,
Simon
PATCH 4/5 dm: Avoid initing built-in devices when chain loading
In reply to Simon GlassWhen U-Boot is not the first-stage bootloader we don't want to init devices early during boot. Add a check to avoid this.
---
common/board_r.c | 3 +++ 1 file changed, 3 insertions(+)
common/board_r.c +3 -0
@@ -320,6 +320,9 @@ static int initr_dm_devices(void) {int ret; +if (!ll_boot_init ()) +return 0 ; +if (IS_ENABLED (CONFIG_TIMER_EARLY )) { ret =dm_timer_init ();if (ret)
Signature · 1 line
2.24.1.735.g03f4e72817-goog
PATCH 4/5 dm: Avoid initing built-in devices when chain loading
Hi Simon,
Quoted 15 lines · Simon Glass
When U-Boot is not the first-stage bootloader we don't want to init devices early during boot. Add a check to avoid this.
Signed-off-by Simon Glass <[email protected]>---
common/board_r.c | 3 +++ 1 file changed, 3 insertions(+)common/board_r.c +0
-0
common/board_r.c static int initr_dm_devices(void) · line 325
Quoted 6 lines
common/board_r.c +3
-0@@ -320,6 +320,9 @@ static int initr_dm_devices(void) {int ret; +if (!ll_boot_init ()) +return 0 ; +
I can't think of a reason why dm_timer_init() cannot be called in this case.
common/board_r.c static int initr_dm_devices(void)
Quoted 4 lines
common/board_r.c +0
-1if (IS_ENABLED (CONFIG_TIMER_EARLY )) { ret =dm_timer_init ();if (ret) --
Regards,
Bin
PATCH 4/5 dm: Avoid initing built-in devices when chain loading
Hi Bin,
Quoted 22 lines · Bin Meng
Hi Simon,
Quoted 18 lines · Simon Glass
When U-Boot is not the first-stage bootloader we don't want to init devices early during boot. Add a check to avoid this.
Signed-off-by Simon Glass <[email protected]>---
common/board_r.c | 3 +++ 1 file changed, 3 insertions(+)common/board_r.c +0
-0@@ -320,6 +320,9 @@ static int initr_dm_devices(void) {int ret;
Quoted 5 lines
common/board_r.c static int initr_dm_devices(void) · line 325
Quoted 3 lines
common/board_r.c +3
-0+if (!ll_boot_init ()) +return 0 ; +I can't think of a reason why
dm_timer_init()cannot be called in this case.
Perhaps we can drop this one, since we don't reset the timer base anymore.
Quoted 5 lines
common/board_r.c static int initr_dm_devices(void)
Quoted 5 lines
common/board_r.c +0
-1if (IS_ENABLED (CONFIG_TIMER_EARLY )) { ret =dm_timer_init ();if (ret) --
Regards,
SImon
PATCH 5/5 pci: Avoid auto-config when chain loading
In reply to Simon GlassWhen U-Boot is not the first-stage bootloader we don't want to re-configure the PCI devices, since this has already been done. Add a check to avoid this.
---
drivers/pci/pci-uclass.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/pci-uclass.c +2 -2
@@ -991,7 +991,7 @@ static int pci_uclass_post_probe(struct udevice *bus)if (ret)return ret; -if (CONFIG_IS_ENABLED (PCI_PNP ) && +if (CONFIG_IS_ENABLED (PCI_PNP ) &&ll_boot_init () && (!hose->skip_auto_config_until_reloc || (gd->flags &GD_FLG_RELOC ))) { ret =pci_auto_config_devices (bus);
@@ -1013,7 +1013,7 @@ static int pci_uclass_post_probe(struct udevice *bus)* Note we only call this 1) after U-Boot is relocated, and 2) * root bus has finished probing. */ -if ((gd->flags &GD_FLG_RELOC ) && (bus->seq ==0 )) { +if ((gd->flags &GD_FLG_RELOC ) && bus->seq ==0 &&ll_boot_init ()) { ret =fsp_init_phase_pci ();if (ret)return ret;
Signature · 1 line
2.24.1.735.g03f4e72817-goog
PATCH 5/5 pci: Avoid auto-config when chain loading
Hi Simon,
Quoted 16 lines · Simon Glass
When U-Boot is not the first-stage bootloader we don't want to re-configure the PCI devices, since this has already been done. Add a check to avoid this.
Signed-off-by Simon Glass <[email protected]>---
drivers/pci/pci-uclass.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/pci/pci-uclass.c +0
-0
drivers/pci/pci-uclass.c static int pci_uclass_post_probe(struct udevice *bus) · line 994
Quoted 5 lines
drivers/pci/pci-uclass.c +1
-1@@ -991,7 +991,7 @@ static int pci_uclass_post_probe(struct udevice *bus)if (ret)return ret; - if (CONFIG_IS_ENABLED(PCI_PNP) && + if (CONFIG_IS_ENABLED(PCI_PNP) && ll_boot_init() &&
Doesn't the PCI_PNP option already cover such situation?
drivers/pci/pci-uclass.c static int pci_uclass_post_probe(struct udevice *bus) · line 1016
Quoted 9 lines
drivers/pci/pci-uclass.c +1
-1(!hose->skip_auto_config_until_reloc || (gd->flags & GD_FLG_RELOC))) { ret =pci_auto_config_devices (bus);@@ -1013,7 +1013,7 @@ static int pci_uclass_post_probe(struct udevice *bus)* Note we only call this 1) after U-Boot is relocated, and 2) * root bus has finished probing. */ -if ((gd->flags &GD_FLG_RELOC ) && (bus->seq ==0 )) { +if ((gd->flags &GD_FLG_RELOC ) && bus->seq ==0 &&ll_boot_init ()) {
So CONFIG_HAVE_FSP already covers this. In such configuration, U-Boot should not turn on CONFIG_HAVE_FSP hence there is no need to check ll_boot_init().
drivers/pci/pci-uclass.c static int pci_uclass_post_probe(struct udevice *bus)
Quoted 4 lines
drivers/pci/pci-uclass.c +0
-1ret =fsp_init_phase_pci ();if (ret)return ret; --
Regards,
Bin
PATCH 5/5 pci: Avoid auto-config when chain loading
Hi Bin,
Quoted 28 lines · Bin Meng
Hi Simon,
Quoted 16 lines · Simon Glass
When U-Boot is not the first-stage bootloader we don't want to re-configure the PCI devices, since this has already been done. Add a check to avoid this.
Signed-off-by Simon Glass <[email protected]>---
drivers/pci/pci-uclass.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/pci/pci-uclass.c +0
-0drivers/pci/pci-uclass.c static int pci_uclass_post_probe(struct udevice *bus) · line 994
Quoted 5 lines
drivers/pci/pci-uclass.c +1
-1@@ -991,7 +991,7 @@ static int pci_uclass_post_probe(struct udevice *bus)if (ret)return ret; - if (CONFIG_IS_ENABLED(PCI_PNP) && + if (CONFIG_IS_ENABLED(PCI_PNP) && ll_boot_init() &&Doesn't the
PCI_PNPoption already cover such situation?
Quoted 13 lines
drivers/pci/pci-uclass.c static int pci_uclass_post_probe(struct udevice *bus) · line 1016
Quoted 9 lines
drivers/pci/pci-uclass.c +1
-1(!hose->skip_auto_config_until_reloc || (gd->flags & GD_FLG_RELOC))) { ret =pci_auto_config_devices (bus);@@ -1013,7 +1013,7 @@ static int pci_uclass_post_probe(struct udevice *bus)* Note we only call this 1) after U-Boot is relocated, and 2) * root bus has finished probing. */ -if ((gd->flags &GD_FLG_RELOC ) && (bus->seq ==0 )) { +if ((gd->flags &GD_FLG_RELOC ) && bus->seq ==0 &&ll_boot_init ()) {So
CONFIG_HAVE_FSPalready covers this. In such configuration, U-Boot should not turn onCONFIG_HAVE_FSPhence there is no need to checkll_boot_init().
Same comment as with patch 1. See if that explains things enough, and if so I can send a v2.
Regards,
Simon
cover x86: Improve support for chain-loading U-Boot
In reply to Simon GlassQuoted 10 lines · Simon Glass
This little series adds a few checks into the code to allow better operation when booting a build from a previous-state loader such as coreboot.
At present we have a 'coreboot' target, but sometimes it is useful to boot a bare-metal target, such as coral, from coreboot. That allows comparison of operation between the bare metal version doing all the init itself and relying on coreboot for some init.
Thank you for sharing. May I ask what devices and configurations you have tested this on?
P.S. I'll be able to test my case after xmas vacations (mid January).
Quoted 22 lines
Simon Glass (5):
x86: fsp: Allow skipping init code when chain loading
x86: apl: Skip init code when chain loading
x86: cpu: Skip init code when chain loading
dm: Avoid initing built-in devices when chain loading
pci: Avoid auto-config when chain loadingarch/x86/cpu/apollolake/fsp_s.c | 2 ++ arch/x86/cpu/cpu.c | 4 +++- arch/x86/cpu/i386/interrupt.c | 3 +++ arch/x86/lib/fsp/fsp_dram.c | 8 ++++++++ arch/x86/lib/fsp/fsp_graphics.c | 3 +++ arch/x86/lib/fsp2/fsp_dram.c | 10 ++++++++++ arch/x86/lib/fsp2/fsp_init.c | 2 +- arch/x86/lib/init_helpers.c | 3 +++ common/board_r.c | 3 +++ drivers/pci/pci-uclass.c | 4 ++-- 10 files changed, 38 insertions(+), 4 deletions(-)--
2.24.1.735.g03f4e72817-goog
Signature · 2 lines
With Best Regards, Andy Shevchenko
cover x86: Improve support for chain-loading U-Boot
Hi Andy,
Quoted 13 lines · Andy Shevchenko
Quoted 10 lines · Simon Glass
This little series adds a few checks into the code to allow better operation when booting a build from a previous-state loader such as coreboot.
At present we have a 'coreboot' target, but sometimes it is useful to boot a bare-metal target, such as coral, from coreboot. That allows comparison of operation between the bare metal version doing all the init itself and relying on coreboot for some init.
Quoted 4 lines
Thank you for sharing. May I ask what devices and configurations you have tested this on?
P.S. I'll be able to test my case after xmas vacations (mid January).
This is only on chromebook_coral. But I think it could work in a similar way with any of the boards.
Merry Christmas!
Simon
cover x86: Improve support for chain-loading U-Boot
In reply to Andy ShevchenkoHi Andy,
Quoted 13 lines · Andy Shevchenko
Quoted 10 lines · Simon Glass
This little series adds a few checks into the code to allow better operation when booting a build from a previous-state loader such as coreboot.
At present we have a 'coreboot' target, but sometimes it is useful to boot a bare-metal target, such as coral, from coreboot. That allows comparison of operation between the bare metal version doing all the init itself and relying on coreboot for some init.
Quoted 5 lines
Thank you for sharing. May I ask what devices and configurations you have tested this on?
P.S. I'll be able to test my case after xmas vacations (mid January).
Do you have any review comments to share?
Regards,
Bin
cover x86: Improve support for chain-loading U-Boot
Quoted 15 lines · Bin Meng
Quoted 13 lines · Andy Shevchenko
Quoted 10 lines · Simon Glass
This little series adds a few checks into the code to allow better operation when booting a build from a previous-state loader such as coreboot.
At present we have a 'coreboot' target, but sometimes it is useful to boot a bare-metal target, such as coral, from coreboot. That allows comparison of operation between the bare metal version doing all the init itself and relying on coreboot for some init.
Quoted 7 lines
Quoted 5 lines
Thank you for sharing. May I ask what devices and configurations you have tested this on?
P.S. I'll be able to test my case after xmas vacations (mid January).Do you have any review comments to share?
Not for time being. Sorry, I'm busy with something else, but if there is a branch with these patches available thru x86 U-Boot tree, it will be easier to me to have a chance to test.
Signature · 2 lines
With Best Regards, Andy Shevchenko
cover x86: Improve support for chain-loading U-Boot
Hi Andy,
Quoted 20 lines · Andy Shevchenko
Quoted 18 lines · Bin Meng
Quoted 16 lines · Andy Shevchenko
Quoted 10 lines · Simon Glass
This little series adds a few checks into the code to allow better operation when booting a build from a previous-state loader such as coreboot.
At present we have a 'coreboot' target, but sometimes it is useful to boot a bare-metal target, such as coral, from coreboot. That allows comparison of operation between the bare metal version doing all the init itself and relying on coreboot for some init.
Thank you for sharing. May I ask what devices and configurations you have tested this on?
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
P.S. I'll be able to test my case after xmas vacations (mid January).Do you have any review comments to share?
Not for time being. Sorry, I'm busy with something else, but if there is a branch with these patches available thru x86 U-Boot tree, it will be easier to me to have a chance to test.
This one is u-boot-dm/cor3chain-working
I always push to the -dm tree before sending patches out, but don't always mention it in the cover letter!
The ACPI patches are at dm/coral-working
Regards,
Simon