The riscv server soc requirements [1] dictates in rule "IOM_200" that
the IOMMU must have at least 4 event counters.  As it stands today we're
creating an iommu-sys device with RISCV_IOMMU_IOCOUNT_NUM (31) counters.

Following the design of setting just the minimal spec requirements, set
hpm-counters to 4.

[1] 
https://docs.riscv.org/reference/server-soc/v1.0/server_soc_requirements.html

Signed-off-by: Daniel Henrique Barboza <[email protected]>
---
 hw/riscv/server_platform_ref.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/riscv/server_platform_ref.c b/hw/riscv/server_platform_ref.c
index e9536515da..ea24720a08 100644
--- a/hw/riscv/server_platform_ref.c
+++ b/hw/riscv/server_platform_ref.c
@@ -67,6 +67,7 @@
 #define SYSCON_POWEROFF                        0x2
 
 #define RVSERVER_PLATFORM_BUS_NUM_IRQS         8
+#define RVSERVER_IOMMU_HPM_COUNTERS            4
 
 #define TYPE_RISCV_SERVER_REF_MACHINE MACHINE_TYPE_NAME("riscv-server-ref")
 OBJECT_DECLARE_SIMPLE_TYPE(RISCVServerRefMachineState, 
RISCV_SERVER_REF_MACHINE)
@@ -639,6 +640,9 @@ static void rvserver_ref_machine_init(MachineState *machine)
     iommu_sys = riscv_create_iommu_sys(mmio_irqchip,
                                        s->memmap[RVSERVER_IOMMU_SYS].base,
                                        IOMMU_SYS_IRQ, false);
+
+    object_property_set_int(OBJECT(iommu_sys), "hpm-counters",
+                            RVSERVER_IOMMU_HPM_COUNTERS, &error_abort);
     sysbus_realize_and_unref(SYS_BUS_DEVICE(iommu_sys), &error_fatal);
 
     s->machine_done.notify = rvserver_ref_machine_done;
-- 
2.43.0


Reply via email to