]> git.baikalelectronics.ru Git - kernel.git/commit
iommu/arm-smmu-v3: Fix size calculation in arm_smmu_mm_invalidate_range()
authorNicolin Chen <nicolinc@nvidia.com>
Tue, 19 Apr 2022 21:01:58 +0000 (14:01 -0700)
committerWill Deacon <will@kernel.org>
Wed, 20 Apr 2022 09:38:48 +0000 (10:38 +0100)
commit4140f3e910a3ff04d947aaec7aa4b5b715a902fe
treeea07f8cc00633d2978fc4c920918e843e188d020
parent6d94017b7b59bab528be97be158d0d602982e3a6
iommu/arm-smmu-v3: Fix size calculation in arm_smmu_mm_invalidate_range()

The arm_smmu_mm_invalidate_range function is designed to be called
by mm core for Shared Virtual Addressing purpose between IOMMU and
CPU MMU. However, the ways of two subsystems defining their "end"
addresses are slightly different. IOMMU defines its "end" address
using the last address of an address range, while mm core defines
that using the following address of an address range:

include/linux/mm_types.h:
unsigned long vm_end;
/* The first byte after our end address ...

This mismatch resulted in an incorrect calculation for size so it
failed to be page-size aligned. Further, it caused a dead loop at
"while (iova < end)" check in __arm_smmu_tlb_inv_range function.

This patch fixes the issue by doing the calculation correctly.

Fixes: e04efbb5da55 ("iommu/arm-smmu-v3: Hook up ATC invalidation to mm ops")
Cc: stable@vger.kernel.org
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
Reviewed-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
Link: https://lore.kernel.org/r/20220419210158.21320-1-nicolinc@nvidia.com
Signed-off-by: Will Deacon <will@kernel.org>
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c