Skip to contentSkip to conversation

RISC-V: Add ACPI support for IOMMU

PATCH Superseded Sunil V L 3 participants 8 messages May 14, 2025 – May 16, 2025

Subsystems (6)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Sunil V L

author maintainer
#0 lore raw

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.

The first patch in the series is a ACPICA patch which is already available in linux-next but included in this series for completeness only.

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

Sunil V L (4):
ACPICA: actbl2: Add definitions for RIMT
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           |   8 +
 drivers/acpi/riscv/Makefile          |   1 +
 drivers/acpi/riscv/init.c            |   2 +
 drivers/acpi/riscv/init.h            |   1 +
 drivers/acpi/riscv/rimt.c            | 537 +++++++++++++++++++++++++++
 drivers/acpi/scan.c                  |   9 +-
 drivers/iommu/riscv/iommu-platform.c |  17 +-
 drivers/iommu/riscv/iommu.c          |  10 +
 include/acpi/actbl2.h                |  83 +++++
 include/linux/acpi_rimt.h            |  21 ++
 13 files changed, 692 insertions(+), 3 deletions(-)
 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 1/4 ACPICA: actbl2: Add definitions for RIMT

ACPICA commit 73c32bc89cad64ab19c1231a202361e917e6823c

RISC-V IO Mapping Table (RIMT) is a new static table defined for RISC-V to communicate IOMMU information to the OS. The specification for RIMT is available at [1]. Add structure definitions for RIMT.

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

---
 include/acpi/actbl2.h | 83 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 83 insertions(+)
include/acpi/actbl2.h +83 -0
index 2e917a8f8bca..99ea8bfe47de 100644
@@ -50,6 +50,7 @@
 #define ACPI_SIG_RAS2           "RAS2"	/* RAS2 Feature table */
 #define ACPI_SIG_RGRT           "RGRT"	/* Regulatory Graphics Resource Table */
 #define ACPI_SIG_RHCT           "RHCT"	/* RISC-V Hart Capabilities Table */
+#define ACPI_SIG_RIMT           "RIMT"	/* RISC-V IO Mapping Table */
 #define ACPI_SIG_SBST           "SBST"	/* Smart Battery Specification Table */
 #define ACPI_SIG_SDEI           "SDEI"	/* Software Delegated Exception Interface Table */
 #define ACPI_SIG_SDEV           "SDEV"	/* Secure Devices table */
@@ -3002,6 +3003,88 @@ struct acpi_rhct_hart_info {
 	u32 uid;		/* ACPI processor UID */
 };
 
+/*******************************************************************************
+ *
+ * RIMT - RISC-V IO Remapping Table
+ *
+ * https://github.com/riscv-non-isa/riscv-acpi-rimt
+ *
+ ******************************************************************************/
+
+struct acpi_table_rimt {
+	struct acpi_table_header header;	/* Common ACPI table header */
+	u32 num_nodes;		/* Number of RIMT Nodes */
+	u32 node_offset;	/* Offset to RIMT Node Array */
+	u32 reserved;
+};
+
+struct acpi_rimt_node {
+	u8 type;
+	u8 revision;
+	u16 length;
+	u16 reserved;
+	u16 id;
+	char node_data[];
+};
+
+enum acpi_rimt_node_type {
+	ACPI_RIMT_NODE_TYPE_IOMMU = 0x0,
+	ACPI_RIMT_NODE_TYPE_PCIE_ROOT_COMPLEX = 0x1,
+	ACPI_RIMT_NODE_TYPE_PLAT_DEVICE = 0x2,
+};
+
+struct acpi_rimt_iommu {
+	u8 hardware_id[8];	/* Hardware ID */
+	u64 base_address;	/* Base Address */
+	u32 flags;		/* Flags */
+	u32 proximity_domain;	/* Proximity Domain */
+	u16 pcie_segment_number;	/* PCIe Segment number */
+	u16 pcie_bdf;		/* PCIe B/D/F */
+	u16 num_interrupt_wires;	/* Number of interrupt wires */
+	u16 interrupt_wire_offset;	/* Interrupt wire array offset */
+	u64 interrupt_wire[];	/* Interrupt wire array */
+};
+
+/* IOMMU Node Flags */
+#define ACPI_RIMT_IOMMU_FLAGS_PCIE      (1)
+#define ACPI_RIMT_IOMMU_FLAGS_PXM_VALID (1 << 1)
+
+/* Interrupt Wire Structure */
+struct acpi_rimt_iommu_wire_gsi {
+	u32 irq_num;		/* Interrupt Number */
+	u32 flags;		/* Flags */
+};
+
+/* Interrupt Wire Flags */
+#define ACPI_RIMT_GSI_LEVEL_TRIGGERRED  (1)
+#define ACPI_RIMT_GSI_ACTIVE_HIGH       (1 << 1)
+
+struct acpi_rimt_id_mapping {
+	u32 source_id_base;	/* Source ID Base */
+	u32 num_ids;		/* Number of IDs */
+	u32 dest_id_base;	/* Destination Device ID Base */
+	u32 dest_offset;	/* Destination IOMMU Offset */
+	u32 flags;		/* Flags */
+};
+
+struct acpi_rimt_pcie_rc {
+	u32 flags;		/* Flags */
+	u16 reserved;		/* Reserved */
+	u16 pcie_segment_number;	/* PCIe Segment number */
+	u16 id_mapping_offset;	/* ID mapping array offset */
+	u16 num_id_mappings;	/* Number of ID mappings */
+};
+
+/* PCIe Root Complex Node Flags */
+#define ACPI_RIMT_PCIE_ATS_SUPPORTED   (1)
+#define ACPI_RIMT_PCIE_PRI_SUPPORTED   (1 << 1)
+
+struct acpi_rimt_platform_device {
+	u16 id_mapping_offset;	/* ID Mapping array offset */
+	u16 num_id_mappings;	/* Number of ID mappings */
+	char device_name[];	/* Device Object Name */
+};
+
 /*******************************************************************************
  *
  * SBST - Smart Battery Specification Table
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH 1/4] ACPICA: actbl2: Add definitions for RIMT

Quoted 11 lines · Sunil V L

ACPICA commit 73c32bc89cad64ab19c1231a202361e917e6823c

RISC-V IO Mapping Table (RIMT) is a new static table defined for RISC-V to communicate IOMMU information to the OS. The specification for RIMT is available at [1]. Add structure definitions for RIMT.

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

An analogous patch is present in linux-next already as

ced63370237a ACPICA: actbl2: Add definitions for RIMT

No need to send this again.

Quoted 108 lines
---
 include/acpi/actbl2.h | 83 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 83 insertions(+)
include/acpi/actbl2.h +83 -1
index 2e917a8f8bca..99ea8bfe47de 100644
@@ -50,6 +50,7 @@
 #define ACPI_SIG_RAS2           "RAS2" /* RAS2 Feature table */
 #define ACPI_SIG_RGRT           "RGRT" /* Regulatory Graphics Resource Table */
 #define ACPI_SIG_RHCT           "RHCT" /* RISC-V Hart Capabilities Table */
+#define ACPI_SIG_RIMT           "RIMT" /* RISC-V IO Mapping Table */
 #define ACPI_SIG_SBST           "SBST" /* Smart Battery Specification Table */
 #define ACPI_SIG_SDEI           "SDEI" /* Software Delegated Exception Interface Table */
 #define ACPI_SIG_SDEV           "SDEV" /* Secure Devices table */
@@ -3002,6 +3003,88 @@ struct acpi_rhct_hart_info {
        u32 uid;                /* ACPI processor UID */
 };
 
+/*******************************************************************************
+ *
+ * RIMT - RISC-V IO Remapping Table
+ *
+ * https://github.com/riscv-non-isa/riscv-acpi-rimt
+ *
+ ******************************************************************************/
+
+struct acpi_table_rimt {
+       struct acpi_table_header header;        /* Common ACPI table header */
+       u32 num_nodes;          /* Number of RIMT Nodes */
+       u32 node_offset;        /* Offset to RIMT Node Array */
+       u32 reserved;
+};
+
+struct acpi_rimt_node {
+       u8 type;
+       u8 revision;
+       u16 length;
+       u16 reserved;
+       u16 id;
+       char node_data[];
+};
+
+enum acpi_rimt_node_type {
+       ACPI_RIMT_NODE_TYPE_IOMMU = 0x0,
+       ACPI_RIMT_NODE_TYPE_PCIE_ROOT_COMPLEX = 0x1,
+       ACPI_RIMT_NODE_TYPE_PLAT_DEVICE = 0x2,
+};
+
+struct acpi_rimt_iommu {
+       u8 hardware_id[8];      /* Hardware ID */
+       u64 base_address;       /* Base Address */
+       u32 flags;              /* Flags */
+       u32 proximity_domain;   /* Proximity Domain */
+       u16 pcie_segment_number;        /* PCIe Segment number */
+       u16 pcie_bdf;           /* PCIe B/D/F */
+       u16 num_interrupt_wires;        /* Number of interrupt wires */
+       u16 interrupt_wire_offset;      /* Interrupt wire array offset */
+       u64 interrupt_wire[];   /* Interrupt wire array */
+};
+
+/* IOMMU Node Flags */
+#define ACPI_RIMT_IOMMU_FLAGS_PCIE      (1)
+#define ACPI_RIMT_IOMMU_FLAGS_PXM_VALID (1 << 1)
+
+/* Interrupt Wire Structure */
+struct acpi_rimt_iommu_wire_gsi {
+       u32 irq_num;            /* Interrupt Number */
+       u32 flags;              /* Flags */
+};
+
+/* Interrupt Wire Flags */
+#define ACPI_RIMT_GSI_LEVEL_TRIGGERRED  (1)
+#define ACPI_RIMT_GSI_ACTIVE_HIGH       (1 << 1)
+
+struct acpi_rimt_id_mapping {
+       u32 source_id_base;     /* Source ID Base */
+       u32 num_ids;            /* Number of IDs */
+       u32 dest_id_base;       /* Destination Device ID Base */
+       u32 dest_offset;        /* Destination IOMMU Offset */
+       u32 flags;              /* Flags */
+};
+
+struct acpi_rimt_pcie_rc {
+       u32 flags;              /* Flags */
+       u16 reserved;           /* Reserved */
+       u16 pcie_segment_number;        /* PCIe Segment number */
+       u16 id_mapping_offset;  /* ID mapping array offset */
+       u16 num_id_mappings;    /* Number of ID mappings */
+};
+
+/* PCIe Root Complex Node Flags */
+#define ACPI_RIMT_PCIE_ATS_SUPPORTED   (1)
+#define ACPI_RIMT_PCIE_PRI_SUPPORTED   (1 << 1)
+
+struct acpi_rimt_platform_device {
+       u16 id_mapping_offset;  /* ID Mapping array offset */
+       u16 num_id_mappings;    /* Number of ID mappings */
+       char device_name[];     /* Device Object Name */
+};
+
 /*******************************************************************************
  *
  * SBST - Smart Battery Specification Table
--

2.43.0

author maintainer
#3 lore raw

PATCH 2/4 ACPI: RISC-V: Add support for RIMT

In reply to Sunil V L

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  |   8 +
 drivers/acpi/riscv/Makefile |   1 +
 drivers/acpi/riscv/init.c   |   2 +
 drivers/acpi/riscv/init.h   |   1 +
 drivers/acpi/riscv/rimt.c   | 537 ++++++++++++++++++++++++++++++++++++
 include/linux/acpi_rimt.h   |  21 ++
 9 files changed, 576 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 f21f1dabb5fe..de125e6db921 100644
@@ -345,6 +345,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 bbec87b79309..ef8357c7207d 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 7f10aa38269d..1462452784d3 100644
@@ -546,6 +546,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 +8 -0
new file mode 100644
index 000000000000..ca089084b29f
@@ -0,0 +1,8 @@
+# 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 +537 -0

537 lines not on this page · raw message

include/linux/acpi_rimt.h new file +21 -0
new file mode 100644
index 000000000000..9c7b2b1580e2
@@ -0,0 +1,21 @@
+/* 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
+int rimt_iommu_configure_id(struct device *dev, const u32 *id_in);
+
+#ifdef CONFIG_ACPI
+int rimt_iommu_register(struct device *dev);
+#else
+static inline int rimt_iommu_register(struct device *dev)
+{
+	return -ENODEV;
+}
+
+#endif
+
+#endif /* _ACPI_RIMT_H */
Signature · 1 line
2.43.0
author maintainer
#4 lore raw

PATCH 3/4 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 | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/acpi/scan.c +7 -2
index fb1fe9f3b1a3..70f57d58fd61 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,12 @@ 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 = viot_iommu_configure(dev);
+	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
#5 lore raw

Re: [PATCH 3/4] ACPI: scan: Add support for RISC-V in acpi_iommu_configure_id()

kernel test robot noticed the following build errors:

Hi Sunil,

kernel test robot noticed the following build errors:

[auto build test ERROR on linus/master]
[also build test ERROR on v6.15-rc6]
[cannot apply to rafael-pm/linux-next rafael-pm/bleeding-edge next-20250514] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Sunil-V-L/ACPICA-actbl2-Add-definitions-for-RIMT/20250514-135910
base:   linus/master
patch link:    https://lore.kernel.org/r/20250514055723.1328557-4-sunilvl%40ventanamicro.com
patch subject: [PATCH 3/4] ACPI: scan: Add support for RISC-V in acpi_iommu_configure_id()
config: loongarch-randconfig-001-20250514 (https://download.01.org/0day-ci/archive/20250515/[email protected]/config)
compiler: loongarch64-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250515/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

loongarch64-linux-ld: drivers/acpi/scan.o: in function `acpi_dma_configure_id':

>> scan.c:(.text+0x1db0): undefined reference to `rimt_iommu_configure_id'
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
maintainer Acked-by on v1 3/4
#6 lore raw

Re: [PATCH 3/4] ACPI: scan: Add support for RISC-V in acpi_iommu_configure_id()

In reply to Sunil V L
Quoted 5 lines · Sunil V L

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

This is fine by me, so

and please route it via RISC-V, but remember about the dependency on the new ACPICA change.

Quoted 34 lines
---
 drivers/acpi/scan.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/acpi/scan.c +7 -3
index fb1fe9f3b1a3..70f57d58fd61 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,12 @@ 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 = viot_iommu_configure(dev);
+       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;
--

2.43.0

author maintainer
#7 lore raw

PATCH 4/4 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 8f049d4a0e2c..e51af4ba54a8 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