lib: sbi: sse: call enable callback before sending IPI
authorClément Léger <cleger@rivosinc.com>
Tue, 9 Apr 2024 10:02:06 +0000 (12:02 +0200)
committerAnup Patel <anup@brainfault.org>
Tue, 7 May 2024 11:58:44 +0000 (17:28 +0530)
Move the enable callback call before sending the IPI. Even though the
event is locked and no race condition can happen, this is more logical.

Signed-off-by: Clément Léger <cleger@rivosinc.com>
Reported-by: Samuel Holland <samuel.holland@sifive.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
lib/sbi/sbi_sse.c

index 2c7f78d255a18abb824fb06330ff47d44b5b58db..fb327f026567b9cd20a25b40f3281b9447328b5f 100644 (file)
@@ -686,12 +686,12 @@ static int sse_event_enable(struct sbi_sse_event *e)
        sse_event_set_state(e, SBI_SSE_STATE_ENABLED);
        sse_event_add_to_list(e);
 
-       if (sse_event_pending(e))
+       sse_event_invoke_cb(e, enable_cb);
+
+       if (sse_event_is_global(e) && sse_event_pending(e))
                sbi_ipi_send_many(1, e->attrs.hartid, sse_ipi_inject_event,
                                  NULL);
 
-       sse_event_invoke_cb(e, enable_cb);
-
        return SBI_OK;
 }