Skip to contentSkip to conversation

RISC-V: Add ACPI support for IOMMU

PATCH Applied Sunil V L 3 participants 6 messages Aug 18, 2025 – Oct 9, 2025

Subsystems (5)
ACPI RISC-V IOMMU RISC-V IOMMU +1 more subsystems
lore
Share & tools
lore

Sunil V L

author maintainer
#0 lore raw

v6 cover RISC-V: Add ACPI support for IOMMU

This series adds support for RISC-V IOMMU on ACPI based platforms. RISC-V IO Mapping Table (RIMT) is a new static ACPI table [1] introduced to communicate IOMMU information to the OS.

[1] - https://github.com/riscv-non-isa/riscv-acpi-rimt/releases/download/v1.0/rimt-spec.pdf

Changes since v5:
1) Rebased to 6.17-rc2
2) Fixed incorrect id_out assignment (Reported by Xianliang)

Changes since v4:
1) Rebased to 6.16-rc6
2) Addressed Anup's feedback on formatting.
3) Added RB tag from Will and Anup.

Changes since v3:
1) Rebased to 6.16-rc5
2) Addressed Drew's feedback on v3.
a) Reordered calling rimt_iommu_configure_id().
b) Removed unnecessary inline.
c) Added pr_fmt.
d) Removed redundant rimt_iommu_configure_id() stub.
3) Added Drew's RB tag in PATCH 3.

Changes since v2:
1) Rebased to 6.16-rc4
2) Removed Anup's SOB and link tags added by mistake in v2.

Changes since v1:
1) Rebased to v6.16-rc1.
2) Dropped ACPICA patch since it is already available in 6.16-rc1.
3) Added Rafael's ACK.
4) Fixed few issues found by bots.

Sunil V L (3):
ACPI: RISC-V: Add support for RIMT
ACPI: scan: Add support for RISC-V in acpi_iommu_configure_id() iommu/riscv: Add ACPI support

 MAINTAINERS                          |   1 +
 arch/riscv/Kconfig                   |   1 +
 drivers/acpi/Kconfig                 |   4 +
 drivers/acpi/riscv/Kconfig           |   7 +
 drivers/acpi/riscv/Makefile          |   1 +
 drivers/acpi/riscv/init.c            |   2 +
 drivers/acpi/riscv/init.h            |   1 +
 drivers/acpi/riscv/rimt.c            | 520 +++++++++++++++++++++++++++
 drivers/acpi/scan.c                  |   4 +
 drivers/iommu/riscv/iommu-platform.c |  17 +-
 drivers/iommu/riscv/iommu.c          |  10 +
 include/linux/acpi_rimt.h            |  28 ++
 12 files changed, 595 insertions(+), 1 deletion(-)
 create mode 100644 drivers/acpi/riscv/Kconfig
 create mode 100644 drivers/acpi/riscv/rimt.c
 create mode 100644 include/linux/acpi_rimt.h
Signature · 1 line
2.43.0
author maintainer
#1 lore raw

PATCH v6 1/3 ACPI: RISC-V: Add support for RIMT

RISC-V IO Mapping Table (RIMT) is a static ACPI table to communicate IOMMU information to the OS. The spec is available at [1].

The changes at high level are,
a) Initialize data structures required for IOMMU/device configuration using the data from RIMT. Provide APIs required for device configuration.
b) Provide an API for IOMMU drivers to register the fwnode with RIMT data structures. This API will create a fwnode for PCIe IOMMU.

[1] - https://github.com/riscv-non-isa/riscv-acpi-rimt

---
 MAINTAINERS                 |   1 +
 arch/riscv/Kconfig          |   1 +
 drivers/acpi/Kconfig        |   4 +
 drivers/acpi/riscv/Kconfig  |   7 +
 drivers/acpi/riscv/Makefile |   1 +
 drivers/acpi/riscv/init.c   |   2 +
 drivers/acpi/riscv/init.h   |   1 +
 drivers/acpi/riscv/rimt.c   | 520 ++++++++++++++++++++++++++++++++++++
 include/linux/acpi_rimt.h   |  28 ++
 9 files changed, 565 insertions(+)
 create mode 100644 drivers/acpi/riscv/Kconfig
 create mode 100644 drivers/acpi/riscv/rimt.c
 create mode 100644 include/linux/acpi_rimt.h
