[PATCH 07/14] lib: sbi_timer: add TSA annotations
Carlos López
carlos.lopezr4096 at gmail.com
Wed Jul 29 09:35:34 PDT 2026
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 at gmail.com>
---
lib/sbi/sbi_timer.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/sbi/sbi_timer.c b/lib/sbi/sbi_timer.c
index 4d737d22a18b..0068e83ec1e9 100644
--- a/lib/sbi/sbi_timer.c
+++ b/lib/sbi/sbi_timer.c
@@ -23,7 +23,7 @@
struct timer_state {
u64 time_delta;
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;
};
@@ -148,6 +148,7 @@ void sbi_timer_set_delta_upper(ulong delta_upper)
#endif
static void __sbi_timer_update_device(struct timer_state *tstate)
+ MUST_HOLD(&tstate->event_list_lock)
{
struct sbi_timer_event *ev;
@@ -176,6 +177,7 @@ static void __sbi_timer_event_stop(struct sbi_timer_event *ev)
static void __sbi_timer_event_start(struct timer_state *tstate,
struct sbi_timer_event *ev, u64 next_event)
+ MUST_HOLD(&tstate->event_list_lock)
{
struct sbi_timer_event *tev, *next_ev = NULL;
@@ -338,6 +340,7 @@ void sbi_timer_set_device(const struct sbi_timer_device *dev)
}
int sbi_timer_init(struct sbi_scratch *scratch, bool cold_boot)
+ NO_THREAD_SAFETY_ANALYSIS
{
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
struct timer_state *tstate;
--
2.51.0
More information about the opensbi
mailing list