All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [PATCH 02/22] x86: Move MP code into mp_init
Date: Thu, 21 May 2020 20:23:06 -0600	[thread overview]
Message-ID: <20200522022326.238388-3-sjg@chromium.org> (raw)
In-Reply-To: <20200522022326.238388-1-sjg@chromium.org>

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@chromium.org>
---

 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 d27324cb4e2..9809ac51117 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>
@@ -626,29 +627,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 c25d17c6474..831fd7035d1 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 9dddf88b5a1..db02904ecb5 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.27.0.rc0.183.gde8f92d652-goog

  parent reply	other threads:[~2020-05-22  2:23 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-22  2:23 [PATCH 00/22] x86: Enhance MTRR functionality to support multiple CPUs Simon Glass
2020-05-22  2:23 ` [PATCH 01/22] x86: mp_init: Switch to livetree Simon Glass
2020-06-10 13:25   ` Wolfgang Wallner
2020-05-22  2:23 ` Simon Glass [this message]
2020-06-10 13:25   ` [PATCH 02/22] x86: Move MP code into mp_init Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 03/22] x86: mp_init: Avoid declarations in header files Simon Glass
2020-06-10 13:25   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 04/22] x86: mp_init: Switch parameter names in start_aps() Simon Glass
2020-06-10 13:25   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 05/22] x86: mp_init: Drop the num_cpus static variable Simon Glass
2020-06-10 13:25   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 06/22] x86: mtrr: Fix 'ensable' typo Simon Glass
2020-06-10 13:26   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 07/22] x86: mp_init: Set up the CPU numbers at the start Simon Glass
2020-06-10 13:26   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 08/22] x86: mp_init: Adjust bsp_init() to return more information Simon Glass
2020-06-10 13:26   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 09/22] x86: cpu: Remove unnecessary #ifdefs Simon Glass
2020-06-10 13:26   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 10/22] x86: mp: Support APs waiting for instructions Simon Glass
2020-06-10 13:27   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 11/22] global_data: Add a generic global_data flag for SMP state Simon Glass
2020-06-10 13:27   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 12/22] x86: Set the SMP flag when MP init is complete Simon Glass
2020-06-10 13:27   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 13/22] x86: mp: Allow running functions on multiple CPUs Simon Glass
2020-06-10 13:27   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 14/22] x86: mp: Park CPUs before running the OS Simon Glass
2020-06-10 13:27   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 15/22] x86: mp: Add iterators for CPUs Simon Glass
2020-06-10 13:27   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 16/22] x86: mtrr: Use MP calls to list the MTRRs Simon Glass
2020-06-10 13:28   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 17/22] x86: mtrr: Update MTRRs on all CPUs Simon Glass
2020-06-10 13:28   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 18/22] x86: mtrr: Add support for writing to MTRRs on any CPU Simon Glass
2020-06-10 13:28   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 19/22] x86: mtrr: Update the command to use the new mtrr calls Simon Glass
2020-06-10 13:28   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 20/22] x86: mtrr: Restructure so command execution is in one place Simon Glass
2020-06-10 13:28   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 21/22] x86: mtrr: Update 'mtrr' to allow setting MTRRs on any CPU Simon Glass
2020-06-10 13:29   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 22/22] x86: mtrr: Enhance 'mtrr' command to list " Simon Glass
2020-06-10 13:29   ` Wolfgang Wallner
2020-05-22 10:54 ` [PATCH 00/22] x86: Enhance MTRR functionality to support multiple CPUs Andy Shevchenko
2020-05-22 13:42   ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200522022326.238388-3-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.