diff mbox series

[07/17] x86: Update the MP constants to avoid conflicts

Message ID 20210407043228.2268429-7-sjg@chromium.org
State Superseded
Delegated to: Bin Meng
Headers show
Series misc: Some more misc patches | expand

Commit Message

Simon Glass April 7, 2021, 4:32 a.m. UTC
These constants conflict with error codes returned by the MP
implementation when something is wrong. In particular, mp_first_cpu()
returns MP_SELECT_BSP when running without multiprocessing enabled.
Since this is -2, it is interpreted as an error by callers, which
expect a positive CPU number for the first CPU.

Correct this by using a different range for the pre-defined CPU
numbers, above zero and out of the range of possible CPU values. For
now it is safe to assume there are no more than 64K CPUs.

This fixes the 'mtrr' command when CONFIG_SMP is not enabled.

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

 arch/x86/include/asm/mp.h | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Comments

Bin Meng April 8, 2021, 2:43 a.m. UTC | #1
On Wed, Apr 7, 2021 at 12:33 PM Simon Glass <sjg@chromium.org> wrote:
>
> These constants conflict with error codes returned by the MP
> implementation when something is wrong. In particular, mp_first_cpu()
> returns MP_SELECT_BSP when running without multiprocessing enabled.
> Since this is -2, it is interpreted as an error by callers, which
> expect a positive CPU number for the first CPU.
>
> Correct this by using a different range for the pre-defined CPU
> numbers, above zero and out of the range of possible CPU values. For
> now it is safe to assume there are no more than 64K CPUs.
>
> This fixes the 'mtrr' command when CONFIG_SMP is not enabled.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  arch/x86/include/asm/mp.h | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
>

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

Patch

diff --git a/arch/x86/include/asm/mp.h b/arch/x86/include/asm/mp.h
index 1a3ae8e3950..e48ba051d92 100644
--- a/arch/x86/include/asm/mp.h
+++ b/arch/x86/include/asm/mp.h
@@ -10,18 +10,22 @@ 
 
 #include <asm/atomic.h>
 #include <asm/cache.h>
+#include <linux/bitops.h>
 
 struct udevice;
 
 enum {
-	/* Indicates that the function should run on all CPUs */
-	MP_SELECT_ALL	= -1,
+	/*
+	 * Indicates that the function should run on all CPUs. We use a large
+	 * number, above the number of real CPUs we expect to find.
+	 */
+	MP_SELECT_ALL	= BIT(16),
 
 	/* Run on boot CPUs */
-	MP_SELECT_BSP	= -2,
+	MP_SELECT_BSP,
 
 	/* Run on non-boot CPUs */
-	MP_SELECT_APS	= -3,
+	MP_SELECT_APS,
 };
 
 typedef int (*mp_callback_t)(struct udevice *cpu, void *arg);