Skip to content

Commit 7e05485

Browse files
rmurphy-armwilldeacon
authored andcommitted
iommu: Ensure .iotlb_sync is called correctly
Many drivers have no reason to use the iotlb_gather mechanism, but do still depend on .iotlb_sync being called to properly complete an unmap. Since the core code is now relying on the gather to detect when there is legitimately something to sync, it should also take care of encoding a successful unmap when the driver does not touch the gather itself. Fixes: 90c5def ("iommu: Do not call drivers for empty gathers") Reported-by: Jon Hunter <jonathanh@nvidia.com> Closes: https://lore.kernel.org/r/8800a38b-8515-4bbe-af15-0dae81274bf7@nvidia.com Signed-off-by: Robin Murphy <robin.murphy@arm.com> Tested-by: Jon Hunter <jonathanh@nvidia.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Tested-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Signed-off-by: Will Deacon <will@kernel.org>
1 parent 8b72aa5 commit 7e05485

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

drivers/iommu/iommu.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2717,6 +2717,12 @@ static size_t __iommu_unmap(struct iommu_domain *domain,
27172717

27182718
pr_debug("unmapped: iova 0x%lx size 0x%zx\n",
27192719
iova, unmapped_page);
2720+
/*
2721+
* If the driver itself isn't using the gather, make sure
2722+
* it looks non-empty so iotlb_sync will still be called.
2723+
*/
2724+
if (iotlb_gather->start >= iotlb_gather->end)
2725+
iommu_iotlb_gather_add_range(iotlb_gather, iova, size);
27202726

27212727
iova += unmapped_page;
27222728
unmapped += unmapped_page;

0 commit comments

Comments
 (0)