[PATCH 0/6] iommu/riscv: Add HPM support for RISC-V IOMMU

Lv Zheng
2026-01-28T02:24:35Z

This patchset adds HPM support for RISC-V IOMMU. The HPM support can be
found in recent announced SpacemiT SoCs (K3), where T100 (SpacemiT
distributed IOMMU) is shipped.

The tested result can be found as follows:

root@sdfirm:~# perf stat --timeout 5000 -a -e riscv_iommu_hpm_0/device-directory-walks,config1=0x20c0010000000000/ dmatest; sleep 1
[ 176.025295] event_source riscv_iommu_hpm_0: Setting event filter: 20c0010000000005, PID PSCID: 0x0, DID GSCID: 0xc0010, PV PSCV: 0x0, DV GSCV: 0x1, IDT: 0x0, DMASK: 0x0, Index: 0
[ 176.110211] dmatest: Started 1 threads using dma0chan0
[ 176.114933] dmatest: dma0chan0-copy0: summary 1 tests, 0 failures 394.94 iops 394 KB/s (0)

Performance counter stats for 'system wide':

3 riscv_iommu_hpm_0/device-directory-walks,config1=0x20c0010000000000/

0.081056000 seconds time elapsed

root@sdfirm:~# perf stat --timeout 5000 -a -e riscv_iommu_hpm_0/first-stage-page-table-walks,config1=0x20c0010000000000/ dmatest; sleep 1
[ 68.050220] event_source riscv_iommu_hpm_0: Setting event filter: 20c0010000000007, PID PSCID: 0x0, DID GSCID: 0xc0010, PV PSCV: 0x0, DV GSCV: 0x1, IDT: 0x0, DMASK: 0x0, Index: 0
[ 68.152992] dmatest: Started 1 threads using dma0chan0
[ 68.158071] dmatest: dma0chan0-copy0: summary 1 tests, 0 failures 401.92 iops 401 KB/s (0)

Performance counter stats for 'system wide':

6 riscv_iommu_hpm_0/first-stage-page-table-walks,config1=0x20c0010000000000/

0.083192000 seconds time elapsed

Jingyu Li (3):
iommu/riscv: Enable IOMMU DMA mapping support
iommu/riscv: Fix WSI mode IRQ number handling
iommu/riscv: Add HPM support for performance monitoring

Lv Zheng (3):
spacemit/t100: Add vendor event support for RISC-V IOMMU HPM
spacemit/t100: Add global filter support for RISC-V IOMMU HPM
spacemit/t100: Add SpacemiT T100 IOATC HPM support

.../bindings/iommu/riscv,iommu.yaml | 6 +
drivers/iommu/Kconfig | 2 +-
drivers/iommu/riscv/Kconfig | 9 +
drivers/iommu/riscv/Makefile | 1 +
drivers/iommu/riscv/iommu-bits.h | 19 +-
drivers/iommu/riscv/iommu-hpm.c | 1141 +++++++++++++++++
drivers/iommu/riscv/iommu-pci.c | 13 +-
drivers/iommu/riscv/iommu-platform.c | 12 +-
drivers/iommu/riscv/iommu.c | 25 +-
drivers/iommu/riscv/iommu.h | 44 +-
10 files changed, 1259 insertions(+), 13 deletions(-)
create mode 100644 drivers/iommu/riscv/iommu-hpm.c

--
2.43.0

This message and any attachment are confidential and may be privileged or otherwise protected from disclosure. If you are not an intended recipient of this message, please delete it and any attachment from your system and notify the sender immediately by reply e-mail. Unintended recipients should not use, copy, disclose or take any action based on this message or any information contained in this message. Emails cannot be guaranteed to be secure or error free as they can be intercepted, amended, lost or destroyed, and you should take full responsibility for security checking.

本邮件及其任何附件具有保密性质，并可能受其他保护或不允许被披露给第三方。如阁下误收到本邮件，敬请立即以回复电子邮件的方式通知发件人，并将本邮件及其任何附件从阁下系统中予以删除。如阁下并非本邮件写明之收件人，敬请切勿使用、复制、披露本邮件或其任何内容，亦请切勿依本邮件或其任何内容而采取任何行动。电子邮件无法保证是一种安全和不会出现任何差错的通信方式，可能会被拦截、修改、丢失或损坏，收件人需自行负责做好安全检查。