summaryrefslogtreecommitdiff
path: root/drivers/iommu/amd/io_pgtable.c
diff options
context:
space:
mode:
authorSuravee Suthikulpanit <suravee.suthikulpanit@amd.com>2020-12-15 10:36:59 +0300
committerJoerg Roedel <jroedel@suse.de>2021-01-28 18:51:17 +0300
commite42ba0633064ef23eb1c8c21edf96bac1541bd4b (patch)
tree4a6628270d783766073404e32892030241a41cee /drivers/iommu/amd/io_pgtable.c
parent18954252a1d0b12e1b77087b55c37fb43b09e12a (diff)
downloadlinux-e42ba0633064ef23eb1c8c21edf96bac1541bd4b.tar.xz
iommu/amd: Restructure code for freeing page table
By consolidate logic into v1_free_pgtable helper function, which is called from IO page table framework. Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Link: https://lore.kernel.org/r/20201215073705.123786-8-suravee.suthikulpanit@amd.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
Diffstat (limited to 'drivers/iommu/amd/io_pgtable.c')
-rw-r--r--drivers/iommu/amd/io_pgtable.c41
1 files changed, 24 insertions, 17 deletions
diff --git a/drivers/iommu/amd/io_pgtable.c b/drivers/iommu/amd/io_pgtable.c
index dbc0ad775d5e..a8fea06efb4f 100644
--- a/drivers/iommu/amd/io_pgtable.c
+++ b/drivers/iommu/amd/io_pgtable.c
@@ -157,23 +157,6 @@ static struct page *free_sub_pt(unsigned long root, int mode,
return freelist;
}
-void free_pagetable(struct domain_pgtable *pgtable)
-{
- struct page *freelist = NULL;
- unsigned long root;
-
- if (pgtable->mode == PAGE_MODE_NONE)
- return;
-
- BUG_ON(pgtable->mode < PAGE_MODE_NONE ||
- pgtable->mode > PAGE_MODE_6_LEVEL);
-
- root = (unsigned long)pgtable->root;
- freelist = free_sub_pt(root, pgtable->mode, freelist);
-
- free_page_list(freelist);
-}
-
void amd_iommu_domain_set_pgtable(struct protection_domain *domain,
u64 *root, int mode)
{
@@ -522,6 +505,30 @@ unsigned long iommu_unmap_page(struct protection_domain *dom,
*/
static void v1_free_pgtable(struct io_pgtable *iop)
{
+ struct amd_io_pgtable *pgtable = container_of(iop, struct amd_io_pgtable, iop);
+ struct protection_domain *dom;
+ struct page *freelist = NULL;
+ unsigned long root;
+
+ if (pgtable->mode == PAGE_MODE_NONE)
+ return;
+
+ dom = container_of(pgtable, struct protection_domain, iop);
+
+ /* Update data structure */
+ amd_iommu_domain_clr_pt_root(dom);
+
+ /* Make changes visible to IOMMUs */
+ amd_iommu_domain_update(dom);
+
+ /* Page-table is not visible to IOMMU anymore, so free it */
+ BUG_ON(pgtable->mode < PAGE_MODE_NONE ||
+ pgtable->mode > PAGE_MODE_6_LEVEL);
+
+ root = (unsigned long)pgtable->root;
+ freelist = free_sub_pt(root, pgtable->mode, freelist);
+
+ free_page_list(freelist);
}
static struct io_pgtable *v1_alloc_pgtable(struct io_pgtable_cfg *cfg, void *cookie)