Commit e6457d7c authored by Suravee Suthikulpanit's avatar Suravee Suthikulpanit Committed by Joerg Roedel

iommu/amd: Update alloc_irq_table and alloc_irq_index

Pass amd_iommu structure as one of the parameter to these functions
as its needed to retrieve variable tables inside these functions.
Co-developed-by: default avatarVasant Hegde <vasant.hegde@amd.com>
Signed-off-by: default avatarVasant Hegde <vasant.hegde@amd.com>
Signed-off-by: default avatarSuravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Link: https://lore.kernel.org/r/20220706113825.25582-20-vasant.hegde@amd.comSigned-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent c4649a45
...@@ -2814,21 +2814,17 @@ static int set_remap_table_entry_alias(struct pci_dev *pdev, u16 alias, ...@@ -2814,21 +2814,17 @@ static int set_remap_table_entry_alias(struct pci_dev *pdev, u16 alias,
return 0; return 0;
} }
static struct irq_remap_table *alloc_irq_table(u16 devid, struct pci_dev *pdev) static struct irq_remap_table *alloc_irq_table(struct amd_iommu *iommu,
u16 devid, struct pci_dev *pdev)
{ {
struct irq_remap_table *table = NULL; struct irq_remap_table *table = NULL;
struct irq_remap_table *new_table = NULL; struct irq_remap_table *new_table = NULL;
struct amd_iommu_pci_seg *pci_seg; struct amd_iommu_pci_seg *pci_seg;
struct amd_iommu *iommu;
unsigned long flags; unsigned long flags;
u16 alias; u16 alias;
spin_lock_irqsave(&iommu_table_lock, flags); spin_lock_irqsave(&iommu_table_lock, flags);
iommu = amd_iommu_rlookup_table[devid];
if (!iommu)
goto out_unlock;
pci_seg = iommu->pci_seg; pci_seg = iommu->pci_seg;
table = pci_seg->irq_lookup_table[devid]; table = pci_seg->irq_lookup_table[devid];
if (table) if (table)
...@@ -2884,18 +2880,14 @@ static struct irq_remap_table *alloc_irq_table(u16 devid, struct pci_dev *pdev) ...@@ -2884,18 +2880,14 @@ static struct irq_remap_table *alloc_irq_table(u16 devid, struct pci_dev *pdev)
return table; return table;
} }
static int alloc_irq_index(u16 devid, int count, bool align, static int alloc_irq_index(struct amd_iommu *iommu, u16 devid, int count,
struct pci_dev *pdev) bool align, struct pci_dev *pdev)
{ {
struct irq_remap_table *table; struct irq_remap_table *table;
int index, c, alignment = 1; int index, c, alignment = 1;
unsigned long flags; unsigned long flags;
struct amd_iommu *iommu = amd_iommu_rlookup_table[devid];
if (!iommu)
return -ENODEV;
table = alloc_irq_table(devid, pdev); table = alloc_irq_table(iommu, devid, pdev);
if (!table) if (!table)
return -ENODEV; return -ENODEV;
...@@ -3267,7 +3259,7 @@ static int irq_remapping_alloc(struct irq_domain *domain, unsigned int virq, ...@@ -3267,7 +3259,7 @@ static int irq_remapping_alloc(struct irq_domain *domain, unsigned int virq,
if (info->type == X86_IRQ_ALLOC_TYPE_IOAPIC) { if (info->type == X86_IRQ_ALLOC_TYPE_IOAPIC) {
struct irq_remap_table *table; struct irq_remap_table *table;
table = alloc_irq_table(devid, NULL); table = alloc_irq_table(iommu, devid, NULL);
if (table) { if (table) {
if (!table->min_index) { if (!table->min_index) {
/* /*
...@@ -3287,10 +3279,10 @@ static int irq_remapping_alloc(struct irq_domain *domain, unsigned int virq, ...@@ -3287,10 +3279,10 @@ static int irq_remapping_alloc(struct irq_domain *domain, unsigned int virq,
info->type == X86_IRQ_ALLOC_TYPE_PCI_MSIX) { info->type == X86_IRQ_ALLOC_TYPE_PCI_MSIX) {
bool align = (info->type == X86_IRQ_ALLOC_TYPE_PCI_MSI); bool align = (info->type == X86_IRQ_ALLOC_TYPE_PCI_MSI);
index = alloc_irq_index(devid, nr_irqs, align, index = alloc_irq_index(iommu, devid, nr_irqs, align,
msi_desc_to_pci_dev(info->desc)); msi_desc_to_pci_dev(info->desc));
} else { } else {
index = alloc_irq_index(devid, nr_irqs, false, NULL); index = alloc_irq_index(iommu, devid, nr_irqs, false, NULL);
} }
if (index < 0) { if (index < 0) {
...@@ -3416,8 +3408,8 @@ static int irq_remapping_select(struct irq_domain *d, struct irq_fwspec *fwspec, ...@@ -3416,8 +3408,8 @@ static int irq_remapping_select(struct irq_domain *d, struct irq_fwspec *fwspec,
if (devid < 0) if (devid < 0)
return 0; return 0;
iommu = __rlookup_amd_iommu((devid >> 16), (devid & 0xffff));
iommu = amd_iommu_rlookup_table[devid];
return iommu && iommu->ir_domain == d; return iommu && iommu->ir_domain == d;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment