[PATCH RFC v3 07/11] RISC-V: QoS: enable resctrl support for Ssqosid

Drew Fustini fustini at kernel.org
Tue Apr 14 18:54:01 PDT 2026


Wire up the RISC-V QoS resctrl implementation:

Add a late_initcall that checks for the Ssqosid extension and, if
present, calls qos_resctrl_setup() to probe CBQRI controllers and
initialize the resctrl filesystem, then registers CPU hotplug callbacks.

Make CONFIG_RISCV_ISA_SSQOSID select ARCH_HAS_CPU_RESCTRL and
RESCTRL_FS, and depends on MISC_FILESYSTEMS.

Add qos_resctrl.o to the build when CONFIG_RISCV_ISA_SSQOSID is set.

Co-developed-by: Adrien Ricciardi <aricciardi at baylibre.com>
Signed-off-by: Adrien Ricciardi <aricciardi at baylibre.com>
Signed-off-by: Drew Fustini <fustini at kernel.org>
---
 arch/riscv/Kconfig             |  3 +++
 arch/riscv/kernel/qos/Makefile |  2 +-
 arch/riscv/kernel/qos/qos.c    | 32 ++++++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 92d2265a0c61..b2fef15b3d4f 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -597,7 +597,10 @@ config RISCV_ISA_SVNAPOT
 
 config RISCV_ISA_SSQOSID
 	bool "Ssqosid extension support for supervisor mode Quality of Service ID"
+	depends on MISC_FILESYSTEMS
 	default n
+	select ARCH_HAS_CPU_RESCTRL
+	select RESCTRL_FS
 	help
 	  Adds support for the Ssqosid ISA extension (Supervisor-mode
 	  Quality of Service ID).
diff --git a/arch/riscv/kernel/qos/Makefile b/arch/riscv/kernel/qos/Makefile
index 9f996263a86d..9ed0c13a854d 100644
--- a/arch/riscv/kernel/qos/Makefile
+++ b/arch/riscv/kernel/qos/Makefile
@@ -1,2 +1,2 @@
 # SPDX-License-Identifier: GPL-2.0
-obj-$(CONFIG_RISCV_ISA_SSQOSID) += qos.o
+obj-$(CONFIG_RISCV_ISA_SSQOSID) += qos.o qos_resctrl.o
diff --git a/arch/riscv/kernel/qos/qos.c b/arch/riscv/kernel/qos/qos.c
index a3c2b910e2e0..560607abf10a 100644
--- a/arch/riscv/kernel/qos/qos.c
+++ b/arch/riscv/kernel/qos/qos.c
@@ -1,8 +1,40 @@
 // SPDX-License-Identifier: GPL-2.0-only
+#include <linux/slab.h>
+#include <linux/err.h>
+#include <linux/cpu.h>
+#include <linux/cpumask.h>
+#include <linux/riscv_qos.h>
+
+#include <asm/csr.h>
 #include <asm/qos.h>
 
+#include "internal.h"
+
 /* cached value of srmcfg csr for each cpu */
 DEFINE_PER_CPU(u32, cpu_srmcfg);
 
 /* default srmcfg value for each cpu, set via resctrl cpu assignment */
 DEFINE_PER_CPU(u32, cpu_srmcfg_default);
+
+static int __init qos_arch_late_init(void)
+{
+	int err;
+
+	if (!riscv_isa_extension_available(NULL, SSQOSID))
+		return -ENODEV;
+
+	err = qos_resctrl_setup();
+	if (err)
+		return err;
+
+	err = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "qos:online",
+				qos_resctrl_online_cpu,
+				qos_resctrl_offline_cpu);
+	if (err < 0) {
+		resctrl_exit();
+		return err;
+	}
+
+	return 0;
+}
+late_initcall(qos_arch_late_init);

-- 
2.43.0




More information about the linux-riscv mailing list