Skip to contentSkip to conversation

RISC-V: Add support for ACPI RQSC table

PATCH New Drew Fustini 1 participant 3 messages Nov 30 RISC-V

lore
Share & tools
lore
#0 lore raw

v3 cover RISC-V: Add support for ACPI RQSC table

Add support for the ACPI RISC-V Quality of Service Controllers (RQSC) table [1] that describes the CBQRI controllers [2] present in a system. A capacity controller is described by the PPTT Cache ID of the cache it backs. A bandwidth controller is described by the SRAT proximity domain of its NUMA node.

This series depends on:
- "riscv: implement Ssqosid extension and CBQRI controllers" v9 [3]
- "RISC-V: ACPI: Add PPTT support" v2 from Sunil [4]
Note: patch 2 has a conflict in include/hw/riscv/virt.h
when applied on riscv-to-apply.next. It is resolved in the branch [9].
- "hw/acpi: Build PPTT rev 3 with cache IDs for MPAM cross-references" from Jinjie's MPAM series [5]
Note: bios-tables-test fails on the riscv64 PPTT golden file
as this patch does not update it.

This series with its dependencies applied is available as a branch [9].

RQSC describes a capacity controller by the PPTT Cache ID of its cache, so this series needs the virt machine to describe caches in the PPTT [4]. Alistair has questioned describing caches on virt [6], so I am not sure that virt is the right machine for this series. I would appreciate feedback on which machine it should target.

Tested with the Linux series [7] at the tip of its b4/ssqosid-cbqri-rqsc branch [8], with this configuration:

  Base addr  Spacing
  0x4820000  4KB  Cluster 0 L2 cache controller
  0x4821000  4KB  Cluster 1 L2 cache controller
  0x4828000  4KB  Memory controller 0
  0x482b000  4KB  Shared L3 cache controller
  qemu-system-riscv64 \
    -M virt,pflash0=pflash0,pflash1=pflash1,aia=aplic-imsic,smp-cache.0.cache=l1d,smp-cache.0.topology=core,smp-cache.1.cache=l1i,smp-cache.1.topology=core,smp-cache.2.cache=l2,smp-cache.2.topology=cluster,smp-cache.3.cache=l3,smp-cache.3.topology=socket \
    -smp cpus=8,sockets=1,clusters=2,cores=4,threads=1 \
    -blockdev node-name=pflash0,driver=file,read-only=on,filename=RISCV_VIRT_CODE.fd \
    -blockdev node-name=pflash1,driver=file,filename=RISCV_VIRT_VARS.fd \
    -device riscv.cbqri.capacity,max_mcids=256,max_rcids=64,ncblks=12,alloc_op_flush_rcid=false,mon_op_config_event=false,mon_op_read_counter=false,mon_evt_id_none=false,mon_evt_id_occupancy=false,mmio_base=0x04820000 \
    -device riscv.cbqri.capacity,max_mcids=256,max_rcids=64,ncblks=12,alloc_op_flush_rcid=false,mon_op_config_event=false,mon_op_read_counter=false,mon_evt_id_none=false,mon_evt_id_occupancy=false,mmio_base=0x04821000 \
    -device riscv.cbqri.capacity,max_mcids=256,max_rcids=64,ncblks=16,cache_level=3,mmio_base=0x0482b000 \
    -device riscv.cbqri.bandwidth,max_mcids=256,max_rcids=64,nbwblks=1024,mrbwb=819,mmio_base=0x04828000

Changes in v3:
- Rebase on Ssqosid and CBQRI v9
- Add a custom PropertyInfo for cache_level (Daniel)
- Remove the redundant strcmp() from the get_details helpers (Daniel)
- Link to v2: https://lore.kernel.org/qemu-devel/[email protected]/

Changes in v2:
- Drop the RFC prefix as RQSC v1.0 is ratified
- Rebase on Sunil's PPTT series and Jinjie's PPTT Cache ID patch
- Add cache_level and node properties to the CBQRI controllers
- Use the PPTT Cache ID and the SRAT proximity domain as the resource
IDs instead of the MMIO address
- Only build the table when CBQRI controllers are present
- Set the table revision to 1
- Make RCID Count and MCID Count 2 bytes each
- Add the Bandwidth per Block field to memory resources
- Make RISCV_VIRT select RISCV_CBQRI
- Link to v1: https://lore.kernel.org/qemu-devel/[email protected]/

[1] https://github.com/riscv-non-isa/riscv-rqsc/releases/tag/v1.0.0
[2] https://github.com/riscv-non-isa/riscv-cbqri/releases/tag/v1.0
[3] https://lore.kernel.org/qemu-devel/[email protected]/
[4] https://lore.kernel.org/qemu-devel/[email protected]/
[5] https://lore.kernel.org/qemu-devel/[email protected]/
[6] https://lore.kernel.org/qemu-devel/[email protected]/
[7] https://lore.kernel.org/all/[email protected]/
[8] https://github.com/tt-fustini/linux/tree/b4/ssqosid-cbqri-rqsc
[9] https://github.com/tt-fustini/qemu/tree/b4/riscv-rqsc

