]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
iommu/amd: Convert to msi_create_parent_irq_domain() helper
authorMarc Zyngier <maz@kernel.org>
Thu, 26 Jun 2025 14:48:54 +0000 (16:48 +0200)
committerJoerg Roedel <joerg.roedel@amd.com>
Fri, 4 Jul 2025 08:28:10 +0000 (10:28 +0200)
Now that we have a concise helper to create an MSI parent domain,
switch the AMD IOMMU remapping over to that.

Signed-off-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Nam Cao <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20241204124549.607054-9-maz@kernel.org
Link: https://lore.kernel.org/r/92e5ae97a03e4ffc272349d0863cd2cc8f904c44.1750858125.git.namcao@linutronix.de
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
drivers/iommu/amd/Kconfig
drivers/iommu/amd/iommu.c

index 994063e5586f0f74dfed1e97f46d7c17163a0a24..ecef69c11144db2e91401697664b65343e87fd6a 100644 (file)
@@ -7,6 +7,7 @@ config AMD_IOMMU
        select PCI_ATS
        select PCI_PRI
        select PCI_PASID
+       select IRQ_MSI_LIB
        select MMU_NOTIFIER
        select IOMMU_API
        select IOMMU_IOVA
index 3117d99cf83d0d8cc46b0c4f13b2c6c1d497c4f4..0cb7c077d388fc223c7bc890b2cf36076fcf77e4 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/notifier.h>
 #include <linux/export.h>
 #include <linux/irq.h>
+#include <linux/irqchip/irq-msi-lib.h>
 #include <linux/msi.h>
 #include <linux/irqdomain.h>
 #include <linux/percpu.h>
@@ -3970,29 +3971,30 @@ static struct irq_chip amd_ir_chip = {
 
 static const struct msi_parent_ops amdvi_msi_parent_ops = {
        .supported_flags        = X86_VECTOR_MSI_FLAGS_SUPPORTED | MSI_FLAG_MULTI_PCI_MSI,
+       .bus_select_token       = DOMAIN_BUS_AMDVI,
+       .bus_select_mask        = MATCH_PCI_MSI,
        .prefix                 = "IR-",
        .init_dev_msi_info      = msi_parent_init_dev_msi_info,
 };
 
 int amd_iommu_create_irq_domain(struct amd_iommu *iommu)
 {
-       struct fwnode_handle *fn;
+       struct irq_domain_info info = {
+               .fwnode         = irq_domain_alloc_named_id_fwnode("AMD-IR", iommu->index),
+               .ops            = &amd_ir_domain_ops,
+               .domain_flags   = IRQ_DOMAIN_FLAG_ISOLATED_MSI,
+               .host_data      = iommu,
+               .parent         = arch_get_ir_parent_domain(),
+       };
 
-       fn = irq_domain_alloc_named_id_fwnode("AMD-IR", iommu->index);
-       if (!fn)
+       if (!info.fwnode)
                return -ENOMEM;
-       iommu->ir_domain = irq_domain_create_hierarchy(arch_get_ir_parent_domain(), 0, 0,
-                                                      fn, &amd_ir_domain_ops, iommu);
+
+       iommu->ir_domain = msi_create_parent_irq_domain(&info, &amdvi_msi_parent_ops);
        if (!iommu->ir_domain) {
-               irq_domain_free_fwnode(fn);
+               irq_domain_free_fwnode(info.fwnode);
                return -ENOMEM;
        }
-
-       irq_domain_update_bus_token(iommu->ir_domain,  DOMAIN_BUS_AMDVI);
-       iommu->ir_domain->flags |= IRQ_DOMAIN_FLAG_MSI_PARENT |
-                                  IRQ_DOMAIN_FLAG_ISOLATED_MSI;
-       iommu->ir_domain->msi_parent_ops = &amdvi_msi_parent_ops;
-
        return 0;
 }