public inbox for opensbi@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] lib: utils/reset: Hang the hart after RPMI system reset message
@ 2025-09-03 14:43 Rahul Pathak
  2025-09-10  5:32 ` Samuel Holland
  2025-09-16  4:24 ` Anup Patel
  0 siblings, 2 replies; 4+ messages in thread
From: Rahul Pathak @ 2025-09-03 14:43 UTC (permalink / raw)
  To: opensbi; +Cc: rpathak, rahul, Anup Patel

RPMI system reset is a posted message which
does not wait for acknowledgement after sending
the RPMI message to PuC. Call the sbi_hart_hang()
to hang the hart after performing the system reset
via RPMI message.

Fixes: 6a26726e08e4 ("lib/utils: reset: Add RPMI System Reset driver")
Reported-by: Anup Patel <apatel@ventanamicro.com>
Signed-off-by: Rahul Pathak <rpathak@ventanamicro.com>
---
 lib/utils/reset/fdt_reset_rpmi.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/utils/reset/fdt_reset_rpmi.c b/lib/utils/reset/fdt_reset_rpmi.c
index edc53932ccc0..c29715d329c4 100644
--- a/lib/utils/reset/fdt_reset_rpmi.c
+++ b/lib/utils/reset/fdt_reset_rpmi.c
@@ -7,6 +7,7 @@
  *   Rahul Pathak <rpathak@ventanamicro.com>
  */
 
+#include <sbi/sbi_hart.h>
 #include <sbi/sbi_error.h>
 #include <sbi/sbi_system.h>
 #include <sbi/sbi_console.h>
@@ -56,6 +57,8 @@ static void rpmi_do_system_reset(u32 reset_type)
 	if (ret)
 		sbi_printf("system reset failed [type: %d]: ret: %d\n",
 			   reset_type, ret);
+
+	sbi_hart_hang();
 }
 
 /**
-- 
2.48.1


-- 
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

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

* Re: [PATCH] lib: utils/reset: Hang the hart after RPMI system reset message
  2025-09-03 14:43 [PATCH] lib: utils/reset: Hang the hart after RPMI system reset message Rahul Pathak
@ 2025-09-10  5:32 ` Samuel Holland
  2025-09-10  6:47   ` Rahul Pathak
  2025-09-16  4:24 ` Anup Patel
  1 sibling, 1 reply; 4+ messages in thread
From: Samuel Holland @ 2025-09-10  5:32 UTC (permalink / raw)
  To: Rahul Pathak, opensbi; +Cc: rahul, Anup Patel

Hi Rahul,

On 2025-09-03 9:43 AM, Rahul Pathak wrote:
> RPMI system reset is a posted message which
> does not wait for acknowledgement after sending
> the RPMI message to PuC. Call the sbi_hart_hang()
> to hang the hart after performing the system reset
> via RPMI message.
> 
> Fixes: 6a26726e08e4 ("lib/utils: reset: Add RPMI System Reset driver")
> Reported-by: Anup Patel <apatel@ventanamicro.com>
> Signed-off-by: Rahul Pathak <rpathak@ventanamicro.com>
> ---
>  lib/utils/reset/fdt_reset_rpmi.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/lib/utils/reset/fdt_reset_rpmi.c b/lib/utils/reset/fdt_reset_rpmi.c
> index edc53932ccc0..c29715d329c4 100644
> --- a/lib/utils/reset/fdt_reset_rpmi.c
> +++ b/lib/utils/reset/fdt_reset_rpmi.c
> @@ -7,6 +7,7 @@
>   *   Rahul Pathak <rpathak@ventanamicro.com>
>   */
>  
> +#include <sbi/sbi_hart.h>
>  #include <sbi/sbi_error.h>
>  #include <sbi/sbi_system.h>
>  #include <sbi/sbi_console.h>
> @@ -56,6 +57,8 @@ static void rpmi_do_system_reset(u32 reset_type)
>  	if (ret)
>  		sbi_printf("system reset failed [type: %d]: ret: %d\n",
>  			   reset_type, ret);
> +
> +	sbi_hart_hang();
>  }
If rpmi_do_system_reset() returns normally, the generic code will continue to
sbi_exit() and eventually sbi_hsm_hart_wait(). Was that problematic in some way?
You've added a Fixes tag, but it's not clear from the commit message what
problem you observed.

If allowing the driver's .system_reset callback to return is problematic (some
driver implementations hang, some don't), then we should mark the function type
as noreturn and update the remaining drivers as well.

Regards,
Samuel


-- 
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

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

* Re: [PATCH] lib: utils/reset: Hang the hart after RPMI system reset message
  2025-09-10  5:32 ` Samuel Holland
@ 2025-09-10  6:47   ` Rahul Pathak
  0 siblings, 0 replies; 4+ messages in thread
From: Rahul Pathak @ 2025-09-10  6:47 UTC (permalink / raw)
  To: Samuel Holland; +Cc: opensbi, rahul, Anup Patel

(resending, previous mail was undelivered on mailing list)

Hi Samuel,

A RPMI based reset driver must simply hang rather than rely on the
implementation fallback (sbi_exit()), which may also have served the
purpose IMO.