---
Drew Fustini (2):
hw/riscv: add cache_level and node properties to CBQRI controllers hw/riscv: add support for ACPI RQSC table

 hw/riscv/Kconfig           |   2 +-
 hw/riscv/cbqri_bandwidth.c |  24 ++++
 hw/riscv/cbqri_capacity.c  |  52 ++++++++
 hw/riscv/virt-acpi-build.c | 292 ++++++++++++++++++++++++++++++++++++++++++++-
 include/hw/riscv/cbqri.h   |  18 +++
 5 files changed, 386 insertions(+), 2 deletions(-)

---
base-commit: 269b271cc6d1633382bfc0d3d6edb5b927e797c6
change-id: 20260201-riscv-rqsc-ae806ee0a7aa
prerequisite-change-id: 20251229-riscv-ssqosid-cbqri-aee2271532ff:v9
prerequisite-patch-id: 7d1487071207ac8c9750af152baec0cfa80b704f
prerequisite-patch-id: 16a09d54969c1914ac65697e555c66c4a6464760
prerequisite-patch-id: 7d852a70275071c5b5cfce579bbb442cf5b4d456
prerequisite-patch-id: 6361057143117707a309b225a6e0d6a708e6f5ff
prerequisite-patch-id: b207082f77e5882c20a061cf415055b6832eef7c
prerequisite-patch-id: a5bcdb9d8fb235a45cae464f328c367b9de403bf
prerequisite-patch-id: 2dbcf1c229f9dbdcda165b199a5a455c187eb8f6
prerequisite-message-id: <[email protected]>
prerequisite-patch-id: 2ff76b9d66b52771c4f963d891f39a6a93fbe5b4
prerequisite-patch-id: 95682b479c131bd09f4bd68426554918e1d43075
prerequisite-patch-id: cca54a74db19c96cb4cf048393dc278d96edd905
prerequisite-patch-id: ee77339d6590704a4240b641ebfc2574f7f29ed5
prerequisite-patch-id: 2b50d0ab2b41d993906cdf0abbd2013192d6e411

Best regards,

Signature · 1 line
Drew Fustini <[email protected]>
#1 lore raw

PATCH v3 1/2 hw/riscv: add cache_level and node properties to CBQRI controllers

The ACPI RQSC table specifies which cache a capacity controller backs and which proximity domain a bandwidth controller serves.

Add a cache_level property to the capacity controller. It accepts 2 or 3 and defaults to 2. Add a node property to the bandwidth controller. It defaults to 0 and rejects a node the machine does not have.

---
 hw/riscv/cbqri_bandwidth.c | 13 +++++++++++++
 hw/riscv/cbqri_capacity.c  | 41 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+)
hw/riscv/cbqri_bandwidth.c +13 -0
index bd8cf2b50e4c..6c33d1738d27 100644
@@ -17,7 +17,9 @@
 #include "hw/core/sysbus.h"
 #include "migration/vmstate.h"
 #include "target/riscv/cpu.h"
+#include "hw/core/boards.h"
 #include "hw/riscv/cbqri.h"
+#include "system/numa.h"
 
 /* Property defaults, shared with riscv_cbqri_bc_caps_init() */
 #define BC_DEFAULT_MAX_MCIDS    256
@@ -139,6 +141,7 @@ typedef struct RiscvCbqriBandwidthState {
 
     uint16_t nbwblks;
     uint16_t mrbwb;
+    uint32_t node;
 
     bool supports_at_code;
 
@@ -542,12 +545,21 @@ static const MemoryRegionOps riscv_cbqri_bc_ops = {
 static void riscv_cbqri_bc_realize(DeviceState *dev, Error **errp)
 {
     RiscvCbqriBandwidthState *bc = RISCV_CBQRI_BC(dev);
+    MachineState *ms = MACHINE(qdev_get_machine());
+    unsigned int nb_nodes = ms->numa_state ? ms->numa_state->num_nodes : 0;
 
     if (!bc->mmio_base) {
         error_setg(errp, "mmio_base property not set");
         return;
     }
 
+    /* Without -numa there is a single implicit node 0. */
+    if (bc->node >= MAX(nb_nodes, 1)) {
+        error_setg(errp, "node %u out of range, %u NUMA node(s)",
+                   bc->node, MAX(nb_nodes, 1));
+        return;
+    }
+
     if (bc->nb_rcids == 0) {
         error_setg(errp, "max_rcids must be at least 1");
         return;
@@ -638,6 +650,7 @@ static const Property riscv_cbqri_bc_properties[] = {
                        BC_DEFAULT_NBWBLKS),
     DEFINE_PROP_UINT16("mrbwb", RiscvCbqriBandwidthState, mrbwb,
                        BC_DEFAULT_MRBWB),
+    DEFINE_PROP_UINT32("node", RiscvCbqriBandwidthState, node, 0),
 
     DEFINE_PROP_BOOL("at_code", RiscvCbqriBandwidthState,
                      supports_at_code, true),
hw/riscv/cbqri_capacity.c +41 -0

70 lines not on this page · raw message

Signature · 1 line
2.43.0
#2 lore raw

PATCH v3 2/2 hw/riscv: add support for ACPI RQSC table

In reply to Drew Fustini

Build the ACPI RISC-V Quality of Service Controllers (RQSC) table for the virt machine when CBQRI controllers are present. A capacity controller is described by the PPTT Cache ID of the cache it backs and a bandwidth controller by the SRAT proximity domain of its NUMA node.

Make RISCV_VIRT select RISCV_CBQRI as the table code calls into the CBQRI devices.

---
 hw/riscv/Kconfig           |   2 +-
 hw/riscv/cbqri_bandwidth.c |  11 ++
 hw/riscv/cbqri_capacity.c  |  11 ++
 hw/riscv/virt-acpi-build.c | 292 ++++++++++++++++++++++++++++++++++++++++++++-
 include/hw/riscv/cbqri.h   |  18 +++
 5 files changed, 332 insertions(+), 2 deletions(-)
hw/riscv/Kconfig +1 -1
index 983b90982549..0fb1f1f48685 100644
@@ -76,7 +76,7 @@ config RISCV_VIRT
     select ACPI
     select ACPI_PCI
     select RISCV_DEVICE_COMMON
-    imply RISCV_CBQRI
+    select RISCV_CBQRI
 
 config RISCV_SERVER_PLATFORM_REF
     bool
hw/riscv/cbqri_bandwidth.c +11 -0
index 6c33d1738d27..8f4247b2b72c 100644
@@ -760,4 +760,15 @@ DeviceState *riscv_cbqri_bc_create(hwaddr addr,
     return dev;
 }
 
+void riscv_cbqri_bc_get_details(DeviceState *ds, RqscController *rqsc)
+{
+    RiscvCbqriBandwidthState *bcs = RISCV_CBQRI_BC(ds);
+
+    rqsc->type = RQSC_CONTROLLER_TYPE_BANDWIDTH;
+    rqsc->mmio_base = bcs->mmio_base;
+    rqsc->rcid_count = bcs->nb_rcids;
+    rqsc->mcid_count = bcs->nb_mcids;
+    rqsc->node = bcs->node;
+}
+
 type_init(riscv_cbqri_bc_register_types)
hw/riscv/cbqri_capacity.c +11 -0
index 288f0b9e0d77..e91a62e3bd75 100644
@@ -809,4 +809,15 @@ DeviceState *riscv_cbqri_cc_create(hwaddr addr,
     return dev;
 }
 
+void riscv_cbqri_cc_get_details(DeviceState *ds, RqscController *rqsc)
+{
+    RiscvCbqriCapacityState *ccs = RISCV_CBQRI_CC(ds);
+
+    rqsc->type = RQSC_CONTROLLER_TYPE_CAPACITY;
+    rqsc->mmio_base = ccs->mmio_base;
+    rqsc->rcid_count = ccs->nb_rcids;
+    rqsc->mcid_count = ccs->nb_mcids;
+    rqsc->cache_level = ccs->cache_level;
+}
+
 type_init(riscv_cbqri_cc_register_types)
hw/riscv/virt-acpi-build.c +291 -1

319 lines not on this page · raw message

include/hw/riscv/cbqri.h +18 -0
index 10b64613599f..3a504cb8d0f3 100644
@@ -78,4 +78,22 @@ DeviceState *riscv_cbqri_cc_create(hwaddr addr,
                                    const RiscvCbqriCapacityCaps *caps);
 DeviceState *riscv_cbqri_bc_create(hwaddr addr,
                                    const RiscvCbqriBandwidthCaps *caps);
+
+/* RQSC QoS Controller Type */
+#define RQSC_CONTROLLER_TYPE_CAPACITY   0
+#define RQSC_CONTROLLER_TYPE_BANDWIDTH  1
+
+/* What the ACPI RQSC table reports about one CBQRI controller */
+typedef struct RqscController {
+    uint8_t type;           /* RQSC_CONTROLLER_TYPE_* */
+    uint64_t mmio_base;
+    uint16_t rcid_count;
+    uint16_t mcid_count;
+    uint8_t cache_level;    /* capacity controllers */
+    uint32_t node;          /* bandwidth controllers */
+} RqscController;
+
+void riscv_cbqri_bc_get_details(DeviceState *ds, RqscController *rqsc);
+void riscv_cbqri_cc_get_details(DeviceState *ds, RqscController *rqsc);
+
 #endif
Signature · 1 line
2.43.0