From: Suravee Suthikulpanit <suravee.suthikulpa...@amd.com>

Start using per PCI segment data structures instead of global data
structures.

Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpa...@amd.com>
Signed-off-by: Vasant Hegde <vasant.he...@amd.com>
---
 drivers/iommu/amd/iommu.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index 6e0cd9c4f57c..493cda5e0246 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -1537,6 +1537,7 @@ static void set_dte_entry(struct amd_iommu *iommu, u16 
devid,
        u64 pte_root = 0;
        u64 flags = 0;
        u32 old_domid;
+       struct dev_table_entry *dev_table = get_dev_table(iommu);
 
        if (domain->iop.mode != PAGE_MODE_NONE)
                pte_root = iommu_virt_to_phys(domain->iop.root);
@@ -1545,7 +1546,7 @@ static void set_dte_entry(struct amd_iommu *iommu, u16 
devid,
                    << DEV_ENTRY_MODE_SHIFT;
        pte_root |= DTE_FLAG_IR | DTE_FLAG_IW | DTE_FLAG_V | DTE_FLAG_TV;
 
-       flags = amd_iommu_dev_table[devid].data[1];
+       flags = dev_table[devid].data[1];
 
        if (ats)
                flags |= DTE_FLAG_IOTLB;
@@ -1584,9 +1585,9 @@ static void set_dte_entry(struct amd_iommu *iommu, u16 
devid,
        flags &= ~DEV_DOMID_MASK;
        flags |= domain->id;
 
-       old_domid = amd_iommu_dev_table[devid].data[1] & DEV_DOMID_MASK;
-       amd_iommu_dev_table[devid].data[1]  = flags;
-       amd_iommu_dev_table[devid].data[0]  = pte_root;
+       old_domid = dev_table[devid].data[1] & DEV_DOMID_MASK;
+       dev_table[devid].data[1]  = flags;
+       dev_table[devid].data[0]  = pte_root;
 
        /*
         * A kdump kernel might be replacing a domain ID that was copied from
@@ -1598,11 +1599,13 @@ static void set_dte_entry(struct amd_iommu *iommu, u16 
devid,
        }
 }
 
-static void clear_dte_entry(u16 devid)
+static void clear_dte_entry(struct amd_iommu *iommu, u16 devid)
 {
+       struct dev_table_entry *dev_table = get_dev_table(iommu);
+
        /* remove entry from the device table seen by the hardware */
-       amd_iommu_dev_table[devid].data[0]  = DTE_FLAG_V | DTE_FLAG_TV;
-       amd_iommu_dev_table[devid].data[1] &= DTE_FLAG_MASK;
+       dev_table[devid].data[0]  = DTE_FLAG_V | DTE_FLAG_TV;
+       dev_table[devid].data[1] &= DTE_FLAG_MASK;
 
        amd_iommu_apply_erratum_63(devid);
 }
@@ -1646,7 +1649,7 @@ static void do_detach(struct iommu_dev_data *dev_data)
        /* Update data structures */
        dev_data->domain = NULL;
        list_del(&dev_data->list);
-       clear_dte_entry(dev_data->devid);
+       clear_dte_entry(iommu, dev_data->devid);
        clone_aliases(iommu, dev_data->dev);
 
        /* Flush the DTE entry */
-- 
2.31.1

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Reply via email to