diff options
| -rw-r--r-- | drivers/iommu/amd_iommu.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index ea120c7b46c9..11ea2d656be8 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c | |||
| @@ -3617,6 +3617,14 @@ static struct irq_remap_table *get_irq_table(u16 devid) | |||
| 3617 | return table; | 3617 | return table; |
| 3618 | } | 3618 | } |
| 3619 | 3619 | ||
| 3620 | static void set_remap_table_entry(struct amd_iommu *iommu, u16 devid, | ||
| 3621 | struct irq_remap_table *table) | ||
| 3622 | { | ||
| 3623 | irq_lookup_table[devid] = table; | ||
| 3624 | set_dte_irq_entry(devid, table); | ||
| 3625 | iommu_flush_dte(iommu, devid); | ||
| 3626 | } | ||
| 3627 | |||
| 3620 | static struct irq_remap_table *alloc_irq_table(u16 devid) | 3628 | static struct irq_remap_table *alloc_irq_table(u16 devid) |
| 3621 | { | 3629 | { |
| 3622 | struct irq_remap_table *table = NULL; | 3630 | struct irq_remap_table *table = NULL; |
| @@ -3637,9 +3645,7 @@ static struct irq_remap_table *alloc_irq_table(u16 devid) | |||
| 3637 | alias = amd_iommu_alias_table[devid]; | 3645 | alias = amd_iommu_alias_table[devid]; |
| 3638 | table = irq_lookup_table[alias]; | 3646 | table = irq_lookup_table[alias]; |
| 3639 | if (table) { | 3647 | if (table) { |
| 3640 | irq_lookup_table[devid] = table; | 3648 | set_remap_table_entry(iommu, devid, table); |
| 3641 | set_dte_irq_entry(devid, table); | ||
| 3642 | iommu_flush_dte(iommu, devid); | ||
| 3643 | goto out; | 3649 | goto out; |
| 3644 | } | 3650 | } |
| 3645 | 3651 | ||
| @@ -3666,14 +3672,9 @@ static struct irq_remap_table *alloc_irq_table(u16 devid) | |||
| 3666 | (MAX_IRQS_PER_TABLE * (sizeof(u64) * 2))); | 3672 | (MAX_IRQS_PER_TABLE * (sizeof(u64) * 2))); |
| 3667 | 3673 | ||
| 3668 | 3674 | ||
| 3669 | irq_lookup_table[devid] = table; | 3675 | set_remap_table_entry(iommu, devid, table); |
| 3670 | set_dte_irq_entry(devid, table); | 3676 | if (devid != alias) |
| 3671 | iommu_flush_dte(iommu, devid); | 3677 | set_remap_table_entry(iommu, alias, table); |
| 3672 | if (devid != alias) { | ||
| 3673 | irq_lookup_table[alias] = table; | ||
| 3674 | set_dte_irq_entry(alias, table); | ||
| 3675 | iommu_flush_dte(iommu, alias); | ||
| 3676 | } | ||
| 3677 | 3678 | ||
| 3678 | out: | 3679 | out: |
| 3679 | iommu_completion_wait(iommu); | 3680 | iommu_completion_wait(iommu); |
