diff mbox series

[v2,39/44] x86: mp: Allow use of mp_run_on_cpus() without MP

Message ID 20200708033246.2626378-20-sjg@chromium.org
State New
Headers show
Series x86: Programmatic generation of ACPI tables (Part C) | expand

Commit Message

Simon Glass July 8, 2020, 3:32 a.m. UTC
At present if MP is not enabled (e.g. booting from coreboot) the 'mtrr'
command does not work correctly. It is not easy to make it work for all
CPUs, since coreboot has halted them and we would need to start them up
again, but it is easy enough to make them work on the boot CPU.

Update the code to avoid assuming that the MP init routine has completed,
so that this can work.

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

(no changes since v1)

 arch/x86/cpu/mp_init.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Comments

Bin Meng July 13, 2020, 6:05 a.m. UTC | #1
Hi Simon,

On Wed, Jul 8, 2020 at 11:34 AM Simon Glass <sjg at chromium.org> wrote:
>
> At present if MP is not enabled (e.g. booting from coreboot) the 'mtrr'
> command does not work correctly. It is not easy to make it work for all
> CPUs, since coreboot has halted them and we would need to start them up
> again, but it is easy enough to make them work on the boot CPU.
>
> Update the code to avoid assuming that the MP init routine has completed,
> so that this can work.
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
>
> (no changes since v1)
>
>  arch/x86/cpu/mp_init.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/cpu/mp_init.c b/arch/x86/cpu/mp_init.c
> index 0f99a405bb..21fbe5bda5 100644
> --- a/arch/x86/cpu/mp_init.c
> +++ b/arch/x86/cpu/mp_init.c
> @@ -558,7 +558,7 @@ static int get_bsp(struct udevice **devp, int *cpu_countp)
>         if (cpu_countp)
>                 *cpu_countp = ret;
>
> -       return dev->req_seq;
> +       return dev->req_seq >= 0 ? dev->req_seq : 0;

I believe this change was already squashed into the part B series,
hence this does not apply on top of u-boot-x86/master.

>  }
>
>  /**
> @@ -718,9 +718,6 @@ int mp_run_on_cpus(int cpu_select, mp_run_func func, void *arg)
>         int num_cpus;
>         int ret;
>
> -       if (!(gd->flags & GD_FLG_SMP_READY))
> -               return -ENXIO;
> -
>         ret = get_bsp(&dev, &num_cpus);
>         if (ret < 0)
>                 return log_msg_ret("bsp", ret);
> @@ -730,6 +727,13 @@ int mp_run_on_cpus(int cpu_select, mp_run_func func, void *arg)
>                 func(arg);
>         }
>
> +       if (!(gd->flags & GD_FLG_SMP_READY)) {
> +               /* Allow use of this function on the BSP only */
> +               if (cpu_select == MP_SELECT_BSP || !cpu_select)
> +                       return 0;
> +               return -ENXIO;
> +       }
> +
>         /* Allow up to 1 second for all APs to finish */
>         ret = run_ap_work(&lcb, dev, num_cpus, 1000 /* ms */);
>         if (ret)

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

Regards,
Bin
diff mbox series

Patch

diff --git a/arch/x86/cpu/mp_init.c b/arch/x86/cpu/mp_init.c
index 0f99a405bb..21fbe5bda5 100644
--- a/arch/x86/cpu/mp_init.c
+++ b/arch/x86/cpu/mp_init.c
@@ -558,7 +558,7 @@  static int get_bsp(struct udevice **devp, int *cpu_countp)
 	if (cpu_countp)
 		*cpu_countp = ret;
 
-	return dev->req_seq;
+	return dev->req_seq >= 0 ? dev->req_seq : 0;
 }
 
 /**
@@ -718,9 +718,6 @@  int mp_run_on_cpus(int cpu_select, mp_run_func func, void *arg)
 	int num_cpus;
 	int ret;
 
-	if (!(gd->flags & GD_FLG_SMP_READY))
-		return -ENXIO;
-
 	ret = get_bsp(&dev, &num_cpus);
 	if (ret < 0)
 		return log_msg_ret("bsp", ret);
@@ -730,6 +727,13 @@  int mp_run_on_cpus(int cpu_select, mp_run_func func, void *arg)
 		func(arg);
 	}
 
+	if (!(gd->flags & GD_FLG_SMP_READY)) {
+		/* Allow use of this function on the BSP only */
+		if (cpu_select == MP_SELECT_BSP || !cpu_select)
+			return 0;
+		return -ENXIO;
+	}
+
 	/* Allow up to 1 second for all APs to finish */
 	ret = run_ap_work(&lcb, dev, num_cpus, 1000 /* ms */);
 	if (ret)