Skip to content

Commit 692c4e4

Browse files
Nate Wattersonwildea01
authored andcommitted
iommu/arm-smmu-v3: limit use of 2-level stream tables
In the current arm-smmu-v3 driver, all smmus that support 2-level stream tables are being forced to use them. This is suboptimal for smmus that support fewer stream id bits than would fill in a single second level table. This patch limits the use of 2-level tables to smmus that both support the feature and whose first level table can possibly contain more than a single entry. Signed-off-by: Nate Watterson <[email protected]> Signed-off-by: Will Deacon <[email protected]>
1 parent 810871c commit 692c4e4

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

drivers/iommu/arm-smmu-v3.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1977,17 +1977,9 @@ static int arm_smmu_init_strtab_2lvl(struct arm_smmu_device *smmu)
19771977
u32 size, l1size;
19781978
struct arm_smmu_strtab_cfg *cfg = &smmu->strtab_cfg;
19791979

1980-
/*
1981-
* If we can resolve everything with a single L2 table, then we
1982-
* just need a single L1 descriptor. Otherwise, calculate the L1
1983-
* size, capped to the SIDSIZE.
1984-
*/
1985-
if (smmu->sid_bits < STRTAB_SPLIT) {
1986-
size = 0;
1987-
} else {
1988-
size = STRTAB_L1_SZ_SHIFT - (ilog2(STRTAB_L1_DESC_DWORDS) + 3);
1989-
size = min(size, smmu->sid_bits - STRTAB_SPLIT);
1990-
}
1980+
/* Calculate the L1 size, capped to the SIDSIZE. */
1981+
size = STRTAB_L1_SZ_SHIFT - (ilog2(STRTAB_L1_DESC_DWORDS) + 3);
1982+
size = min(size, smmu->sid_bits - STRTAB_SPLIT);
19911983
cfg->num_l1_ents = 1 << size;
19921984

19931985
size += STRTAB_SPLIT;
@@ -2498,6 +2490,13 @@ static int arm_smmu_device_hw_probe(struct arm_smmu_device *smmu)
24982490
smmu->ssid_bits = reg >> IDR1_SSID_SHIFT & IDR1_SSID_MASK;
24992491
smmu->sid_bits = reg >> IDR1_SID_SHIFT & IDR1_SID_MASK;
25002492

2493+
/*
2494+
* If the SMMU supports fewer bits than would fill a single L2 stream
2495+
* table, use a linear table instead.
2496+
*/
2497+
if (smmu->sid_bits <= STRTAB_SPLIT)
2498+
smmu->features &= ~ARM_SMMU_FEAT_2_LVL_STRTAB;
2499+
25012500
/* IDR5 */
25022501
reg = readl_relaxed(smmu->base + ARM_SMMU_IDR5);
25032502

0 commit comments

Comments
 (0)