* [PATCH 0/8] ACPI: LoongArch: Add IOVT table support
@ 2026-06-17 7:48 Bibo Mao
2026-06-17 7:48 ` [PATCH 1/8] ACPI: LoongArch: Add acpi_arch_init() support Bibo Mao
` (8 more replies)
0 siblings, 9 replies; 12+ messages in thread
From: Bibo Mao @ 2026-06-17 7:48 UTC (permalink / raw)
To: Huacai Chen, Rafael J . Wysocki
Cc: Len Brown, Saket Dumbre, linux-kernel, loongarch, linux-acpi,
acpica-devel, lixianglai, bibo.mao
I/O Virtualization Table is ACPI table for LoongArch IOMMU devices, it
is merged on ACPI Spec 6.6, and it can be located at
https://www.loongson.cn/uploads/images/2024110517404135188.LoongArch-IO-Virtualization-Table-Specification.pdf
Here add IOVT table parsing on LoongArch system, it is for use about
LoongArch IOMMU driver in future.
Bibo Mao (8):
ACPI: LoongArch: Add acpi_arch_init() support
ACPI: LoongArch: Add ACPI_IOVT option
ACPI: LoongArch: Enable pci acs function if acpi iovt tables exist
ACPI: LoongArch: Add acpi_arch_late_init support
ACPI: LoongArch: Scan IOMMU devices in IOVT table
ACPI: LoongArch: Add iovt device entry table scanning
ACPI: scan: Add support for LoongArch in acpi_iommu_configure_id()
MAINTAINERS: Add entry for drivers/acpi/loongarch
MAINTAINERS | 9 ++
arch/loongarch/Kconfig | 1 +
drivers/acpi/Kconfig | 4 +
drivers/acpi/Makefile | 2 +-
drivers/acpi/bus.c | 2 +
drivers/acpi/loongarch/Kconfig | 7 +
drivers/acpi/loongarch/Makefile | 3 +
drivers/acpi/loongarch/init.c | 16 ++
drivers/acpi/loongarch/init.h | 5 +
drivers/acpi/loongarch/iovt.c | 274 ++++++++++++++++++++++++++++++++
drivers/acpi/scan.c | 3 +
include/acpi/actbl2.h | 3 +
include/linux/acpi.h | 1 +
include/linux/acpi_iovt.h | 13 ++
14 files changed, 342 insertions(+), 1 deletion(-)
create mode 100644 drivers/acpi/loongarch/Kconfig
create mode 100644 drivers/acpi/loongarch/Makefile
create mode 100644 drivers/acpi/loongarch/init.c
create mode 100644 drivers/acpi/loongarch/init.h
create mode 100644 drivers/acpi/loongarch/iovt.c
create mode 100644 include/linux/acpi_iovt.h
base-commit: 6b5a2b7d9bc156e505f09e698d85d6a1547c1206
--
2.39.3
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/8] ACPI: LoongArch: Add acpi_arch_init() support
2026-06-17 7:48 [PATCH 0/8] ACPI: LoongArch: Add IOVT table support Bibo Mao
@ 2026-06-17 7:48 ` Bibo Mao
2026-06-17 7:48 ` [PATCH 2/8] ACPI: LoongArch: Add ACPI_IOVT option Bibo Mao
` (7 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Bibo Mao @ 2026-06-17 7:48 UTC (permalink / raw)
To: Huacai Chen, Rafael J . Wysocki
Cc: Len Brown, Saket Dumbre, linux-kernel, loongarch, linux-acpi,
acpica-devel, lixianglai, bibo.mao
Add acpi_arch_init() API on LoongArch, now it is empty.
In the future, IOVT table parsing will be added.
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
drivers/acpi/Makefile | 2 +-
drivers/acpi/loongarch/Makefile | 2 ++
drivers/acpi/loongarch/init.c | 7 +++++++
3 files changed, 10 insertions(+), 1 deletion(-)
create mode 100644 drivers/acpi/loongarch/Makefile
create mode 100644 drivers/acpi/loongarch/init.c
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index d1b0affb844f..91584a3c1e01 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -131,6 +131,6 @@ obj-y += dptf/
obj-$(CONFIG_ARM64) += arm64/
obj-$(CONFIG_ACPI_VIOT) += viot.o
-
+obj-$(CONFIG_LOONGARCH) += loongarch/
obj-$(CONFIG_RISCV) += riscv/
obj-$(CONFIG_X86) += x86/
diff --git a/drivers/acpi/loongarch/Makefile b/drivers/acpi/loongarch/Makefile
new file mode 100644
index 000000000000..d3764139dfaf
--- /dev/null
+++ b/drivers/acpi/loongarch/Makefile
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0-only
+obj-y += init.o
diff --git a/drivers/acpi/loongarch/init.c b/drivers/acpi/loongarch/init.c
new file mode 100644
index 000000000000..7008e50b3e9d
--- /dev/null
+++ b/drivers/acpi/loongarch/init.c
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <linux/acpi.h>
+
+void __init acpi_arch_init(void)
+{
+}
--
2.39.3
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 2/8] ACPI: LoongArch: Add ACPI_IOVT option
2026-06-17 7:48 [PATCH 0/8] ACPI: LoongArch: Add IOVT table support Bibo Mao
2026-06-17 7:48 ` [PATCH 1/8] ACPI: LoongArch: Add acpi_arch_init() support Bibo Mao
@ 2026-06-17 7:48 ` Bibo Mao
2026-06-17 7:48 ` [PATCH 3/8] ACPI: LoongArch: Enable pci acs function if acpi iovt tables exist Bibo Mao
` (6 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Bibo Mao @ 2026-06-17 7:48 UTC (permalink / raw)
To: Huacai Chen, Rafael J . Wysocki
Cc: Len Brown, Saket Dumbre, linux-kernel, loongarch, linux-acpi,
acpica-devel, lixianglai, bibo.mao
ACPI_IOVT is acpi table with IOMMU device on LoongArch system, here
option ACPI_IOVT is added. And empty function acpi_iovt_init() is
added and called in acpi_arch_init().
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
arch/loongarch/Kconfig | 1 +
drivers/acpi/Kconfig | 4 ++++
drivers/acpi/loongarch/Kconfig | 7 +++++++
drivers/acpi/loongarch/Makefile | 1 +
drivers/acpi/loongarch/init.c | 3 +++
drivers/acpi/loongarch/init.h | 4 ++++
drivers/acpi/loongarch/iovt.c | 7 +++++++
7 files changed, 27 insertions(+)
create mode 100644 drivers/acpi/loongarch/Kconfig
create mode 100644 drivers/acpi/loongarch/init.h
create mode 100644 drivers/acpi/loongarch/iovt.c
diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig
index 3f69c5d7e48e..6f0b6b539c0b 100644
--- a/arch/loongarch/Kconfig
+++ b/arch/loongarch/Kconfig
@@ -6,6 +6,7 @@ config LOONGARCH
select ACPI_GENERIC_GSI if ACPI
select ACPI_MCFG if ACPI
select ACPI_HOTPLUG_CPU if ACPI_PROCESSOR && HOTPLUG_CPU
+ select ACPI_IOVT if ACPI
select ACPI_PPTT if ACPI
select ACPI_SYSTEM_POWER_STATES_SUPPORT if ACPI
select ARCH_BINFMT_ELF_STATE
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index f165d14cf61a..192e6f18eda1 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -550,6 +550,10 @@ if ARM64
source "drivers/acpi/arm64/Kconfig"
endif
+if LOONGARCH
+source "drivers/acpi/loongarch/Kconfig"
+endif
+
if RISCV
source "drivers/acpi/riscv/Kconfig"
endif
diff --git a/drivers/acpi/loongarch/Kconfig b/drivers/acpi/loongarch/Kconfig
new file mode 100644
index 000000000000..91ba3c35b9bf
--- /dev/null
+++ b/drivers/acpi/loongarch/Kconfig
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# ACPI Configuration for LOONGARCH
+#
+
+config ACPI_IOVT
+ bool
diff --git a/drivers/acpi/loongarch/Makefile b/drivers/acpi/loongarch/Makefile
index d3764139dfaf..c338d3102fc1 100644
--- a/drivers/acpi/loongarch/Makefile
+++ b/drivers/acpi/loongarch/Makefile
@@ -1,2 +1,3 @@
# SPDX-License-Identifier: GPL-2.0-only
obj-y += init.o
+obj-$(CONFIG_ACPI_IOVT) += iovt.o
diff --git a/drivers/acpi/loongarch/init.c b/drivers/acpi/loongarch/init.c
index 7008e50b3e9d..9233f6c1cb55 100644
--- a/drivers/acpi/loongarch/init.c
+++ b/drivers/acpi/loongarch/init.c
@@ -1,7 +1,10 @@
// SPDX-License-Identifier: GPL-2.0-only
#include <linux/acpi.h>
+#include "init.h"
void __init acpi_arch_init(void)
{
+ if (IS_ENABLED(CONFIG_ACPI_IOVT))
+ acpi_iovt_init();
}
diff --git a/drivers/acpi/loongarch/init.h b/drivers/acpi/loongarch/init.h
new file mode 100644
index 000000000000..070ea187bfae
--- /dev/null
+++ b/drivers/acpi/loongarch/init.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#include <linux/init.h>
+
+void __init acpi_iovt_init(void);
diff --git a/drivers/acpi/loongarch/iovt.c b/drivers/acpi/loongarch/iovt.c
new file mode 100644
index 000000000000..793ed13a2cef
--- /dev/null
+++ b/drivers/acpi/loongarch/iovt.c
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include "init.h"
+
+void __init acpi_iovt_init(void)
+{
+}
--
2.39.3
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 3/8] ACPI: LoongArch: Enable pci acs function if acpi iovt tables exist
2026-06-17 7:48 [PATCH 0/8] ACPI: LoongArch: Add IOVT table support Bibo Mao
2026-06-17 7:48 ` [PATCH 1/8] ACPI: LoongArch: Add acpi_arch_init() support Bibo Mao
2026-06-17 7:48 ` [PATCH 2/8] ACPI: LoongArch: Add ACPI_IOVT option Bibo Mao
@ 2026-06-17 7:48 ` Bibo Mao
2026-06-17 7:48 ` [PATCH 4/8] ACPI: LoongArch: Add acpi_arch_late_init support Bibo Mao
` (5 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Bibo Mao @ 2026-06-17 7:48 UTC (permalink / raw)
To: Huacai Chen, Rafael J . Wysocki
Cc: Len Brown, Saket Dumbre, linux-kernel, loongarch, linux-acpi,
acpica-devel, lixianglai, bibo.mao
IOMMU requires pci acs function enabled, so that all the DMA transaction
of pci device is routed to upper PCI bridge and IOMMU device.
Here scan IOMMU iovt table in function acpi_iovt_init(), which is
executed before PCI device sanning, and enable pci acs function if
iovt tables exist.
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
drivers/acpi/loongarch/iovt.c | 47 +++++++++++++++++++++++++++++++++++
include/acpi/actbl2.h | 3 +++
2 files changed, 50 insertions(+)
diff --git a/drivers/acpi/loongarch/iovt.c b/drivers/acpi/loongarch/iovt.c
index 793ed13a2cef..5e3d866796a9 100644
--- a/drivers/acpi/loongarch/iovt.c
+++ b/drivers/acpi/loongarch/iovt.c
@@ -1,7 +1,54 @@
// SPDX-License-Identifier: GPL-2.0-only
+#include <linux/acpi.h>
+#include <linux/pci.h>
#include "init.h"
+#ifdef CONFIG_PCI
+static void __init iovt_enable_acs(struct acpi_iovt_iommu *iommu)
+{
+ static bool acs_enabled __initdata;
+
+ if (acs_enabled)
+ return;
+
+ /* IOMMU V1 only supports PCI device management */
+ if ((iommu->header.type == ACPI_IOVT_IOMMU_V1) ||
+ (iommu->flags & (ACPI_IOVT_PCI_DEVICE | ACPI_IOVT_MAGAGE_BY_SEGMENT))) {
+ pci_request_acs();
+ acs_enabled = true;
+ }
+}
+#else
+static inline void iovt_enable_acs(struct acpi_iovt_iommu *iommu) { }
+#endif
+
void __init acpi_iovt_init(void)
{
+ acpi_status status;
+ struct acpi_table_header *hdr;
+ struct acpi_table_iovt *iovt;
+ struct acpi_iovt_iommu *iommu;
+ int i;
+
+ status = acpi_get_table(ACPI_SIG_IOVT, 0, &hdr);
+ if (ACPI_FAILURE(status)) {
+ if (status != AE_NOT_FOUND) {
+ const char *msg = acpi_format_exception(status);
+
+ pr_err("Failed to get table, %s\n", msg);
+ }
+
+ return;
+ }
+
+ iovt = (struct acpi_table_iovt *)&hdr;
+ iommu = ACPI_ADD_PTR(struct acpi_iovt_iommu, iovt, iovt->iommu_offset);
+ for (i = 0; i < iovt->iommu_count; i++) {
+ iovt_enable_acs(iommu);
+
+ iommu = ACPI_ADD_PTR(struct acpi_iovt_iommu, iommu, iommu->header.length);
+ }
+
+ acpi_put_table(hdr);
}
diff --git a/include/acpi/actbl2.h b/include/acpi/actbl2.h
index baef525367b5..acc51a42c3ed 100644
--- a/include/acpi/actbl2.h
+++ b/include/acpi/actbl2.h
@@ -892,6 +892,9 @@ struct acpi_iovt_header {
/* Values for Type field above */
+#define ACPI_IOVT_PCI_DEVICE BIT(0)
+#define ACPI_IOVT_PXM_VALID BIT(1)
+#define ACPI_IOVT_MAGAGE_BY_SEGMENT BIT(2)
enum acpi_iovt_iommu_type {
ACPI_IOVT_IOMMU_V1 = 0x00,
ACPI_IOVT_IOMMU_RESERVED = 0x01 /* 1 and greater are reserved */
--
2.39.3
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 4/8] ACPI: LoongArch: Add acpi_arch_late_init support
2026-06-17 7:48 [PATCH 0/8] ACPI: LoongArch: Add IOVT table support Bibo Mao
` (2 preceding siblings ...)
2026-06-17 7:48 ` [PATCH 3/8] ACPI: LoongArch: Enable pci acs function if acpi iovt tables exist Bibo Mao
@ 2026-06-17 7:48 ` Bibo Mao
2026-06-17 7:48 ` [PATCH 5/8] ACPI: LoongArch: Scan IOMMU devices in IOVT table Bibo Mao
` (4 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Bibo Mao @ 2026-06-17 7:48 UTC (permalink / raw)
To: Huacai Chen, Rafael J . Wysocki
Cc: Len Brown, Saket Dumbre, linux-kernel, loongarch, linux-acpi,
acpica-devel, lixianglai, bibo.mao
On LoongArch system, IOMMU is PCI device, its device id is based
on BDF information. IOVT table scanning should be called after PCI
device scanning.
Here api acpi_arch_late_init() is added, it is a weak function on
other architectures. On LoongArch it is empty function now, IOVT table
scanning function be will executed in this function later.
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
drivers/acpi/bus.c | 2 ++
drivers/acpi/loongarch/init.c | 4 ++++
include/linux/acpi.h | 1 +
3 files changed, 7 insertions(+)
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 3b7db94b81f7..4a2d2bab05cd 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -1556,6 +1556,7 @@ struct kobject *acpi_kobj;
EXPORT_SYMBOL_GPL(acpi_kobj);
void __weak __init acpi_arch_init(void) { }
+void __weak __init acpi_arch_late_init(void) { }
static int __init acpi_init(void)
{
@@ -1594,6 +1595,7 @@ static int __init acpi_init(void)
acpi_wakeup_device_init();
acpi_debugger_init();
acpi_setup_sb_notify_handler();
+ acpi_arch_late_init();
acpi_viot_init();
return 0;
}
diff --git a/drivers/acpi/loongarch/init.c b/drivers/acpi/loongarch/init.c
index 9233f6c1cb55..1aa9bfa66e51 100644
--- a/drivers/acpi/loongarch/init.c
+++ b/drivers/acpi/loongarch/init.c
@@ -8,3 +8,7 @@ void __init acpi_arch_init(void)
if (IS_ENABLED(CONFIG_ACPI_IOVT))
acpi_iovt_init();
}
+
+void __init acpi_arch_late_init(void)
+{
+}
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 67effb91fa98..24d00d01bf12 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -1610,6 +1610,7 @@ static inline int acpi_pptt_get_cpumask_from_cache_id(u32 cache_id,
#endif
void acpi_arch_init(void);
+void acpi_arch_late_init(void);
#ifdef CONFIG_ACPI_PCC
void acpi_init_pcc(void);
--
2.39.3
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 5/8] ACPI: LoongArch: Scan IOMMU devices in IOVT table
2026-06-17 7:48 [PATCH 0/8] ACPI: LoongArch: Add IOVT table support Bibo Mao
` (3 preceding siblings ...)
2026-06-17 7:48 ` [PATCH 4/8] ACPI: LoongArch: Add acpi_arch_late_init support Bibo Mao
@ 2026-06-17 7:48 ` Bibo Mao
2026-06-17 7:48 ` [PATCH 6/8] ACPI: LoongArch: Add iovt device entry table scanning Bibo Mao
` (3 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Bibo Mao @ 2026-06-17 7:48 UTC (permalink / raw)
To: Huacai Chen, Rafael J . Wysocki
Cc: Len Brown, Saket Dumbre, linux-kernel, loongarch, linux-acpi,
acpica-devel, lixianglai, bibo.mao
In function acpi_iovt_init(), IOMMU devices are parsed in IOVT table.
And these IOMMU devices can put in list iovt_fwnode_list.
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
drivers/acpi/loongarch/init.c | 2 +
drivers/acpi/loongarch/init.h | 1 +
drivers/acpi/loongarch/iovt.c | 121 ++++++++++++++++++++++++++++++++++
3 files changed, 124 insertions(+)
diff --git a/drivers/acpi/loongarch/init.c b/drivers/acpi/loongarch/init.c
index 1aa9bfa66e51..e7272ee197c7 100644
--- a/drivers/acpi/loongarch/init.c
+++ b/drivers/acpi/loongarch/init.c
@@ -11,4 +11,6 @@ void __init acpi_arch_init(void)
void __init acpi_arch_late_init(void)
{
+ if (IS_ENABLED(CONFIG_ACPI_IOVT))
+ acpi_iovt_late_init();
}
diff --git a/drivers/acpi/loongarch/init.h b/drivers/acpi/loongarch/init.h
index 070ea187bfae..85e5197553ad 100644
--- a/drivers/acpi/loongarch/init.h
+++ b/drivers/acpi/loongarch/init.h
@@ -2,3 +2,4 @@
#include <linux/init.h>
void __init acpi_iovt_init(void);
+void __init acpi_iovt_late_init(void);
diff --git a/drivers/acpi/loongarch/iovt.c b/drivers/acpi/loongarch/iovt.c
index 5e3d866796a9..47d2ce20e3f5 100644
--- a/drivers/acpi/loongarch/iovt.c
+++ b/drivers/acpi/loongarch/iovt.c
@@ -4,6 +4,19 @@
#include <linux/pci.h>
#include "init.h"
+struct iovt_fwnode {
+ struct list_head list;
+ struct fwnode_handle *fwnode;
+ int flag;
+ int segment;
+ int devid;
+ int nid;
+};
+
+/* Root pointer to the mapped IOVT table */
+static LIST_HEAD(iovt_fwnode_list);
+static DEFINE_SPINLOCK(iovt_fwnode_lock);
+
#ifdef CONFIG_PCI
static void __init iovt_enable_acs(struct acpi_iovt_iommu *iommu)
{
@@ -23,6 +36,94 @@ static void __init iovt_enable_acs(struct acpi_iovt_iommu *iommu)
static inline void iovt_enable_acs(struct acpi_iovt_iommu *iommu) { }
#endif
+static int __init iovt_get_pci_iommu_fwnode(struct iovt_fwnode *np, u16 segment, u16 bdf)
+{
+ struct pci_dev *pdev;
+ struct fwnode_handle *fwnode;
+
+ pdev = pci_get_domain_bus_and_slot(segment, PCI_BUS_NUM(bdf), bdf & 0xff);
+ if (!pdev) {
+ pr_err("Could not find PCI IOMMU\n");
+ return -ENODEV;
+ }
+
+ fwnode = dev_fwnode(&pdev->dev);
+ if (!fwnode) {
+ /*
+ * PCI devices aren't necessarily described by ACPI. Create a
+ * fwnode so the IOMMU subsystem can identify this device.
+ */
+ fwnode = acpi_alloc_fwnode_static();
+ if (!fwnode) {
+ pci_dev_put(pdev);
+ return -ENOMEM;
+ }
+ set_primary_fwnode(&pdev->dev, fwnode);
+ }
+
+ np->fwnode = dev_fwnode(&pdev->dev);
+ if (np->flag & ACPI_IOVT_PXM_VALID)
+ set_dev_node(&pdev->dev, np->nid);
+ pci_dev_put(pdev);
+ return 0;
+}
+
+static int __init iovt_add_iommu(struct acpi_iovt_iommu *iommu)
+{
+ struct iovt_fwnode *np;
+ struct fwnode_handle *fwnode;
+ int ret;
+
+ np = kzalloc_obj(struct iovt_fwnode, GFP_ATOMIC);
+ if (WARN_ON(!np))
+ return -ENOMEM;
+
+ INIT_LIST_HEAD(&np->list);
+ np->flag = iommu->flags;
+ np->segment = iommu->segment;
+ if (np->flag & ACPI_IOVT_PXM_VALID)
+ np->nid = pxm_to_node(iommu->proximity_domain);
+
+ if (np->flag & ACPI_IOVT_PCI_DEVICE) {
+ np->devid = iommu->device_id;
+ ret = iovt_get_pci_iommu_fwnode(np, np->segment, np->devid);
+ if (ret) {
+ kfree(np);
+ return ret;
+ }
+
+ } else {
+ fwnode = acpi_alloc_fwnode_static();
+ if (!fwnode) {
+ kfree(np);
+ return -ENOMEM;
+ }
+
+ np->fwnode = fwnode;
+ }
+
+ spin_lock(&iovt_fwnode_lock);
+ list_add_tail(&np->list, &iovt_fwnode_list);
+ spin_unlock(&iovt_fwnode_lock);
+ return 0;
+}
+
+static void __init iovt_init_devices(struct acpi_table_header *header)
+{
+ struct acpi_iovt_iommu *iommu;
+ struct acpi_table_iovt *iovt;
+ int i;
+
+ iovt = (struct acpi_table_iovt *)header;
+
+ /* Get the first IOVT node */
+ iommu = ACPI_ADD_PTR(struct acpi_iovt_iommu, iovt, iovt->iommu_offset);
+ for (i = 0; i < iovt->iommu_count; i++) {
+ iovt_add_iommu(iommu);
+ iommu = ACPI_ADD_PTR(struct acpi_iovt_iommu, iommu, iommu->header.length);
+ }
+}
+
void __init acpi_iovt_init(void)
{
acpi_status status;
@@ -52,3 +153,23 @@ void __init acpi_iovt_init(void)
acpi_put_table(hdr);
}
+
+void __init acpi_iovt_late_init(void)
+{
+ acpi_status status;
+ struct acpi_table_header *hdr;
+
+ status = acpi_get_table(ACPI_SIG_IOVT, 0, &hdr);
+ if (ACPI_FAILURE(status)) {
+ if (status != AE_NOT_FOUND) {
+ const char *msg = acpi_format_exception(status);
+
+ pr_err("Failed to get table, %s\n", msg);
+ }
+
+ return;
+ }
+
+ iovt_init_devices(hdr);
+ acpi_put_table(hdr);
+}
--
2.39.3
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 6/8] ACPI: LoongArch: Add iovt device entry table scanning
2026-06-17 7:48 [PATCH 0/8] ACPI: LoongArch: Add IOVT table support Bibo Mao
` (4 preceding siblings ...)
2026-06-17 7:48 ` [PATCH 5/8] ACPI: LoongArch: Scan IOMMU devices in IOVT table Bibo Mao
@ 2026-06-17 7:48 ` Bibo Mao
2026-06-17 7:48 ` [PATCH 7/8] ACPI: scan: Add support for LoongArch in acpi_iommu_configure_id() Bibo Mao
` (2 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Bibo Mao @ 2026-06-17 7:48 UTC (permalink / raw)
To: Huacai Chen, Rafael J . Wysocki
Cc: Len Brown, Saket Dumbre, linux-kernel, loongarch, linux-acpi,
acpica-devel, lixianglai, bibo.mao
Iovt device entry table are device entry lists which are managed by
IOMMU device, each IOMMU device has its ownd device entry table.
Here add iovt device entry table scanning function in function
iovt_add_iommu().
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
drivers/acpi/loongarch/iovt.c | 53 ++++++++++++++++++++++++++++++++++-
1 file changed, 52 insertions(+), 1 deletion(-)
diff --git a/drivers/acpi/loongarch/iovt.c b/drivers/acpi/loongarch/iovt.c
index 47d2ce20e3f5..7deedb8219b2 100644
--- a/drivers/acpi/loongarch/iovt.c
+++ b/drivers/acpi/loongarch/iovt.c
@@ -4,6 +4,12 @@
#include <linux/pci.h>
#include "init.h"
+struct iovt_device_entry {
+ struct list_head list;
+ int start_devid;
+ int end_devid;
+};
+
struct iovt_fwnode {
struct list_head list;
struct fwnode_handle *fwnode;
@@ -11,6 +17,7 @@ struct iovt_fwnode {
int segment;
int devid;
int nid;
+ struct list_head ep_list;
};
/* Root pointer to the mapped IOVT table */
@@ -72,7 +79,10 @@ static int __init iovt_add_iommu(struct acpi_iovt_iommu *iommu)
{
struct iovt_fwnode *np;
struct fwnode_handle *fwnode;
- int ret;
+ struct acpi_iovt_device_entry *ep;
+ struct iovt_device_entry *entry;
+ int i, ret, start_devid;
+ bool is_start = false;
np = kzalloc_obj(struct iovt_fwnode, GFP_ATOMIC);
if (WARN_ON(!np))
@@ -102,6 +112,47 @@ static int __init iovt_add_iommu(struct acpi_iovt_iommu *iommu)
np->fwnode = fwnode;
}
+ if (np->flag & ACPI_IOVT_MAGAGE_BY_SEGMENT)
+ goto skip;
+
+ INIT_LIST_HEAD(&np->ep_list);
+ ep = ACPI_ADD_PTR(struct acpi_iovt_device_entry, iommu, iommu->device_entry_offset);
+ for (i = 0; i < iommu->device_entry_num; i++) {
+ switch (ep->type) {
+ case ACPI_IOVT_DEVICE_ENTRY_START:
+ is_start = true;
+ start_devid = ep->device_id;
+ break;
+ case ACPI_IOVT_DEVICE_ENTRY_END:
+ if (!is_start)
+ break;
+
+ entry = kzalloc_obj(struct iovt_device_entry, GFP_ATOMIC);
+ if (!entry)
+ return -ENOMEM;
+
+ entry->start_devid = start_devid;
+ entry->end_devid = ep->device_id;
+ list_add_tail(&entry->list, &np->ep_list);
+ is_start = false;
+ break;
+ case ACPI_IOVT_DEVICE_ENTRY_SINGLE:
+ entry = kzalloc_obj(struct iovt_device_entry, GFP_ATOMIC);
+ if (!entry)
+ return -ENOMEM;
+
+ entry->start_devid = ep->device_id;
+ entry->end_devid = ep->device_id;
+ list_add_tail(&entry->list, &np->ep_list);
+ is_start = false;
+ break;
+ default:
+ break;
+ }
+ ep = ACPI_ADD_PTR(struct acpi_iovt_device_entry, ep, ep->length);
+ }
+
+skip:
spin_lock(&iovt_fwnode_lock);
list_add_tail(&np->list, &iovt_fwnode_list);
spin_unlock(&iovt_fwnode_lock);
--
2.39.3
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 7/8] ACPI: scan: Add support for LoongArch in acpi_iommu_configure_id()
2026-06-17 7:48 [PATCH 0/8] ACPI: LoongArch: Add IOVT table support Bibo Mao
` (5 preceding siblings ...)
2026-06-17 7:48 ` [PATCH 6/8] ACPI: LoongArch: Add iovt device entry table scanning Bibo Mao
@ 2026-06-17 7:48 ` Bibo Mao
2026-06-17 7:48 ` [PATCH 8/8] MAINTAINERS: Add entry for drivers/acpi/loongarch Bibo Mao
2026-07-13 10:06 ` [PATCH 0/8] ACPI: LoongArch: Add IOVT table support Bibo Mao
8 siblings, 0 replies; 12+ messages in thread
From: Bibo Mao @ 2026-06-17 7:48 UTC (permalink / raw)
To: Huacai Chen, Rafael J . Wysocki
Cc: Len Brown, Saket Dumbre, linux-kernel, loongarch, linux-acpi,
acpica-devel, lixianglai, bibo.mao
acpi_iommu_configure_id() currently supports only IORT (ARM) and VIOT.
Add support for IOVT (LoongArch) as well.
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
drivers/acpi/loongarch/iovt.c | 48 +++++++++++++++++++++++++++++++++++
drivers/acpi/scan.c | 3 +++
include/linux/acpi_iovt.h | 13 ++++++++++
3 files changed, 64 insertions(+)
create mode 100644 include/linux/acpi_iovt.h
diff --git a/drivers/acpi/loongarch/iovt.c b/drivers/acpi/loongarch/iovt.c
index 7deedb8219b2..c769cfc74310 100644
--- a/drivers/acpi/loongarch/iovt.c
+++ b/drivers/acpi/loongarch/iovt.c
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
#include <linux/acpi.h>
+#include <linux/acpi_iovt.h>
#include <linux/pci.h>
#include "init.h"
@@ -224,3 +225,50 @@ void __init acpi_iovt_late_init(void)
iovt_init_devices(hdr);
acpi_put_table(hdr);
}
+
+static int iovt_pci_dev_iommu_init(struct pci_dev *pdev, u16 dev_id, void *data)
+{
+ u32 epid;
+ struct iovt_fwnode *np;
+ struct device *aliased_dev = data;
+ u32 domain = pci_domain_nr(pdev->bus);
+ struct iovt_device_entry *entry;
+
+ list_for_each_entry(np, &iovt_fwnode_list, list) {
+ if (domain != np->segment)
+ continue;
+
+ /* We're not translating ourself */
+ if (dev_id == np->devid)
+ return -EINVAL;
+
+ epid = (domain << 16) + dev_id;
+ if (np->flag & ACPI_IOVT_MAGAGE_BY_SEGMENT)
+ return acpi_iommu_fwspec_init(aliased_dev, epid, np->fwnode);
+
+ list_for_each_entry(entry, &np->ep_list, list) {
+ if (dev_id >= entry->start_devid && dev_id <= entry->end_devid)
+ return acpi_iommu_fwspec_init(aliased_dev, epid, np->fwnode);
+ }
+ }
+
+ return -ENODEV;
+}
+
+/*
+ * iovt_iommu_configure_id - Set-up IOMMU configuration for a device.
+ *
+ * @dev: device to configure
+ * @id_in: optional input id const value pointer
+ *
+ * Returns: 0 on success, <0 on failure
+ */
+int iovt_iommu_configure_id(struct device *dev, const u32 *id_in)
+{
+ int err = -ENODEV;
+
+ if (!dev_is_pci(dev))
+ return err;
+
+ return pci_for_each_dma_alias(to_pci_dev(dev), iovt_pci_dev_iommu_init, dev);
+}
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 9a7ac2eb9ce0..508575f25e10 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -13,6 +13,7 @@
#include <linux/kernel.h>
#include <linux/acpi.h>
#include <linux/acpi_iort.h>
+#include <linux/acpi_iovt.h>
#include <linux/acpi_rimt.h>
#include <linux/acpi_viot.h>
#include <linux/iommu.h>
@@ -1629,6 +1630,8 @@ static int acpi_iommu_configure_id(struct device *dev, const u32 *id_in)
err = rimt_iommu_configure_id(dev, id_in);
if (err && err != -EPROBE_DEFER)
err = viot_iommu_configure(dev);
+ if (err && err != -EPROBE_DEFER)
+ err = iovt_iommu_configure_id(dev, id_in);
mutex_unlock(&iommu_probe_device_lock);
diff --git a/include/linux/acpi_iovt.h b/include/linux/acpi_iovt.h
new file mode 100644
index 000000000000..25a846b96260
--- /dev/null
+++ b/include/linux/acpi_iovt.h
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef __ACPI_IOVT_H__
+#define __ACPI_IOVT_H__
+
+#if defined(CONFIG_IOMMU_API) && defined(CONFIG_ACPI_IOVT)
+int iovt_iommu_configure_id(struct device *dev, const u32 *id_in);
+#else
+static inline int iovt_iommu_configure_id(struct device *dev, const u32 *id_in)
+{ return -ENODEV; }
+#endif
+
+#endif
--
2.39.3
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 8/8] MAINTAINERS: Add entry for drivers/acpi/loongarch
2026-06-17 7:48 [PATCH 0/8] ACPI: LoongArch: Add IOVT table support Bibo Mao
` (6 preceding siblings ...)
2026-06-17 7:48 ` [PATCH 7/8] ACPI: scan: Add support for LoongArch in acpi_iommu_configure_id() Bibo Mao
@ 2026-06-17 7:48 ` Bibo Mao
2026-07-13 10:06 ` [PATCH 0/8] ACPI: LoongArch: Add IOVT table support Bibo Mao
8 siblings, 0 replies; 12+ messages in thread
From: Bibo Mao @ 2026-06-17 7:48 UTC (permalink / raw)
To: Huacai Chen, Rafael J . Wysocki
Cc: Len Brown, Saket Dumbre, linux-kernel, loongarch, linux-acpi,
acpica-devel, lixianglai, bibo.mao
ACPI defines few LoongArch specific tables which need parsing code
added in drivers/acpi/loongarch. Add maintainer entries for this newly
created folder.
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
MAINTAINERS | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index 3d6db8cb608f..49a20feca9fc 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -348,6 +348,15 @@ S: Maintained
F: drivers/acpi/riscv/
F: include/linux/acpi_rimt.h
+ACPI FOR LoongArch (ACPI/LoongArch)
+M: Bibo Mao <maobibo@loongson.cn>
+R: Huacai Chen <chenhuacai@kernel.org>
+L: linux-acpi@vger.kernel.org
+L: loongarch@lists.linux.dev
+S: Maintained
+F: drivers/acpi/loongarch/
+F: include/linux/acpi_iovt.h
+
ACPI PCC(Platform Communication Channel) MAILBOX DRIVER
M: Sudeep Holla <sudeep.holla@kernel.org>
L: linux-acpi@vger.kernel.org
--
2.39.3
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH 0/8] ACPI: LoongArch: Add IOVT table support
2026-06-17 7:48 [PATCH 0/8] ACPI: LoongArch: Add IOVT table support Bibo Mao
` (7 preceding siblings ...)
2026-06-17 7:48 ` [PATCH 8/8] MAINTAINERS: Add entry for drivers/acpi/loongarch Bibo Mao
@ 2026-07-13 10:06 ` Bibo Mao
2026-07-13 13:40 ` Huacai Chen
8 siblings, 1 reply; 12+ messages in thread
From: Bibo Mao @ 2026-07-13 10:06 UTC (permalink / raw)
To: maobibo
Cc: acpica-devel, chenhuacai, lenb, linux-acpi, linux-kernel,
lixianglai, loongarch, rafael, saket.dumbre
slightly ping.
>I/O Virtualization Table is ACPI table for LoongArch IOMMU devices, it
>is merged on ACPI Spec 6.6, and it can be located at
> https://www.loongson.cn/uploads/images/2024110517404135188.LoongArch-IO-Virtualization-Table-Specification.pdf
>
>Here add IOVT table parsing on LoongArch system, it is for use about
>LoongArch IOMMU driver in future.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/8] ACPI: LoongArch: Add IOVT table support
2026-07-13 10:06 ` [PATCH 0/8] ACPI: LoongArch: Add IOVT table support Bibo Mao
@ 2026-07-13 13:40 ` Huacai Chen
2026-07-14 2:23 ` Bibo Mao
0 siblings, 1 reply; 12+ messages in thread
From: Huacai Chen @ 2026-07-13 13:40 UTC (permalink / raw)
To: Bibo Mao
Cc: acpica-devel, lenb, linux-acpi, linux-kernel, lixianglai,
loongarch, rafael, saket.dumbre
Hi, Bibo,
On Mon, Jul 13, 2026 at 6:14 PM Bibo Mao <maobibo@loongson.cn> wrote:
>
> slightly ping.
I think the series can be re-organized as 3 patches:
ACPI: LoongArch: Add acpi_arch_[late]_init()
includes Patch-1/4 in this series roughly.
ACPI: LoongArch: Add IOVT device entry table scanning
includes Patch-3/5/6/7 in this series roughly.
ACPI: LoongArch: Add ACPI_IOVT config options
includes Patch-2/8 in this series roughly.
Huacai
>
> >I/O Virtualization Table is ACPI table for LoongArch IOMMU devices, it
> >is merged on ACPI Spec 6.6, and it can be located at
> > https://www.loongson.cn/uploads/images/2024110517404135188.LoongArch-IO-Virtualization-Table-Specification.pdf
> >
> >Here add IOVT table parsing on LoongArch system, it is for use about
> >LoongArch IOMMU driver in future.
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/8] ACPI: LoongArch: Add IOVT table support
2026-07-13 13:40 ` Huacai Chen
@ 2026-07-14 2:23 ` Bibo Mao
0 siblings, 0 replies; 12+ messages in thread
From: Bibo Mao @ 2026-07-14 2:23 UTC (permalink / raw)
To: Huacai Chen
Cc: acpica-devel, lenb, linux-acpi, linux-kernel, lixianglai,
loongarch, rafael, saket.dumbre
On 2026/7/13 下午9:40, Huacai Chen wrote:
> Hi, Bibo,
>
> On Mon, Jul 13, 2026 at 6:14 PM Bibo Mao <maobibo@loongson.cn> wrote:
>>
>> slightly ping.
> I think the series can be re-organized as 3 patches:
>
> ACPI: LoongArch: Add acpi_arch_[late]_init()
> includes Patch-1/4 in this series roughly.
>
> ACPI: LoongArch: Add IOVT device entry table scanning
> includes Patch-3/5/6/7 in this series roughly.
>
> ACPI: LoongArch: Add ACPI_IOVT config options
> includes Patch-2/8 in this series roughly.
Waiting the response from others, will do this if there is no disagreement.
Regards
Bibo Mao
>
>
> Huacai
>
>>
>>> I/O Virtualization Table is ACPI table for LoongArch IOMMU devices, it
>>> is merged on ACPI Spec 6.6, and it can be located at
>>> https://www.loongson.cn/uploads/images/2024110517404135188.LoongArch-IO-Virtualization-Table-Specification.pdf
>>>
>>> Here add IOVT table parsing on LoongArch system, it is for use about
>>> LoongArch IOMMU driver in future.
>>
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2026-07-14 2:23 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-17 7:48 [PATCH 0/8] ACPI: LoongArch: Add IOVT table support Bibo Mao
2026-06-17 7:48 ` [PATCH 1/8] ACPI: LoongArch: Add acpi_arch_init() support Bibo Mao
2026-06-17 7:48 ` [PATCH 2/8] ACPI: LoongArch: Add ACPI_IOVT option Bibo Mao
2026-06-17 7:48 ` [PATCH 3/8] ACPI: LoongArch: Enable pci acs function if acpi iovt tables exist Bibo Mao
2026-06-17 7:48 ` [PATCH 4/8] ACPI: LoongArch: Add acpi_arch_late_init support Bibo Mao
2026-06-17 7:48 ` [PATCH 5/8] ACPI: LoongArch: Scan IOMMU devices in IOVT table Bibo Mao
2026-06-17 7:48 ` [PATCH 6/8] ACPI: LoongArch: Add iovt device entry table scanning Bibo Mao
2026-06-17 7:48 ` [PATCH 7/8] ACPI: scan: Add support for LoongArch in acpi_iommu_configure_id() Bibo Mao
2026-06-17 7:48 ` [PATCH 8/8] MAINTAINERS: Add entry for drivers/acpi/loongarch Bibo Mao
2026-07-13 10:06 ` [PATCH 0/8] ACPI: LoongArch: Add IOVT table support Bibo Mao
2026-07-13 13:40 ` Huacai Chen
2026-07-14 2:23 ` Bibo Mao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox