Commit 54625ef1 authored by Suravee Suthikulpanit's avatar Suravee Suthikulpanit Committed by Joerg Roedel

iommu/amd: Update set_dte_entry and clear_dte_entry

Start using per PCI segment data structures instead of global data
structures.
Signed-off-by: default avatarSuravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Signed-off-by: default avatarVasant Hegde <vasant.hegde@amd.com>
Link: https://lore.kernel.org/r/20220706113825.25582-22-vasant.hegde@amd.comSigned-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent ccacd94f
...@@ -1537,6 +1537,7 @@ static void set_dte_entry(struct amd_iommu *iommu, u16 devid, ...@@ -1537,6 +1537,7 @@ static void set_dte_entry(struct amd_iommu *iommu, u16 devid,
u64 pte_root = 0; u64 pte_root = 0;
u64 flags = 0; u64 flags = 0;
u32 old_domid; u32 old_domid;
struct dev_table_entry *dev_table = get_dev_table(iommu);
if (domain->iop.mode != PAGE_MODE_NONE) if (domain->iop.mode != PAGE_MODE_NONE)
pte_root = iommu_virt_to_phys(domain->iop.root); pte_root = iommu_virt_to_phys(domain->iop.root);
...@@ -1545,7 +1546,7 @@ static void set_dte_entry(struct amd_iommu *iommu, u16 devid, ...@@ -1545,7 +1546,7 @@ static void set_dte_entry(struct amd_iommu *iommu, u16 devid,
<< DEV_ENTRY_MODE_SHIFT; << DEV_ENTRY_MODE_SHIFT;
pte_root |= DTE_FLAG_IR | DTE_FLAG_IW | DTE_FLAG_V | DTE_FLAG_TV; 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) if (ats)
flags |= DTE_FLAG_IOTLB; flags |= DTE_FLAG_IOTLB;
...@@ -1584,9 +1585,9 @@ static void set_dte_entry(struct amd_iommu *iommu, u16 devid, ...@@ -1584,9 +1585,9 @@ static void set_dte_entry(struct amd_iommu *iommu, u16 devid,
flags &= ~DEV_DOMID_MASK; flags &= ~DEV_DOMID_MASK;
flags |= domain->id; flags |= domain->id;
old_domid = amd_iommu_dev_table[devid].data[1] & DEV_DOMID_MASK; old_domid = dev_table[devid].data[1] & DEV_DOMID_MASK;
amd_iommu_dev_table[devid].data[1] = flags; dev_table[devid].data[1] = flags;
amd_iommu_dev_table[devid].data[0] = pte_root; dev_table[devid].data[0] = pte_root;
/* /*
* A kdump kernel might be replacing a domain ID that was copied from * 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, ...@@ -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 */ /* remove entry from the device table seen by the hardware */
amd_iommu_dev_table[devid].data[0] = DTE_FLAG_V | DTE_FLAG_TV; 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[1] &= DTE_FLAG_MASK;
amd_iommu_apply_erratum_63(devid); amd_iommu_apply_erratum_63(devid);
} }
...@@ -1646,7 +1649,7 @@ static void do_detach(struct iommu_dev_data *dev_data) ...@@ -1646,7 +1649,7 @@ static void do_detach(struct iommu_dev_data *dev_data)
/* Update data structures */ /* Update data structures */
dev_data->domain = NULL; dev_data->domain = NULL;
list_del(&dev_data->list); list_del(&dev_data->list);
clear_dte_entry(dev_data->devid); clear_dte_entry(iommu, dev_data->devid);
clone_aliases(iommu, dev_data->dev); clone_aliases(iommu, dev_data->dev);
/* Flush the DTE entry */ /* Flush the DTE entry */
......
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