I won't say that it introduced a bug, but rather that this was
supposed to be done in the initial commit of the driver but was
missed, hence the Fixes tag.

Thanks
Rahul

On Wed, Sep 10, 2025 at 11:02 AM Samuel Holland
<samuel.holland@sifive.com> wrote:
>
> Hi Rahul,
>
> On 2025-09-03 9:43 AM, Rahul Pathak wrote:
> > RPMI system reset is a posted message which
> > does not wait for acknowledgement after sending
> > the RPMI message to PuC. Call the sbi_hart_hang()
> > to hang the hart after performing the system reset
> > via RPMI message.
> >
> > Fixes: 6a26726e08e4 ("lib/utils: reset: Add RPMI System Reset driver")
> > Reported-by: Anup Patel <apatel@ventanamicro.com>
> > Signed-off-by: Rahul Pathak <rpathak@ventanamicro.com>
> > ---
> >  lib/utils/reset/fdt_reset_rpmi.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/lib/utils/reset/fdt_reset_rpmi.c b/lib/utils/reset/fdt_reset_rpmi.c
> > index edc53932ccc0..c29715d329c4 100644
> > --- a/lib/utils/reset/fdt_reset_rpmi.c
> > +++ b/lib/utils/reset/fdt_reset_rpmi.c
> > @@ -7,6 +7,7 @@
> >   *   Rahul Pathak <rpathak@ventanamicro.com>
> >   */
> >
> > +#include <sbi/sbi_hart.h>
> >  #include <sbi/sbi_error.h>
> >  #include <sbi/sbi_system.h>
> >  #include <sbi/sbi_console.h>
> > @@ -56,6 +57,8 @@ static void rpmi_do_system_reset(u32 reset_type)
> >       if (ret)
> >               sbi_printf("system reset failed [type: %d]: ret: %d\n",
> >                          reset_type, ret);
> > +
> > +     sbi_hart_hang();
> >  }
> If rpmi_do_system_reset() returns normally, the generic code will continue to
> sbi_exit() and eventually sbi_hsm_hart_wait(). Was that problematic in some way?
> You've added a Fixes tag, but it's not clear from the commit message what
> problem you observed.
>
> If allowing the driver's .system_reset callback to return is problematic (some
> driver implementations hang, some don't), then we should mark the function type
> as noreturn and update the remaining drivers as well.
>
> Regards,
> Samuel
>

-- 
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

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

* Re: [PATCH] lib: utils/reset: Hang the hart after RPMI system reset message
  2025-09-03 14:43 [PATCH] lib: utils/reset: Hang the hart after RPMI system reset message Rahul Pathak
  2025-09-10  5:32 ` Samuel Holland
@ 2025-09-16  4:24 ` Anup Patel
  1 sibling, 0 replies; 4+ messages in thread
From: Anup Patel @ 2025-09-16  4:24 UTC (permalink / raw)
  To: Rahul Pathak; +Cc: opensbi, rahul, Anup Patel

On Thu, Sep 4, 2025 at 12:48 AM Rahul Pathak <rpathak@ventanamicro.com> wrote:
>
> RPMI system reset is a posted message which
> does not wait for acknowledgement after sending
> the RPMI message to PuC. Call the sbi_hart_hang()
> to hang the hart after performing the system reset
> via RPMI message.
>
> Fixes: 6a26726e08e4 ("lib/utils: reset: Add RPMI System Reset driver")
> Reported-by: Anup Patel <apatel@ventanamicro.com>
> Signed-off-by: Rahul Pathak <rpathak@ventanamicro.com>

I assume no further concerns on this patch hence merging it.

Applied this patch to the riscv/opensbi repo.

Thanks,
Anup

> ---
>  lib/utils/reset/fdt_reset_rpmi.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/lib/utils/reset/fdt_reset_rpmi.c b/lib/utils/reset/fdt_reset_rpmi.c
> index edc53932ccc0..c29715d329c4 100644
> --- a/lib/utils/reset/fdt_reset_rpmi.c
> +++ b/lib/utils/reset/fdt_reset_rpmi.c
> @@ -7,6 +7,7 @@
>   *   Rahul Pathak <rpathak@ventanamicro.com>
>   */
>
> +#include <sbi/sbi_hart.h>
>  #include <sbi/sbi_error.h>
>  #include <sbi/sbi_system.h>
>  #include <sbi/sbi_console.h>
> @@ -56,6 +57,8 @@ static void rpmi_do_system_reset(u32 reset_type)
>         if (ret)
>                 sbi_printf("system reset failed [type: %d]: ret: %d\n",
>                            reset_type, ret);
> +
> +       sbi_hart_hang();
>  }
>
>  /**
> --
> 2.48.1
>
>
> --
> opensbi mailing list
> opensbi@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi

-- 
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

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

end of thread, other threads:[~2025-09-16  4:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-03 14:43 [PATCH] lib: utils/reset: Hang the hart after RPMI system reset message Rahul Pathak
2025-09-10  5:32 ` Samuel Holland
2025-09-10  6:47   ` Rahul Pathak
2025-09-16  4:24 ` Anup Patel

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