mirror of
https://github.com/torvalds/linux.git
synced 2024-11-27 14:41:39 +00:00
iommu/amd: Introduce struct amd_ir_data.iommu
Add a pointer to struct amd_iommu to amd_ir_data structure, which can be used to correlate interrupt remapping data to a per-PCI-segment interrupt remapping table. Co-developed-by: Vasant Hegde <vasant.hegde@amd.com> Signed-off-by: Vasant Hegde <vasant.hegde@amd.com> Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Link: https://lore.kernel.org/r/20220706113825.25582-18-vasant.hegde@amd.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
This commit is contained in:
parent
9873ae6e94
commit
9457d75c05
@ -989,6 +989,7 @@ struct irq_2_irte {
|
||||
|
||||
struct amd_ir_data {
|
||||
u32 cached_ga_tag;
|
||||
struct amd_iommu *iommu;
|
||||
struct irq_2_irte irq_2_irte;
|
||||
struct msi_msg msi_entry;
|
||||
void *entry; /* Pointer to union irte or struct irte_ga */
|
||||
|
@ -3002,16 +3002,11 @@ static int modify_irte(u16 devid, int index, union irte *irte)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void free_irte(u16 devid, int index)
|
||||
static void free_irte(struct amd_iommu *iommu, u16 devid, int index)
|
||||
{
|
||||
struct irq_remap_table *table;
|
||||
struct amd_iommu *iommu;
|
||||
unsigned long flags;
|
||||
|
||||
iommu = amd_iommu_rlookup_table[devid];
|
||||
if (iommu == NULL)
|
||||
return;
|
||||
|
||||
table = get_irq_table(iommu, devid);
|
||||
if (!table)
|
||||
return;
|
||||
@ -3195,7 +3190,7 @@ static void irq_remapping_prepare_irte(struct amd_ir_data *data,
|
||||
int devid, int index, int sub_handle)
|
||||
{
|
||||
struct irq_2_irte *irte_info = &data->irq_2_irte;
|
||||
struct amd_iommu *iommu = amd_iommu_rlookup_table[devid];
|
||||
struct amd_iommu *iommu = data->iommu;
|
||||
|
||||
if (!iommu)
|
||||
return;
|
||||
@ -3336,6 +3331,7 @@ static int irq_remapping_alloc(struct irq_domain *domain, unsigned int virq,
|
||||
goto out_free_data;
|
||||
}
|
||||
|
||||
data->iommu = iommu;
|
||||
irq_data->hwirq = (devid << 16) + i;
|
||||
irq_data->chip_data = data;
|
||||
irq_data->chip = &amd_ir_chip;
|
||||
@ -3352,7 +3348,7 @@ out_free_data:
|
||||
kfree(irq_data->chip_data);
|
||||
}
|
||||
for (i = 0; i < nr_irqs; i++)
|
||||
free_irte(devid, index + i);
|
||||
free_irte(iommu, devid, index + i);
|
||||
out_free_parent:
|
||||
irq_domain_free_irqs_common(domain, virq, nr_irqs);
|
||||
return ret;
|
||||
@ -3371,7 +3367,7 @@ static void irq_remapping_free(struct irq_domain *domain, unsigned int virq,
|
||||
if (irq_data && irq_data->chip_data) {
|
||||
data = irq_data->chip_data;
|
||||
irte_info = &data->irq_2_irte;
|
||||
free_irte(irte_info->devid, irte_info->index);
|
||||
free_irte(data->iommu, irte_info->devid, irte_info->index);
|
||||
kfree(data->entry);
|
||||
kfree(data);
|
||||
}
|
||||
@ -3389,7 +3385,7 @@ static int irq_remapping_activate(struct irq_domain *domain,
|
||||
{
|
||||
struct amd_ir_data *data = irq_data->chip_data;
|
||||
struct irq_2_irte *irte_info = &data->irq_2_irte;
|
||||
struct amd_iommu *iommu = amd_iommu_rlookup_table[irte_info->devid];
|
||||
struct amd_iommu *iommu = data->iommu;
|
||||
struct irq_cfg *cfg = irqd_cfg(irq_data);
|
||||
|
||||
if (!iommu)
|
||||
@ -3406,7 +3402,7 @@ static void irq_remapping_deactivate(struct irq_domain *domain,
|
||||
{
|
||||
struct amd_ir_data *data = irq_data->chip_data;
|
||||
struct irq_2_irte *irte_info = &data->irq_2_irte;
|
||||
struct amd_iommu *iommu = amd_iommu_rlookup_table[irte_info->devid];
|
||||
struct amd_iommu *iommu = data->iommu;
|
||||
|
||||
if (iommu)
|
||||
iommu->irte_ops->deactivate(data->entry, irte_info->devid,
|
||||
@ -3502,12 +3498,16 @@ EXPORT_SYMBOL(amd_iommu_deactivate_guest_mode);
|
||||
static int amd_ir_set_vcpu_affinity(struct irq_data *data, void *vcpu_info)
|
||||
{
|
||||
int ret;
|
||||
struct amd_iommu *iommu;
|
||||
struct amd_iommu_pi_data *pi_data = vcpu_info;
|
||||
struct vcpu_data *vcpu_pi_info = pi_data->vcpu_data;
|
||||
struct amd_ir_data *ir_data = data->chip_data;
|
||||
struct irq_2_irte *irte_info = &ir_data->irq_2_irte;
|
||||
struct iommu_dev_data *dev_data = search_dev_data(NULL, irte_info->devid);
|
||||
struct iommu_dev_data *dev_data;
|
||||
|
||||
if (ir_data->iommu == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
dev_data = search_dev_data(ir_data->iommu, irte_info->devid);
|
||||
|
||||
/* Note:
|
||||
* This device has never been set up for guest mode.
|
||||
@ -3529,10 +3529,6 @@ static int amd_ir_set_vcpu_affinity(struct irq_data *data, void *vcpu_info)
|
||||
pi_data->is_guest_mode = false;
|
||||
}
|
||||
|
||||
iommu = amd_iommu_rlookup_table[irte_info->devid];
|
||||
if (iommu == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
pi_data->prev_ga_tag = ir_data->cached_ga_tag;
|
||||
if (pi_data->is_guest_mode) {
|
||||
ir_data->ga_root_ptr = (pi_data->base >> 12);
|
||||
@ -3578,7 +3574,7 @@ static int amd_ir_set_affinity(struct irq_data *data,
|
||||
struct irq_2_irte *irte_info = &ir_data->irq_2_irte;
|
||||
struct irq_cfg *cfg = irqd_cfg(data);
|
||||
struct irq_data *parent = data->parent_data;
|
||||
struct amd_iommu *iommu = amd_iommu_rlookup_table[irte_info->devid];
|
||||
struct amd_iommu *iommu = ir_data->iommu;
|
||||
int ret;
|
||||
|
||||
if (!iommu)
|
||||
@ -3648,7 +3644,7 @@ int amd_iommu_update_ga(int cpu, bool is_run, void *data)
|
||||
!ref || !entry || !entry->lo.fields_vapic.guest_mode)
|
||||
return 0;
|
||||
|
||||
iommu = amd_iommu_rlookup_table[devid];
|
||||
iommu = ir_data->iommu;
|
||||
if (!iommu)
|
||||
return -ENODEV;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user