]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iommu/intel: Convert to msi_create_parent_irq_domain() helper
authorMarc Zyngier <maz@kernel.org>
Thu, 26 Jun 2025 14:48:55 +0000 (16:48 +0200)
committerJoerg Roedel <joerg.roedel@amd.com>
Fri, 4 Jul 2025 08:28:11 +0000 (10:28 +0200)
Now that we have a concise helper to create an MSI parent domain,
switch the Intel 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-10-maz@kernel.org
Link: https://lore.kernel.org/r/169c793c50be8493cfd9d11affb00e9ed6341c36.1750858125.git.namcao@linutronix.de
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
drivers/iommu/Kconfig
drivers/iommu/intel/irq_remapping.c

index 0a33d995d15dd759eb47705c00b411f1157b408a..c5ce712a37b9f80c7bcca5110aecb6f4454d85b5 100644 (file)
@@ -200,6 +200,7 @@ source "drivers/iommu/riscv/Kconfig"
 config IRQ_REMAP
        bool "Support for Interrupt Remapping"
        depends on X86_64 && X86_IO_APIC && PCI_MSI && ACPI
+       select IRQ_MSI_LIB
        help
          Supports Interrupt remapping for IO-APIC and MSI devices.
          To use x2apic mode in the CPU's which support x2APIC enhancements or
index cf7b6882ec755ba30fce33cbd8fae61b79fa83e0..2ef71ba696b1fb3eaf7cf68620b5c6fb370a11fe 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/hpet.h>
 #include <linux/pci.h>
 #include <linux/irq.h>
+#include <linux/irqchip/irq-msi-lib.h>
 #include <linux/acpi.h>
 #include <linux/irqdomain.h>
 #include <linux/crash_dump.h>
@@ -518,8 +519,14 @@ static void iommu_enable_irq_remapping(struct intel_iommu *iommu)
 
 static int intel_setup_irq_remapping(struct intel_iommu *iommu)
 {
+       struct irq_domain_info info = {
+               .ops            = &intel_ir_domain_ops,
+               .parent         = arch_get_ir_parent_domain(),
+               .domain_flags   = IRQ_DOMAIN_FLAG_ISOLATED_MSI,
+               .size           = INTR_REMAP_TABLE_ENTRIES,
+               .host_data      = iommu,
+       };
        struct ir_table *ir_table;
-       struct fwnode_handle *fn;
        unsigned long *bitmap;
        void *ir_table_base;
 
@@ -544,25 +551,16 @@ static int intel_setup_irq_remapping(struct intel_iommu *iommu)
                goto out_free_pages;
        }
 
-       fn = irq_domain_alloc_named_id_fwnode("INTEL-IR", iommu->seq_id);
-       if (!fn)
+       info.fwnode = irq_domain_alloc_named_id_fwnode("INTEL-IR", iommu->seq_id);
+       if (!info.fwnode)
                goto out_free_bitmap;
 
-       iommu->ir_domain =
-               irq_domain_create_hierarchy(arch_get_ir_parent_domain(),
-                                           0, INTR_REMAP_TABLE_ENTRIES,
-                                           fn, &intel_ir_domain_ops,
-                                           iommu);
+       iommu->ir_domain = msi_create_parent_irq_domain(&info, &dmar_msi_parent_ops);
        if (!iommu->ir_domain) {
                pr_err("IR%d: failed to allocate irqdomain\n", iommu->seq_id);
                goto out_free_fwnode;
        }
 
-       irq_domain_update_bus_token(iommu->ir_domain,  DOMAIN_BUS_DMAR);
-       iommu->ir_domain->flags |= IRQ_DOMAIN_FLAG_MSI_PARENT |
-                                  IRQ_DOMAIN_FLAG_ISOLATED_MSI;
-       iommu->ir_domain->msi_parent_ops = &dmar_msi_parent_ops;
-
        ir_table->base = ir_table_base;
        ir_table->bitmap = bitmap;
        iommu->ir_table = ir_table;
@@ -608,7 +606,7 @@ out_free_ir_domain:
        irq_domain_remove(iommu->ir_domain);
        iommu->ir_domain = NULL;
 out_free_fwnode:
-       irq_domain_free_fwnode(fn);
+       irq_domain_free_fwnode(info.fwnode);
 out_free_bitmap:
        bitmap_free(bitmap);
 out_free_pages:
@@ -1530,6 +1528,8 @@ static const struct irq_domain_ops intel_ir_domain_ops = {
 
 static const struct msi_parent_ops dmar_msi_parent_ops = {
        .supported_flags        = X86_VECTOR_MSI_FLAGS_SUPPORTED | MSI_FLAG_MULTI_PCI_MSI,
+       .bus_select_token       = DOMAIN_BUS_DMAR,
+       .bus_select_mask        = MATCH_PCI_MSI,
        .prefix                 = "IR-",
        .init_dev_msi_info      = msi_parent_init_dev_msi_info,
 };