[PATCH v6 02/25] x86: Move MP code into mp_init
Simon Glass
sjg at chromium.org
Fri Jul 17 16:48:08 CEST 2020
At present the 'flight plan' for CPUs is passed into mp_init. But it is
always the same. Move it into the mp_init file so everything is in one
place. Also drop the SMI function since it does nothing. If we implement
SMIs, more refactoring will be needed anyway.
Signed-off-by: Simon Glass <sjg at chromium.org>
Reviewed-by: Wolfgang Wallner <wolfgang.wallner at br-automation.com>
Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
---
(no changes since v1)
arch/x86/cpu/i386/cpu.c | 24 +++++-------------------
arch/x86/cpu/mp_init.c | 22 ++++++++++------------
arch/x86/include/asm/mp.h | 17 +----------------
3 files changed, 16 insertions(+), 47 deletions(-)
diff --git a/arch/x86/cpu/i386/cpu.c b/arch/x86/cpu/i386/cpu.c
index a6a6afec8c..55a0907bc8 100644
--- a/arch/x86/cpu/i386/cpu.c
+++ b/arch/x86/cpu/i386/cpu.c
@@ -21,6 +21,7 @@
#include <common.h>
#include <cpu_func.h>
#include <init.h>
+#include <log.h>
#include <malloc.h>
#include <spl.h>
#include <asm/control_regs.h>
@@ -631,29 +632,14 @@ int cpu_jump_to_64bit_uboot(ulong target)
}
#ifdef CONFIG_SMP
-static int enable_smis(struct udevice *cpu, void *unused)
-{
- return 0;
-}
-
-static struct mp_flight_record mp_steps[] = {
- MP_FR_BLOCK_APS(mp_init_cpu, NULL, mp_init_cpu, NULL),
- /* Wait for APs to finish initialization before proceeding */
- MP_FR_BLOCK_APS(NULL, NULL, enable_smis, NULL),
-};
-
int x86_mp_init(void)
{
- struct mp_params mp_params;
-
- mp_params.parallel_microcode_load = 0,
- mp_params.flight_plan = &mp_steps[0];
- mp_params.num_records = ARRAY_SIZE(mp_steps);
- mp_params.microcode_pointer = 0;
+ int ret;
- if (mp_init(&mp_params)) {
+ ret = mp_init();
+ if (ret) {
printf("Warning: MP init failure\n");
- return -EIO;
+ return log_ret(ret);
}
return 0;
diff --git a/arch/x86/cpu/mp_init.c b/arch/x86/cpu/mp_init.c
index c25d17c647..831fd7035d 100644
--- a/arch/x86/cpu/mp_init.c
+++ b/arch/x86/cpu/mp_init.c
@@ -41,6 +41,9 @@ struct saved_msr {
uint32_t hi;
} __packed;
+static struct mp_flight_record mp_steps[] = {
+ MP_FR_BLOCK_APS(mp_init_cpu, NULL, mp_init_cpu, NULL),
+};
struct mp_flight_plan {
int num_records;
@@ -372,7 +375,7 @@ static int start_aps(int ap_count, atomic_t *num_aps)
return 0;
}
-static int bsp_do_flight_plan(struct udevice *cpu, struct mp_params *mp_params)
+static int bsp_do_flight_plan(struct udevice *cpu, struct mp_flight_plan *plan)
{
int i;
int ret = 0;
@@ -380,8 +383,8 @@ static int bsp_do_flight_plan(struct udevice *cpu, struct mp_params *mp_params)
const int step_us = 100;
int num_aps = num_cpus - 1;
- for (i = 0; i < mp_params->num_records; i++) {
- struct mp_flight_record *rec = &mp_params->flight_plan[i];
+ for (i = 0; i < plan->num_records; i++) {
+ struct mp_flight_record *rec = &plan->records[i];
/* Wait for APs if the record is not released */
if (atomic_read(&rec->barrier) == 0) {
@@ -420,7 +423,7 @@ static int init_bsp(struct udevice **devp)
return 0;
}
-int mp_init(struct mp_params *p)
+int mp_init(void)
{
int num_aps;
atomic_t *ap_count;
@@ -445,11 +448,6 @@ int mp_init(struct mp_params *p)
return ret;
}
- if (p == NULL || p->flight_plan == NULL || p->num_records < 1) {
- printf("Invalid MP parameters\n");
- return -EINVAL;
- }
-
num_cpus = cpu_get_count(cpu);
if (num_cpus < 0) {
debug("Cannot get number of CPUs: err=%d\n", num_cpus);
@@ -464,8 +462,8 @@ int mp_init(struct mp_params *p)
debug("Warning: Device tree does not describe all CPUs. Extra ones will not be started correctly\n");
/* Copy needed parameters so that APs have a reference to the plan */
- mp_info.num_records = p->num_records;
- mp_info.records = p->flight_plan;
+ mp_info.num_records = ARRAY_SIZE(mp_steps);
+ mp_info.records = mp_steps;
/* Load the SIPI vector */
ret = load_sipi_vector(&ap_count, num_cpus);
@@ -489,7 +487,7 @@ int mp_init(struct mp_params *p)
}
/* Walk the flight plan for the BSP */
- ret = bsp_do_flight_plan(cpu, p);
+ ret = bsp_do_flight_plan(cpu, &mp_info);
if (ret) {
debug("CPU init failed: err=%d\n", ret);
return ret;
diff --git a/arch/x86/include/asm/mp.h b/arch/x86/include/asm/mp.h
index 9dddf88b5a..db02904ecb 100644
--- a/arch/x86/include/asm/mp.h
+++ b/arch/x86/include/asm/mp.h
@@ -51,21 +51,6 @@ struct mp_flight_record {
#define MP_FR_NOBLOCK_APS(ap_func, ap_arg, bsp_func, bsp_arg) \
MP_FLIGHT_RECORD(1, ap_func, ap_arg, bsp_func, bsp_arg)
-/*
- * The mp_params structure provides the arguments to the mp subsystem
- * for bringing up APs.
- *
- * At present this is overkill for U-Boot, but it may make it easier to add
- * SMM support.
- */
-struct mp_params {
- int parallel_microcode_load;
- const void *microcode_pointer;
- /* Flight plan for APs and BSP */
- struct mp_flight_record *flight_plan;
- int num_records;
-};
-
/*
* mp_init() will set up the SIPI vector and bring up the APs according to
* mp_params. Each flight record will be executed according to the plan. Note
@@ -85,7 +70,7 @@ struct mp_params {
*
* mp_init() returns < 0 on error, 0 on success.
*/
-int mp_init(struct mp_params *params);
+int mp_init(void);
/* Probes the CPU device */
int mp_init_cpu(struct udevice *cpu, void *unused);
--
2.28.0.rc0.105.gf9edc3c819-goog
More information about the U-Boot
mailing list