OpenSBI Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Anup Patel <apatel@ventanamicro.com>
To: opensbi@lists.infradead.org
Subject: [PATCH] lib: sbi: Put event after use in sbi_sse_exit() loop
Date: Thu,  9 May 2024 12:42:28 +0530	[thread overview]
Message-ID: <20240509071228.1401289-1-apatel@ventanamicro.com> (raw)

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")
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
---
 lib/sbi/sbi_sse.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lib/sbi/sbi_sse.c b/lib/sbi/sbi_sse.c
index 18dfdb6..0cd6ba6 100644
--- a/lib/sbi/sbi_sse.c
+++ b/lib/sbi/sbi_sse.c
@@ -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



             reply	other threads:[~2024-05-09  7:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-09  7:12 Anup Patel [this message]
2024-05-09 10:41 ` [PATCH] lib: sbi: Put event after use in sbi_sse_exit() loop Himanshu Chauhan
2024-05-15  6:25 ` Anup Patel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240509071228.1401289-1-apatel@ventanamicro.com \
    --to=apatel@ventanamicro.com \
    --cc=opensbi@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox