iommu/amd: Switch to MSI base domains
authorThomas Gleixner <tglx@linutronix.de>
Thu, 24 Nov 2022 23:26:10 +0000 (00:26 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Mon, 5 Dec 2022 21:22:33 +0000 (22:22 +0100)
Remove the global PCI/MSI irqdomain implementation and provide the required
MSI parent ops so the PCI/MSI code can detect the new parent and setup per
device domains.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Acked-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20221124232326.209212272@linutronix.de
arch/x86/kernel/apic/msi.c
drivers/iommu/amd/amd_iommu_types.h
drivers/iommu/amd/iommu.c
include/linux/irqdomain_defs.h

index a8dccb0f8c7400d2b1ab32ab1798b0ea305c4ea6..d198da3ddbf1f59e797e6e99ab4b5c56335f98d4 100644 (file)
@@ -218,6 +218,7 @@ static bool x86_init_dev_msi_info(struct device *dev, struct irq_domain *domain,
                info->flags |= MSI_FLAG_NOMASK_QUIRK;
                break;
        case DOMAIN_BUS_DMAR:
+       case DOMAIN_BUS_AMDVI:
                break;
        default:
                WARN_ON_ONCE(1);
index 1d0a70c85333aa6831c05fc797e5b6ea15cfe111..3d684190b4d537d15f5251277d5637aea65acd7f 100644 (file)
@@ -734,7 +734,6 @@ struct amd_iommu {
        u8 max_counters;
 #ifdef CONFIG_IRQ_REMAP
        struct irq_domain *ir_domain;
-       struct irq_domain *msi_domain;
 
        struct amd_irte_ops *irte_ops;
 #endif
index 67e209c2b7b1eb5f8632274fd3e72648d9f56782..7caccd8996f93cdf931119834e4eeec0895f980c 100644 (file)
@@ -815,7 +815,7 @@ amd_iommu_set_pci_msi_domain(struct device *dev, struct amd_iommu *iommu)
            !pci_dev_has_default_msi_parent_domain(to_pci_dev(dev)))
                return;
 
-       dev_set_msi_domain(dev, iommu->msi_domain);
+       dev_set_msi_domain(dev, iommu->ir_domain);
 }
 
 #else /* CONFIG_IRQ_REMAP */
@@ -3648,6 +3648,12 @@ static struct irq_chip amd_ir_chip = {
        .irq_compose_msi_msg    = ir_compose_msi_msg,
 };
 
+static const struct msi_parent_ops amdvi_msi_parent_ops = {
+       .supported_flags        = X86_VECTOR_MSI_FLAGS_SUPPORTED | MSI_FLAG_MULTI_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;
@@ -3655,16 +3661,17 @@ int amd_iommu_create_irq_domain(struct amd_iommu *iommu)
        fn = irq_domain_alloc_named_id_fwnode("AMD-IR", iommu->index);
        if (!fn)
                return -ENOMEM;
-       iommu->ir_domain = irq_domain_create_tree(fn, &amd_ir_domain_ops, iommu);
+       iommu->ir_domain = irq_domain_create_hierarchy(arch_get_ir_parent_domain(), 0, 0,
+                                                      fn, &amd_ir_domain_ops, iommu);
        if (!iommu->ir_domain) {
                irq_domain_free_fwnode(fn);
                return -ENOMEM;
        }
 
-       iommu->ir_domain->parent = arch_get_ir_parent_domain();
-       iommu->msi_domain = arch_create_remap_msi_irq_domain(iommu->ir_domain,
-                                                            "AMD-IR-MSI",
-                                                            iommu->index);
+       irq_domain_update_bus_token(iommu->ir_domain,  DOMAIN_BUS_AMDVI);
+       iommu->ir_domain->flags |= IRQ_DOMAIN_FLAG_MSI_PARENT;
+       iommu->ir_domain->msi_parent_ops = &amdvi_msi_parent_ops;
+
        return 0;
 }
 
index 3a09396ac88d25fdde4c4d65b1afd371f4bee549..0b2d8a83e0d837c7ce5e3fab22904bafa97fee08 100644 (file)
@@ -24,6 +24,7 @@ enum irq_domain_bus_token {
        DOMAIN_BUS_PCI_DEVICE_MSI,
        DOMAIN_BUS_PCI_DEVICE_MSIX,
        DOMAIN_BUS_DMAR,
+       DOMAIN_BUS_AMDVI,
 };
 
 #endif /* _LINUX_IRQDOMAIN_DEFS_H */