Skip to contentSkip to conversation

lib: sbi: Put event after use in sbi_sse_exit() loop

PATCH New Anup Patel 3 participants 3 messages May 9, 2024 – May 15, 2024

lore
Share & tools
lore

Anup Patel

author
#0 lore raw

PATCH 1/1 lib: sbi: Put event after use in sbi_sse_exit() loop

Currently, the sbi_sse_exit() gets event in a loop but does not put it back after use. This results in global events remaining locked causing hangs on sub-sequent calls to sse_event_get() for global events.

Fixes c8cdf01d8f3a ("lib: sbi: Add support for Supervisor Software Events extension")
---
 lib/sbi/sbi_sse.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
lib/sbi/sbi_sse.c +7 -2
index 18dfdb6..0cd6ba6 100644
@@ -1121,13 +1121,18 @@ void sbi_sse_exit(struct sbi_scratch *scratch)
 
 	for (i = 0; i < EVENT_COUNT; i++) {
 		e = sse_event_get(supported_events[i]);
-
-		if (!e || e->attrs.hartid != current_hartid())
+		if (!e)
 			continue;
 
+		if (e->attrs.hartid != current_hartid())
+			goto skip;
+
 		if (sse_event_state(e) > SBI_SSE_STATE_REGISTERED) {
 			sbi_printf("Event %d in invalid state at exit", i);
 			sse_event_set_state(e, SBI_SSE_STATE_UNUSED);
 		}
+
+skip:
+		sse_event_put(e);
 	}
 }
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/1 lib: sbi: Put event after use in sbi_sse_exit() loop

Quoted 26 lines · Anup Patel

Currently, the sbi_sse_exit() gets event in a loop but does not put it back after use. This results in global events remaining locked causing hangs on sub-sequent calls to sse_event_get() for global events.

Fixes c8cdf01d8f3a ("lib: sbi: Add support for Supervisor Software Events extension")
---
  lib/sbi/sbi_sse.c | 9 +++++++--
  1 file changed, 7 insertions(+), 2 deletions(-)
lib/sbi/sbi_sse.c +3 -2
index 18dfdb6..0cd6ba6 100644
@@ -1121,13 +1121,18 @@ void sbi_sse_exit(struct sbi_scratch *scratch)
 
  	for (i = 0; i < EVENT_COUNT; i++) {
  		e = sse_event_get(supported_events[i]);
-
-		if (!e || e->attrs.hartid != current_hartid())
+		if (!e)
  			continue;
 
+		if (e->attrs.hartid != current_hartid())
+			goto skip;

lib/sbi/sbi_sse.c void sbi_sse_exit(struct sbi_scratch *scratch) · line 1138

Quoted 10 lines
lib/sbi/sbi_sse.c +4 -0
+
  		if (sse_event_state(e) > SBI_SSE_STATE_REGISTERED) {
  			sbi_printf("Event %d in invalid state at exit", i);
  			sse_event_set_state(e, SBI_SSE_STATE_UNUSED);
  		}
+
+skip:
+		sse_event_put(e);
  	}
  }

LGTM.

Regards
Himanshu

Applied
#2 lore raw

PATCH 1/1 lib: sbi: Put event after use in sbi_sse_exit() loop

In reply to Anup Patel
Quoted 8 lines · On Thu, May 9, 2024 at 12:42?PM Anup Patel <[email protected]> wrote:

Currently, the sbi_sse_exit() gets event in a loop but does not put it back after use. This results in global events remaining locked causing hangs on sub-sequent calls to sse_event_get() for global events.

Fixes c8cdf01d8f3a ("lib: sbi: Add support for Supervisor Software Events extension")

Applied this patch to the riscv/opensbi repo.

Thanks,
Anup

Quoted 32 lines
---
 lib/sbi/sbi_sse.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
lib/sbi/sbi_sse.c +7 -3
index 18dfdb6..0cd6ba6 100644
@@ -1121,13 +1121,18 @@ void sbi_sse_exit(struct sbi_scratch *scratch)
 
        for (i = 0; i < EVENT_COUNT; i++) {
                e = sse_event_get(supported_events[i]);
-
-               if (!e || e->attrs.hartid != current_hartid())
+               if (!e)
                        continue;
 
+               if (e->attrs.hartid != current_hartid())
+                       goto skip;
+
                if (sse_event_state(e) > SBI_SSE_STATE_REGISTERED) {
                        sbi_printf("Event %d in invalid state at exit", i);
                        sse_event_set_state(e, SBI_SSE_STATE_UNUSED);
                }
+
+skip:
+               sse_event_put(e);
        }
 }
--

2.34.1