Commit 7e054852 authored by Robin Murphy's avatar Robin Murphy Committed by Will Deacon
Browse files

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: 90c5def1 ("iommu: Do not call drivers for empty gathers")
Reported-by: default avatarJon Hunter <jonathanh@nvidia.com>
Closes: https://lore.kernel.org/r/8800a38b-8515-4bbe-af15-0dae81274bf7@nvidia.com


Signed-off-by: default avatarRobin Murphy <robin.murphy@arm.com>
Tested-by: default avatarJon Hunter <jonathanh@nvidia.com>
Reviewed-by: default avatarJason Gunthorpe <jgg@nvidia.com>
Tested-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: default avatarWill Deacon <will@kernel.org>
parent 8b72aa57
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -2717,6 +2717,12 @@ static size_t __iommu_unmap(struct iommu_domain *domain,

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

		iova += unmapped_page;
		unmapped += unmapped_page;