lib: sbi_timer: add TSA annotations

Add Thread Safety Analysis (TSA) annotations for the timer
implementation. This includes indicating which fields are protected
by a spinlock, and annotating which functions must be called under a
spinlock. Exclude sbi_timer_init(), as the spinlock cannot be acquired
before it is initialized.

Signed-off-by: Carlos López <carlos.lopezr4096@gmail.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260909162322.29778-9-carlos.lopezr4096@gmail.com
Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
Carlos López
2026-09-16 09:48:30 +05:30
committed by Anup Patel
parent 497ca4ccad
commit f5fd674f18
+4 -1
View File
@@ -23,7 +23,7 @@
struct timer_state { struct timer_state {
u64 time_delta; u64 time_delta;
spinlock_t event_list_lock; spinlock_t event_list_lock;
struct sbi_dlist event_list; struct sbi_dlist event_list GUARDED_BY(&event_list_lock);
struct sbi_timer_event smode_ev; struct sbi_timer_event smode_ev;
}; };
@@ -160,6 +160,7 @@ void sbi_timer_set_delta_upper(ulong delta_upper)
#endif #endif
static void __sbi_timer_update_device(struct timer_state *tstate) static void __sbi_timer_update_device(struct timer_state *tstate)
MUST_HOLD(&tstate->event_list_lock)
{ {
struct sbi_timer_event *ev; struct sbi_timer_event *ev;
@@ -188,6 +189,7 @@ static void __sbi_timer_event_stop(struct sbi_timer_event *ev)
static void __sbi_timer_event_start(struct timer_state *tstate, static void __sbi_timer_event_start(struct timer_state *tstate,
struct sbi_timer_event *ev, u64 next_event) struct sbi_timer_event *ev, u64 next_event)
MUST_HOLD(&tstate->event_list_lock)
{ {
struct sbi_timer_event *tev, *next_ev = NULL; struct sbi_timer_event *tev, *next_ev = NULL;
@@ -350,6 +352,7 @@ void sbi_timer_set_device(const struct sbi_timer_device *dev)
} }
int sbi_timer_init(struct sbi_scratch *scratch, bool cold_boot) int sbi_timer_init(struct sbi_scratch *scratch, bool cold_boot)
NO_THREAD_SAFETY_ANALYSIS
{ {
const struct sbi_platform *plat = sbi_platform_ptr(scratch); const struct sbi_platform *plat = sbi_platform_ptr(scratch);
struct timer_state *tstate; struct timer_state *tstate;