Skip to contentSkip to conversation

SBI SRST extension support

PATCH In review Anup Patel 7 participants 15 messages Jun 9, 2021 – Jan 11, 2022 RISC-V

lore
Share & tools
lore

Anup Patel

author
#0 lore raw

v7 cover SBI SRST extension support

This series adds SBI SRST extension support to Linux RISC-V.

These patches can be found in riscv_sbi_srst_v7 branch at:
https://github.com/avpatel/linux

Changes since v6:
- Dropped PATCH1 of v6 series because it's already merged
- Rebased on Linux-5.13-rc5

Changes since v5:
- Factored-out pr_info() related change into separate patch
- Added cover letter

Changes since v4:
- We should compare both major and minor number to ensure that SBI spec version is 0.3 (or above) for detecting SRST extension.

Changes since v3:
- Rebased on Linux-5.12-rc1
- Check SBI spec version when probing for SRST extension

Changes since v2:
- Rebased on Linux-5.10-rc5
- Updated patch as-per SBI SRST extension available in the latest SBI v0.3-draft specification

Changes since v1:
- Updated patch as-per latest SBI SRST extension draft spec where we have only one SBI call with "reset_type" parameter

Anup Patel (1):
RISC-V: Use SBI SRST extension when available

 arch/riscv/include/asm/sbi.h | 24 ++++++++++++++++++++++++
 arch/riscv/kernel/sbi.c      | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 59 insertions(+)
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH v7 1/1 RISC-V: Use SBI SRST extension when available

The SBI SRST extension provides a standard way to poweroff and reboot the system irrespective to whether Linux RISC-V S-mode is running natively (HS-mode) or inside Guest/VM (VS-mode).

