RISC-V: Add ACPI support for IOMMU
Subsystems (5)
Sunil V L
maintainerv5 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 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
Sunil V L
maintainerPATCH v5 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
@@ -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
@@ -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
@@ -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 +7 -0
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
Re: [PATCH v5 1/3] ACPI: RISC-V: Add support for RIMT
Hi Sunil,
drivers/acpi/riscv/rimt.c line 288
Quoted 7 lines · Sunil V L
drivers/acpi/riscv/rimt.c new file +7
-0+ parent = ACPI_ADD_PTR(struct acpi_rimt_node, rimt_table, map->dest_offset); + +if (node->type ==ACPI_RIMT_NODE_TYPE_PLAT_DEVICE || + node->type ==ACPI_RIMT_NODE_TYPE_PCIE_ROOT_COMPLEX ) { + *id_out = map->dest_offset; +return parent; + }
Why do we assign dest_offset to id_out? The dest_offset is the iommu offset, not a valid deviceid required for platform device in rimt_plat_iommu_map?
Regards,
Xianliang
Sunil V L
maintainerRe: [PATCH v5 1/3] ACPI: RISC-V: Add support for RIMT
Quoted 14 lines · XianLiang Huang
Hi Sunil,
drivers/acpi/riscv/rimt.c line 288
Quoted 7 lines · Sunil V L
drivers/acpi/riscv/rimt.c new file +7
-0+ parent = ACPI_ADD_PTR(struct acpi_rimt_node, rimt_table, map->dest_offset); + +if (node->type ==ACPI_RIMT_NODE_TYPE_PLAT_DEVICE || + node->type ==ACPI_RIMT_NODE_TYPE_PCIE_ROOT_COMPLEX ) { + *id_out = map->dest_offset; +return parent; + }Why do we assign
dest_offsettoid_out? Thedest_offsetis the iommu offset, not a valid deviceid required for platform device inrimt_plat_iommu_map?
Good catch!. Thanks!. It should be dest_id_base. Let me fix it in next revision.
Thanks!
Sunil
Sunil V L
maintainerPATCH v5 2/3 ACPI: scan: Add support for RISC-V in acpi_iommu_configure_id()
In reply to Sunil V Lacpi_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
@@ -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
Sunil V L
maintainerPATCH v5 3/3 iommu/riscv: Add ACPI support
In reply to Sunil V LRISC-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
@@ -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
@@ -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>
@@ -1651,6 +1653,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
Palmer Dabbelt
maintainerQuoted 35 lines · Sunil V L
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 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 callingrimt_iommu_configure_id().
b) Removed unnecessary inline.
c) Addedpr_fmt.
d) Removed redundantrimt_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 inacpi_iommu_configure_id()iommu/riscv: Add ACPI support
Quoted 12 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 ++
Thanks. Anup came to the patchwork meeting this morning and asked me to pick it up. It only barely touches arch/riscv stuff so I'd figured it was going somewhere else, but happy to do so. I've picked it up into my staging tree as
* e5efe466d9bd - (HEAD -> for-next, palmer/for-next) Merge patch series "RISC-V: Add ACPI support for IOMMU" (2 minutes ago) <Palmer Dabbelt>
|\ | * 368ed89f7ac9 - iommu/riscv: Add ACPI support (2 minutes ago) <Sunil V L> | * 0d7c16d0df92 - ACPI: scan: Add support for RISC-V in acpi_iommu_configure_id() (2 minutes ago) <Sunil V L> | * ea35561bc965 - ACPI: RISC-V: Add support for RIMT (2 minutes ago) <Sunil V L>
it should show up on for-next assuming it builds and such (it's behind some fixes, so might take a bit). Happy to do a tag if someone wants, just let me know...
Quoted 4 lines
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
This series was applied to riscv/linux.git (for-next) by Palmer Dabbelt <[email protected]>:
Hello:
This series was applied to riscv/linux.git (for-next) by Palmer Dabbelt <[email protected]>:
Quoted 4 lines · On Wed, 16 Jul 2025 16:10:56 +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.
Quoted 8 lines
[1] - https://github.com/riscv-non-isa/riscv-acpi-rimt/releases/download/v1.0/rimt-spec.pdf
Changes since v4:
1) Rebased to 6.16-rc6
2) Addressed Anup's feedback on formatting.
3) Added RB tag from Will and Anup.[...]
Here is the summary with links:
- [v5,1/3] ACPI: RISC-V: Add support for RIMT
https://git.kernel.org/riscv/c/ea35561bc965 - [v5,2/3] ACPI: scan: Add support for RISC-V in acpi_iommu_configure_id() https://git.kernel.org/riscv/c/0d7c16d0df92 - [v5,3/3] iommu/riscv: Add ACPI support https://git.kernel.org/riscv/c/368ed89f7ac9
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html