[PATCH 10/14] lib: sbi_sse: inline enable event locking

Carlos López carlos.lopezr4096 at gmail.com
Wed Jul 29 09:35:37 PDT 2026


In preparation to add TSA annotations, inline sse_enabled_event_lock()
and sse_enabled_event_unlock(). This will help the compiler reason about
locking of the hart state by explicitly acquiring the spinlock in the
callers.

Signed-off-by: Carlos López <carlos.lopezr4096 at gmail.com>
---
 lib/sbi/sbi_sse.c | 34 ++++++++--------------------------
 1 file changed, 8 insertions(+), 26 deletions(-)

diff --git a/lib/sbi/sbi_sse.c b/lib/sbi/sbi_sse.c
index 818afb871e01..21a4247096ad 100644
--- a/lib/sbi/sbi_sse.c
+++ b/lib/sbi/sbi_sse.c
@@ -265,28 +265,6 @@ static struct sse_global_event *sse_get_global_event(struct sbi_sse_event *e)
 	return container_of(e, struct sse_global_event, event);
 }
 
-/**
- * If event is global, must be called under enabled event lock
- */
-static void sse_enabled_event_lock(struct sbi_sse_event *e)
-{
-	struct sse_hart_state *shs;
-
-	shs = sse_get_hart_state(e);
-	spin_lock(&shs->enabled_event_lock);
-}
-
-/**
- * If event is global, must be called under enabled event lock
- */
-static void sse_enabled_event_unlock(struct sbi_sse_event *e)
-{
-	struct sse_hart_state *shs;
-
-	shs = sse_get_hart_state(e);
-	spin_unlock(&shs->enabled_event_lock);
-}
-
 static void sse_event_set_state(struct sbi_sse_event *e,
 				unsigned long new_state)
 {
@@ -870,14 +848,16 @@ int sbi_sse_enable(uint32_t event_id)
 {
 	int ret;
 	struct sbi_sse_event *e;
+	struct sse_hart_state *shs;
 
 	ret = sse_event_get(event_id, &e);
 	if (ret)
 		return ret;
 
-	sse_enabled_event_lock(e);
+	shs = sse_get_hart_state(e);
+	spin_lock(&shs->enabled_event_lock);
 	ret = sse_event_enable(e);
-	sse_enabled_event_unlock(e);
+	spin_unlock(&shs->enabled_event_lock);
 	sse_event_put(e);
 
 	return ret;
@@ -887,14 +867,16 @@ int sbi_sse_disable(uint32_t event_id)
 {
 	int ret;
 	struct sbi_sse_event *e;
+	struct sse_hart_state *shs;
 
 	ret = sse_event_get(event_id, &e);
 	if (ret)
 		return ret;
 
-	sse_enabled_event_lock(e);
+	shs = sse_get_hart_state(e);
+	spin_lock(&shs->enabled_event_lock);
 	ret = sse_event_disable(e);
-	sse_enabled_event_unlock(e);
+	spin_unlock(&shs->enabled_event_lock);
 
 	sse_event_put(e);
 
-- 
2.51.0




More information about the opensbi mailing list