iommu/amd: Introduce per PCI segment dev_data_list
This will replace global dev_data_list. Co-developed-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> 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-7-vasant.hegde@amd.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
This commit is contained in:
parent
333e581bcd
commit
39a303ba4a
|
@ -546,6 +546,9 @@ struct amd_iommu_pci_seg {
|
|||
/* List with all PCI segments in the system */
|
||||
struct list_head list;
|
||||
|
||||
/* List of all available dev_data structures */
|
||||
struct llist_head dev_data_list;
|
||||
|
||||
/* PCI segment number */
|
||||
u16 id;
|
||||
|
||||
|
|
|
@ -1527,6 +1527,7 @@ static struct amd_iommu_pci_seg *__init alloc_pci_segment(u16 id)
|
|||
return NULL;
|
||||
|
||||
pci_seg->id = id;
|
||||
init_llist_head(&pci_seg->dev_data_list);
|
||||
list_add_tail(&pci_seg->list, &amd_iommu_pci_seg_list);
|
||||
|
||||
if (alloc_dev_table(pci_seg))
|
||||
|
|
|
@ -62,9 +62,6 @@
|
|||
|
||||
static DEFINE_SPINLOCK(pd_bitmap_lock);
|
||||
|
||||
/* List of all available dev_data structures */
|
||||
static LLIST_HEAD(dev_data_list);
|
||||
|
||||
LIST_HEAD(ioapic_map);
|
||||
LIST_HEAD(hpet_map);
|
||||
LIST_HEAD(acpihid_map);
|
||||
|
@ -195,9 +192,10 @@ static struct protection_domain *to_pdomain(struct iommu_domain *dom)
|
|||
return container_of(dom, struct protection_domain, domain);
|
||||
}
|
||||
|
||||
static struct iommu_dev_data *alloc_dev_data(u16 devid)
|
||||
static struct iommu_dev_data *alloc_dev_data(struct amd_iommu *iommu, u16 devid)
|
||||
{
|
||||
struct iommu_dev_data *dev_data;
|
||||
struct amd_iommu_pci_seg *pci_seg = iommu->pci_seg;
|
||||
|
||||
dev_data = kzalloc(sizeof(*dev_data), GFP_KERNEL);
|
||||
if (!dev_data)
|
||||
|
@ -207,19 +205,20 @@ static struct iommu_dev_data *alloc_dev_data(u16 devid)
|
|||
dev_data->devid = devid;
|
||||
ratelimit_default_init(&dev_data->rs);
|
||||
|
||||
llist_add(&dev_data->dev_data_list, &dev_data_list);
|
||||
llist_add(&dev_data->dev_data_list, &pci_seg->dev_data_list);
|
||||
return dev_data;
|
||||
}
|
||||
|
||||
static struct iommu_dev_data *search_dev_data(u16 devid)
|
||||
static struct iommu_dev_data *search_dev_data(struct amd_iommu *iommu, u16 devid)
|
||||
{
|
||||
struct iommu_dev_data *dev_data;
|
||||
struct llist_node *node;
|
||||
struct amd_iommu_pci_seg *pci_seg = iommu->pci_seg;
|
||||
|
||||
if (llist_empty(&dev_data_list))
|
||||
if (llist_empty(&pci_seg->dev_data_list))
|
||||
return NULL;
|
||||
|
||||
node = dev_data_list.first;
|
||||
node = pci_seg->dev_data_list.first;
|
||||
llist_for_each_entry(dev_data, node, dev_data_list) {
|
||||
if (dev_data->devid == devid)
|
||||
return dev_data;
|
||||
|
@ -288,10 +287,10 @@ static struct iommu_dev_data *find_dev_data(u16 devid)
|
|||
struct iommu_dev_data *dev_data;
|
||||
struct amd_iommu *iommu = amd_iommu_rlookup_table[devid];
|
||||
|
||||
dev_data = search_dev_data(devid);
|
||||
dev_data = search_dev_data(iommu, devid);
|
||||
|
||||
if (dev_data == NULL) {
|
||||
dev_data = alloc_dev_data(devid);
|
||||
dev_data = alloc_dev_data(iommu, devid);
|
||||
if (!dev_data)
|
||||
return NULL;
|
||||
|
||||
|
@ -3466,7 +3465,7 @@ static int amd_ir_set_vcpu_affinity(struct irq_data *data, void *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(irte_info->devid);
|
||||
struct iommu_dev_data *dev_data = search_dev_data(NULL, irte_info->devid);
|
||||
|
||||
/* Note:
|
||||
* This device has never been set up for guest mode.
|
||||
|
|
Loading…
Reference in New Issue