MAINTAINERS +1 -0
index daf520a13bdf..7a4ae2929721 100644
@@ -347,6 +347,7 @@ L:	[email protected]
 L:	[email protected]
 S:	Maintained
 F:	drivers/acpi/riscv/
+F:	include/linux/acpi_rimt.h
 
 ACPI PCC(Platform Communication Channel) MAILBOX DRIVER
 M:	Sudeep Holla <[email protected]>
arch/riscv/Kconfig +1 -0
index a4b233a0659e..7563f43ec026 100644
@@ -16,6 +16,7 @@ config RISCV
 	select ACPI_MCFG if (ACPI && PCI)
 	select ACPI_PPTT if ACPI
 	select ACPI_REDUCED_HARDWARE_ONLY if ACPI
+	select ACPI_RIMT if ACPI
 	select ACPI_SPCR_TABLE if ACPI
 	select ARCH_DMA_DEFAULT_COHERENT
 	select ARCH_ENABLE_HUGEPAGE_MIGRATION if HUGETLB_PAGE && MIGRATION
drivers/acpi/Kconfig +4 -0
index b594780a57d7..2cdbd08b30e4 100644
@@ -547,6 +547,10 @@ if ARM64
 source "drivers/acpi/arm64/Kconfig"
 endif
 
+if RISCV
+source "drivers/acpi/riscv/Kconfig"
+endif
+
 config ACPI_PPTT
 	bool
 
drivers/acpi/riscv/Kconfig new file +7 -0
new file mode 100644
index 000000000000..046296a18d00
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# ACPI Configuration for RISC-V
+#
+
+config ACPI_RIMT
+	bool
drivers/acpi/riscv/Makefile +1 -0
index a96fdf1e2cb8..1284a076fa88 100644
@@ -2,3 +2,4 @@
 obj-y					+= rhct.o init.o irq.o
 obj-$(CONFIG_ACPI_PROCESSOR_IDLE)	+= cpuidle.o
 obj-$(CONFIG_ACPI_CPPC_LIB)		+= cppc.o
+obj-$(CONFIG_ACPI_RIMT)			+= rimt.o
drivers/acpi/riscv/init.c +2 -0
index 673e4d5dd752..7c00f7995e86 100644
@@ -10,4 +10,6 @@
 void __init acpi_arch_init(void)
 {
 	riscv_acpi_init_gsi_mapping();
+	if (IS_ENABLED(CONFIG_ACPI_RIMT))
+		riscv_acpi_rimt_init();
 }
drivers/acpi/riscv/init.h +1 -0
index 0b9a07e4031f..1680aa2aaf23 100644
@@ -2,3 +2,4 @@
 #include <linux/init.h>
 
 void __init riscv_acpi_init_gsi_mapping(void);
+void __init riscv_acpi_rimt_init(void);
drivers/acpi/riscv/rimt.c new file +520 -0

520 lines not on this page · raw message

include/linux/acpi_rimt.h new file +28 -0
new file mode 100644
index 000000000000..fad3adc4d899
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ *  Copyright (C) 2024-2025, Ventana Micro Systems Inc.
+ *	Author: Sunil V L <[email protected]>
+ */
+
+#ifndef _ACPI_RIMT_H
+#define _ACPI_RIMT_H
+
+#ifdef CONFIG_ACPI_RIMT
+int rimt_iommu_register(struct device *dev);
+#else
+static inline int rimt_iommu_register(struct device *dev)
+{
+	return -ENODEV;
+}
+#endif
+
+#if defined(CONFIG_IOMMU_API) && defined(CONFIG_ACPI_RIMT)
+int rimt_iommu_configure_id(struct device *dev, const u32 *id_in);
+#else
+static inline int rimt_iommu_configure_id(struct device *dev, const u32 *id_in)
+{
+	return -ENODEV;
+}
+#endif
+
+#endif /* _ACPI_RIMT_H */
Signature · 1 line
2.43.0
author maintainer
#2 lore raw

