Skip to contentSkip to conversation

lib: utils/reset: Hang the hart after RPMI system reset message

PATCH Applied Rahul Pathak 3 participants 4 messages Sep 3, 2025 – Sep 16, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib: utils/reset: Hang the hart after RPMI system reset message

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")
---
 lib/utils/reset/fdt_reset_rpmi.c | 3 +++
 1 file changed, 3 insertions(+)
lib/utils/reset/fdt_reset_rpmi.c +3 -0
index edc53932ccc0..c29715d329c4 100644
@@ -7,6 +7,7 @@
  *   Rahul Pathak <[email protected]>
  */
 
+#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();
 }
 
 /**
Signature · 7 lines
2.48.1


-- 
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi
#1 lore raw

Hi Rahul,

Quoted 26 lines · Rahul Pathak

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")
---
 lib/utils/reset/fdt_reset_rpmi.c | 3 +++
 1 file changed, 3 insertions(+)
lib/utils/reset/fdt_reset_rpmi.c +1 -0
index edc53932ccc0..c29715d329c4 100644
@@ -7,6 +7,7 @@
  *   Rahul Pathak <[email protected]>
  */
 
+#include <sbi/sbi_hart.h>
 #include <sbi/sbi_error.h>
 #include <sbi/sbi_system.h>
 #include <sbi/sbi_console.h>

lib/utils/reset/fdt_reset_rpmi.c static void rpmi_do_system_reset(u32 reset_type) · line 62

Quoted 6 lines
lib/utils/reset/fdt_reset_rpmi.c +2 -0
@@ -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

Signature · 3 lines
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi
#2 lore raw

(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

Quoted 48 lines · Samuel Holland

Hi Rahul,

Quoted 26 lines · Rahul Pathak

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")
---
 lib/utils/reset/fdt_reset_rpmi.c | 3 +++
 1 file changed, 3 insertions(+)
lib/utils/reset/fdt_reset_rpmi.c +1 -0
index edc53932ccc0..c29715d329c4 100644
@@ -7,6 +7,7 @@
  *   Rahul Pathak <[email protected]>
  */
 
+#include <sbi/sbi_hart.h>
 #include <sbi/sbi_error.h>
 #include <sbi/sbi_system.h>
 #include <sbi/sbi_console.h>

lib/utils/reset/fdt_reset_rpmi.c static void rpmi_do_system_reset(u32 reset_type) · line 62

Quoted 6 lines
lib/utils/reset/fdt_reset_rpmi.c +2 -0
@@ -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

Signature · 3 lines
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi
Applied
#3 lore raw
In reply to Rahul Pathak
Quoted 10 lines · Rahul Pathak

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

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

Applied this patch to the riscv/opensbi repo.

Thanks,
Anup

Quoted 33 lines
---
 lib/utils/reset/fdt_reset_rpmi.c | 3 +++
 1 file changed, 3 insertions(+)
lib/utils/reset/fdt_reset_rpmi.c +3 -1
index edc53932ccc0..c29715d329c4 100644
@@ -7,6 +7,7 @@
  *   Rahul Pathak <[email protected]>
  */
 
+#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
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi

Signature · 3 lines
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi