From 0e400da642d2b9830b0d41b431dbf12cd7921b52 Mon Sep 17 00:00:00 2001 From: Michael Neuling Date: Thu, 9 Apr 2026 21:49:59 -0500 Subject: [PATCH 1/2] riscv: dts: tenstorrent: Add PMU node to blackhole for Linux perf support Add a riscv,pmu device tree node with SBI PMU event mappings for the SiFive X280 hardware performance counters. This enables OpenSBI to expose the SBI PMU extension, allowing Linux perf to use the 4 programmable counters (mhpmcounter3-6) across 3 event classes: instruction commit, microarchitectural, and memory system events. Event encodings are derived from the SiFive Tenstorrent X280 MC Manual (21G3.04.00) Table 13, section 3.10.5. Assisted-by: Claude:claude-opus-4-6[1m] Signed-off-by: Michael Neuling Reviewed-by: Drew Fustini Signed-off-by: Drew Fustini --- .../riscv/boot/dts/tenstorrent/blackhole.dtsi | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/arch/riscv/boot/dts/tenstorrent/blackhole.dtsi b/arch/riscv/boot/dts/tenstorrent/blackhole.dtsi index 6408810d8d80..5f709e45d9b2 100644 --- a/arch/riscv/boot/dts/tenstorrent/blackhole.dtsi +++ b/arch/riscv/boot/dts/tenstorrent/blackhole.dtsi @@ -77,6 +77,54 @@ cpu3_intc: interrupt-controller { }; }; + pmu { + compatible = "riscv,pmu"; + riscv,event-to-mhpmevent = + /* SBI_PMU_HW_CPU_CYCLES -> CPU cycles */ + <0x00001 0x00000000 0x0001>, + /* SBI_PMU_HW_INSTRUCTIONS -> Instructions executed */ + <0x00002 0x00000000 0x0004>, + /* SBI_PMU_HW_CACHE_REFERENCES -> I-cache/ITIM busy | D-cache/DTIM busy */ + <0x00003 0x00000000 0x1801>, + /* SBI_PMU_HW_CACHE_MISSES -> I-cache miss | D-cache miss */ + <0x00004 0x00000000 0x0302>, + /* SBI_PMU_HW_BRANCH_INSTRUCTIONS -> Conditional branch retired */ + <0x00005 0x00000000 0x4000>, + /* + * SBI_PMU_HW_BRANCH_MISSES -> + * Branch direction misprediction | Branch/jump target misprediction + */ + <0x00006 0x00000000 0x6001>, + /* L1D_READ_MISS -> Data cache miss or MMIO access */ + <0x10001 0x00000000 0x0202>, + /* L1D_WRITE_ACCESS -> Data cache write-back */ + <0x10002 0x00000000 0x0402>, + /* L1I_READ_MISS -> Instruction cache miss */ + <0x10009 0x00000000 0x0102>, + /* LL_READ_MISS -> UTLB miss */ + <0x10011 0x00000000 0x2002>, + /* DTLB_READ_MISS -> Data TLB miss */ + <0x10019 0x00000000 0x1002>, + /* ITLB_READ_MISS -> Instruction TLB miss */ + <0x10021 0x00000000 0x0802>; + riscv,event-to-mhpmcounters = + <0x00001 0x00001 0x01>, + <0x00002 0x00002 0x04>, + <0x00003 0x00006 0x78>, + <0x10001 0x10002 0x78>, + <0x10009 0x10009 0x78>, + <0x10011 0x10011 0x78>, + <0x10019 0x10019 0x78>, + <0x10021 0x10021 0x78>; + riscv,raw-event-to-mhpmcounters = + /* Class 0: Instruction Commit Events, bits 8-25 variant */ + <0x0 0x0 0xffffffff 0xfc0000ff 0x78>, + /* Class 1: Microarchitectural Events, bits 8-18 variant */ + <0x0 0x1 0xffffffff 0xfff800ff 0x78>, + /* Class 2: Memory System Events, bits 8-13 variant */ + <0x0 0x2 0xffffffff 0xffffc0ff 0x78>; + }; + soc { #address-cells = <2>; #size-cells = <2>; From 33583baeb1ba7d328e6a9775d889036900b74cdb Mon Sep 17 00:00:00 2001 From: Nicholas Piggin Date: Thu, 21 May 2026 10:06:33 -0700 Subject: [PATCH 2/2] dt-bindings: iommu: riscv: Add bindings for Tenstorrent RISC-V IOMMU Extend the binding to cover details specific to the Tenstorrent RISC-V IOMMU. In particular, a second register range is added which contains M-privileged registers, e.g., PMAs and PMPs. The RISC-V spec S-privileged registers remain in the first register range and are compatible with "riscv,iommu" so the Linux driver does not notice any difference, but the binding will be used by OpenSBI and potentially other M-mode software. Reviewed-by: Joel Stanley Acked-by: Conor Dooley Acked-by: Joerg Roedel Signed-off-by: Nicholas Piggin [fustini: fix dt_binding_check errors] Signed-off-by: Drew Fustini --- .../bindings/iommu/riscv,iommu.yaml | 59 ++++++++++++++++--- 1 file changed, 51 insertions(+), 8 deletions(-) diff --git a/Documentation/devicetree/bindings/iommu/riscv,iommu.yaml b/Documentation/devicetree/bindings/iommu/riscv,iommu.yaml index d4838c3b3741..f83efb3ee000 100644 --- a/Documentation/devicetree/bindings/iommu/riscv,iommu.yaml +++ b/Documentation/devicetree/bindings/iommu/riscv,iommu.yaml @@ -32,22 +32,35 @@ properties: # should be specified along with 'reg' property providing MMIO location. compatible: oneOf: - - items: + - description: Platform (non-PCIe) IOMMU implementations + items: - enum: - qemu,riscv-iommu + - tenstorrent,riscv-iommu - const: riscv,iommu - - items: + - description: PCIe IOMMU implementations + items: - enum: - pci1efd,edf1 - const: riscv,pci-iommu reg: - maxItems: 1 - description: - For non-PCI devices this represents base address and size of for the - IOMMU memory mapped registers interface. - For PCI IOMMU hardware implementation this should represent an address - of the IOMMU, as defined in the PCI Bus Binding reference. + minItems: 1 + items: + - description: + For non-PCI devices, base address and size of the IOMMU memory + mapped registers interface. For PCI IOMMU hardware + implementation, an address of the IOMMU, as defined in the PCI + Bus Binding reference. + - description: + Region containing platform specific MMRs for machine-mode + configuration, such as PMA and PMP registers. + + reg-names: + minItems: 1 + items: + - const: base + - const: machine '#iommu-cells': const: 1 @@ -75,6 +88,26 @@ required: additionalProperties: false +allOf: + - if: + properties: + compatible: + contains: + enum: + - tenstorrent,riscv-iommu + then: + properties: + reg: + minItems: 2 + reg-names: + minItems: 2 + else: + properties: + reg: + maxItems: 1 + reg-names: + maxItems: 1 + examples: - |+ /* Example 1 (IOMMU device with wired interrupts) */ @@ -145,3 +178,13 @@ examples: }; }; }; + + - |+ + /* Example 5 (Tenstorrent IOMMU device with MSIs) */ + iommu5: iommu@d2020000 { + compatible = "tenstorrent,riscv-iommu", "riscv,iommu"; + reg = <0xd2020000 0x10000>, <0xaa000000 0x10000>; + reg-names = "base", "machine"; + msi-parent = <&imsics_smode>; + #iommu-cells = <1>; + };