OpenSBI Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lib: sbi: Put event after use in sbi_sse_exit() loop
@ 2024-05-09  7:12 Anup Patel
  2024-05-09 10:41 ` Himanshu Chauhan
  2024-05-15  6:25 ` Anup Patel
  0 siblings, 2 replies; 3+ messages in thread
From: Anup Patel @ 2024-05-09  7:12 UTC (permalink / raw)
  To: opensbi

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



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] lib: sbi: Put event after use in sbi_sse_exit() loop
  2024-05-09  7:12 [PATCH] lib: sbi: Put event after use in sbi_sse_exit() loop Anup Patel
@ 2024-05-09 10:41 ` Himanshu Chauhan
  2024-05-15  6:25 ` Anup Patel
  1 sibling, 0 replies; 3+ messages in thread
From: Himanshu Chauhan @ 2024-05-09 10:41 UTC (permalink / raw)
  To: opensbi



On 09/05/24 12:42, Anup Patel 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")
> 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);
>   	}
>   }

LGTM.

Reviewed-by: Himanshu Chauhan <hchauhan@ventanamicro.com>

Regards
Himanshu


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] lib: sbi: Put event after use in sbi_sse_exit() loop
  2024-05-09  7:12 [PATCH] lib: sbi: Put event after use in sbi_sse_exit() loop Anup Patel
  2024-05-09 10:41 ` Himanshu Chauhan
@ 2024-05-15  6:25 ` Anup Patel
  1 sibling, 0 replies; 3+ messages in thread
From: Anup Patel @ 2024-05-15  6:25 UTC (permalink / raw)
  To: opensbi

On Thu, May 9, 2024 at 12:42?PM Anup Patel <apatel@ventanamicro.com> 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")
> Signed-off-by: Anup Patel <apatel@ventanamicro.com>

Applied this patch to the riscv/opensbi repo.

Thanks,
Anup

> ---
>  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
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-05-15  6:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-09  7:12 [PATCH] lib: sbi: Put event after use in sbi_sse_exit() loop Anup Patel
2024-05-09 10:41 ` Himanshu Chauhan
2024-05-15  6:25 ` Anup Patel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox