summaryrefslogtreecommitdiff
path: root/include/sbi/riscv_locks.h
AgeCommit message (Collapse)AuthorFilesLines
2021-05-14lib: sbi: Have spinlock checks return boolDaniel Schaefer1-2/+2
spin_lock_check already returned bool in the source file but not in the header. With some toolchains that causes an error, as it should. Because it and related functions all essentially return a bool, we can use this opportunity to change them. Signed-off-by: Daniel Schaefer <git@danielschaefer.me> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-04-09lib: sbi: Replace test-and-set locks by ticket locksChristoph Muellner1-11/+22
Replace the test-and-set spinlock implementation with ticket locks in order to get fairness (in form of FIFO order). The implementation uses a 32-bit wide struct, which consists of two 16-bit counters (owner and next). This is inspired by similar spinlock implementations on other architectures. This allows that the code works for both, RV32 and RV64. Signed-off-by: Christoph Muellner <cmuellner@linux.com> Reviewed-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Xiang W <wxjstz@126.com>
2021-04-09include: sbi: Allow direct initialization via SPIN_LOCK_INIT()Christoph Muellner1-1/+1
The current implementation of SPIN_LOCK_INIT() provides the spinlock to be initialized as reference. This does not allow a direct initialization of the spinlock object at the creation site. Let's pass the spinlock directly instead (like Linux does as well) and adjust all users of the macro (in fact there is only one user). Signed-off-by: Christoph Muellner <cmuellner@linux.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2019-04-24all: run clang-format and update checked-in filesOlof Johansson1-5/+6
Noisy commit, no functional changes. Generated with an current upstream clang-format and: clang-format -i $(find . -name \*.[ch]) Signed-off-by: Olof Johansson <olof@lixom.net>
2019-01-24all: Update copyright header in all filesAnup patel1-3/+3
This patch updates copyright header in all files as follows: 1. Makes "SPDX-License-Identifier: BSD-2-Clause" as first line 2. Change copyright year to 2019 for Western Digital Signed-off-by: Anup Patel <anup.patel@wdc.com>
2018-12-11Initial commit.Anup Patel1-0/+33
Signed-off-by: Anup Patel <anup.patel@wdc.com>