Skip to content

Commit 8154f3c

Browse files
Marc Zyngierjoergroedel
authored andcommitted
iommu/intel: Convert to msi_create_parent_irq_domain() helper
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 <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Signed-off-by: Nam Cao <[email protected]> Link: https://lore.kernel.org/all/[email protected] Link: https://lore.kernel.org/r/169c793c50be8493cfd9d11affb00e9ed6341c36.1750858125.git.namcao@linutronix.de Signed-off-by: Joerg Roedel <[email protected]>
1 parent 0eaa67a commit 8154f3c

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

drivers/iommu/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ source "drivers/iommu/riscv/Kconfig"
200200
config IRQ_REMAP
201201
bool "Support for Interrupt Remapping"
202202
depends on X86_64 && X86_IO_APIC && PCI_MSI && ACPI
203+
select IRQ_MSI_LIB
203204
help
204205
Supports Interrupt remapping for IO-APIC and MSI devices.
205206
To use x2apic mode in the CPU's which support x2APIC enhancements or

drivers/iommu/intel/irq_remapping.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/hpet.h>
1111
#include <linux/pci.h>
1212
#include <linux/irq.h>
13+
#include <linux/irqchip/irq-msi-lib.h>
1314
#include <linux/acpi.h>
1415
#include <linux/irqdomain.h>
1516
#include <linux/crash_dump.h>
@@ -518,8 +519,14 @@ static void iommu_enable_irq_remapping(struct intel_iommu *iommu)
518519

519520
static int intel_setup_irq_remapping(struct intel_iommu *iommu)
520521
{
522+
struct irq_domain_info info = {
523+
.ops = &intel_ir_domain_ops,
524+
.parent = arch_get_ir_parent_domain(),
525+
.domain_flags = IRQ_DOMAIN_FLAG_ISOLATED_MSI,
526+
.size = INTR_REMAP_TABLE_ENTRIES,
527+
.host_data = iommu,
528+
};
521529
struct ir_table *ir_table;
522-
struct fwnode_handle *fn;
523530
unsigned long *bitmap;
524531
void *ir_table_base;
525532

@@ -544,25 +551,16 @@ static int intel_setup_irq_remapping(struct intel_iommu *iommu)
544551
goto out_free_pages;
545552
}
546553

547-
fn = irq_domain_alloc_named_id_fwnode("INTEL-IR", iommu->seq_id);
548-
if (!fn)
554+
info.fwnode = irq_domain_alloc_named_id_fwnode("INTEL-IR", iommu->seq_id);
555+
if (!info.fwnode)
549556
goto out_free_bitmap;
550557

551-
iommu->ir_domain =
552-
irq_domain_create_hierarchy(arch_get_ir_parent_domain(),
553-
0, INTR_REMAP_TABLE_ENTRIES,
554-
fn, &intel_ir_domain_ops,
555-
iommu);
558+
iommu->ir_domain = msi_create_parent_irq_domain(&info, &dmar_msi_parent_ops);
556559
if (!iommu->ir_domain) {
557560
pr_err("IR%d: failed to allocate irqdomain\n", iommu->seq_id);
558561
goto out_free_fwnode;
559562
}
560563

561-
irq_domain_update_bus_token(iommu->ir_domain, DOMAIN_BUS_DMAR);
562-
iommu->ir_domain->flags |= IRQ_DOMAIN_FLAG_MSI_PARENT |
563-
IRQ_DOMAIN_FLAG_ISOLATED_MSI;
564-
iommu->ir_domain->msi_parent_ops = &dmar_msi_parent_ops;
565-
566564
ir_table->base = ir_table_base;
567565
ir_table->bitmap = bitmap;
568566
iommu->ir_table = ir_table;
@@ -608,7 +606,7 @@ static int intel_setup_irq_remapping(struct intel_iommu *iommu)
608606
irq_domain_remove(iommu->ir_domain);
609607
iommu->ir_domain = NULL;
610608
out_free_fwnode:
611-
irq_domain_free_fwnode(fn);
609+
irq_domain_free_fwnode(info.fwnode);
612610
out_free_bitmap:
613611
bitmap_free(bitmap);
614612
out_free_pages:
@@ -1530,6 +1528,8 @@ static const struct irq_domain_ops intel_ir_domain_ops = {
15301528

15311529
static const struct msi_parent_ops dmar_msi_parent_ops = {
15321530
.supported_flags = X86_VECTOR_MSI_FLAGS_SUPPORTED | MSI_FLAG_MULTI_PCI_MSI,
1531+
.bus_select_token = DOMAIN_BUS_DMAR,
1532+
.bus_select_mask = MATCH_PCI_MSI,
15331533
.prefix = "IR-",
15341534
.init_dev_msi_info = msi_parent_init_dev_msi_info,
15351535
};

0 commit comments

Comments
 (0)