iommu/amd: Update set_dte_irq_entry
authorSuravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Wed, 6 Jul 2022 11:38:14 +0000 (17:08 +0530)
committerJoerg Roedel <jroedel@suse.de>
Thu, 7 Jul 2022 07:37:47 +0000 (09:37 +0200)
Start using per PCI segment device table instead of global
device table.

Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Signed-off-by: Vasant Hegde <vasant.hegde@amd.com>
Link: https://lore.kernel.org/r/20220706113825.25582-25-vasant.hegde@amd.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/amd/iommu.c

index 790a344..f1fab41 100644 (file)
@@ -2731,18 +2731,20 @@ EXPORT_SYMBOL(amd_iommu_device_info);
 static struct irq_chip amd_ir_chip;
 static DEFINE_SPINLOCK(iommu_table_lock);
 
-static void set_dte_irq_entry(u16 devid, struct irq_remap_table *table)
+static void set_dte_irq_entry(struct amd_iommu *iommu, u16 devid,
+                             struct irq_remap_table *table)
 {
        u64 dte;
+       struct dev_table_entry *dev_table = get_dev_table(iommu);
 
-       dte     = amd_iommu_dev_table[devid].data[2];
+       dte     = dev_table[devid].data[2];
        dte     &= ~DTE_IRQ_PHYS_ADDR_MASK;
        dte     |= iommu_virt_to_phys(table->table);
        dte     |= DTE_IRQ_REMAP_INTCTL;
        dte     |= DTE_INTTABLEN;
        dte     |= DTE_IRQ_REMAP_ENABLE;
 
-       amd_iommu_dev_table[devid].data[2] = dte;
+       dev_table[devid].data[2] = dte;
 }
 
 static struct irq_remap_table *get_irq_table(struct amd_iommu *iommu, u16 devid)
@@ -2793,7 +2795,7 @@ static void set_remap_table_entry(struct amd_iommu *iommu, u16 devid,
        struct amd_iommu_pci_seg *pci_seg = iommu->pci_seg;
 
        pci_seg->irq_lookup_table[devid] = table;
-       set_dte_irq_entry(devid, table);
+       set_dte_irq_entry(iommu, devid, table);
        iommu_flush_dte(iommu, devid);
 }
 
@@ -2809,8 +2811,7 @@ static int set_remap_table_entry_alias(struct pci_dev *pdev, u16 alias,
 
        pci_seg = iommu->pci_seg;
        pci_seg->irq_lookup_table[alias] = table;
-       set_dte_irq_entry(alias, table);
-
+       set_dte_irq_entry(iommu, alias, table);
        iommu_flush_dte(pci_seg->rlookup_table[alias], alias);
 
        return 0;