PATCH v6 2/3 ACPI: scan: Add support for RISC-V in acpi_iommu_configure_id()

In reply to Sunil V L

acpi_iommu_configure_id() currently supports only IORT (ARM) and VIOT. Add support for RISC-V as well.

---
 drivers/acpi/scan.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/acpi/scan.c +4 -0
index fb1fe9f3b1a3..f022f32de8a4 100644
@@ -11,6 +11,7 @@
 #include <linux/kernel.h>
 #include <linux/acpi.h>
 #include <linux/acpi_iort.h>
+#include <linux/acpi_rimt.h>
 #include <linux/acpi_viot.h>
 #include <linux/iommu.h>
 #include <linux/signal.h>
@@ -1628,8 +1629,11 @@ static int acpi_iommu_configure_id(struct device *dev, const u32 *id_in)
 	}
 
 	err = iort_iommu_configure_id(dev, id_in);
+	if (err && err != -EPROBE_DEFER)
+		err = rimt_iommu_configure_id(dev, id_in);
 	if (err && err != -EPROBE_DEFER)
 		err = viot_iommu_configure(dev);
+
 	mutex_unlock(&iommu_probe_device_lock);
 
 	return err;
Signature · 1 line
2.43.0
author maintainer
#3 lore raw

PATCH v6 3/3 iommu/riscv: Add ACPI support

In reply to Sunil V L

RISC-V IO Mapping Table (RIMT) provides the information about the IOMMU to the OS in ACPI. Add support for ACPI in RISC-V IOMMU drivers by using RIMT data.

The changes at high level are,

a) Register the IOMMU with RIMT data structures.
b) Enable probing of platform IOMMU in ACPI way using the ACPIID defined for the RISC-V IOMMU in the BRS spec [1]. Configure the MSI domain if the platform IOMMU uses MSIs.

[1] - https://github.com/riscv-non-isa/riscv-brs/blob/main/acpi-id.adoc

---
 drivers/iommu/riscv/iommu-platform.c | 17 ++++++++++++++++-
 drivers/iommu/riscv/iommu.c          | 10 ++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)
drivers/iommu/riscv/iommu-platform.c +16 -1
index 725e919b97ef..83a28c83f991 100644
@@ -10,6 +10,8 @@
  *	Tomasz Jeznach <[email protected]>
  */
 
+#include <linux/acpi.h>
+#include <linux/irqchip/riscv-imsic.h>
 #include <linux/kernel.h>
 #include <linux/msi.h>
 #include <linux/of_irq.h>
@@ -46,6 +48,7 @@ static int riscv_iommu_platform_probe(struct platform_device *pdev)
 	enum riscv_iommu_igs_settings igs;
 	struct device *dev = &pdev->dev;
 	struct riscv_iommu_device *iommu = NULL;
+	struct irq_domain *msi_domain;
 	struct resource *res = NULL;
 	int vec, ret;
 