The SBI SRST extension is available in the SBI v0.3 specification. (Refer, https://github.com/riscv/riscv-sbi-doc/releases/tag/v0.3.0-rc1)

This patch extends Linux RISC-V SBI implementation to detect and use SBI SRST extension.

---
 arch/riscv/include/asm/sbi.h | 24 ++++++++++++++++++++++++
 arch/riscv/kernel/sbi.c      | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 59 insertions(+)
arch/riscv/include/asm/sbi.h +24 -0
index 0d42693cb65e..289621da4a2a 100644
@@ -27,6 +27,7 @@ enum sbi_ext_id {
 	SBI_EXT_IPI = 0x735049,
 	SBI_EXT_RFENCE = 0x52464E43,
 	SBI_EXT_HSM = 0x48534D,
+	SBI_EXT_SRST = 0x53525354,
 };
 
 enum sbi_ext_base_fid {
@@ -70,6 +71,21 @@ enum sbi_hsm_hart_status {
 	SBI_HSM_HART_STATUS_STOP_PENDING,
 };
 
+enum sbi_ext_srst_fid {
+	SBI_EXT_SRST_RESET = 0,
+};
+
+enum sbi_srst_reset_type {
+	SBI_SRST_RESET_TYPE_SHUTDOWN = 0,
+	SBI_SRST_RESET_TYPE_COLD_REBOOT,
+	SBI_SRST_RESET_TYPE_WARM_REBOOT,
+};
+
+enum sbi_srst_reset_reason {
+	SBI_SRST_RESET_REASON_NONE = 0,
+	SBI_SRST_RESET_REASON_SYS_FAILURE,
+};
+
 #define SBI_SPEC_VERSION_DEFAULT	0x1
 #define SBI_SPEC_VERSION_MAJOR_SHIFT	24
 #define SBI_SPEC_VERSION_MAJOR_MASK	0x7f
@@ -148,6 +164,14 @@ static inline unsigned long sbi_minor_version(void)
 	return sbi_spec_version & SBI_SPEC_VERSION_MINOR_MASK;
 }
 
+/* Make SBI version */
+static inline unsigned long sbi_mk_version(unsigned long major,
+					    unsigned long minor)
+{
+	return ((major & SBI_SPEC_VERSION_MAJOR_MASK) <<
+		SBI_SPEC_VERSION_MAJOR_SHIFT) | minor;
+}
+
 int sbi_err_map_linux_errno(int err);
 #else /* CONFIG_RISCV_SBI */
 static inline int sbi_remote_fence_i(const unsigned long *hart_mask) { return -1; }
arch/riscv/kernel/sbi.c +35 -0
index 7402a417f38e..9a84f0cb5175 100644
@@ -7,6 +7,7 @@
 
 #include <linux/init.h>
 #include <linux/pm.h>
+#include <linux/reboot.h>
 #include <asm/sbi.h>
 #include <asm/smp.h>
 
@@ -501,6 +502,32 @@ int sbi_remote_hfence_vvma_asid(const unsigned long *hart_mask,
 }
 EXPORT_SYMBOL(sbi_remote_hfence_vvma_asid);
 
+static void sbi_srst_reset(unsigned long type, unsigned long reason)
+{
+	sbi_ecall(SBI_EXT_SRST, SBI_EXT_SRST_RESET, type, reason,
+		  0, 0, 0, 0);
+	pr_warn("%s: type=0x%lx reason=0x%lx failed\n",
+		__func__, type, reason);
+}
+
+static int sbi_srst_reboot(struct notifier_block *this,
+			   unsigned long mode, void *cmd)
+{
+	sbi_srst_reset((mode == REBOOT_WARM || mode == REBOOT_SOFT) ?
+		       SBI_SRST_RESET_TYPE_WARM_REBOOT :
+		       SBI_SRST_RESET_TYPE_COLD_REBOOT,
+		       SBI_SRST_RESET_REASON_NONE);
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block sbi_srst_reboot_nb;
+
+static void sbi_srst_power_off(void)
+{
+	sbi_srst_reset(SBI_SRST_RESET_TYPE_SHUTDOWN,
+		       SBI_SRST_RESET_REASON_NONE);
+}
+
 /**
  * sbi_probe_extension() - Check if an SBI extension ID is supported or not.
  * @extid: The extension ID to be probed.
@@ -608,6 +635,14 @@ void __init sbi_init(void)
 		} else {
 			__sbi_rfence	= __sbi_rfence_v01;
 		}
+		if ((sbi_spec_version >= sbi_mk_version(0, 3)) &&
+		    (sbi_probe_extension(SBI_EXT_SRST) > 0)) {
+			pr_info("SBI SRST extension detected\n");
+			pm_power_off = sbi_srst_power_off;
+			sbi_srst_reboot_nb.notifier_call = sbi_srst_reboot;
+			sbi_srst_reboot_nb.priority = 192;
+			register_restart_handler(&sbi_srst_reboot_nb);
+		}
 	} else {
 		__sbi_set_timer = __sbi_set_timer_v01;
 		__sbi_send_ipi	= __sbi_send_ipi_v01;
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH v7 1/1] RISC-V: Use SBI SRST extension when available

Hi Palmer,

Quoted 7 lines · Anup Patel

The SBI SRST extension provides a standard way to poweroff and reboot the system irrespective to whether Linux RISC-V S-mode is running natively (HS-mode) or inside Guest/VM (VS-mode).

The SBI SRST extension is available in the SBI v0.3 specification. (Refer, https://github.com/riscv/riscv-sbi-doc/releases/tag/v0.3.0-rc1)

Can you please consider this patch for Linux-5.14-rc1 ?

The SBI v0.3 spec is already frozen and this patch has been floating on LKML for quite a few months now.

Regards,
Anup

Quoted 123 lines

This patch extends Linux RISC-V SBI implementation to detect and use SBI SRST extension.

---
 arch/riscv/include/asm/sbi.h | 24 ++++++++++++++++++++++++
 arch/riscv/kernel/sbi.c      | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 59 insertions(+)
arch/riscv/include/asm/sbi.h +24 -0
index 0d42693cb65e..289621da4a2a 100644
@@ -27,6 +27,7 @@ enum sbi_ext_id {
        SBI_EXT_IPI = 0x735049,
        SBI_EXT_RFENCE = 0x52464E43,
        SBI_EXT_HSM = 0x48534D,
+       SBI_EXT_SRST = 0x53525354,
 };
 
 enum sbi_ext_base_fid {
@@ -70,6 +71,21 @@ enum sbi_hsm_hart_status {
        SBI_HSM_HART_STATUS_STOP_PENDING,
 };
 
+enum sbi_ext_srst_fid {
+       SBI_EXT_SRST_RESET = 0,
+};
+
+enum sbi_srst_reset_type {
+       SBI_SRST_RESET_TYPE_SHUTDOWN = 0,
+       SBI_SRST_RESET_TYPE_COLD_REBOOT,
+       SBI_SRST_RESET_TYPE_WARM_REBOOT,
+};
+
+enum sbi_srst_reset_reason {
+       SBI_SRST_RESET_REASON_NONE = 0,
+       SBI_SRST_RESET_REASON_SYS_FAILURE,
+};
+
 #define SBI_SPEC_VERSION_DEFAULT       0x1
 #define SBI_SPEC_VERSION_MAJOR_SHIFT   24
 #define SBI_SPEC_VERSION_MAJOR_MASK    0x7f
@@ -148,6 +164,14 @@ static inline unsigned long sbi_minor_version(void)
        return sbi_spec_version & SBI_SPEC_VERSION_MINOR_MASK;
 }
 
+/* Make SBI version */
+static inline unsigned long sbi_mk_version(unsigned long major,
+                                           unsigned long minor)
+{
+       return ((major & SBI_SPEC_VERSION_MAJOR_MASK) <<
+               SBI_SPEC_VERSION_MAJOR_SHIFT) | minor;
+}
+
 int sbi_err_map_linux_errno(int err);
 #else /* CONFIG_RISCV_SBI */
 static inline int sbi_remote_fence_i(const unsigned long *hart_mask) { return -1; }
arch/riscv/kernel/sbi.c +35 -1
index 7402a417f38e..9a84f0cb5175 100644
@@ -7,6 +7,7 @@
 
 #include <linux/init.h>
 #include <linux/pm.h>
+#include <linux/reboot.h>
 #include <asm/sbi.h>
 #include <asm/smp.h>
 
@@ -501,6 +502,32 @@ int sbi_remote_hfence_vvma_asid(const unsigned long *hart_mask,
 }
 EXPORT_SYMBOL(sbi_remote_hfence_vvma_asid);
 
+static void sbi_srst_reset(unsigned long type, unsigned long reason)
+{
+       sbi_ecall(SBI_EXT_SRST, SBI_EXT_SRST_RESET, type, reason,
+                 0, 0, 0, 0);
+       pr_warn("%s: type=0x%lx reason=0x%lx failed\n",
+               __func__, type, reason);
+}
+
+static int sbi_srst_reboot(struct notifier_block *this,
+                          unsigned long mode, void *cmd)
+{
+       sbi_srst_reset((mode == REBOOT_WARM || mode == REBOOT_SOFT) ?
+                      SBI_SRST_RESET_TYPE_WARM_REBOOT :
+                      SBI_SRST_RESET_TYPE_COLD_REBOOT,
+                      SBI_SRST_RESET_REASON_NONE);
+       return NOTIFY_DONE;
+}
+
+static struct notifier_block sbi_srst_reboot_nb;
+
+static void sbi_srst_power_off(void)
+{
+       sbi_srst_reset(SBI_SRST_RESET_TYPE_SHUTDOWN,
+                      SBI_SRST_RESET_REASON_NONE);
+}
+
 /**
  * sbi_probe_extension() - Check if an SBI extension ID is supported or not.
  * @extid: The extension ID to be probed.
@@ -608,6 +635,14 @@ void __init sbi_init(void)
                } else {
                        __sbi_rfence    = __sbi_rfence_v01;
                }
+               if ((sbi_spec_version >= sbi_mk_version(0, 3)) &&
+                   (sbi_probe_extension(SBI_EXT_SRST) > 0)) {
+                       pr_info("SBI SRST extension detected\n");
+                       pm_power_off = sbi_srst_power_off;
+                       sbi_srst_reboot_nb.notifier_call = sbi_srst_reboot;
+                       sbi_srst_reboot_nb.priority = 192;
+                       register_restart_handler(&sbi_srst_reboot_nb);
+               }
        } else {
                __sbi_set_timer = __sbi_set_timer_v01;
                __sbi_send_ipi  = __sbi_send_ipi_v01;
--

2.25.1

#3 lore raw

Re: [PATCH v7 1/1] RISC-V: Use SBI SRST extension when available

Quoted 8 lines · On Mon, 21 Jun 2021 21:46:46 PDT (-0700), [email protected] wrote:

Hi Palmer,

Quoted 5 lines · Anup Patel

The SBI SRST extension provides a standard way to poweroff and reboot the system irrespective to whether Linux RISC-V S-mode is running natively (HS-mode) or inside Guest/VM (VS-mode).

Quoted 7 lines
Quoted 2 lines

The SBI SRST extension is available in the SBI v0.3 specification. (Refer, https://github.com/riscv/riscv-sbi-doc/releases/tag/v0.3.0-rc1)

Can you please consider this patch for Linux-5.14-rc1 ?

The SBI v0.3 spec is already frozen and this patch has been floating on LKML for quite a few months now.

I didn't realize that SBI-0.3 had been frozed. That link is to a RC, the cooresponding v0.3.0 tag isn't in that repo. Can you give me a pointer to the frozen spec?

Quoted 127 lines

Regards,
Anup

Quoted 123 lines

This patch extends Linux RISC-V SBI implementation to detect and use SBI SRST extension.

---
 arch/riscv/include/asm/sbi.h | 24 ++++++++++++++++++++++++
 arch/riscv/kernel/sbi.c      | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 59 insertions(+)
arch/riscv/include/asm/sbi.h +24 -0
index 0d42693cb65e..289621da4a2a 100644
@@ -27,6 +27,7 @@ enum sbi_ext_id {
        SBI_EXT_IPI = 0x735049,
        SBI_EXT_RFENCE = 0x52464E43,
        SBI_EXT_HSM = 0x48534D,
+       SBI_EXT_SRST = 0x53525354,
 };
 
 enum sbi_ext_base_fid {
@@ -70,6 +71,21 @@ enum sbi_hsm_hart_status {
        SBI_HSM_HART_STATUS_STOP_PENDING,
 };
 
+enum sbi_ext_srst_fid {
+       SBI_EXT_SRST_RESET = 0,
+};
+
+enum sbi_srst_reset_type {
+       SBI_SRST_RESET_TYPE_SHUTDOWN = 0,
+       SBI_SRST_RESET_TYPE_COLD_REBOOT,
+       SBI_SRST_RESET_TYPE_WARM_REBOOT,
+};
+
+enum sbi_srst_reset_reason {
+       SBI_SRST_RESET_REASON_NONE = 0,
+       SBI_SRST_RESET_REASON_SYS_FAILURE,
+};
+
 #define SBI_SPEC_VERSION_DEFAULT       0x1
 #define SBI_SPEC_VERSION_MAJOR_SHIFT   24
 #define SBI_SPEC_VERSION_MAJOR_MASK    0x7f
@@ -148,6 +164,14 @@ static inline unsigned long sbi_minor_version(void)
        return sbi_spec_version & SBI_SPEC_VERSION_MINOR_MASK;
 }
 
+/* Make SBI version */
+static inline unsigned long sbi_mk_version(unsigned long major,
+                                           unsigned long minor)
+{
+       return ((major & SBI_SPEC_VERSION_MAJOR_MASK) <<
+               SBI_SPEC_VERSION_MAJOR_SHIFT) | minor;
+}
+
 int sbi_err_map_linux_errno(int err);
 #else /* CONFIG_RISCV_SBI */
 static inline int sbi_remote_fence_i(const unsigned long *hart_mask) { return -1; }
arch/riscv/kernel/sbi.c +35 -1
index 7402a417f38e..9a84f0cb5175 100644
@@ -7,6 +7,7 @@
 
 #include <linux/init.h>
 #include <linux/pm.h>
+#include <linux/reboot.h>
 #include <asm/sbi.h>
 #include <asm/smp.h>
 
@@ -501,6 +502,32 @@ int sbi_remote_hfence_vvma_asid(const unsigned long *hart_mask,
 }
 EXPORT_SYMBOL(sbi_remote_hfence_vvma_asid);
 
+static void sbi_srst_reset(unsigned long type, unsigned long reason)
+{
+       sbi_ecall(SBI_EXT_SRST, SBI_EXT_SRST_RESET, type, reason,
+                 0, 0, 0, 0);
+       pr_warn("%s: type=0x%lx reason=0x%lx failed\n",
+               __func__, type, reason);
+}
+
+static int sbi_srst_reboot(struct notifier_block *this,
+                          unsigned long mode, void *cmd)
+{
+       sbi_srst_reset((mode == REBOOT_WARM || mode == REBOOT_SOFT) ?
+                      SBI_SRST_RESET_TYPE_WARM_REBOOT :
+                      SBI_SRST_RESET_TYPE_COLD_REBOOT,
+                      SBI_SRST_RESET_REASON_NONE);
+       return NOTIFY_DONE;
+}
+
+static struct notifier_block sbi_srst_reboot_nb;
+
+static void sbi_srst_power_off(void)
+{
+       sbi_srst_reset(SBI_SRST_RESET_TYPE_SHUTDOWN,
+                      SBI_SRST_RESET_REASON_NONE);
+}
+
 /**
  * sbi_probe_extension() - Check if an SBI extension ID is supported or not.
  * @extid: The extension ID to be probed.
@@ -608,6 +635,14 @@ void __init sbi_init(void)
                } else {
                        __sbi_rfence    = __sbi_rfence_v01;
                }
+               if ((sbi_spec_version >= sbi_mk_version(0, 3)) &&
+                   (sbi_probe_extension(SBI_EXT_SRST) > 0)) {
+                       pr_info("SBI SRST extension detected\n");
+                       pm_power_off = sbi_srst_power_off;
+                       sbi_srst_reboot_nb.notifier_call = sbi_srst_reboot;
+                       sbi_srst_reboot_nb.priority = 192;
+                       register_restart_handler(&sbi_srst_reboot_nb);
+               }
        } else {
                __sbi_set_timer = __sbi_set_timer_v01;
                __sbi_send_ipi  = __sbi_send_ipi_v01;
--

2.25.1

#4 lore raw

Re: [PATCH v7 1/1] RISC-V: Use SBI SRST extension when available

Quoted 13 lines · Palmer Dabbelt
Quoted 11 lines · On Mon, 21 Jun 2021 21:46:46 PDT (-0700), [email protected] wrote:

Hi Palmer,

Quoted 7 lines · Anup Patel

The SBI SRST extension provides a standard way to poweroff and reboot the system irrespective to whether Linux RISC-V S-mode is running natively (HS-mode) or inside Guest/VM (VS-mode).

The SBI SRST extension is available in the SBI v0.3 specification. (Refer, https://github.com/riscv/riscv-sbi-doc/releases/tag/v0.3.0-rc1)

Quoted 8 lines
Quoted 4 lines

Can you please consider this patch for Linux-5.14-rc1 ?

The SBI v0.3 spec is already frozen and this patch has been floating on LKML for quite a few months now.

I didn't realize that SBI-0.3 had been frozed. That link is to a RC, the cooresponding v0.3.0 tag isn't in that repo. Can you give me a pointer to the frozen spec?

Here's the link to SBI v0.3.0 tag:
https://github.com/riscv/riscv-sbi-doc/releases/tag/v0.3.0

We treat RC tags as frozen in SBI spec because no functional changes are done in SBI spec after it is tagged as RC. We only do typo fixes and clarifications on SBI spec RC release.

Regards,
Anup

Quoted 120 lines
Quoted 120 lines

Regards,
Anup

Quoted 115 lines

This patch extends Linux RISC-V SBI implementation to detect and use SBI SRST extension.

---
 arch/riscv/include/asm/sbi.h | 24 ++++++++++++++++++++++++
 arch/riscv/kernel/sbi.c      | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 59 insertions(+)
arch/riscv/include/asm/sbi.h +24 -0
index 0d42693cb65e..289621da4a2a 100644
@@ -27,6 +27,7 @@ enum sbi_ext_id {
        SBI_EXT_IPI = 0x735049,
        SBI_EXT_RFENCE = 0x52464E43,
        SBI_EXT_HSM = 0x48534D,
+       SBI_EXT_SRST = 0x53525354,
 };
 
 enum sbi_ext_base_fid {
@@ -70,6 +71,21 @@ enum sbi_hsm_hart_status {
        SBI_HSM_HART_STATUS_STOP_PENDING,
 };
 
+enum sbi_ext_srst_fid {
+       SBI_EXT_SRST_RESET = 0,
+};
+
+enum sbi_srst_reset_type {
+       SBI_SRST_RESET_TYPE_SHUTDOWN = 0,
+       SBI_SRST_RESET_TYPE_COLD_REBOOT,
+       SBI_SRST_RESET_TYPE_WARM_REBOOT,
+};
+
+enum sbi_srst_reset_reason {
+       SBI_SRST_RESET_REASON_NONE = 0,
+       SBI_SRST_RESET_REASON_SYS_FAILURE,
+};
+
 #define SBI_SPEC_VERSION_DEFAULT       0x1
 #define SBI_SPEC_VERSION_MAJOR_SHIFT   24
 #define SBI_SPEC_VERSION_MAJOR_MASK    0x7f
@@ -148,6 +164,14 @@ static inline unsigned long sbi_minor_version(void)
        return sbi_spec_version & SBI_SPEC_VERSION_MINOR_MASK;
 }
 
+/* Make SBI version */
+static inline unsigned long sbi_mk_version(unsigned long major,
+                                           unsigned long minor)
+{
+       return ((major & SBI_SPEC_VERSION_MAJOR_MASK) <<
+               SBI_SPEC_VERSION_MAJOR_SHIFT) | minor;
+}
+
 int sbi_err_map_linux_errno(int err);
 #else /* CONFIG_RISCV_SBI */
 static inline int sbi_remote_fence_i(const unsigned long *hart_mask) { return -1; }
arch/riscv/kernel/sbi.c +33 -0
index 7402a417f38e..9a84f0cb5175 100644
@@ -7,6 +7,7 @@
 
 #include <linux/init.h>
 #include <linux/pm.h>
+#include <linux/reboot.h>
 #include <asm/sbi.h>
 #include <asm/smp.h>
 
@@ -501,6 +502,32 @@ int sbi_remote_hfence_vvma_asid(const unsigned long *hart_mask,
 }
 EXPORT_SYMBOL(sbi_remote_hfence_vvma_asid);
 
+static void sbi_srst_reset(unsigned long type, unsigned long reason)
+{
+       sbi_ecall(SBI_EXT_SRST, SBI_EXT_SRST_RESET, type, reason,
+                 0, 0, 0, 0);
+       pr_warn("%s: type=0x%lx reason=0x%lx failed\n",
+               __func__, type, reason);
+}
+
+static int sbi_srst_reboot(struct notifier_block *this,
+                          unsigned long mode, void *cmd)
+{
+       sbi_srst_reset((mode == REBOOT_WARM || mode == REBOOT_SOFT) ?
+                      SBI_SRST_RESET_TYPE_WARM_REBOOT :
+                      SBI_SRST_RESET_TYPE_COLD_REBOOT,
+                      SBI_SRST_RESET_REASON_NONE);
+       return NOTIFY_DONE;
+}
+
+static struct notifier_block sbi_srst_reboot_nb;
+
+static void sbi_srst_power_off(void)
+{
+       sbi_srst_reset(SBI_SRST_RESET_TYPE_SHUTDOWN,
+                      SBI_SRST_RESET_REASON_NONE);
+}
+
 /**
  * sbi_probe_extension() - Check if an SBI extension ID is supported or not.
  * @extid: The extension ID to be probed.
@@ -608,6 +635,14 @@ void __init sbi_init(void)
                } else {
                        __sbi_rfence    = __sbi_rfence_v01;
                }
+               if ((sbi_spec_version >= sbi_mk_version(0, 3)) &&
+                   (sbi_probe_extension(SBI_EXT_SRST) > 0)) {
+                       pr_info("SBI SRST extension detected\n");
+                       pm_power_off = sbi_srst_power_off;
+                       sbi_srst_reboot_nb.notifier_call = sbi_srst_reboot;
+                       sbi_srst_reboot_nb.priority = 192;
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
arch/riscv/kernel/sbi.c +2 -1
+                       register_restart_handler(&sbi_srst_reboot_nb);
+               }
        } else {
                __sbi_set_timer = __sbi_set_timer_v01;
                __sbi_send_ipi  = __sbi_send_ipi_v01;
--

2.25.1

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

author
#5 lore raw

Re: [PATCH v7 1/1] RISC-V: Use SBI SRST extension when available

On 08/07/21, 9:22 AM, "Anup Patel" <[email protected]> wrote:

On Wed, Jul 7, 2021 at 1:57 AM Palmer Dabbelt <[email protected]> wrote:
>
> On Mon, 21 Jun 2021 21:46:46 PDT (-0700), [email protected] wrote:
> > Hi Palmer,
> >
> > On Wed, Jun 9, 2021 at 5:43 PM Anup Patel <[email protected]> wrote:
> >>
> >> The SBI SRST extension provides a standard way to poweroff and > >> reboot the system irrespective to whether Linux RISC-V S-mode > >> is running natively (HS-mode) or inside Guest/VM (VS-mode).
> >>
> >> The SBI SRST extension is available in the SBI v0.3 specification. > >> (Refer, https://github.com/riscv/riscv-sbi-doc/releases/tag/v0.3.0-rc1)
> >
> > Can you please consider this patch for Linux-5.14-rc1 ?
> >
> > The SBI v0.3 spec is already frozen and this patch has been
> > floating on LKML for quite a few months now.
>
> I didn't realize that SBI-0.3 had been frozed. That link is to a RC, > the cooresponding v0.3.0 tag isn't in that repo. Can you give me a > pointer to the frozen spec?

Here's the link to SBI v0.3.0 tag:
https://github.com/riscv/riscv-sbi-doc/releases/tag/v0.3.0

We treat RC tags as frozen in SBI spec because no functional changes are done in SBI spec after it is tagged as RC. We only do typo fixes and clarifications on SBI spec RC release.

Can you take this patch for Linux-5.14 ??

Regards,
Anup

    Regards,
    Anup

    >
    > >
    > > Regards,
    > > Anup
    > >
    > >>
    > >> This patch extends Linux RISC-V SBI implementation to detect
    > >> and use SBI SRST extension.
    > >>
    > >> Signed-off-by: Anup Patel <[email protected]>
    > >> Reviewed-by: Atish Patra <[email protected]>
    > >> ---
    > >>  arch/riscv/include/asm/sbi.h | 24 ++++++++++++++++++++++++
    > >>  arch/riscv/kernel/sbi.c      | 35 +++++++++++++++++++++++++++++++++++
    > >>  2 files changed, 59 insertions(+)
    > >>
    > >> diff --git a/arch/riscv/include/asm/sbi.h b/arch/riscv/include/asm/sbi.h
    > >> index 0d42693cb65e..289621da4a2a 100644
    > >> --- a/arch/riscv/include/asm/sbi.h
    > >> +++ b/arch/riscv/include/asm/sbi.h
    > >> @@ -27,6 +27,7 @@ enum sbi_ext_id {
    > >>         SBI_EXT_IPI = 0x735049,
    > >>         SBI_EXT_RFENCE = 0x52464E43,
    > >>         SBI_EXT_HSM = 0x48534D,
    > >> +       SBI_EXT_SRST = 0x53525354,
    > >>  };
    > >>
    > >>  enum sbi_ext_base_fid {
    > >> @@ -70,6 +71,21 @@ enum sbi_hsm_hart_status {
    > >>         SBI_HSM_HART_STATUS_STOP_PENDING,
    > >>  };
    > >>
    > >> +enum sbi_ext_srst_fid {
    > >> +       SBI_EXT_SRST_RESET = 0,
    > >> +};
    > >> +
    > >> +enum sbi_srst_reset_type {
    > >> +       SBI_SRST_RESET_TYPE_SHUTDOWN = 0,
    > >> +       SBI_SRST_RESET_TYPE_COLD_REBOOT,
    > >> +       SBI_SRST_RESET_TYPE_WARM_REBOOT,
    > >> +};
    > >> +
    > >> +enum sbi_srst_reset_reason {
    > >> +       SBI_SRST_RESET_REASON_NONE = 0,
    > >> +       SBI_SRST_RESET_REASON_SYS_FAILURE,
    > >> +};
    > >> +
    > >>  #define SBI_SPEC_VERSION_DEFAULT       0x1
    > >>  #define SBI_SPEC_VERSION_MAJOR_SHIFT   24
    > >>  #define SBI_SPEC_VERSION_MAJOR_MASK    0x7f
    > >> @@ -148,6 +164,14 @@ static inline unsigned long sbi_minor_version(void)
    > >>         return sbi_spec_version & SBI_SPEC_VERSION_MINOR_MASK;
    > >>  }
    > >>
    > >> +/* Make SBI version */
    > >> +static inline unsigned long sbi_mk_version(unsigned long major,
    > >> +                                           unsigned long minor)
    > >> +{
    > >> +       return ((major & SBI_SPEC_VERSION_MAJOR_MASK) <<
    > >> +               SBI_SPEC_VERSION_MAJOR_SHIFT) | minor;
    > >> +}
    > >> +
    > >>  int sbi_err_map_linux_errno(int err);
    > >>  #else /* CONFIG_RISCV_SBI */
    > >>  static inline int sbi_remote_fence_i(const unsigned long *hart_mask) { return -1; }
    > >> diff --git a/arch/riscv/kernel/sbi.c b/arch/riscv/kernel/sbi.c
    > >> index 7402a417f38e..9a84f0cb5175 100644
    > >> --- a/arch/riscv/kernel/sbi.c
    > >> +++ b/arch/riscv/kernel/sbi.c
    > >> @@ -7,6 +7,7 @@
    > >>
    > >>  #include <linux/init.h>
    > >>  #include <linux/pm.h>
    > >> +#include <linux/reboot.h>
    > >>  #include <asm/sbi.h>
    > >>  #include <asm/smp.h>
    > >>
    > >> @@ -501,6 +502,32 @@ int sbi_remote_hfence_vvma_asid(const unsigned long *hart_mask,
    > >>  }
    > >>  EXPORT_SYMBOL(sbi_remote_hfence_vvma_asid);
    > >>
    > >> +static void sbi_srst_reset(unsigned long type, unsigned long reason)
    > >> +{
    > >> +       sbi_ecall(SBI_EXT_SRST, SBI_EXT_SRST_RESET, type, reason,
    > >> +                 0, 0, 0, 0);
    > >> +       pr_warn("%s: type=0x%lx reason=0x%lx failed\n",
    > >> +               __func__, type, reason);
    > >> +}
    > >> +
    > >> +static int sbi_srst_reboot(struct notifier_block *this,
    > >> +                          unsigned long mode, void *cmd)
    > >> +{
    > >> +       sbi_srst_reset((mode == REBOOT_WARM || mode == REBOOT_SOFT) ?
    > >> +                      SBI_SRST_RESET_TYPE_WARM_REBOOT :
    > >> +                      SBI_SRST_RESET_TYPE_COLD_REBOOT,
    > >> +                      SBI_SRST_RESET_REASON_NONE);
    > >> +       return NOTIFY_DONE;
    > >> +}
    > >> +
    > >> +static struct notifier_block sbi_srst_reboot_nb;
    > >> +
    > >> +static void sbi_srst_power_off(void)
    > >> +{
    > >> +       sbi_srst_reset(SBI_SRST_RESET_TYPE_SHUTDOWN,
    > >> +                      SBI_SRST_RESET_REASON_NONE);
    > >> +}
    > >> +
    > >>  /**
    > >>   * sbi_probe_extension() - Check if an SBI extension ID is supported or not.
    > >>   * @extid: The extension ID to be probed.
    > >> @@ -608,6 +635,14 @@ void __init sbi_init(void)
    > >>                 } else {
    > >>                         __sbi_rfence    = __sbi_rfence_v01;
    > >>                 }
    > >> +               if ((sbi_spec_version >= sbi_mk_version(0, 3)) &&
    > >> +                   (sbi_probe_extension(SBI_EXT_SRST) > 0)) {
    > >> +                       pr_info("SBI SRST extension detected\n");
    > >> +                       pm_power_off = sbi_srst_power_off;
    > >> +                       sbi_srst_reboot_nb.notifier_call = sbi_srst_reboot;
    > >> +                       sbi_srst_reboot_nb.priority = 192;
    > >> +                       register_restart_handler(&sbi_srst_reboot_nb);
    > >> +               }
    > >>         } else {
    > >>                 __sbi_set_timer = __sbi_set_timer_v01;
    > >>                 __sbi_send_ipi  = __sbi_send_ipi_v01;
    > >> --
    > >> 2.25.1
    > >>
#6 lore raw

Re: [PATCH v7 1/1] RISC-V: Use SBI SRST extension when available

Quoted 27 lines · Anup Patel

On 08/07/21, 9:22 AM, "Anup Patel" <[email protected]> wrote:

On Wed, Jul 7, 2021 at 1:57 AM Palmer Dabbelt <[email protected]> wrote:
>
> On Mon, 21 Jun 2021 21:46:46 PDT (-0700), [email protected] wrote:
> > Hi Palmer,
> >
> > On Wed, Jun 9, 2021 at 5:43 PM Anup Patel <[email protected]> wrote:
> >>
> >> The SBI SRST extension provides a standard way to poweroff and > >> reboot the system irrespective to whether Linux RISC-V S-mode > >> is running natively (HS-mode) or inside Guest/VM (VS-mode).
> >>
> >> The SBI SRST extension is available in the SBI v0.3 specification. > >> (Refer, https://github.com/riscv/riscv-sbi-doc/releases/tag/v0.3.0-rc1)
> >
> > Can you please consider this patch for Linux-5.14-rc1 ?
> >
> > The SBI v0.3 spec is already frozen and this patch has been
> > floating on LKML for quite a few months now.
>
> I didn't realize that SBI-0.3 had been frozed. That link is to a RC, > the cooresponding v0.3.0 tag isn't in that repo. Can you give me a > pointer to the frozen spec?

Quoted 6 lines

Here's the link to SBI v0.3.0 tag:
https://github.com/riscv/riscv-sbi-doc/releases/tag/v0.3.0

We treat RC tags as frozen in SBI spec because no functional changes are done in SBI spec after it is tagged as RC. We only do typo fixes and clarifications on SBI spec RC release.

Treating the 0.3.0-rc1 as frozen as soon as it's released is a terrifying policy: some of the fixes I sent in after I saw rc1 released change the actual meaning of the text, even if they were meant to change them to what I thought the intended meaning was supposed to be. That means the actual text of 0.3.0-rc1 and 0.3.0 conflict with each other. Given that frozen comes with a guarntee of backwards compatibility, does that mean that the behavior allowed by 0.3.0-rc1 is compliant with the SBI, even if it was likely just allowed by a wording mistake?

If you're going to freeze things at rc1 then you really need to be quite explicit about that, as generally the point of RCs is to elicit review/testing. Looks like I was the only person to have provided any review, so I guess I was the only one who assumed "We don't expect any significant functional changes. We will wait for any further feedback and release the official v0.3 in a month or so." actually meant "this is frozen".

Quoted 1 line

Can you take this patch for Linux-5.14 ??

No, sorry, it's way too late for that. Please be specific about when you freeze specifications in the future, so we can all stay on the same page.

Quoted 136 lines

Regards,
Anup

    Regards,
    Anup

    >
    > >
    > > Regards,
    > > Anup
    > >
    > >>
    > >> This patch extends Linux RISC-V SBI implementation to detect
    > >> and use SBI SRST extension.
    > >>
    > >> Signed-off-by: Anup Patel <[email protected]>
    > >> Reviewed-by: Atish Patra <[email protected]>
    > >> ---
    > >>  arch/riscv/include/asm/sbi.h | 24 ++++++++++++++++++++++++
    > >>  arch/riscv/kernel/sbi.c      | 35 +++++++++++++++++++++++++++++++++++
    > >>  2 files changed, 59 insertions(+)
    > >>
    > >> diff --git a/arch/riscv/include/asm/sbi.h b/arch/riscv/include/asm/sbi.h
    > >> index 0d42693cb65e..289621da4a2a 100644
    > >> --- a/arch/riscv/include/asm/sbi.h
    > >> +++ b/arch/riscv/include/asm/sbi.h
    > >> @@ -27,6 +27,7 @@ enum sbi_ext_id {
    > >>         SBI_EXT_IPI = 0x735049,
    > >>         SBI_EXT_RFENCE = 0x52464E43,
    > >>         SBI_EXT_HSM = 0x48534D,
    > >> +       SBI_EXT_SRST = 0x53525354,
    > >>  };
    > >>
    > >>  enum sbi_ext_base_fid {
    > >> @@ -70,6 +71,21 @@ enum sbi_hsm_hart_status {
    > >>         SBI_HSM_HART_STATUS_STOP_PENDING,
    > >>  };
    > >>
    > >> +enum sbi_ext_srst_fid {
    > >> +       SBI_EXT_SRST_RESET = 0,
    > >> +};
    > >> +
    > >> +enum sbi_srst_reset_type {
    > >> +       SBI_SRST_RESET_TYPE_SHUTDOWN = 0,
    > >> +       SBI_SRST_RESET_TYPE_COLD_REBOOT,
    > >> +       SBI_SRST_RESET_TYPE_WARM_REBOOT,
    > >> +};
    > >> +
    > >> +enum sbi_srst_reset_reason {
    > >> +       SBI_SRST_RESET_REASON_NONE = 0,
    > >> +       SBI_SRST_RESET_REASON_SYS_FAILURE,
    > >> +};
    > >> +
    > >>  #define SBI_SPEC_VERSION_DEFAULT       0x1
    > >>  #define SBI_SPEC_VERSION_MAJOR_SHIFT   24
    > >>  #define SBI_SPEC_VERSION_MAJOR_MASK    0x7f
    > >> @@ -148,6 +164,14 @@ static inline unsigned long sbi_minor_version(void)
    > >>         return sbi_spec_version & SBI_SPEC_VERSION_MINOR_MASK;
    > >>  }
    > >>
    > >> +/* Make SBI version */
    > >> +static inline unsigned long sbi_mk_version(unsigned long major,
    > >> +                                           unsigned long minor)
    > >> +{
    > >> +       return ((major & SBI_SPEC_VERSION_MAJOR_MASK) <<
    > >> +               SBI_SPEC_VERSION_MAJOR_SHIFT) | minor;
    > >> +}
    > >> +
    > >>  int sbi_err_map_linux_errno(int err);
    > >>  #else /* CONFIG_RISCV_SBI */
    > >>  static inline int sbi_remote_fence_i(const unsigned long *hart_mask) { return -1; }
    > >> diff --git a/arch/riscv/kernel/sbi.c b/arch/riscv/kernel/sbi.c
    > >> index 7402a417f38e..9a84f0cb5175 100644
    > >> --- a/arch/riscv/kernel/sbi.c
    > >> +++ b/arch/riscv/kernel/sbi.c
    > >> @@ -7,6 +7,7 @@
    > >>
    > >>  #include <linux/init.h>
    > >>  #include <linux/pm.h>
    > >> +#include <linux/reboot.h>
    > >>  #include <asm/sbi.h>
    > >>  #include <asm/smp.h>
    > >>
    > >> @@ -501,6 +502,32 @@ int sbi_remote_hfence_vvma_asid(const unsigned long *hart_mask,
    > >>  }
    > >>  EXPORT_SYMBOL(sbi_remote_hfence_vvma_asid);
    > >>
    > >> +static void sbi_srst_reset(unsigned long type, unsigned long reason)
    > >> +{
    > >> +       sbi_ecall(SBI_EXT_SRST, SBI_EXT_SRST_RESET, type, reason,
    > >> +                 0, 0, 0, 0);
    > >> +       pr_warn("%s: type=0x%lx reason=0x%lx failed\n",
    > >> +               __func__, type, reason);
    > >> +}
    > >> +
    > >> +static int sbi_srst_reboot(struct notifier_block *this,
    > >> +                          unsigned long mode, void *cmd)
    > >> +{
    > >> +       sbi_srst_reset((mode == REBOOT_WARM || mode == REBOOT_SOFT) ?
    > >> +                      SBI_SRST_RESET_TYPE_WARM_REBOOT :
    > >> +                      SBI_SRST_RESET_TYPE_COLD_REBOOT,
    > >> +                      SBI_SRST_RESET_REASON_NONE);
    > >> +       return NOTIFY_DONE;
    > >> +}
    > >> +
    > >> +static struct notifier_block sbi_srst_reboot_nb;
    > >> +
    > >> +static void sbi_srst_power_off(void)
    > >> +{
    > >> +       sbi_srst_reset(SBI_SRST_RESET_TYPE_SHUTDOWN,
    > >> +                      SBI_SRST_RESET_REASON_NONE);
    > >> +}
    > >> +
    > >>  /**
    > >>   * sbi_probe_extension() - Check if an SBI extension ID is supported or not.
    > >>   * @extid: The extension ID to be probed.
    > >> @@ -608,6 +635,14 @@ void __init sbi_init(void)
    > >>                 } else {
    > >>                         __sbi_rfence    = __sbi_rfence_v01;
    > >>                 }
    > >> +               if ((sbi_spec_version >= sbi_mk_version(0, 3)) &&
    > >> +                   (sbi_probe_extension(SBI_EXT_SRST) > 0)) {
    > >> +                       pr_info("SBI SRST extension detected\n");
    > >> +                       pm_power_off = sbi_srst_power_off;
    > >> +                       sbi_srst_reboot_nb.notifier_call = sbi_srst_reboot;
    > >> +                       sbi_srst_reboot_nb.priority = 192;
    > >> +                       register_restart_handler(&sbi_srst_reboot_nb);
    > >> +               }
    > >>         } else {
    > >>                 __sbi_set_timer = __sbi_set_timer_v01;
    > >>                 __sbi_send_ipi  = __sbi_send_ipi_v01;
    > >> --
    > >> 2.25.1
    > >>
maintainer
#7 lore raw

Re: [PATCH v7 1/1] RISC-V: Use SBI SRST extension when available

Quoted 52 lines · Palmer Dabbelt
Quoted 27 lines · Anup Patel

On 08/07/21, 9:22 AM, "Anup Patel" <[email protected]> wrote:

On Wed, Jul 7, 2021 at 1:57 AM Palmer Dabbelt <[email protected]> wrote:
>
> On Mon, 21 Jun 2021 21:46:46 PDT (-0700), [email protected] wrote:
> > Hi Palmer,
> >
> > On Wed, Jun 9, 2021 at 5:43 PM Anup Patel <[email protected]> wrote:
> >>
> >> The SBI SRST extension provides a standard way to poweroff and > >> reboot the system irrespective to whether Linux RISC-V S-mode > >> is running natively (HS-mode) or inside Guest/VM (VS-mode).
> >>
> >> The SBI SRST extension is available in the SBI v0.3 specification. > >> (Refer, https://github.com/riscv/riscv-sbi-doc/releases/tag/v0.3.0-rc1)
> >
> > Can you please consider this patch for Linux-5.14-rc1 ?
> >
> > The SBI v0.3 spec is already frozen and this patch has been
> > floating on LKML for quite a few months now.
>
> I didn't realize that SBI-0.3 had been frozed. That link is to a RC, > the cooresponding v0.3.0 tag isn't in that repo. Can you give me a > pointer to the frozen spec?

Quoted 6 lines

Here's the link to SBI v0.3.0 tag:
https://github.com/riscv/riscv-sbi-doc/releases/tag/v0.3.0

We treat RC tags as frozen in SBI spec because no functional changes are done in SBI spec after it is tagged as RC. We only do typo fixes and clarifications on SBI spec RC release.

Treating the 0.3.0-rc1 as frozen as soon as it's released is a terrifying policy: some of the fixes I sent in after I saw rc1 released change the actual meaning of the text, even if they were meant to change them to what I thought the intended meaning was supposed to be. That means the actual text of 0.3.0-rc1 and 0.3.0 conflict with each other. Given that frozen comes with a guarntee of backwards compatibility, does that mean that the behavior allowed by 0.3.0-rc1 is compliant with the SBI, even if it was likely just allowed by a wording mistake?

If you're going to freeze things at rc1 then you really need to be quite explicit about that, as generally the point of RCs is to elicit review/testing. Looks like I was the only person to have provided any review, so I guess I was the only one who assumed "We don't expect any significant functional changes. We will wait for any further feedback and release the official v0.3 in a month or so." actually meant "this is frozen".

Quoted 5 lines
Quoted 1 line

Can you take this patch for Linux-5.14 ??

No, sorry, it's way too late for that. Please be specific about when you freeze specifications in the future, so we can all stay on the same page.

I went and talked to Krste, and he says that there's a whole process for freezing extensions that this hasn't gone through. They don't have anything written down that I can point to, but can you guys please just get on the same page about this? It seems like every time I talk to someone from the RISC-V foundation I get a conflicting description of what's going on, and I'm entirely out of patience when it comes to getting blamed for all the chaos over there.

Quoted 137 lines
Quoted 137 lines

Regards,
Anup

    Regards,
    Anup

    >
    > >
    > > Regards,
    > > Anup
    > >
    > >>
    > >> This patch extends Linux RISC-V SBI implementation to detect
    > >> and use SBI SRST extension.
    > >>
    > >> Signed-off-by: Anup Patel <[email protected]>
    > >> Reviewed-by: Atish Patra <[email protected]>
    > >> ---
    > >>  arch/riscv/include/asm/sbi.h | 24 ++++++++++++++++++++++++
    > >>  arch/riscv/kernel/sbi.c      | 35 +++++++++++++++++++++++++++++++++++
    > >>  2 files changed, 59 insertions(+)
    > >>
    > >> diff --git a/arch/riscv/include/asm/sbi.h b/arch/riscv/include/asm/sbi.h
    > >> index 0d42693cb65e..289621da4a2a 100644
    > >> --- a/arch/riscv/include/asm/sbi.h
    > >> +++ b/arch/riscv/include/asm/sbi.h
    > >> @@ -27,6 +27,7 @@ enum sbi_ext_id {
    > >>         SBI_EXT_IPI = 0x735049,
    > >>         SBI_EXT_RFENCE = 0x52464E43,
    > >>         SBI_EXT_HSM = 0x48534D,
    > >> +       SBI_EXT_SRST = 0x53525354,
    > >>  };
    > >>
    > >>  enum sbi_ext_base_fid {
    > >> @@ -70,6 +71,21 @@ enum sbi_hsm_hart_status {
    > >>         SBI_HSM_HART_STATUS_STOP_PENDING,
    > >>  };
    > >>
    > >> +enum sbi_ext_srst_fid {
    > >> +       SBI_EXT_SRST_RESET = 0,
    > >> +};
    > >> +
    > >> +enum sbi_srst_reset_type {
    > >> +       SBI_SRST_RESET_TYPE_SHUTDOWN = 0,
    > >> +       SBI_SRST_RESET_TYPE_COLD_REBOOT,
    > >> +       SBI_SRST_RESET_TYPE_WARM_REBOOT,
    > >> +};
    > >> +
    > >> +enum sbi_srst_reset_reason {
    > >> +       SBI_SRST_RESET_REASON_NONE = 0,
    > >> +       SBI_SRST_RESET_REASON_SYS_FAILURE,
    > >> +};
    > >> +
    > >>  #define SBI_SPEC_VERSION_DEFAULT       0x1
    > >>  #define SBI_SPEC_VERSION_MAJOR_SHIFT   24
    > >>  #define SBI_SPEC_VERSION_MAJOR_MASK    0x7f
    > >> @@ -148,6 +164,14 @@ static inline unsigned long sbi_minor_version(void)
    > >>         return sbi_spec_version & SBI_SPEC_VERSION_MINOR_MASK;
    > >>  }
    > >>
    > >> +/* Make SBI version */
    > >> +static inline unsigned long sbi_mk_version(unsigned long major,
    > >> +                                           unsigned long minor)
    > >> +{
    > >> +       return ((major & SBI_SPEC_VERSION_MAJOR_MASK) <<
    > >> +               SBI_SPEC_VERSION_MAJOR_SHIFT) | minor;
    > >> +}
    > >> +
    > >>  int sbi_err_map_linux_errno(int err);
    > >>  #else /* CONFIG_RISCV_SBI */
    > >>  static inline int sbi_remote_fence_i(const unsigned long *hart_mask) { return -1; }
    > >> diff --git a/arch/riscv/kernel/sbi.c b/arch/riscv/kernel/sbi.c
    > >> index 7402a417f38e..9a84f0cb5175 100644
    > >> --- a/arch/riscv/kernel/sbi.c
    > >> +++ b/arch/riscv/kernel/sbi.c
    > >> @@ -7,6 +7,7 @@
    > >>
    > >>  #include <linux/init.h>
    > >>  #include <linux/pm.h>
    > >> +#include <linux/reboot.h>
    > >>  #include <asm/sbi.h>
    > >>  #include <asm/smp.h>
    > >>
    > >> @@ -501,6 +502,32 @@ int sbi_remote_hfence_vvma_asid(const unsigned long *hart_mask,
    > >>  }
    > >>  EXPORT_SYMBOL(sbi_remote_hfence_vvma_asid);
    > >>
    > >> +static void sbi_srst_reset(unsigned long type, unsigned long reason)
    > >> +{
    > >> +       sbi_ecall(SBI_EXT_SRST, SBI_EXT_SRST_RESET, type, reason,
    > >> +                 0, 0, 0, 0);
    > >> +       pr_warn("%s: type=0x%lx reason=0x%lx failed\n",
    > >> +               __func__, type, reason);
    > >> +}
    > >> +
    > >> +static int sbi_srst_reboot(struct notifier_block *this,
    > >> +                          unsigned long mode, void *cmd)
    > >> +{
    > >> +       sbi_srst_reset((mode == REBOOT_WARM || mode == REBOOT_SOFT) ?
    > >> +                      SBI_SRST_RESET_TYPE_WARM_REBOOT :
    > >> +                      SBI_SRST_RESET_TYPE_COLD_REBOOT,
    > >> +                      SBI_SRST_RESET_REASON_NONE);
    > >> +       return NOTIFY_DONE;
    > >> +}
    > >> +
    > >> +static struct notifier_block sbi_srst_reboot_nb;
    > >> +
    > >> +static void sbi_srst_power_off(void)
    > >> +{
    > >> +       sbi_srst_reset(SBI_SRST_RESET_TYPE_SHUTDOWN,
    > >> +                      SBI_SRST_RESET_REASON_NONE);
    > >> +}
    > >> +
    > >>  /**
    > >>   * sbi_probe_extension() - Check if an SBI extension ID is supported or not.
    > >>   * @extid: The extension ID to be probed.
    > >> @@ -608,6 +635,14 @@ void __init sbi_init(void)
    > >>                 } else {
    > >>                         __sbi_rfence    = __sbi_rfence_v01;
    > >>                 }
    > >> +               if ((sbi_spec_version >= sbi_mk_version(0, 3)) &&
    > >> +                   (sbi_probe_extension(SBI_EXT_SRST) > 0)) {
    > >> +                       pr_info("SBI SRST extension detected\n");
    > >> +                       pm_power_off = sbi_srst_power_off;
    > >> +                       sbi_srst_reboot_nb.notifier_call = sbi_srst_reboot;
    > >> +                       sbi_srst_reboot_nb.priority = 192;
    > >> +                       register_restart_handler(&sbi_srst_reboot_nb);
    > >> +               }
    > >>         } else {
    > >>                 __sbi_set_timer = __sbi_set_timer_v01;
    > >>                 __sbi_send_ipi  = __sbi_send_ipi_v01;
    > >> --
    > >> 2.25.1
    > >>
#8 lore raw

Re: [PATCH v7 1/1] RISC-V: Use SBI SRST extension when available

Quoted 60 lines · Palmer Dabbelt
Quoted 52 lines · Palmer Dabbelt
Quoted 27 lines · Anup Patel

On 08/07/21, 9:22 AM, "Anup Patel" <[email protected]> wrote:

On Wed, Jul 7, 2021 at 1:57 AM Palmer Dabbelt <[email protected]> wrote:
>
> On Mon, 21 Jun 2021 21:46:46 PDT (-0700), [email protected] wrote:
> > Hi Palmer,
> >
> > On Wed, Jun 9, 2021 at 5:43 PM Anup Patel <[email protected]> wrote:
> >>
> >> The SBI SRST extension provides a standard way to poweroff and > >> reboot the system irrespective to whether Linux RISC-V S-mode > >> is running natively (HS-mode) or inside Guest/VM (VS-mode).
> >>
> >> The SBI SRST extension is available in the SBI v0.3 specification. > >> (Refer, https://github.com/riscv/riscv-sbi-doc/releases/tag/v0.3.0-rc1)
> >
> > Can you please consider this patch for Linux-5.14-rc1 ?
> >
> > The SBI v0.3 spec is already frozen and this patch has been
> > floating on LKML for quite a few months now.
>
> I didn't realize that SBI-0.3 had been frozed. That link is to a RC, > the cooresponding v0.3.0 tag isn't in that repo. Can you give me a > pointer to the frozen spec?

Quoted 6 lines

Here's the link to SBI v0.3.0 tag:
https://github.com/riscv/riscv-sbi-doc/releases/tag/v0.3.0

We treat RC tags as frozen in SBI spec because no functional changes are done in SBI spec after it is tagged as RC. We only do typo fixes and clarifications on SBI spec RC release.

Treating the 0.3.0-rc1 as frozen as soon as it's released is a terrifying policy: some of the fixes I sent in after I saw rc1 released change the actual meaning of the text, even if they were meant to change them to what I thought the intended meaning was supposed to be. That means the actual text of 0.3.0-rc1 and 0.3.0 conflict with each other. Given that frozen comes with a guarntee of backwards compatibility, does that mean that the behavior allowed by 0.3.0-rc1 is compliant with the SBI, even if it was likely just allowed by a wording mistake?

If you're going to freeze things at rc1 then you really need to be quite explicit about that, as generally the point of RCs is to elicit review/testing. Looks like I was the only person to have provided any review, so I guess I was the only one who assumed "We don't expect any significant functional changes. We will wait for any further feedback and release the official v0.3 in a month or so." actually meant "this is frozen".

Quoted 5 lines
Quoted 1 line

Can you take this patch for Linux-5.14 ??

No, sorry, it's way too late for that. Please be specific about when you freeze specifications in the future, so we can all stay on the same page.

Quoted 7 lines

I went and talked to Krste, and he says that there's a whole process for freezing extensions that this hasn't gone through. They don't have anything written down that I can point to, but can you guys please just get on the same page about this? It seems like every time I talk to someone from the RISC-V foundation I get a conflicting description of what's going on, and I'm entirely out of patience when it comes to getting blamed for all the chaos over there.

The RISC-V SBI is a pure software specification and not a ISA specification. In fact, this is not even non-ISA specification dealing with a MMIO (or hardware) device. There is no process defined for RISC-V software specifications.

The last SBI v0.2 release was done by you (Palmer). At that time, you simply tagged the SBI v0.2 release and announced it everywhere.

Regards,
Anup

Quoted 138 lines
Quoted 138 lines
Quoted 138 lines

Regards,
Anup

    Regards,
    Anup

    >
    > >
    > > Regards,
    > > Anup
    > >
    > >>
    > >> This patch extends Linux RISC-V SBI implementation to detect
    > >> and use SBI SRST extension.
    > >>
    > >> Signed-off-by: Anup Patel <[email protected]>
    > >> Reviewed-by: Atish Patra <[email protected]>
    > >> ---
    > >>  arch/riscv/include/asm/sbi.h | 24 ++++++++++++++++++++++++
    > >>  arch/riscv/kernel/sbi.c      | 35 +++++++++++++++++++++++++++++++++++
    > >>  2 files changed, 59 insertions(+)
    > >>
    > >> diff --git a/arch/riscv/include/asm/sbi.h b/arch/riscv/include/asm/sbi.h
    > >> index 0d42693cb65e..289621da4a2a 100644
    > >> --- a/arch/riscv/include/asm/sbi.h
    > >> +++ b/arch/riscv/include/asm/sbi.h
    > >> @@ -27,6 +27,7 @@ enum sbi_ext_id {
    > >>         SBI_EXT_IPI = 0x735049,
    > >>         SBI_EXT_RFENCE = 0x52464E43,
    > >>         SBI_EXT_HSM = 0x48534D,
    > >> +       SBI_EXT_SRST = 0x53525354,
    > >>  };
    > >>
    > >>  enum sbi_ext_base_fid {
    > >> @@ -70,6 +71,21 @@ enum sbi_hsm_hart_status {
    > >>         SBI_HSM_HART_STATUS_STOP_PENDING,
    > >>  };
    > >>
    > >> +enum sbi_ext_srst_fid {
    > >> +       SBI_EXT_SRST_RESET = 0,
    > >> +};
    > >> +
    > >> +enum sbi_srst_reset_type {
    > >> +       SBI_SRST_RESET_TYPE_SHUTDOWN = 0,
    > >> +       SBI_SRST_RESET_TYPE_COLD_REBOOT,
    > >> +       SBI_SRST_RESET_TYPE_WARM_REBOOT,
    > >> +};
    > >> +
    > >> +enum sbi_srst_reset_reason {
    > >> +       SBI_SRST_RESET_REASON_NONE = 0,
    > >> +       SBI_SRST_RESET_REASON_SYS_FAILURE,
    > >> +};
    > >> +
    > >>  #define SBI_SPEC_VERSION_DEFAULT       0x1
    > >>  #define SBI_SPEC_VERSION_MAJOR_SHIFT   24
    > >>  #define SBI_SPEC_VERSION_MAJOR_MASK    0x7f
    > >> @@ -148,6 +164,14 @@ static inline unsigned long sbi_minor_version(void)
    > >>         return sbi_spec_version & SBI_SPEC_VERSION_MINOR_MASK;
    > >>  }
    > >>
    > >> +/* Make SBI version */
    > >> +static inline unsigned long sbi_mk_version(unsigned long major,
    > >> +                                           unsigned long minor)
    > >> +{
    > >> +       return ((major & SBI_SPEC_VERSION_MAJOR_MASK) <<
    > >> +               SBI_SPEC_VERSION_MAJOR_SHIFT) | minor;
    > >> +}
    > >> +
    > >>  int sbi_err_map_linux_errno(int err);
    > >>  #else /* CONFIG_RISCV_SBI */
    > >>  static inline int sbi_remote_fence_i(const unsigned long *hart_mask) { return -1; }
    > >> diff --git a/arch/riscv/kernel/sbi.c b/arch/riscv/kernel/sbi.c
    > >> index 7402a417f38e..9a84f0cb5175 100644
    > >> --- a/arch/riscv/kernel/sbi.c
    > >> +++ b/arch/riscv/kernel/sbi.c
    > >> @@ -7,6 +7,7 @@
    > >>
    > >>  #include <linux/init.h>
    > >>  #include <linux/pm.h>
    > >> +#include <linux/reboot.h>
    > >>  #include <asm/sbi.h>
    > >>  #include <asm/smp.h>
    > >>
    > >> @@ -501,6 +502,32 @@ int sbi_remote_hfence_vvma_asid(const unsigned long *hart_mask,
    > >>  }
    > >>  EXPORT_SYMBOL(sbi_remote_hfence_vvma_asid);
    > >>
    > >> +static void sbi_srst_reset(unsigned long type, unsigned long reason)
    > >> +{
    > >> +       sbi_ecall(SBI_EXT_SRST, SBI_EXT_SRST_RESET, type, reason,
    > >> +                 0, 0, 0, 0);
    > >> +       pr_warn("%s: type=0x%lx reason=0x%lx failed\n",
    > >> +               __func__, type, reason);
    > >> +}
    > >> +
    > >> +static int sbi_srst_reboot(struct notifier_block *this,
    > >> +                          unsigned long mode, void *cmd)
    > >> +{
    > >> +       sbi_srst_reset((mode == REBOOT_WARM || mode == REBOOT_SOFT) ?
    > >> +                      SBI_SRST_RESET_TYPE_WARM_REBOOT :
    > >> +                      SBI_SRST_RESET_TYPE_COLD_REBOOT,
    > >> +                      SBI_SRST_RESET_REASON_NONE);
    > >> +       return NOTIFY_DONE;
    > >> +}
    > >> +
    > >> +static struct notifier_block sbi_srst_reboot_nb;
    > >> +
    > >> +static void sbi_srst_power_off(void)
    > >> +{
    > >> +       sbi_srst_reset(SBI_SRST_RESET_TYPE_SHUTDOWN,
    > >> +                      SBI_SRST_RESET_REASON_NONE);
    > >> +}
    > >> +
    > >>  /**
    > >>   * sbi_probe_extension() - Check if an SBI extension ID is supported or not.
    > >>   * @extid: The extension ID to be probed.
    > >> @@ -608,6 +635,14 @@ void __init sbi_init(void)
    > >>                 } else {
    > >>                         __sbi_rfence    = __sbi_rfence_v01;
    > >>                 }
    > >> +               if ((sbi_spec_version >= sbi_mk_version(0, 3)) &&
    > >> +                   (sbi_probe_extension(SBI_EXT_SRST) > 0)) {
    > >> +                       pr_info("SBI SRST extension detected\n");
    > >> +                       pm_power_off = sbi_srst_power_off;
    > >> +                       sbi_srst_reboot_nb.notifier_call = sbi_srst_reboot;
    > >> +                       sbi_srst_reboot_nb.priority = 192;
    > >> +                       register_restart_handler(&sbi_srst_reboot_nb);
    > >> +               }
    > >>         } else {
    > >>                 __sbi_set_timer = __sbi_set_timer_v01;
    > >>                 __sbi_send_ipi  = __sbi_send_ipi_v01;
    > >> --
    > >> 2.25.1
    > >>
#9 lore raw

Re: [PATCH v7 1/1] RISC-V: Use SBI SRST extension when available

In reply to Palmer Dabbelt
Quoted 60 lines · Palmer Dabbelt
Quoted 52 lines · Palmer Dabbelt
Quoted 27 lines · Anup Patel

On 08/07/21, 9:22 AM, "Anup Patel" <[email protected]> wrote:

On Wed, Jul 7, 2021 at 1:57 AM Palmer Dabbelt <[email protected]> wrote:
>
> On Mon, 21 Jun 2021 21:46:46 PDT (-0700), [email protected] wrote:
> > Hi Palmer,
> >
> > On Wed, Jun 9, 2021 at 5:43 PM Anup Patel <[email protected]> wrote:
> >>
> >> The SBI SRST extension provides a standard way to poweroff and > >> reboot the system irrespective to whether Linux RISC-V S-mode > >> is running natively (HS-mode) or inside Guest/VM (VS-mode).
> >>
> >> The SBI SRST extension is available in the SBI v0.3 specification. > >> (Refer, https://github.com/riscv/riscv-sbi-doc/releases/tag/v0.3.0-rc1)
> >
> > Can you please consider this patch for Linux-5.14-rc1 ?
> >
> > The SBI v0.3 spec is already frozen and this patch has been
> > floating on LKML for quite a few months now.
>
> I didn't realize that SBI-0.3 had been frozed. That link is to a RC, > the cooresponding v0.3.0 tag isn't in that repo. Can you give me a > pointer to the frozen spec?

Quoted 6 lines

Here's the link to SBI v0.3.0 tag:
https://github.com/riscv/riscv-sbi-doc/releases/tag/v0.3.0

We treat RC tags as frozen in SBI spec because no functional changes are done in SBI spec after it is tagged as RC. We only do typo fixes and clarifications on SBI spec RC release.

Treating the 0.3.0-rc1 as frozen as soon as it's released is a terrifying policy: some of the fixes I sent in after I saw rc1 released change the actual meaning of the text, even if they were meant to change them to what I thought the intended meaning was supposed to be. That means the actual text of 0.3.0-rc1 and 0.3.0 conflict with each other. Given that frozen comes with a guarntee of backwards compatibility, does that mean that the behavior allowed by 0.3.0-rc1 is compliant with the SBI, even if it was likely just allowed by a wording mistake?

If you're going to freeze things at rc1 then you really need to be quite explicit about that, as generally the point of RCs is to elicit review/testing. Looks like I was the only person to have provided any review, so I guess I was the only one who assumed "We don't expect any significant functional changes. We will wait for any further feedback and release the official v0.3 in a month or so." actually meant "this is frozen".

Quoted 5 lines
Quoted 1 line

Can you take this patch for Linux-5.14 ??

No, sorry, it's way too late for that. Please be specific about when you freeze specifications in the future, so we can all stay on the same page.

Quoted 7 lines

I went and talked to Krste, and he says that there's a whole process for freezing extensions that this hasn't gone through. They don't have anything written down that I can point to, but can you guys please just get on the same page about this? It seems like every time I talk to someone from the RISC-V foundation I get a conflicting description of what's going on, and I'm entirely out of patience when it comes to getting blamed for all the chaos over there.

For your information, the SBI spec is owned by the platform HSC so feel free to talk to the chairs Kumar Sankarn and Atish Patra.

The SBI v0.3 release has been approved by the platform HSC.

There are many working groups in RISC-V International and a lot of activities happening so for any specification you should talk to the people who are owning the specification first.

Regards,
Anup

Quoted 138 lines
Quoted 138 lines
Quoted 138 lines

Regards,
Anup

    Regards,
    Anup

    >
    > >
    > > Regards,
    > > Anup
    > >
    > >>
    > >> This patch extends Linux RISC-V SBI implementation to detect
    > >> and use SBI SRST extension.
    > >>
    > >> Signed-off-by: Anup Patel <[email protected]>
    > >> Reviewed-by: Atish Patra <[email protected]>
    > >> ---
    > >>  arch/riscv/include/asm/sbi.h | 24 ++++++++++++++++++++++++
    > >>  arch/riscv/kernel/sbi.c      | 35 +++++++++++++++++++++++++++++++++++
    > >>  2 files changed, 59 insertions(+)
    > >>
    > >> diff --git a/arch/riscv/include/asm/sbi.h b/arch/riscv/include/asm/sbi.h
    > >> index 0d42693cb65e..289621da4a2a 100644
    > >> --- a/arch/riscv/include/asm/sbi.h
    > >> +++ b/arch/riscv/include/asm/sbi.h
    > >> @@ -27,6 +27,7 @@ enum sbi_ext_id {
    > >>         SBI_EXT_IPI = 0x735049,
    > >>         SBI_EXT_RFENCE = 0x52464E43,
    > >>         SBI_EXT_HSM = 0x48534D,
    > >> +       SBI_EXT_SRST = 0x53525354,
    > >>  };
    > >>
    > >>  enum sbi_ext_base_fid {
    > >> @@ -70,6 +71,21 @@ enum sbi_hsm_hart_status {
    > >>         SBI_HSM_HART_STATUS_STOP_PENDING,
    > >>  };
    > >>
    > >> +enum sbi_ext_srst_fid {
    > >> +       SBI_EXT_SRST_RESET = 0,
    > >> +};
    > >> +
    > >> +enum sbi_srst_reset_type {
    > >> +       SBI_SRST_RESET_TYPE_SHUTDOWN = 0,
    > >> +       SBI_SRST_RESET_TYPE_COLD_REBOOT,
    > >> +       SBI_SRST_RESET_TYPE_WARM_REBOOT,
    > >> +};
    > >> +
    > >> +enum sbi_srst_reset_reason {
    > >> +       SBI_SRST_RESET_REASON_NONE = 0,
    > >> +       SBI_SRST_RESET_REASON_SYS_FAILURE,
    > >> +};
    > >> +
    > >>  #define SBI_SPEC_VERSION_DEFAULT       0x1
    > >>  #define SBI_SPEC_VERSION_MAJOR_SHIFT   24
    > >>  #define SBI_SPEC_VERSION_MAJOR_MASK    0x7f
    > >> @@ -148,6 +164,14 @@ static inline unsigned long sbi_minor_version(void)
    > >>         return sbi_spec_version & SBI_SPEC_VERSION_MINOR_MASK;
    > >>  }
    > >>
    > >> +/* Make SBI version */
    > >> +static inline unsigned long sbi_mk_version(unsigned long major,
    > >> +                                           unsigned long minor)
    > >> +{
    > >> +       return ((major & SBI_SPEC_VERSION_MAJOR_MASK) <<
    > >> +               SBI_SPEC_VERSION_MAJOR_SHIFT) | minor;
    > >> +}
    > >> +
    > >>  int sbi_err_map_linux_errno(int err);
    > >>  #else /* CONFIG_RISCV_SBI */
    > >>  static inline int sbi_remote_fence_i(const unsigned long *hart_mask) { return -1; }
    > >> diff --git a/arch/riscv/kernel/sbi.c b/arch/riscv/kernel/sbi.c
    > >> index 7402a417f38e..9a84f0cb5175 100644
    > >> --- a/arch/riscv/kernel/sbi.c
    > >> +++ b/arch/riscv/kernel/sbi.c
    > >> @@ -7,6 +7,7 @@
    > >>
    > >>  #include <linux/init.h>
    > >>  #include <linux/pm.h>
    > >> +#include <linux/reboot.h>
    > >>  #include <asm/sbi.h>
    > >>  #include <asm/smp.h>
    > >>
    > >> @@ -501,6 +502,32 @@ int sbi_remote_hfence_vvma_asid(const unsigned long *hart_mask,
    > >>  }
    > >>  EXPORT_SYMBOL(sbi_remote_hfence_vvma_asid);
    > >>
    > >> +static void sbi_srst_reset(unsigned long type, unsigned long reason)
    > >> +{
    > >> +       sbi_ecall(SBI_EXT_SRST, SBI_EXT_SRST_RESET, type, reason,
    > >> +                 0, 0, 0, 0);
    > >> +       pr_warn("%s: type=0x%lx reason=0x%lx failed\n",
    > >> +               __func__, type, reason);
    > >> +}
    > >> +
    > >> +static int sbi_srst_reboot(struct notifier_block *this,
    > >> +                          unsigned long mode, void *cmd)
    > >> +{
    > >> +       sbi_srst_reset((mode == REBOOT_WARM || mode == REBOOT_SOFT) ?
    > >> +                      SBI_SRST_RESET_TYPE_WARM_REBOOT :
    > >> +                      SBI_SRST_RESET_TYPE_COLD_REBOOT,
    > >> +                      SBI_SRST_RESET_REASON_NONE);
    > >> +       return NOTIFY_DONE;
    > >> +}
    > >> +
    > >> +static struct notifier_block sbi_srst_reboot_nb;
    > >> +
    > >> +static void sbi_srst_power_off(void)
    > >> +{
    > >> +       sbi_srst_reset(SBI_SRST_RESET_TYPE_SHUTDOWN,
    > >> +                      SBI_SRST_RESET_REASON_NONE);
    > >> +}
    > >> +
    > >>  /**
    > >>   * sbi_probe_extension() - Check if an SBI extension ID is supported or not.
    > >>   * @extid: The extension ID to be probed.
    > >> @@ -608,6 +635,14 @@ void __init sbi_init(void)
    > >>                 } else {
    > >>                         __sbi_rfence    = __sbi_rfence_v01;
    > >>                 }
    > >> +               if ((sbi_spec_version >= sbi_mk_version(0, 3)) &&
    > >> +                   (sbi_probe_extension(SBI_EXT_SRST) > 0)) {
    > >> +                       pr_info("SBI SRST extension detected\n");
    > >> +                       pm_power_off = sbi_srst_power_off;
    > >> +                       sbi_srst_reboot_nb.notifier_call = sbi_srst_reboot;
    > >> +                       sbi_srst_reboot_nb.priority = 192;
    > >> +                       register_restart_handler(&sbi_srst_reboot_nb);
    > >> +               }
    > >>         } else {
    > >>                 __sbi_set_timer = __sbi_set_timer_v01;
    > >>                 __sbi_send_ipi  = __sbi_send_ipi_v01;
    > >> --
    > >> 2.25.1
    > >>
#10 lore raw

Re: [PATCH v7 1/1] RISC-V: Use SBI SRST extension when available

In reply to Palmer Dabbelt
Quoted 56 lines · Palmer Dabbelt
Quoted 54 lines · Palmer Dabbelt
Quoted 27 lines · Anup Patel

On 08/07/21, 9:22 AM, "Anup Patel" <[email protected]> wrote:

On Wed, Jul 7, 2021 at 1:57 AM Palmer Dabbelt <[email protected]> wrote:
>
> On Mon, 21 Jun 2021 21:46:46 PDT (-0700), [email protected] wrote:
> > Hi Palmer,
> >
> > On Wed, Jun 9, 2021 at 5:43 PM Anup Patel <[email protected]> wrote:
> >>
> >> The SBI SRST extension provides a standard way to poweroff and > >> reboot the system irrespective to whether Linux RISC-V S-mode > >> is running natively (HS-mode) or inside Guest/VM (VS-mode).
> >>
> >> The SBI SRST extension is available in the SBI v0.3 specification. > >> (Refer, https://github.com/riscv/riscv-sbi-doc/releases/tag/v0.3.0-rc1)
> >
> > Can you please consider this patch for Linux-5.14-rc1 ?
> >
> > The SBI v0.3 spec is already frozen and this patch has been
> > floating on LKML for quite a few months now.
>
> I didn't realize that SBI-0.3 had been frozed. That link is to a RC, > the cooresponding v0.3.0 tag isn't in that repo. Can you give me a > pointer to the frozen spec?

Quoted 6 lines

Here's the link to SBI v0.3.0 tag:
https://github.com/riscv/riscv-sbi-doc/releases/tag/v0.3.0

We treat RC tags as frozen in SBI spec because no functional changes are done in SBI spec after it is tagged as RC. We only do typo fixes and clarifications on SBI spec RC release.

Treating the 0.3.0-rc1 as frozen as soon as it's released is a terrifying policy: some of the fixes I sent in after I saw rc1 released change the actual meaning of the text, even if they were meant to change them to what I thought the intended meaning was supposed to be. That means the actual text of 0.3.0-rc1 and 0.3.0 conflict with each other. Given that frozen comes with a guarntee of backwards compatibility, does that mean that the behavior allowed by 0.3.0-rc1 is compliant with the SBI, even if it was likely just allowed by a wording mistake?

If you're going to freeze things at rc1 then you really need to be quite explicit about that, as generally the point of RCs is to elicit review/testing. Looks like I was the only person to have provided any review, so I guess I was the only one who assumed "We don't expect any significant functional changes. We will wait for any further feedback and release the official v0.3 in a month or so." actually meant "this is frozen".

Quoted 1 line

Can you take this patch for Linux-5.14 ??

Quoted 8 lines
Quoted 3 lines

No, sorry, it's way too late for that. Please be specific about when you freeze specifications in the future, so we can all stay on the same page.

I went and talked to Krste, and he says that there's a whole process for freezing extensions that this hasn't gone through. They don't have anything written down that I can point to, but can you guys please just get on the same page about this? It seems like every time I talk to

Absolutely. The freezing extensions process is documented right now[1] but that is only meant
for ISA/hardware/platform specifications. There is no process defined for a SBI specification which is purely
a software specification because SBI specification release processes(v0.1 and v0.2) predate these documented processes. The SBI specification is owned by the Platform HSC which falls under the purview of software HC.
You can see a detailed chart of the RVI organization at [2]. All the aspects of SBI specification are discussed
in platform meetings[3] and frozen only after public review[4] and approval from the platform working group
and the software HC. The official SBI specification(v0.3) will also be available along with all other RISC-V specifications
once they figure out how to structure non-ISA specifications.

I have cc'd Kumar (chair of the Platform HSC) and Philip (chair of the software HC) in case they want to add anything.
I was not aware of the fact that Krste/Andrew are not aware of the progress of the SBI specification.
I will raise this topic during the next meeting and make sure they are in the loop as well.

Quoted 4 lines

someone from the RISC-V foundation I get a conflicting description of what's going on, and I'm entirely out of patience when it comes to getting blamed for all the chaos over there.

I agree the RVI process has not been very clear in the past. However, that has changed a lot in recent times thanks to Mark and other working group chairs. I don't think anybody is blaming you for the delay in ratification of the RVI specifications.
There is a clear path for all the specifications to be ratified e.g. the AIA and H extensions are planned to be frozen by the end of this year.
Let me know if you want to see the timeline of each specification and I can point you to the correct sheet.

[1] https://docs.google.com/presentation/d/1nQ5uFb39KA6gvUi5SReWfIQSiRN7hp6z7ZPfctE4mKk/edit#slide=id.ga0a994c3c8_0_6
[2] https://docs.google.com/presentation/d/1eEVuu6lRZd9iiDnZQSZME7Q7svtTG3pGIKHPmZ79B8E/edit#slide=id.ga275a504df_0_9
[3] https://github.com/riscv/riscv-platform-specs/wiki
[4] https://lists.riscv.org/g/tech-unixplatformspec/message/1042

Quoted 142 lines
Quoted 129 lines
Quoted 129 lines

Regards,
Anup

    Regards,
    Anup

    >
    > >
    > > Regards,
    > > Anup
    > >
    > >>
    > >> This patch extends Linux RISC-V SBI implementation to detect
    > >> and use SBI SRST extension.
    > >>
    > >> Signed-off-by: Anup Patel <[email protected]>
    > >> Reviewed-by: Atish Patra <[email protected]>
    > >> ---
    > >>  arch/riscv/include/asm/sbi.h | 24 ++++++++++++++++++++++++
    > >>  arch/riscv/kernel/sbi.c      | 35 +++++++++++++++++++++++++++++++++++
    > >>  2 files changed, 59 insertions(+)
    > >>
    > >> diff --git a/arch/riscv/include/asm/sbi.h b/arch/riscv/include/asm/sbi.h
    > >> index 0d42693cb65e..289621da4a2a 100644
    > >> --- a/arch/riscv/include/asm/sbi.h
    > >> +++ b/arch/riscv/include/asm/sbi.h
    > >> @@ -27,6 +27,7 @@ enum sbi_ext_id {
    > >>         SBI_EXT_IPI = 0x735049,
    > >>         SBI_EXT_RFENCE = 0x52464E43,
    > >>         SBI_EXT_HSM = 0x48534D,
    > >> +       SBI_EXT_SRST = 0x53525354,
    > >>  };
    > >>
    > >>  enum sbi_ext_base_fid {
    > >> @@ -70,6 +71,21 @@ enum sbi_hsm_hart_status {
    > >>         SBI_HSM_HART_STATUS_STOP_PENDING,
    > >>  };
    > >>
    > >> +enum sbi_ext_srst_fid {
    > >> +       SBI_EXT_SRST_RESET = 0,
    > >> +};
    > >> +
    > >> +enum sbi_srst_reset_type {
    > >> +       SBI_SRST_RESET_TYPE_SHUTDOWN = 0,
    > >> +       SBI_SRST_RESET_TYPE_COLD_REBOOT,
    > >> +       SBI_SRST_RESET_TYPE_WARM_REBOOT,
    > >> +};
    > >> +
    > >> +enum sbi_srst_reset_reason {
    > >> +       SBI_SRST_RESET_REASON_NONE = 0,
    > >> +       SBI_SRST_RESET_REASON_SYS_FAILURE,
    > >> +};
    > >> +
    > >>  #define SBI_SPEC_VERSION_DEFAULT       0x1
    > >>  #define SBI_SPEC_VERSION_MAJOR_SHIFT   24
    > >>  #define SBI_SPEC_VERSION_MAJOR_MASK    0x7f
    > >> @@ -148,6 +164,14 @@ static inline unsigned long sbi_minor_version(void)
    > >>         return sbi_spec_version & SBI_SPEC_VERSION_MINOR_MASK;
    > >>  }
    > >>
    > >> +/* Make SBI version */
    > >> +static inline unsigned long sbi_mk_version(unsigned long major,
    > >> +                                           unsigned long minor)
    > >> +{
    > >> +       return ((major & SBI_SPEC_VERSION_MAJOR_MASK) <<
    > >> +               SBI_SPEC_VERSION_MAJOR_SHIFT) | minor;
    > >> +}
    > >> +
    > >>  int sbi_err_map_linux_errno(int err);
    > >>  #else /* CONFIG_RISCV_SBI */
    > >>  static inline int sbi_remote_fence_i(const unsigned long *hart_mask) { return -1; }
    > >> diff --git a/arch/riscv/kernel/sbi.c b/arch/riscv/kernel/sbi.c
    > >> index 7402a417f38e..9a84f0cb5175 100644
    > >> --- a/arch/riscv/kernel/sbi.c
    > >> +++ b/arch/riscv/kernel/sbi.c
    > >> @@ -7,6 +7,7 @@
    > >>
    > >>  #include <linux/init.h>
    > >>  #include <linux/pm.h>
    > >> +#include <linux/reboot.h>
    > >>  #include <asm/sbi.h>
    > >>  #include <asm/smp.h>
    > >>
    > >> @@ -501,6 +502,32 @@ int sbi_remote_hfence_vvma_asid(const unsigned long *hart_mask,
    > >>  }
    > >>  EXPORT_SYMBOL(sbi_remote_hfence_vvma_asid);
    > >>
    > >> +static void sbi_srst_reset(unsigned long type, unsigned long reason)
    > >> +{
    > >> +       sbi_ecall(SBI_EXT_SRST, SBI_EXT_SRST_RESET, type, reason,
    > >> +                 0, 0, 0, 0);
    > >> +       pr_warn("%s: type=0x%lx reason=0x%lx failed\n",
    > >> +               __func__, type, reason);
    > >> +}
    > >> +
    > >> +static int sbi_srst_reboot(struct notifier_block *this,
    > >> +                          unsigned long mode, void *cmd)
    > >> +{
    > >> +       sbi_srst_reset((mode == REBOOT_WARM || mode == REBOOT_SOFT) ?
    > >> +                      SBI_SRST_RESET_TYPE_WARM_REBOOT :
    > >> +                      SBI_SRST_RESET_TYPE_COLD_REBOOT,
    > >> +                      SBI_SRST_RESET_REASON_NONE);
    > >> +       return NOTIFY_DONE;
    > >> +}
    > >> +
    > >> +static struct notifier_block sbi_srst_reboot_nb;
    > >> +
    > >> +static void sbi_srst_power_off(void)
    > >> +{
    > >> +       sbi_srst_reset(SBI_SRST_RESET_TYPE_SHUTDOWN,
    > >> +                      SBI_SRST_RESET_REASON_NONE);
    > >> +}
    > >> +
    > >>  /**
    > >>   * sbi_probe_extension() - Check if an SBI extension ID is supported or not.
    > >>   * @extid: The extension ID to be probed.
    > >> @@ -608,6 +635,14 @@ void __init sbi_init(void)
    > >>                 } else {
    > >>                         __sbi_rfence    = __sbi_rfence_v01;
    > >>                 }
    > >> +               if ((sbi_spec_version >= sbi_mk_version(0, 3)) &&
    > >> +                   (sbi_probe_extension(SBI_EXT_SRST) > 0)) {
    > >> +                       pr_info("SBI SRST extension detected\n");
    > >> +                       pm_power_off = sbi_srst_power_off;
    > >> +                       sbi_srst_reboot_nb.notifier_call = sbi_srst_reboot;
    > >> +                       sbi_srst_reboot_nb.priority = 192;
    > >> +                       register_restart_handler(&sbi_srst_reboot_nb);
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

+ }

        } else {
                __sbi_set_timer = __sbi_set_timer_v01;
                __sbi_send_ipi  = __sbi_send_ipi_v01;

--
2.25.1

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

Signature · 2 lines
Regards,
Atish
#11 lore raw

Re: [PATCH v7 1/1] RISC-V: Use SBI SRST extension when available

Quoted 103 lines · Atish Patra
Quoted 56 lines · Palmer Dabbelt
Quoted 54 lines · Palmer Dabbelt
Quoted 27 lines · Anup Patel

On 08/07/21, 9:22 AM, "Anup Patel" <[email protected]> wrote:

On Wed, Jul 7, 2021 at 1:57 AM Palmer Dabbelt <[email protected]> wrote:
>
> On Mon, 21 Jun 2021 21:46:46 PDT (-0700), [email protected] wrote:
> > Hi Palmer,
> >
> > On Wed, Jun 9, 2021 at 5:43 PM Anup Patel <[email protected]> wrote:
> >>
> >> The SBI SRST extension provides a standard way to poweroff and > >> reboot the system irrespective to whether Linux RISC-V S-mode > >> is running natively (HS-mode) or inside Guest/VM (VS-mode). > >>
> >> The SBI SRST extension is available in the SBI v0.3 specification. > >> (Refer, https://github.com/riscv/riscv-sbi-doc/releases/tag/v0.3.0-rc1)
> >
> > Can you please consider this patch for Linux-5.14-rc1 ?
> >
> > The SBI v0.3 spec is already frozen and this patch has been
> > floating on LKML for quite a few months now.
>
> I didn't realize that SBI-0.3 had been frozed. That link is to a RC, > the cooresponding v0.3.0 tag isn't in that repo. Can you give me a > pointer to the frozen spec?

Quoted 6 lines

Here's the link to SBI v0.3.0 tag:
https://github.com/riscv/riscv-sbi-doc/releases/tag/v0.3.0

We treat RC tags as frozen in SBI spec because no functional changes are done in SBI spec after it is tagged as RC. We only do typo fixes and clarifications on SBI spec RC release.

Treating the 0.3.0-rc1 as frozen as soon as it's released is a terrifying policy: some of the fixes I sent in after I saw rc1 released change the actual meaning of the text, even if they were meant to change them to what I thought the intended meaning was supposed to be. That means the actual text of 0.3.0-rc1 and 0.3.0 conflict with each other. Given that frozen comes with a guarntee of backwards compatibility, does that mean that the behavior allowed by 0.3.0-rc1 is compliant with the SBI, even if it was likely just allowed by a wording mistake?

If you're going to freeze things at rc1 then you really need to be quite explicit about that, as generally the point of RCs is to elicit review/testing. Looks like I was the only person to have provided any review, so I guess I was the only one who assumed "We don't expect any significant functional changes. We will wait for any further feedback and release the official v0.3 in a month or so." actually meant "this is frozen".

Quoted 1 line

Can you take this patch for Linux-5.14 ??

Quoted 8 lines
Quoted 3 lines

No, sorry, it's way too late for that. Please be specific about when you freeze specifications in the future, so we can all stay on the same page.

I went and talked to Krste, and he says that there's a whole process for freezing extensions that this hasn't gone through. They don't have anything written down that I can point to, but can you guys please just get on the same page about this? It seems like every time I talk to

Absolutely. The freezing extensions process is documented right now[1] but that is only meant
for ISA/hardware/platform specifications. There is no process defined for a SBI specification which is purely
a software specification because SBI specification release processes(v0.1 and v0.2) predate these documented processes. The SBI specification is owned by the Platform HSC which falls under the purview of software HC.
You can see a detailed chart of the RVI organization at [2]. All the aspects of SBI specification are discussed
in platform meetings[3] and frozen only after public review[4] and approval from the platform working group
and the software HC. The official SBI specification(v0.3) will also be available along with all other RISC-V specifications
once they figure out how to structure non-ISA specifications.

I have cc'd Kumar (chair of the Platform HSC) and Philip (chair of the software HC) in case they want to add anything.
I was not aware of the fact that Krste/Andrew are not aware of the progress of the SBI specification.
I will raise this topic during the next meeting and make sure they are in the loop as well.

Quoted 4 lines

someone from the RISC-V foundation I get a conflicting description of what's going on, and I'm entirely out of patience when it comes to getting blamed for all the chaos over there.

I agree the RVI process has not been very clear in the past. However, that has changed a lot in recent times thanks to Mark and other working group chairs. I don't think anybody is blaming you for the delay in ratification of the RVI specifications.
There is a clear path for all the specifications to be ratified e.g. the AIA and H extensions are planned to be frozen by the end of this year.
Let me know if you want to see the timeline of each specification and I can point you to the correct sheet.

Quoted 4 lines

[1] https://docs.google.com/presentation/d/1nQ5uFb39KA6gvUi5SReWfIQSiRN7hp6z7ZPfctE4mKk/edit#slide=id.ga0a994c3c8_0_6
[2] https://docs.google.com/presentation/d/1eEVuu6lRZd9iiDnZQSZME7Q7svtTG3pGIKHPmZ79B8E/edit#slide=id.ga275a504df_0_9
[3] https://github.com/riscv/riscv-platform-specs/wiki
[4] https://lists.riscv.org/g/tech-unixplatformspec/message/1042

https://github.com/riscv-non-isa/riscv-sbi-doc/releases/tag/v0.3.1-rc1
has:

"This tag the release candidate of version 0.3.1 of the RISC-V SBI specification. It doesn't have any significant changes other than typos. A new release is created to adapt the ratification process for non-ISA specifications defined by RVI recently."

Has this patch to wait until release 0.3.1 of the SBI specification is ratified? What is the timeline?

Could you, please, provide a link the the non-ISA ratification process description.

Best regards

Heinrich

#12 lore raw

Re: [PATCH v7 1/1] RISC-V: Use SBI SRST extension when available

Quoted 113 lines · Heinrich Schuchardt
Quoted 103 lines · Atish Patra
Quoted 56 lines · Palmer Dabbelt
Quoted 54 lines · Palmer Dabbelt
Quoted 27 lines · Anup Patel

On 08/07/21, 9:22 AM, "Anup Patel" <[email protected]> wrote:

On Wed, Jul 7, 2021 at 1:57 AM Palmer Dabbelt <[email protected]> wrote:
>
> On Mon, 21 Jun 2021 21:46:46 PDT (-0700), [email protected] wrote:
> > Hi Palmer,
> >
> > On Wed, Jun 9, 2021 at 5:43 PM Anup Patel <[email protected]> wrote:
> >>
> >> The SBI SRST extension provides a standard way to poweroff and > >> reboot the system irrespective to whether Linux RISC-V S-mode > >> is running natively (HS-mode) or inside Guest/VM (VS-mode). > >>
> >> The SBI SRST extension is available in the SBI v0.3 specification. > >> (Refer, https://github.com/riscv/riscv-sbi-doc/releases/tag/v0.3.0-rc1)
> >
> > Can you please consider this patch for Linux-5.14-rc1 ?
> >
> > The SBI v0.3 spec is already frozen and this patch has been
> > floating on LKML for quite a few months now.
>
> I didn't realize that SBI-0.3 had been frozed. That link is to a RC, > the cooresponding v0.3.0 tag isn't in that repo. Can you give me a > pointer to the frozen spec?

Quoted 6 lines

Here's the link to SBI v0.3.0 tag:
https://github.com/riscv/riscv-sbi-doc/releases/tag/v0.3.0

We treat RC tags as frozen in SBI spec because no functional changes are done in SBI spec after it is tagged as RC. We only do typo fixes and clarifications on SBI spec RC release.

Treating the 0.3.0-rc1 as frozen as soon as it's released is a terrifying policy: some of the fixes I sent in after I saw rc1 released change the actual meaning of the text, even if they were meant to change them to what I thought the intended meaning was supposed to be. That means the actual text of 0.3.0-rc1 and 0.3.0 conflict with each other. Given that frozen comes with a guarntee of backwards compatibility, does that mean that the behavior allowed by 0.3.0-rc1 is compliant with the SBI, even if it was likely just allowed by a wording mistake?

If you're going to freeze things at rc1 then you really need to be quite explicit about that, as generally the point of RCs is to elicit review/testing. Looks like I was the only person to have provided any review, so I guess I was the only one who assumed "We don't expect any significant functional changes. We will wait for any further feedback and release the official v0.3 in a month or so." actually meant "this is frozen".

Quoted 1 line

Can you take this patch for Linux-5.14 ??

Quoted 8 lines
Quoted 3 lines

No, sorry, it's way too late for that. Please be specific about when you freeze specifications in the future, so we can all stay on the same page.

I went and talked to Krste, and he says that there's a whole process for freezing extensions that this hasn't gone through. They don't have anything written down that I can point to, but can you guys please just get on the same page about this? It seems like every time I talk to

Absolutely. The freezing extensions process is documented right now[1] but that is only meant
for ISA/hardware/platform specifications. There is no process defined for a SBI specification which is purely
a software specification because SBI specification release processes(v0.1 and v0.2) predate these documented processes. The SBI specification is owned by the Platform HSC which falls under the purview of software HC.
You can see a detailed chart of the RVI organization at [2]. All the aspects of SBI specification are discussed
in platform meetings[3] and frozen only after public review[4] and approval from the platform working group
and the software HC. The official SBI specification(v0.3) will also be available along with all other RISC-V specifications
once they figure out how to structure non-ISA specifications.

I have cc'd Kumar (chair of the Platform HSC) and Philip (chair of the software HC) in case they want to add anything.
I was not aware of the fact that Krste/Andrew are not aware of the progress of the SBI specification.
I will raise this topic during the next meeting and make sure they are in the loop as well.

Quoted 4 lines

someone from the RISC-V foundation I get a conflicting description of what's going on, and I'm entirely out of patience when it comes to getting blamed for all the chaos over there.

I agree the RVI process has not been very clear in the past. However, that has changed a lot in recent times thanks to Mark and other working group chairs. I don't think anybody is blaming you for the delay in ratification of the RVI specifications.
There is a clear path for all the specifications to be ratified e.g. the AIA and H extensions are planned to be frozen by the end of this year.
Let me know if you want to see the timeline of each specification and I can point you to the correct sheet.

Quoted 4 lines

[1] https://docs.google.com/presentation/d/1nQ5uFb39KA6gvUi5SReWfIQSiRN7hp6z7ZPfctE4mKk/edit#slide=id.ga0a994c3c8_0_6
[2] https://docs.google.com/presentation/d/1eEVuu6lRZd9iiDnZQSZME7Q7svtTG3pGIKHPmZ79B8E/edit#slide=id.ga275a504df_0_9
[3] https://github.com/riscv/riscv-platform-specs/wiki
[4] https://lists.riscv.org/g/tech-unixplatformspec/message/1042

https://github.com/riscv-non-isa/riscv-sbi-doc/releases/tag/v0.3.1-rc1
has:

Quoted 7 lines

"This tag the release candidate of version 0.3.1 of the RISC-V SBI specification. It doesn't have any significant changes other than typos. A new release is created to adapt the ratification process for non-ISA specifications defined by RVI recently."

Has this patch to wait until release 0.3.1 of the SBI specification is ratified?

Not ratified, Frozen (officially as per newly defined RVI process)

Quoted 2 lines

What is the timeline?

Probably, a few more weeks. We have already presented it to the chairs meeting and got it approved.
We are waiting for the TSC votes and some conclusion about the version of frozen->ratified spec.
RVI wants all the specifications to start with 1.0 while SBI specification has legacy version numbers.

The specification will be frozen and sent to the public review once those items are resolved.

Quoted 2 lines

Could you, please, provide a link the the non-ISA ratification process description.

Here is the template for every non-ISA specification has to follow
https://docs.google.com/document/d/1-DZQ-5IzQlG1PLX8acic9SaLaU8SQIHRYewBrE1Zoxo/edit?usp=sharing

Here is the folder with all other specifications in pipeline
https://drive.google.com/drive/u/1/folders/11NFLODgCxTTORNrPhNT15cHV-fZLFn4U

Quoted 4 lines

Best regards

Heinrich

--
Regards,
Atish

#13 lore raw

Re: [PATCH v7 1/1] RISC-V: Use SBI SRST extension when available

Quoted 120 lines · Atish Patra
Quoted 118 lines · Heinrich Schuchardt
Quoted 103 lines · Atish Patra
Quoted 56 lines · Palmer Dabbelt
Quoted 54 lines · Palmer Dabbelt
Quoted 27 lines · Anup Patel

On 08/07/21, 9:22 AM, "Anup Patel" <[email protected]> wrote:

On Wed, Jul 7, 2021 at 1:57 AM Palmer Dabbelt <[email protected]> wrote:
>
> On Mon, 21 Jun 2021 21:46:46 PDT (-0700), [email protected] wrote:
> > Hi Palmer,
> >
> > On Wed, Jun 9, 2021 at 5:43 PM Anup Patel <[email protected]> wrote:
> >>
> >> The SBI SRST extension provides a standard way to poweroff and > >> reboot the system irrespective to whether Linux RISC-V S-mode > >> is running natively (HS-mode) or inside Guest/VM (VS-mode). > >>
> >> The SBI SRST extension is available in the SBI v0.3 specification. > >> (Refer, https://github.com/riscv/riscv-sbi-doc/releases/tag/v0.3.0-rc1)
> >
> > Can you please consider this patch for Linux-5.14-rc1 ?
> >
> > The SBI v0.3 spec is already frozen and this patch has been
> > floating on LKML for quite a few months now.
>
> I didn't realize that SBI-0.3 had been frozed. That link is to a RC, > the cooresponding v0.3.0 tag isn't in that repo. Can you give me a > pointer to the frozen spec?

Quoted 6 lines

Here's the link to SBI v0.3.0 tag:
https://github.com/riscv/riscv-sbi-doc/releases/tag/v0.3.0

We treat RC tags as frozen in SBI spec because no functional changes are done in SBI spec after it is tagged as RC. We only do typo fixes and clarifications on SBI spec RC release.

Treating the 0.3.0-rc1 as frozen as soon as it's released is a terrifying policy: some of the fixes I sent in after I saw rc1 released change the actual meaning of the text, even if they were meant to change them to what I thought the intended meaning was supposed to be. That means the actual text of 0.3.0-rc1 and 0.3.0 conflict with each other. Given that frozen comes with a guarntee of backwards compatibility, does that mean that the behavior allowed by 0.3.0-rc1 is compliant with the SBI, even if it was likely just allowed by a wording mistake?

If you're going to freeze things at rc1 then you really need to be quite explicit about that, as generally the point of RCs is to elicit review/testing. Looks like I was the only person to have provided any review, so I guess I was the only one who assumed "We don't expect any significant functional changes. We will wait for any further feedback and release the official v0.3 in a month or so." actually meant "this is frozen".

Quoted 1 line

Can you take this patch for Linux-5.14 ??

Quoted 8 lines
Quoted 3 lines

No, sorry, it's way too late for that. Please be specific about when you freeze specifications in the future, so we can all stay on the same page.

I went and talked to Krste, and he says that there's a whole process for freezing extensions that this hasn't gone through. They don't have anything written down that I can point to, but can you guys please just get on the same page about this? It seems like every time I talk to

Absolutely. The freezing extensions process is documented right now[1] but that is only meant
for ISA/hardware/platform specifications. There is no process defined for a SBI specification which is purely
a software specification because SBI specification release processes(v0.1 and v0.2) predate these documented processes. The SBI specification is owned by the Platform HSC which falls under the purview of software HC.
You can see a detailed chart of the RVI organization at [2]. All the aspects of SBI specification are discussed
in platform meetings[3] and frozen only after public review[4] and approval from the platform working group
and the software HC. The official SBI specification(v0.3) will also be available along with all other RISC-V specifications
once they figure out how to structure non-ISA specifications.

I have cc'd Kumar (chair of the Platform HSC) and Philip (chair of the software HC) in case they want to add anything.
I was not aware of the fact that Krste/Andrew are not aware of the progress of the SBI specification.
I will raise this topic during the next meeting and make sure they are in the loop as well.

Quoted 4 lines

someone from the RISC-V foundation I get a conflicting description of what's going on, and I'm entirely out of patience when it comes to getting blamed for all the chaos over there.

I agree the RVI process has not been very clear in the past. However, that has changed a lot in recent times thanks to Mark and other working group chairs. I don't think anybody is blaming you for the delay in ratification of the RVI specifications.
There is a clear path for all the specifications to be ratified e.g. the AIA and H extensions are planned to be frozen by the end of this year.
Let me know if you want to see the timeline of each specification and I can point you to the correct sheet.

Quoted 4 lines

[1] https://docs.google.com/presentation/d/1nQ5uFb39KA6gvUi5SReWfIQSiRN7hp6z7ZPfctE4mKk/edit#slide=id.ga0a994c3c8_0_6
[2] https://docs.google.com/presentation/d/1eEVuu6lRZd9iiDnZQSZME7Q7svtTG3pGIKHPmZ79B8E/edit#slide=id.ga275a504df_0_9
[3] https://github.com/riscv/riscv-platform-specs/wiki
[4] https://lists.riscv.org/g/tech-unixplatformspec/message/1042

https://github.com/riscv-non-isa/riscv-sbi-doc/releases/tag/v0.3.1-rc1
has:

"This tag the release candidate of version 0.3.1 of the RISC-V SBI specification. It doesn't have any significant changes other than typos. A new release is created to adapt the ratification process for non-ISA specifications defined by RVI recently."

Quoted 7 lines
Quoted 2 lines

Has this patch to wait until release 0.3.1 of the SBI specification is ratified?

Not ratified, Frozen (officially as per newly defined RVI process)

Quoted 2 lines

What is the timeline?

According to this mail, the "SBI specification is considered as frozen now as per the RISC-V International policies":
http://lists.infradead.org/pipermail/opensbi/2022-January/002357.html

Therefore can we get this patch queued for 5.17-rc1?

Thanks,
Aurelien

Signature · 2 lines
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
[email protected]                 http://www.aurel32.net
maintainer
#14 lore raw

Re: [PATCH v7 1/1] RISC-V: Use SBI SRST extension when available

Quoted 126 lines · On Tue, 11 Jan 2022 01:32:24 PST (-0800), [email protected] wrote:
Quoted 125 lines · Atish Patra
Quoted 113 lines · Heinrich Schuchardt
Quoted 103 lines · Atish Patra
Quoted 56 lines · Palmer Dabbelt
Quoted 54 lines · Palmer Dabbelt
Quoted 27 lines · Anup Patel

On 08/07/21, 9:22 AM, "Anup Patel" <[email protected]> wrote:

On Wed, Jul 7, 2021 at 1:57 AM Palmer Dabbelt <[email protected]> wrote:
>
> On Mon, 21 Jun 2021 21:46:46 PDT (-0700), [email protected] wrote:
> > Hi Palmer,
> >
> > On Wed, Jun 9, 2021 at 5:43 PM Anup Patel <[email protected]> wrote:
> >>
> >> The SBI SRST extension provides a standard way to poweroff and > >> reboot the system irrespective to whether Linux RISC-V S-mode > >> is running natively (HS-mode) or inside Guest/VM (VS-mode). > >>
> >> The SBI SRST extension is available in the SBI v0.3 specification. > >> (Refer, https://github.com/riscv/riscv-sbi-doc/releases/tag/v0.3.0-rc1)
> >
> > Can you please consider this patch for Linux-5.14-rc1 ?
> >
> > The SBI v0.3 spec is already frozen and this patch has been
> > floating on LKML for quite a few months now.
>
> I didn't realize that SBI-0.3 had been frozed. That link is to a RC, > the cooresponding v0.3.0 tag isn't in that repo. Can you give me a > pointer to the frozen spec?

Quoted 6 lines

Here's the link to SBI v0.3.0 tag:
https://github.com/riscv/riscv-sbi-doc/releases/tag/v0.3.0

We treat RC tags as frozen in SBI spec because no functional changes are done in SBI spec after it is tagged as RC. We only do typo fixes and clarifications on SBI spec RC release.

Treating the 0.3.0-rc1 as frozen as soon as it's released is a terrifying policy: some of the fixes I sent in after I saw rc1 released change the actual meaning of the text, even if they were meant to change them to what I thought the intended meaning was supposed to be. That means the actual text of 0.3.0-rc1 and 0.3.0 conflict with each other. Given that frozen comes with a guarntee of backwards compatibility, does that mean that the behavior allowed by 0.3.0-rc1 is compliant with the SBI, even if it was likely just allowed by a wording mistake?

If you're going to freeze things at rc1 then you really need to be quite explicit about that, as generally the point of RCs is to elicit review/testing. Looks like I was the only person to have provided any review, so I guess I was the only one who assumed "We don't expect any significant functional changes. We will wait for any further feedback and release the official v0.3 in a month or so." actually meant "this is frozen".

Quoted 1 line

Can you take this patch for Linux-5.14 ??

Quoted 8 lines
Quoted 3 lines

No, sorry, it's way too late for that. Please be specific about when you freeze specifications in the future, so we can all stay on the same page.

I went and talked to Krste, and he says that there's a whole process for freezing extensions that this hasn't gone through. They don't have anything written down that I can point to, but can you guys please just get on the same page about this? It seems like every time I talk to

Absolutely. The freezing extensions process is documented right now[1] but that is only meant
for ISA/hardware/platform specifications. There is no process defined for a SBI specification which is purely
a software specification because SBI specification release processes(v0.1 and v0.2) predate these documented processes. The SBI specification is owned by the Platform HSC which falls under the purview of software HC.
You can see a detailed chart of the RVI organization at [2]. All the aspects of SBI specification are discussed
in platform meetings[3] and frozen only after public review[4] and approval from the platform working group
and the software HC. The official SBI specification(v0.3) will also be available along with all other RISC-V specifications
once they figure out how to structure non-ISA specifications.

I have cc'd Kumar (chair of the Platform HSC) and Philip (chair of the software HC) in case they want to add anything.
I was not aware of the fact that Krste/Andrew are not aware of the progress of the SBI specification.
I will raise this topic during the next meeting and make sure they are in the loop as well.

Quoted 4 lines

someone from the RISC-V foundation I get a conflicting description of what's going on, and I'm entirely out of patience when it comes to getting blamed for all the chaos over there.

I agree the RVI process has not been very clear in the past. However, that has changed a lot in recent times thanks to Mark and other working group chairs. I don't think anybody is blaming you for the delay in ratification of the RVI specifications.
There is a clear path for all the specifications to be ratified e.g. the AIA and H extensions are planned to be frozen by the end of this year.
Let me know if you want to see the timeline of each specification and I can point you to the correct sheet.

Quoted 4 lines

[1] https://docs.google.com/presentation/d/1nQ5uFb39KA6gvUi5SReWfIQSiRN7hp6z7ZPfctE4mKk/edit#slide=id.ga0a994c3c8_0_6
[2] https://docs.google.com/presentation/d/1eEVuu6lRZd9iiDnZQSZME7Q7svtTG3pGIKHPmZ79B8E/edit#slide=id.ga275a504df_0_9
[3] https://github.com/riscv/riscv-platform-specs/wiki
[4] https://lists.riscv.org/g/tech-unixplatformspec/message/1042

https://github.com/riscv-non-isa/riscv-sbi-doc/releases/tag/v0.3.1-rc1
has:

Quoted 7 lines

"This tag the release candidate of version 0.3.1 of the RISC-V SBI specification. It doesn't have any significant changes other than typos. A new release is created to adapt the ratification process for non-ISA specifications defined by RVI recently."

Has this patch to wait until release 0.3.1 of the SBI specification is ratified?

Not ratified, Frozen (officially as per newly defined RVI process)

Quoted 8 lines
Quoted 2 lines
Quoted 2 lines

What is the timeline?

According to this mail, the "SBI specification is considered as frozen now as per the RISC-V International policies":
http://lists.infradead.org/pipermail/opensbi/2022-January/002357.html

Therefore can we get this patch queued for 5.17-rc1?

Thanks. Atish had actually pointed this out last night, but I wasn't at the computer. This in on for-next.