Skip to content

Commit c84c5ab

Browse files
jgunthorpewilldeacon
authored andcommitted
iommu/arm-smmu-v3: Do not zero the strtab twice
dmam_alloc_coherent() already returns zero'd memory so cfg->strtab.l1_desc (the list of DMA addresses for the L2 entries) is already zero'd. arm_smmu_init_l1_strtab() goes through and calls arm_smmu_write_strtab_l1_desc() on the newly allocated (and zero'd) struct arm_smmu_strtab_l1_desc, which ends up computing 'val = 0' and zeroing it again. Remove arm_smmu_init_l1_strtab() and just call devm_kcalloc() from arm_smmu_init_strtab_2lvl to allocate the companion struct. Tested-by: Nicolin Chen <[email protected]> Reviewed-by: Mostafa Saleh <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]> Reviewed-by: Nicolin Chen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent f3b273b commit c84c5ab

File tree

1 file changed

+6
-20
lines changed

1 file changed

+6
-20
lines changed

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

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3523,25 +3523,6 @@ static int arm_smmu_init_queues(struct arm_smmu_device *smmu)
35233523
PRIQ_ENT_DWORDS, "priq");
35243524
}
35253525

3526-
static int arm_smmu_init_l1_strtab(struct arm_smmu_device *smmu)
3527-
{
3528-
unsigned int i;
3529-
struct arm_smmu_strtab_cfg *cfg = &smmu->strtab_cfg;
3530-
void *strtab = smmu->strtab_cfg.strtab;
3531-
3532-
cfg->l1_desc = devm_kcalloc(smmu->dev, cfg->num_l1_ents,
3533-
sizeof(*cfg->l1_desc), GFP_KERNEL);
3534-
if (!cfg->l1_desc)
3535-
return -ENOMEM;
3536-
3537-
for (i = 0; i < cfg->num_l1_ents; ++i) {
3538-
arm_smmu_write_strtab_l1_desc(strtab, &cfg->l1_desc[i]);
3539-
strtab += STRTAB_L1_DESC_DWORDS << 3;
3540-
}
3541-
3542-
return 0;
3543-
}
3544-
35453526
static int arm_smmu_init_strtab_2lvl(struct arm_smmu_device *smmu)
35463527
{
35473528
void *strtab;
@@ -3577,7 +3558,12 @@ static int arm_smmu_init_strtab_2lvl(struct arm_smmu_device *smmu)
35773558
reg |= FIELD_PREP(STRTAB_BASE_CFG_SPLIT, STRTAB_SPLIT);
35783559
cfg->strtab_base_cfg = reg;
35793560

3580-
return arm_smmu_init_l1_strtab(smmu);
3561+
cfg->l1_desc = devm_kcalloc(smmu->dev, cfg->num_l1_ents,
3562+
sizeof(*cfg->l1_desc), GFP_KERNEL);
3563+
if (!cfg->l1_desc)
3564+
return -ENOMEM;
3565+
3566+
return 0;
35813567
}
35823568

35833569
static int arm_smmu_init_strtab_linear(struct arm_smmu_device *smmu)

0 commit comments

Comments
 (0)