Skip to contentSkip to conversation

riscv: Add riscv_force_qspinlock for early_param

PATCH In review [email protected] 2 participants 4 messages Dec 14, 2024 – Feb 26, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 riscv: Add riscv_force_qspinlock for early_param

From: Guo Ren <[email protected]>

When CONFIG_RISCV_COMBO_SPINLOCKS is enabled, permit qspinlock force enabled. See the Kconfig entry for RISCV_COMBO_SPINLOCKS.

---
 Documentation/admin-guide/kernel-parameters.txt |  5 +++++
 arch/riscv/kernel/setup.c                       | 13 ++++++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)
Documentation/admin-guide/kernel-parameters.txt +5 -0
index 3872bc6ec49d..43d0df2922b2 100644
@@ -5887,6 +5887,11 @@
 			[KNL] Disable ring 3 MONITOR/MWAIT feature on supported
 			CPUs.
 
+	riscv_force_qspinlock [RISCV, EARLY]
+			When CONFIG_RISCV_COMBO_SPINLOCKS is enabled, permit
+			qspinlock force enabled. See the Kconfig entry for
+			RISCV_COMBO_SPINLOCKS.
+
 	riscv_isa_fallback [RISCV,EARLY]
 			When CONFIG_RISCV_ISA_FALLBACK is not enabled, permit
 			falling back to detecting extension support by parsing
arch/riscv/kernel/setup.c +12 -1
index 45010e71df86..74b13bc64c9c 100644
@@ -247,6 +247,15 @@ static void __init parse_dtb(void)
 #if defined(CONFIG_RISCV_COMBO_SPINLOCKS)
 DEFINE_STATIC_KEY_TRUE(qspinlock_key);
 EXPORT_SYMBOL(qspinlock_key);
+
+static bool force_qspinlock;
+
+static int __init riscv_force_qspinlock(char *p)
+{
+	force_qspinlock = true;
+	return 0;
+}
+early_param("riscv_force_qspinlock", riscv_force_qspinlock);
 #endif
 
 static void __init riscv_spinlock_init(void)
@@ -267,7 +276,9 @@ static void __init riscv_spinlock_init(void)
 		using_ext = "using Ziccrse";
 	}
 #if defined(CONFIG_RISCV_COMBO_SPINLOCKS)
