riscv: Add qspinlock support
authorAlexandre Ghiti <alexghiti@rivosinc.com>
Sun, 3 Nov 2024 14:51:53 +0000 (15:51 +0100)
committerPalmer Dabbelt <palmer@rivosinc.com>
Mon, 11 Nov 2024 15:33:20 +0000 (07:33 -0800)
commitab83647fadae2f1f723119dc066b39a461d6d288
tree7f07ef18ee81fa7666f9500f87c4989368f71639
parent447b2afbcde16be43c9459507f48f5c602c121c0
riscv: Add qspinlock support

In order to produce a generic kernel, a user can select
CONFIG_COMBO_SPINLOCKS which will fallback at runtime to the ticket
spinlock implementation if Zabha or Ziccrse are not present.

Note that we can't use alternatives here because the discovery of
extensions is done too late and we need to start with the qspinlock
implementation because the ticket spinlock implementation would pollute
the spinlock value, so let's use static keys.

This is largely based on Guo's work and Leonardo reviews at [1].

Link: https://lore.kernel.org/linux-riscv/20231225125847.2778638-1-guoren@kernel.org/
Signed-off-by: Guo Ren <guoren@kernel.org>
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Reviewed-by: Andrea Parri <parri.andrea@gmail.com>
Link: https://lore.kernel.org/r/20241103145153.105097-14-alexghiti@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Documentation/features/locking/queued-spinlocks/arch-support.txt
arch/riscv/Kconfig
arch/riscv/include/asm/Kbuild
arch/riscv/include/asm/spinlock.h [new file with mode: 0644]
arch/riscv/kernel/setup.c
include/asm-generic/qspinlock.h
include/asm-generic/ticket_spinlock.h