diff mbox series

[U-Boot,v3,030/108] x86: Move CPU init to before spl_init()

Message ID 20191021033913.220758-30-sjg@chromium.org
State Accepted
Commit 0e72ac715007a85cf89683883bd84bdcfa185b0a
Delegated to: Bin Meng
Headers show
Series x86: Add initial support for apollolake | expand

Commit Message

Simon Glass Oct. 21, 2019, 3:37 a.m. UTC
At present we call spl_init() before identifying the CPU. This is not a
good idea - e.g. if bootstage is enabled then it will try to set up the
timer which works better if the CPU is identified.

Put explicit code at each entry pointer to identify the CPU.

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

Changes in v3: None
Changes in v2: None

 arch/x86/cpu/start_from_spl.S | 1 +
 arch/x86/lib/spl.c            | 4 ++++
 arch/x86/lib/tpl.c            | 5 +++++
 3 files changed, 10 insertions(+)

Comments

Bin Meng Oct. 28, 2019, 7:52 a.m. UTC | #1
On Mon, Oct 21, 2019 at 11:40 AM Simon Glass <sjg@chromium.org> wrote:
>
> At present we call spl_init() before identifying the CPU. This is not a
> good idea - e.g. if bootstage is enabled then it will try to set up the
> timer which works better if the CPU is identified.
>
> Put explicit code at each entry pointer to identify the CPU.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v3: None
> Changes in v2: None
>
>  arch/x86/cpu/start_from_spl.S | 1 +
>  arch/x86/lib/spl.c            | 4 ++++
>  arch/x86/lib/tpl.c            | 5 +++++
>  3 files changed, 10 insertions(+)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Bin Meng Nov. 2, 2019, 9:58 a.m. UTC | #2
On Mon, Oct 28, 2019 at 3:52 PM Bin Meng <bmeng.cn@gmail.com> wrote:
>
> On Mon, Oct 21, 2019 at 11:40 AM Simon Glass <sjg@chromium.org> wrote:
> >
> > At present we call spl_init() before identifying the CPU. This is not a
> > good idea - e.g. if bootstage is enabled then it will try to set up the
> > timer which works better if the CPU is identified.
> >
> > Put explicit code at each entry pointer to identify the CPU.
> >
> > Signed-off-by: Simon Glass <sjg@chromium.org>
> > ---
> >
> > Changes in v3: None
> > Changes in v2: None
> >
> >  arch/x86/cpu/start_from_spl.S | 1 +
> >  arch/x86/lib/spl.c            | 4 ++++
> >  arch/x86/lib/tpl.c            | 5 +++++
> >  3 files changed, 10 insertions(+)
> >
>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

applied to u-boot-x86, thanks!
diff mbox series

Patch

diff --git a/arch/x86/cpu/start_from_spl.S b/arch/x86/cpu/start_from_spl.S
index a73b4d7c459..22cab2dd6ce 100644
--- a/arch/x86/cpu/start_from_spl.S
+++ b/arch/x86/cpu/start_from_spl.S
@@ -31,6 +31,7 @@  _start:
 
 	call	board_init_f_init_reserve
 
+	call	x86_cpu_reinit_f
 	xorl	%eax, %eax
 	call	board_init_f
 	call	board_init_f_r
diff --git a/arch/x86/lib/spl.c b/arch/x86/lib/spl.c
index a8eaafeb5b5..1677f80b25c 100644
--- a/arch/x86/lib/spl.c
+++ b/arch/x86/lib/spl.c
@@ -67,6 +67,10 @@  static int x86_spl_init(void)
 	int ret;
 
 	debug("%s starting\n", __func__);
+	if (IS_ENABLED(TPL))
+		ret = x86_cpu_reinit_f();
+	else
+		ret = x86_cpu_init_f();
 	ret = spl_init();
 	if (ret) {
 		debug("%s: spl_init() failed\n", __func__);
diff --git a/arch/x86/lib/tpl.c b/arch/x86/lib/tpl.c
index 6ca3f7b1f20..363984f7f27 100644
--- a/arch/x86/lib/tpl.c
+++ b/arch/x86/lib/tpl.c
@@ -24,6 +24,11 @@  static int x86_tpl_init(void)
 	int ret;
 
 	debug("%s starting\n", __func__);
+	ret = x86_cpu_init_tpl();
+	if (ret) {
+		debug("%s: x86_cpu_init_tpl() failed\n", __func__);
+		return ret;
+	}
 	ret = spl_init();
 	if (ret) {
 		debug("%s: spl_init() failed\n", __func__);