@@ -76,8 +79,13 @@ static int riscv_iommu_platform_probe(struct platform_device *pdev)
 	switch (igs) {
 	case RISCV_IOMMU_CAPABILITIES_IGS_BOTH:
 	case RISCV_IOMMU_CAPABILITIES_IGS_MSI:
-		if (is_of_node(dev->fwnode))
+		if (is_of_node(dev_fwnode(dev))) {
 			of_msi_configure(dev, to_of_node(dev->fwnode));
+		} else {
+			msi_domain = irq_find_matching_fwnode(imsic_acpi_get_fwnode(dev),
+							      DOMAIN_BUS_PLATFORM_MSI);
+			dev_set_msi_domain(dev, msi_domain);
+		}
 
 		if (!dev_get_msi_domain(dev)) {
 			dev_warn(dev, "failed to find an MSI domain\n");
@@ -150,6 +158,12 @@ static const struct of_device_id riscv_iommu_of_match[] = {
 	{},
 };
 
+static const struct acpi_device_id riscv_iommu_acpi_match[] = {
+	{ "RSCV0004", 0 },
+	{}
+};
+MODULE_DEVICE_TABLE(acpi, riscv_iommu_acpi_match);
+
 static struct platform_driver riscv_iommu_platform_driver = {
 	.probe = riscv_iommu_platform_probe,
 	.remove = riscv_iommu_platform_remove,
@@ -158,6 +172,7 @@ static struct platform_driver riscv_iommu_platform_driver = {
 		.name = "riscv,iommu",
 		.of_match_table = riscv_iommu_of_match,
 		.suppress_bind_attrs = true,
+		.acpi_match_table = riscv_iommu_acpi_match,
 	},
 };
 
drivers/iommu/riscv/iommu.c +10 -0
index 2d0d31ba2886..7d9370aa58f0 100644
@@ -12,6 +12,8 @@
 
 #define pr_fmt(fmt) "riscv-iommu: " fmt
 
+#include <linux/acpi.h>
+#include <linux/acpi_rimt.h>
 #include <linux/compiler.h>
 #include <linux/crash_dump.h>
 #include <linux/init.h>
@@ -1650,6 +1652,14 @@ int riscv_iommu_init(struct riscv_iommu_device *iommu)
 		goto err_iodir_off;
 	}
 
+	if (!acpi_disabled) {
+		rc = rimt_iommu_register(iommu->dev);
+		if (rc) {
+			dev_err_probe(iommu->dev, rc, "cannot register iommu with RIMT\n");
+			goto err_remove_sysfs;
+		}
+	}
+
 	rc = iommu_device_register(&iommu->iommu, &riscv_iommu_ops, iommu->dev);
 	if (rc) {
 		dev_err_probe(iommu->dev, rc, "cannot register iommu interface\n");
Signature · 1 line
2.43.0
maintainer Applied
#4 lore raw
In reply to Sunil V L
Quoted 5 lines · Sunil V L

Sunil V L (3):
ACPI: RISC-V: Add support for RIMT
ACPI: scan: Add support for RISC-V in acpi_iommu_configure_id() iommu/riscv: Add ACPI support

Quoted 16 lines
 MAINTAINERS                          |   1 +
 arch/riscv/Kconfig                   |   1 +
 drivers/acpi/Kconfig                 |   4 +
 drivers/acpi/riscv/Kconfig           |   7 +
 drivers/acpi/riscv/Makefile          |   1 +
 drivers/acpi/riscv/init.c            |   2 +
 drivers/acpi/riscv/init.h            |   1 +
 drivers/acpi/riscv/rimt.c            | 520 +++++++++++++++++++++++++++
 drivers/acpi/scan.c                  |   4 +
 drivers/iommu/riscv/iommu-platform.c |  17 +-
 drivers/iommu/riscv/iommu.c          |  10 +
 include/linux/acpi_rimt.h            |  28 ++
 12 files changed, 595 insertions(+), 1 deletion(-)
 create mode 100644 drivers/acpi/riscv/Kconfig
 create mode 100644 drivers/acpi/riscv/rimt.c
 create mode 100644 include/linux/acpi_rimt.h

Applied, thanks.

#5 lore raw
In reply to Sunil V L
This series was applied to riscv/linux.git (for-next) by Joerg Roedel <[email protected]>:

Hello:

This series was applied to riscv/linux.git (for-next) by Joerg Roedel <[email protected]>:

Quoted 11 lines · On Mon, 18 Aug 2025 10:28:04 +0530 you wrote:

This series adds support for RISC-V IOMMU on ACPI based platforms. RISC-V IO Mapping Table (RIMT) is a new static ACPI table [1] introduced to communicate IOMMU information to the OS.

[1] - https://github.com/riscv-non-isa/riscv-acpi-rimt/releases/download/v1.0/rimt-spec.pdf

Changes since v5:
1) Rebased to 6.17-rc2
2) Fixed incorrect id_out assignment (Reported by Xianliang)

[...]

Here is the summary with links:
- [v6,1/3] ACPI: RISC-V: Add support for RIMT

    https://git.kernel.org/riscv/c/8f7729552582
  - [v6,2/3] ACPI: scan: Add support for RISC-V in acpi_iommu_configure_id()
    https://git.kernel.org/riscv/c/cbf4fbc484e1
  - [v6,3/3] iommu/riscv: Add ACPI support
    https://git.kernel.org/riscv/c/4f901b3dce57

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html