lib: sbi_sse: pass SSE hart state explicitly

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@gmail.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260909162322.29778-13-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 fc1ae7a641
commit 43bb3df782
+13 -10
View File
@@ -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;
@@ -778,13 +779,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);
@@ -795,7 +797,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)
{
@@ -807,7 +810,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);
@@ -830,7 +833,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;
}
}
@@ -851,7 +854,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);
@@ -870,7 +873,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);