diff mbox

[v1,4/4] iommu/tegra: gart: Correct number of unmapped bytes

Message ID f30500403195b029ee236fff3b3c6f0b4dc60cbb.1499270277.git.digetx@gmail.com
State Deferred
Headers show

Commit Message

Dmitry Osipenko July 5, 2017, 4:29 p.m. UTC
The iommu_unmap() treats zero bytes number returned by an IOMMU driver as
an indicator that unmapping should be stopped. As a result, GART driver
unmaps only the first page entry of the whole range, which is incorrect.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/iommu/tegra-gart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Thierry Reding Sept. 26, 2017, 11:09 a.m. UTC | #1
On Wed, Jul 05, 2017 at 07:29:48PM +0300, Dmitry Osipenko wrote:
> The iommu_unmap() treats zero bytes number returned by an IOMMU driver as
> an indicator that unmapping should be stopped. As a result, GART driver
> unmaps only the first page entry of the whole range, which is incorrect.
> 
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
>  drivers/iommu/tegra-gart.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Is this perhaps the bug that you were referring to in an earlier patch?
Looks to me like you'd run into that bug everytime you try mapping an
IOVA that wasn't properly unmapped before.

Anyway, this looks like the right thing to do:

Acked-by: Thierry Reding <treding@nvidia.com>
diff mbox

Patch

diff --git a/drivers/iommu/tegra-gart.c b/drivers/iommu/tegra-gart.c
index 55fdb56d85ea..c622f4a4bedd 100644
--- a/drivers/iommu/tegra-gart.c
+++ b/drivers/iommu/tegra-gart.c
@@ -309,7 +309,7 @@  static size_t gart_iommu_unmap(struct iommu_domain *domain, unsigned long iova,
 	gart_set_pte(gart, iova, 0);
 	FLUSH_GART_REGS(gart);
 	spin_unlock_irqrestore(&gart->pte_lock, flags);
-	return 0;
+	return bytes;
 }
 
 static phys_addr_t gart_iommu_iova_to_phys(struct iommu_domain *domain,