Commit 9873ae6e authored by Suravee Suthikulpanit's avatar Suravee Suthikulpanit Committed by Joerg Roedel

iommu/amd: Update irq_remapping_alloc to use IOMMU lookup helper function

To allow IOMMU rlookup using both PCI segment and device ID.
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-17-vasant.hegde@amd.comSigned-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent 8b71c9bf
...@@ -3246,8 +3246,9 @@ static int irq_remapping_alloc(struct irq_domain *domain, unsigned int virq, ...@@ -3246,8 +3246,9 @@ static int irq_remapping_alloc(struct irq_domain *domain, unsigned int virq,
struct irq_alloc_info *info = arg; struct irq_alloc_info *info = arg;
struct irq_data *irq_data; struct irq_data *irq_data;
struct amd_ir_data *data = NULL; struct amd_ir_data *data = NULL;
struct amd_iommu *iommu;
struct irq_cfg *cfg; struct irq_cfg *cfg;
int i, ret, devid; int i, ret, devid, seg, sbdf;
int index; int index;
if (!info) if (!info)
...@@ -3263,8 +3264,14 @@ static int irq_remapping_alloc(struct irq_domain *domain, unsigned int virq, ...@@ -3263,8 +3264,14 @@ static int irq_remapping_alloc(struct irq_domain *domain, unsigned int virq,
if (info->type == X86_IRQ_ALLOC_TYPE_PCI_MSI) if (info->type == X86_IRQ_ALLOC_TYPE_PCI_MSI)
info->flags &= ~X86_IRQ_ALLOC_CONTIGUOUS_VECTORS; info->flags &= ~X86_IRQ_ALLOC_CONTIGUOUS_VECTORS;
devid = get_devid(info); sbdf = get_devid(info);
if (devid < 0) if (sbdf < 0)
return -EINVAL;
seg = PCI_SBDF_TO_SEGID(sbdf);
devid = PCI_SBDF_TO_DEVID(sbdf);
iommu = __rlookup_amd_iommu(seg, devid);
if (!iommu)
return -EINVAL; return -EINVAL;
ret = irq_domain_alloc_irqs_parent(domain, virq, nr_irqs, arg); ret = irq_domain_alloc_irqs_parent(domain, virq, nr_irqs, arg);
...@@ -3273,7 +3280,6 @@ static int irq_remapping_alloc(struct irq_domain *domain, unsigned int virq, ...@@ -3273,7 +3280,6 @@ 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;
struct amd_iommu *iommu;
table = alloc_irq_table(devid, NULL); table = alloc_irq_table(devid, NULL);
if (table) { if (table) {
...@@ -3283,7 +3289,6 @@ static int irq_remapping_alloc(struct irq_domain *domain, unsigned int virq, ...@@ -3283,7 +3289,6 @@ static int irq_remapping_alloc(struct irq_domain *domain, unsigned int virq,
* interrupts. * interrupts.
*/ */
table->min_index = 32; table->min_index = 32;
iommu = amd_iommu_rlookup_table[devid];
for (i = 0; i < 32; ++i) for (i = 0; i < 32; ++i)
iommu->irte_ops->set_allocated(table, i); iommu->irte_ops->set_allocated(table, i);
} }
......
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