diff options
author | Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> | 2023-09-21 12:21:40 +0300 |
---|---|---|
committer | Joerg Roedel <jroedel@suse.de> | 2023-09-25 13:39:02 +0300 |
commit | 45677ab1e5ca65622b35cc231c5d31c699cfaefe (patch) | |
tree | e0eaa1c9bc6f0e94b8760f515d3b514cec97a8e3 /drivers/iommu/amd/io_pgtable_v2.c | |
parent | 4c721d6a085ca7baa4289bcf786c71684b2ef281 (diff) | |
download | linux-45677ab1e5ca65622b35cc231c5d31c699cfaefe.tar.xz |
iommu/amd: Miscellaneous clean up when free domain
* Use the protection_domain_free() helper function to free domain.
The function has been modified to also free memory used for the v1 and v2
page tables. Also clear gcr3 table in v2 page table free path.
* Refactor code into cleanup_domain() for reusability. Change BUG_ON to
WARN_ON in cleanup path.
* Protection domain dev_cnt should be read when the domain is locked.
Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Co-developed-by: Vasant Hegde <vasant.hegde@amd.com>
Signed-off-by: Vasant Hegde <vasant.hegde@amd.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Jerry Snitselaar <jsnitsel@redhat.com>
Link: https://lore.kernel.org/r/20230921092147.5930-8-vasant.hegde@amd.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Diffstat (limited to 'drivers/iommu/amd/io_pgtable_v2.c')
-rw-r--r-- | drivers/iommu/amd/io_pgtable_v2.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/iommu/amd/io_pgtable_v2.c b/drivers/iommu/amd/io_pgtable_v2.c index e9ef2e0a62f6..f818a7e254d4 100644 --- a/drivers/iommu/amd/io_pgtable_v2.c +++ b/drivers/iommu/amd/io_pgtable_v2.c @@ -363,10 +363,10 @@ static void v2_free_pgtable(struct io_pgtable *iop) if (!(pdom->flags & PD_IOMMUV2_MASK)) return; - /* - * Make changes visible to IOMMUs. No need to clear gcr3 entry - * as gcr3 table is already freed. - */ + /* Clear gcr3 entry */ + amd_iommu_domain_clear_gcr3(&pdom->domain, 0); + + /* Make changes visible to IOMMUs */ amd_iommu_domain_update(pdom); /* Free page table */ |