Kyösti Mälkki has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/59094 )
Change subject: [WIP,RFC] Clean up spinlocks ......................................................................
[WIP,RFC] Clean up spinlocks
This reverts commit 037ee4b5562099771795d52cf7149ddff8dd3595.
TBD: Breaks romstage co-operative threading, since those need implementation of spin_lock() that is not a spinlock.
IMO commit a98d302fe9 x86/smp/spinlock: Disable thread coop when taking spinlock is wrong and should be reverted too.
Change-Id: Iba52febdeee78294f916775ee9ce8a82d6203570 Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com --- D src/arch/arm/include/armv4/arch/smp/spinlock.h M src/arch/x86/include/arch/smp/spinlock.h M src/include/rules.h M src/include/smp/spinlock.h D src/soc/amd/common/psp_verstage/include/arch/smp/spinlock.h 5 files changed, 11 insertions(+), 43 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/94/59094/1
diff --git a/src/arch/arm/include/armv4/arch/smp/spinlock.h b/src/arch/arm/include/armv4/arch/smp/spinlock.h deleted file mode 100644 index 0a3a4d4..0000000 --- a/src/arch/arm/include/armv4/arch/smp/spinlock.h +++ /dev/null @@ -1,15 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ - -#ifndef _ARCH_SMP_SPINLOCK_H -#define _ARCH_SMP_SPINLOCK_H - -#define DECLARE_SPIN_LOCK(x) -#define spin_is_locked(lock) 0 -#define spin_unlock_wait(lock) do {} while (0) -#define spin_lock(lock) do {} while (0) -#define spin_unlock(lock) do {} while (0) - -#include <smp/node.h> -#define boot_cpu() 1 - -#endif diff --git a/src/arch/x86/include/arch/smp/spinlock.h b/src/arch/x86/include/arch/smp/spinlock.h index 0c06c22..ba8e928 100644 --- a/src/arch/x86/include/arch/smp/spinlock.h +++ b/src/arch/x86/include/arch/smp/spinlock.h @@ -15,10 +15,6 @@
#define SPIN_LOCK_UNLOCKED { 1 }
-#define STAGE_HAS_SPINLOCKS !ENV_ROMSTAGE_OR_BEFORE - -#if STAGE_HAS_SPINLOCKS - #define DECLARE_SPIN_LOCK(x) \ static spinlock_t x = SPIN_LOCK_UNLOCKED;
@@ -71,14 +67,6 @@ : "=m" (lock->lock) : : "memory"); }
-#else - -#define DECLARE_SPIN_LOCK(x) -#define spin_is_locked(lock) 0 -#define spin_unlock_wait(lock) do {} while (0) -#define spin_lock(lock) do {} while (0) -#define spin_unlock(lock) do {} while (0) - #endif
#endif /* ARCH_SMP_SPINLOCK_H */ diff --git a/src/include/rules.h b/src/include/rules.h index ec3d22d..c64062b 100644 --- a/src/include/rules.h +++ b/src/include/rules.h @@ -292,6 +292,16 @@ #define ENV_INITIAL_STAGE ENV_BOOTBLOCK #endif
+ +#if ENV_X86 +#define STAGE_HAS_SPINLOCKS !ENV_ROMSTAGE_OR_BEFORE +#elif ENV_RISCV +#define STAGE_HAS_SPINLOCKS 1 +#else +#define STAGE_HAS_SPINLOCKS 0 +#endif +#define ENV_STAGE_SUPPORTS_SMP CONFIG(SMP) && STAGE_HAS_SPINLOCKS + /** * For pre-DRAM stages and post-CAR always build with simple device model, ie. * PCI, PNP and CPU functions operate without use of devicetree. The reason diff --git a/src/include/smp/spinlock.h b/src/include/smp/spinlock.h index 8554aa05..116830c 100644 --- a/src/include/smp/spinlock.h +++ b/src/include/smp/spinlock.h @@ -1,7 +1,7 @@ #ifndef SMP_SPINLOCK_H #define SMP_SPINLOCK_H
-#if CONFIG(SMP) +#if ENV_STAGE_SUPPORTS_SMP #include <arch/smp/spinlock.h> #else /* !CONFIG_SMP */
diff --git a/src/soc/amd/common/psp_verstage/include/arch/smp/spinlock.h b/src/soc/amd/common/psp_verstage/include/arch/smp/spinlock.h deleted file mode 100644 index 0a3a4d4..0000000 --- a/src/soc/amd/common/psp_verstage/include/arch/smp/spinlock.h +++ /dev/null @@ -1,15 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ - -#ifndef _ARCH_SMP_SPINLOCK_H -#define _ARCH_SMP_SPINLOCK_H - -#define DECLARE_SPIN_LOCK(x) -#define spin_is_locked(lock) 0 -#define spin_unlock_wait(lock) do {} while (0) -#define spin_lock(lock) do {} while (0) -#define spin_unlock(lock) do {} while (0) - -#include <smp/node.h> -#define boot_cpu() 1 - -#endif