diff mbox series

[v4,3/9] x86: cpu: Skip init code when chain loading

Message ID 20200426151302.93418-4-sjg@chromium.org
State Superseded
Headers show
Series x86: Improve support for chain-loading U-Boot | expand

Commit Message

Simon Glass April 26, 2020, 3:12 p.m. UTC
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 <sjg at chromium.org>
---

Changes in v4: None
Changes in v3: None
Changes in v2:
- Drop the other check in interrupt_init() which is not needed now

 arch/x86/cpu/cpu.c            | 4 +++-
 arch/x86/cpu/i386/interrupt.c | 6 ++++--
 arch/x86/lib/init_helpers.c   | 3 +++
 3 files changed, 10 insertions(+), 3 deletions(-)

Comments

Bin Meng April 30, 2020, 9:32 a.m. UTC | #1
On Sun, Apr 26, 2020 at 11:13 PM Simon Glass <sjg at chromium.org> wrote:
>
> 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 <sjg at chromium.org>
> ---
>
> Changes in v4: None
> Changes in v3: None
> Changes in v2:
> - Drop the other check in interrupt_init() which is not needed now
>
>  arch/x86/cpu/cpu.c            | 4 +++-
>  arch/x86/cpu/i386/interrupt.c | 6 ++++--
>  arch/x86/lib/init_helpers.c   | 3 +++
>  3 files changed, 10 insertions(+), 3 deletions(-)
>

Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
diff mbox series

Patch

diff --git a/arch/x86/cpu/cpu.c b/arch/x86/cpu/cpu.c
index cec04b481b..8526e856d7 100644
--- a/arch/x86/cpu/cpu.c
+++ b/arch/x86/cpu/cpu.c
@@ -239,8 +239,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)
diff --git a/arch/x86/cpu/i386/interrupt.c b/arch/x86/cpu/i386/interrupt.c
index 4c7e9ea215..e67a116ac1 100644
--- a/arch/x86/cpu/i386/interrupt.c
+++ b/arch/x86/cpu/i386/interrupt.c
@@ -264,6 +264,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 = irq_first_device_type(X86_IRQT_BASE, &dev);
 	if (ret && ret != -ENODEV)
@@ -295,8 +298,7 @@  int interrupt_init(void)
 	 * TODO(sjg at chromium.org): But we don't handle these correctly when
 	 * booted from EFI.
 	 */
-	if (ll_boot_init())
-		enable_interrupts();
+	enable_interrupts();
 #endif
 
 	return 0;
diff --git a/arch/x86/lib/init_helpers.c b/arch/x86/lib/init_helpers.c
index 5bb55e256f..d906b528b3 100644
--- a/arch/x86/lib/init_helpers.c
+++ b/arch/x86/lib/init_helpers.c
@@ -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();
 }