-	else {
+	else if (force_qspinlock) {
+		using_ext = "force";
+	} else {
 		static_branch_disable(&qspinlock_key);
 		pr_info("Ticket spinlock: enabled\n");
 		return;
Signature · 1 line
2.40.1
#1 lore raw

Hi Guo,

Quoted 49 lines · On 14/12/2024 05:35, [email protected] wrote:

From: Guo Ren <[email protected]>

When CONFIG_RISCV_COMBO_SPINLOCKS is enabled, permit qspinlock force enabled. See the Kconfig entry for RISCV_COMBO_SPINLOCKS.

---
  Documentation/admin-guide/kernel-parameters.txt |  5 +++++
  arch/riscv/kernel/setup.c                       | 13 ++++++++++++-
  2 files changed, 17 insertions(+), 1 deletion(-)
Documentation/admin-guide/kernel-parameters.txt +5 -0
index 3872bc6ec49d..43d0df2922b2 100644
@@ -5887,6 +5887,11 @@
  			[KNL] Disable ring 3 MONITOR/MWAIT feature on supported
  			CPUs.
 
+	riscv_force_qspinlock [RISCV, EARLY]
+			When CONFIG_RISCV_COMBO_SPINLOCKS is enabled, permit
+			qspinlock force enabled. See the Kconfig entry for
+			RISCV_COMBO_SPINLOCKS.
+
  	riscv_isa_fallback [RISCV,EARLY]
  			When CONFIG_RISCV_ISA_FALLBACK is not enabled, permit
  			falling back to detecting extension support by parsing
arch/riscv/kernel/setup.c +9 -0
index 45010e71df86..74b13bc64c9c 100644
@@ -247,6 +247,15 @@ static void __init parse_dtb(void)
  #if defined(CONFIG_RISCV_COMBO_SPINLOCKS)
  DEFINE_STATIC_KEY_TRUE(qspinlock_key);
  EXPORT_SYMBOL(qspinlock_key);
+
+static bool force_qspinlock;
+
+static int __init riscv_force_qspinlock(char *p)
+{
+	force_qspinlock = true;
+	return 0;
+}
+early_param("riscv_force_qspinlock", riscv_force_qspinlock);
  #endif
 
  static void __init riscv_spinlock_init(void)

arch/riscv/kernel/setup.c static void __init riscv_spinlock_init(void) · line 284

Quoted 10 lines
arch/riscv/kernel/setup.c +3 -1
@@ -267,7 +276,9 @@ static void __init riscv_spinlock_init(void)
  		using_ext = "using Ziccrse";
  	}
  #if defined(CONFIG_RISCV_COMBO_SPINLOCKS)
-	else {
+	else if (force_qspinlock) {
+		using_ext = "force";
+	} else {
  		static_branch_disable(&qspinlock_key);
  		pr_info("Ticket spinlock: enabled\n");
  		return;

What's the use case for this early param? To me that implies that a platform may have another extension which would allow the usage of qspinlock, so why not listing it in riscv_spinlock_init() instead?

Thanks,

Alex

author
#2 lore raw
Quoted 51 lines · Alexandre Ghiti

Hi Guo,

Quoted 47 lines · On 14/12/2024 05:35, [email protected] wrote:

From: Guo Ren <[email protected]>

When CONFIG_RISCV_COMBO_SPINLOCKS is enabled, permit qspinlock force enabled. See the Kconfig entry for RISCV_COMBO_SPINLOCKS.

---
  Documentation/admin-guide/kernel-parameters.txt |  5 +++++
  arch/riscv/kernel/setup.c                       | 13 ++++++++++++-
  2 files changed, 17 insertions(+), 1 deletion(-)
Documentation/admin-guide/kernel-parameters.txt +5 -0
index 3872bc6ec49d..43d0df2922b2 100644
@@ -5887,6 +5887,11 @@
                      [KNL] Disable ring 3 MONITOR/MWAIT feature on supported
                      CPUs.
 
+     riscv_force_qspinlock [RISCV, EARLY]
+                     When CONFIG_RISCV_COMBO_SPINLOCKS is enabled, permit
+                     qspinlock force enabled. See the Kconfig entry for
+                     RISCV_COMBO_SPINLOCKS.
+
      riscv_isa_fallback [RISCV,EARLY]
                      When CONFIG_RISCV_ISA_FALLBACK is not enabled, permit
                      falling back to detecting extension support by parsing
arch/riscv/kernel/setup.c +9 -0
index 45010e71df86..74b13bc64c9c 100644
@@ -247,6 +247,15 @@ static void __init parse_dtb(void)
  #if defined(CONFIG_RISCV_COMBO_SPINLOCKS)
  DEFINE_STATIC_KEY_TRUE(qspinlock_key);
  EXPORT_SYMBOL(qspinlock_key);
+
+static bool force_qspinlock;
+
+static int __init riscv_force_qspinlock(char *p)
+{
+     force_qspinlock = true;
+     return 0;
+}
+early_param("riscv_force_qspinlock", riscv_force_qspinlock);
  #endif
 
Quoted 16 lines

arch/riscv/kernel/setup.c static void __init riscv_spinlock_init(void) · line 284

Quoted 12 lines
arch/riscv/kernel/setup.c +3 -1
  static void __init riscv_spinlock_init(void)
@@ -267,7 +276,9 @@ static void __init riscv_spinlock_init(void)
              using_ext = "using Ziccrse";
      }
  #if defined(CONFIG_RISCV_COMBO_SPINLOCKS)
-     else {
+     else if (force_qspinlock) {
+             using_ext = "force";
+     } else {
              static_branch_disable(&qspinlock_key);
              pr_info("Ticket spinlock: enabled\n");
              return;

What's the use case for this early param? To me that implies that a platform may have another extension which would allow the usage of

We want to use it for sg2042 & th1520. No new extension was introduced, and some micro-architecture could give LR/SC implementation a forward progress guarantee more than the spec required.

Quoted 1 line

qspinlock, so why not listing it in riscv_spinlock_init() instead?

List all platforms in riscv_spinlock_init is noisy, maybe give a qspinlock param in cmdline, and they could put it in their boot args.

Quoted 5 lines

Thanks,

Alex

Signature · 2 lines
Best Regards
 Guo Ren
#3 lore raw

Hi Guo,

First sorry I did not follow up on this patch.

Quoted 66 lines · Guo Ren
Quoted 50 lines · Alexandre Ghiti

Hi Guo,

Quoted 47 lines · On 14/12/2024 05:35, [email protected] wrote:

From: Guo Ren <[email protected]>

When CONFIG_RISCV_COMBO_SPINLOCKS is enabled, permit qspinlock force enabled. See the Kconfig entry for RISCV_COMBO_SPINLOCKS.

---
   Documentation/admin-guide/kernel-parameters.txt |  5 +++++
   arch/riscv/kernel/setup.c                       | 13 ++++++++++++-
   2 files changed, 17 insertions(+), 1 deletion(-)
Documentation/admin-guide/kernel-parameters.txt +5 -0
index 3872bc6ec49d..43d0df2922b2 100644
@@ -5887,6 +5887,11 @@
                       [KNL] Disable ring 3 MONITOR/MWAIT feature on supported
                       CPUs.
 
+     riscv_force_qspinlock [RISCV, EARLY]
+                     When CONFIG_RISCV_COMBO_SPINLOCKS is enabled, permit
+                     qspinlock force enabled. See the Kconfig entry for
+                     RISCV_COMBO_SPINLOCKS.
+
       riscv_isa_fallback [RISCV,EARLY]
                       When CONFIG_RISCV_ISA_FALLBACK is not enabled, permit
                       falling back to detecting extension support by parsing
arch/riscv/kernel/setup.c +9 -0
index 45010e71df86..74b13bc64c9c 100644
@@ -247,6 +247,15 @@ static void __init parse_dtb(void)
   #if defined(CONFIG_RISCV_COMBO_SPINLOCKS)
   DEFINE_STATIC_KEY_TRUE(qspinlock_key);
   EXPORT_SYMBOL(qspinlock_key);
+
+static bool force_qspinlock;
+
+static int __init riscv_force_qspinlock(char *p)
+{
+     force_qspinlock = true;
+     return 0;
+}
+early_param("riscv_force_qspinlock", riscv_force_qspinlock);
   #endif
 
Quoted 15 lines

arch/riscv/kernel/setup.c static void __init riscv_spinlock_init(void) · line 284

Quoted 12 lines
arch/riscv/kernel/setup.c +3 -1
   static void __init riscv_spinlock_init(void)
@@ -267,7 +276,9 @@ static void __init riscv_spinlock_init(void)
               using_ext = "using Ziccrse";
       }
   #if defined(CONFIG_RISCV_COMBO_SPINLOCKS)
-     else {
+     else if (force_qspinlock) {
+             using_ext = "force";
+     } else {
               static_branch_disable(&qspinlock_key);
               pr_info("Ticket spinlock: enabled\n");
               return;

What's the use case for this early param? To me that implies that a platform may have another extension which would allow the usage of

Quoted 4 lines

We want to use it for sg2042 & th1520. No new extension was introduced, and some micro-architecture could give LR/SC implementation a forward progress guarantee more than the spec required.

But then those platforms support Ziccrse which is enough to use qspinlocks right?

Thanks,

Alex

Quoted 10 lines
Quoted 2 lines

qspinlock, so why not listing it in riscv_spinlock_init() instead?

List all platforms in riscv_spinlock_init is noisy, maybe give a qspinlock param in cmdline, and they could put it in their boot args.

Quoted 4 lines

Thanks,

Alex