[PATCH 11/14] lib: sbi_sse: pass SSE hart state explicitly
Carlos López
carlos.lopezr4096 at gmail.com
Wed Jul 29 09:35:38 PDT 2026
In preparation to add TSA annotations, pass the SSE hart state owning an
event, instead of relying on sse_get_hart_state() to retrieve it from
the event itself. This makes the relationship more explicit, and will
allow the compiler to reason about the state of locks.
Signed-off-by: Carlos López <carlos.lopezr4096 at gmail.com>
---
lib/sbi/sbi_sse.c | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/lib/sbi/sbi_sse.c b/lib/sbi/sbi_sse.c
index 21a4247096ad..9b630430173c 100644
--- a/lib/sbi/sbi_sse.c
+++ b/lib/sbi/sbi_sse.c
@@ -328,9 +328,9 @@ static void sse_event_remove_from_list(struct sbi_sse_event *e)
/**
* Must be called under owner hart lock
*/
-static void sse_event_add_to_list(struct sbi_sse_event *e)
+static void sse_event_add_to_list(struct sse_hart_state *state,
+ struct sbi_sse_event *e)
{
- struct sse_hart_state *state = sse_get_hart_state(e);
struct sbi_sse_event *tmp;
sbi_list_for_each_entry(tmp, &state->enabled_event_list, node) {
@@ -346,7 +346,8 @@ static void sse_event_add_to_list(struct sbi_sse_event *e)
/**
* Must be called under owner hart lock
*/
-static int sse_event_disable(struct sbi_sse_event *e)
+static int sse_event_disable(struct sse_hart_state *shs,
+ struct sbi_sse_event *e)
{
if (sse_event_state(e) != SBI_SSE_STATE_ENABLED)
return SBI_EINVALID_STATE;
@@ -783,13 +784,14 @@ static int sse_inject_event(uint32_t event_id, unsigned long hartid)
/**
* Must be called under owner hart lock
*/
-static int sse_event_enable(struct sbi_sse_event *e)
+static int sse_event_enable(struct sse_hart_state *shs,
+ struct sbi_sse_event *e)
{
if (sse_event_state(e) != SBI_SSE_STATE_REGISTERED)
return SBI_EINVALID_STATE;
sse_event_set_state(e, SBI_SSE_STATE_ENABLED);
- sse_event_add_to_list(e);
+ sse_event_add_to_list(shs, e);
sse_event_invoke_cb(e, enable_cb);
@@ -800,7 +802,8 @@ static int sse_event_enable(struct sbi_sse_event *e)
return SBI_OK;
}
-static int sse_event_complete(struct sbi_sse_event *e,
+static int sse_event_complete(struct sse_hart_state *shs,
+ struct sbi_sse_event *e,
struct sbi_trap_regs *regs,
struct sbi_ecall_return *out)
{
@@ -812,7 +815,7 @@ static int sse_event_complete(struct sbi_sse_event *e,
sse_event_set_state(e, SBI_SSE_STATE_ENABLED);
if (e->attrs.config & SBI_SSE_ATTR_CONFIG_ONESHOT)
- sse_event_disable(e);
+ sse_event_disable(shs, e);
sse_event_invoke_cb(e, complete_cb);
@@ -835,7 +838,7 @@ int sbi_sse_complete(struct sbi_trap_regs *regs, struct sbi_ecall_return *out)
* the one that needs to be completed
*/
if (sse_event_state(tmp) == SBI_SSE_STATE_RUNNING) {
- ret = sse_event_complete(tmp, regs, out);
+ ret = sse_event_complete(state, tmp, regs, out);
break;
}
}
@@ -856,7 +859,7 @@ int sbi_sse_enable(uint32_t event_id)
shs = sse_get_hart_state(e);
spin_lock(&shs->enabled_event_lock);
- ret = sse_event_enable(e);
+ ret = sse_event_enable(shs, e);
spin_unlock(&shs->enabled_event_lock);
sse_event_put(e);
@@ -875,7 +878,7 @@ int sbi_sse_disable(uint32_t event_id)
shs = sse_get_hart_state(e);
spin_lock(&shs->enabled_event_lock);
- ret = sse_event_disable(e);
+ ret = sse_event_disable(shs, e);
spin_unlock(&shs->enabled_event_lock);
sse_event_put(e);
--
2.51.0
More information about the opensbi
mailing list