Skip to content

Commit 6833b8f

Browse files
rmurphy-armwilldeacon
authored andcommitted
iommu/arm-smmu-v3: Set TTL invalidation hint better
When io-pgtable unmaps a whole table, rather than waste time walking it to find the leaf entries to invalidate exactly, it simply expects .tlb_flush_walk with nominal last-level granularity to invalidate any leaf entries at higher intermediate levels as well. This works fine with page-based invalidation, but with range commands we need to be careful with the TTL hint - unconditionally setting it based on the given level 3 granule means that an invalidation for a level 1 table would strictly not be required to affect level 2 block entries. It's easy to comply with the expected behaviour by simply not setting the TTL hint for non-leaf invalidations, so let's do that. Signed-off-by: Robin Murphy <[email protected]> Link: https://lore.kernel.org/r/b409d9a17c52dc0db51faee91d92737bb7975f5b.1685637456.git.robin.murphy@arm.com Signed-off-by: Will Deacon <[email protected]>
1 parent 0bfbfc5 commit 6833b8f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1898,8 +1898,13 @@ static void __arm_smmu_tlb_inv_range(struct arm_smmu_cmdq_ent *cmd,
18981898
/* Convert page size of 12,14,16 (log2) to 1,2,3 */
18991899
cmd->tlbi.tg = (tg - 10) / 2;
19001900

1901-
/* Determine what level the granule is at */
1902-
cmd->tlbi.ttl = 4 - ((ilog2(granule) - 3) / (tg - 3));
1901+
/*
1902+
* Determine what level the granule is at. For non-leaf, io-pgtable
1903+
* assumes .tlb_flush_walk can invalidate multiple levels at once,
1904+
* so ignore the nominal last-level granule and leave TTL=0.
1905+
*/
1906+
if (cmd->tlbi.leaf)
1907+
cmd->tlbi.ttl = 4 - ((ilog2(granule) - 3) / (tg - 3));
19031908

19041909
num_pages = size >> tg;
19051910
}

0 commit comments

Comments
 (0)