Raul Rangel has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/59732 )
Change subject: WIP: arch/{x86,riscv},smp: Delete spinlock.h ......................................................................
WIP: arch/{x86,riscv},smp: Delete spinlock.h
spinlock.h has been replaced with mutex.h.
BUG=b:179699789 TEST=Boot guybrush to OS
Signed-off-by: Raul E Rangel rrangel@chromium.org Change-Id: I0d204ea96cc843f1f10d152559a9ee06735623ef --- D src/arch/riscv/include/arch/smp/spinlock.h M src/arch/riscv/smp.c M src/arch/x86/cpu.c D src/arch/x86/include/arch/smp/spinlock.h D src/include/smp/spinlock.h 5 files changed, 0 insertions(+), 115 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/32/59732/1
diff --git a/src/arch/riscv/include/arch/smp/spinlock.h b/src/arch/riscv/include/arch/smp/spinlock.h deleted file mode 100644 index b316ff0..0000000 --- a/src/arch/riscv/include/arch/smp/spinlock.h +++ /dev/null @@ -1,28 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ - -#ifndef ARCH_SMP_SPINLOCK_H -#define ARCH_SMP_SPINLOCK_H - -#include <arch/encoding.h> -#include <arch/smp/atomic.h> - -#define barrier() { asm volatile ("fence" ::: "memory"); } - -typedef struct { - atomic_t lock; -} spinlock_t; - -static inline void spinlock_lock(spinlock_t *lock) -{ - while (atomic_swap(&lock->lock, -1)) - ; - barrier(); -} - -static inline void spinlock_unlock(spinlock_t *lock) -{ - barrier(); - atomic_set(&lock->lock, 0); -} - -#endif // ARCH_SMP_SPINLOCK_H diff --git a/src/arch/riscv/smp.c b/src/arch/riscv/smp.c index 1d58602..3ffca44 100644 --- a/src/arch/riscv/smp.c +++ b/src/arch/riscv/smp.c @@ -2,7 +2,6 @@
#include <arch/encoding.h> #include <arch/smp/smp.h> -#include <arch/smp/spinlock.h> #include <mcall.h> #include <console/console.h>
diff --git a/src/arch/x86/cpu.c b/src/arch/x86/cpu.c index f4cb83a..554aa2f 100644 --- a/src/arch/x86/cpu.c +++ b/src/arch/x86/cpu.c @@ -11,7 +11,6 @@ #include <cpu/x86/tsc.h> #include <device/path.h> #include <device/device.h> -#include <smp/spinlock.h>
#if ENV_X86_32 /* Standard macro to see if a specific flag is changeable */ diff --git a/src/arch/x86/include/arch/smp/spinlock.h b/src/arch/x86/include/arch/smp/spinlock.h deleted file mode 100644 index c7008c1..0000000 --- a/src/arch/x86/include/arch/smp/spinlock.h +++ /dev/null @@ -1,70 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ - -#ifndef ARCH_SMP_SPINLOCK_H -#define ARCH_SMP_SPINLOCK_H - -#include <thread.h> - -/* - * Your basic SMP spinlocks, allowing only a single CPU anywhere - */ - -typedef struct { - volatile unsigned int lock; -} spinlock_t; - -#define SPIN_LOCK_UNLOCKED { 1 } - -#define DECLARE_SPIN_LOCK(x) \ - static spinlock_t x = SPIN_LOCK_UNLOCKED; - -/* - * Simple spin lock operations. There are two variants, one clears IRQ's - * on the local processor, one does not. - * - * We make no fairness assumptions. They have a cost. - */ -#define barrier() __asm__ __volatile__("" : : : "memory") -#define spin_is_locked(x) (*(volatile char *)(&(x)->lock) <= 0) -#define spin_unlock_wait(x) do { barrier(); } while (spin_is_locked(x)) -#undef barrier - -#define spin_lock_string \ - "\n1:\t" \ - "lock ; decb %0\n\t" \ - "js 2f\n" \ - ".section .text.lock,"ax"\n" \ - "2:\t" \ - "cmpb $0,%0\n\t" \ - "rep;nop\n\t" \ - "jle 2b\n\t" \ - "jmp 1b\n" \ - ".previous" - -/* - * This works. Despite all the confusion. - */ -#define spin_unlock_string \ - "movb $1,%0" - -static __always_inline void spin_lock(spinlock_t *lock) -{ - __asm__ __volatile__( - spin_lock_string - : "=m" (lock->lock) : : "memory"); - - /* Switching contexts while holding a spinlock will lead to deadlocks */ - thread_coop_disable(); - -} - -static __always_inline void spin_unlock(spinlock_t *lock) -{ - thread_coop_enable(); - - __asm__ __volatile__( - spin_unlock_string - : "=m" (lock->lock) : : "memory"); -} - -#endif /* ARCH_SMP_SPINLOCK_H */ diff --git a/src/include/smp/spinlock.h b/src/include/smp/spinlock.h deleted file mode 100644 index 116830c..0000000 --- a/src/include/smp/spinlock.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef SMP_SPINLOCK_H -#define SMP_SPINLOCK_H - -#if ENV_STAGE_SUPPORTS_SMP -#include <arch/smp/spinlock.h> -#else /* !CONFIG_SMP */ - -#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 /* SMP_SPINLOCK_H */