Skip to content

Commit a4d7536

Browse files
jgunthorpewilldeacon
authored andcommitted
iommu/arm-smmu-v3: Shrink the strtab l1_desc array
The top of the 2 level stream table is (at most) 128k entries big, and two high order allocations are required. One of __le64 which is programmed into the HW (1M), and one of struct arm_smmu_strtab_l1_desc which holds the CPU pointer (3M). There is no reason to store the l2ptr_dma as nothing reads it. devm stores a copy of it and the DMA memory will be freed via devm mechanisms. span is a constant of 8+1. Remove both. This removes 16 bytes from each arm_smmu_l1_ctx_desc and saves up to 2M of memory per iommu instance. 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 c84c5ab commit a4d7536

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,13 +1448,12 @@ static void arm_smmu_free_cd_tables(struct arm_smmu_master *master)
14481448
}
14491449

14501450
/* Stream table manipulation functions */
1451-
static void
1452-
arm_smmu_write_strtab_l1_desc(__le64 *dst, struct arm_smmu_strtab_l1_desc *desc)
1451+
static void arm_smmu_write_strtab_l1_desc(__le64 *dst, dma_addr_t l2ptr_dma)
14531452
{
14541453
u64 val = 0;
14551454

1456-
val |= FIELD_PREP(STRTAB_L1_DESC_SPAN, desc->span);
1457-
val |= desc->l2ptr_dma & STRTAB_L1_DESC_L2PTR_MASK;
1455+
val |= FIELD_PREP(STRTAB_L1_DESC_SPAN, STRTAB_SPLIT + 1);
1456+
val |= l2ptr_dma & STRTAB_L1_DESC_L2PTR_MASK;
14581457

14591458
/* The HW has 64 bit atomicity with stores to the L2 STE table */
14601459
WRITE_ONCE(*dst, cpu_to_le64(val));
@@ -1663,6 +1662,7 @@ static int arm_smmu_init_l2_strtab(struct arm_smmu_device *smmu, u32 sid)
16631662
{
16641663
size_t size;
16651664
void *strtab;
1665+
dma_addr_t l2ptr_dma;
16661666
struct arm_smmu_strtab_cfg *cfg = &smmu->strtab_cfg;
16671667
struct arm_smmu_strtab_l1_desc *desc = &cfg->l1_desc[sid >> STRTAB_SPLIT];
16681668

@@ -1672,8 +1672,7 @@ static int arm_smmu_init_l2_strtab(struct arm_smmu_device *smmu, u32 sid)
16721672
size = 1 << (STRTAB_SPLIT + ilog2(STRTAB_STE_DWORDS) + 3);
16731673
strtab = &cfg->strtab[(sid >> STRTAB_SPLIT) * STRTAB_L1_DESC_DWORDS];
16741674

1675-
desc->span = STRTAB_SPLIT + 1;
1676-
desc->l2ptr = dmam_alloc_coherent(smmu->dev, size, &desc->l2ptr_dma,
1675+
desc->l2ptr = dmam_alloc_coherent(smmu->dev, size, &l2ptr_dma,
16771676
GFP_KERNEL);
16781677
if (!desc->l2ptr) {
16791678
dev_err(smmu->dev,
@@ -1683,7 +1682,7 @@ static int arm_smmu_init_l2_strtab(struct arm_smmu_device *smmu, u32 sid)
16831682
}
16841683

16851684
arm_smmu_init_initial_stes(desc->l2ptr, 1 << STRTAB_SPLIT);
1686-
arm_smmu_write_strtab_l1_desc(strtab, desc);
1685+
arm_smmu_write_strtab_l1_desc(strtab, l2ptr_dma);
16871686
return 0;
16881687
}
16891688

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -579,10 +579,7 @@ struct arm_smmu_priq {
579579

580580
/* High-level stream table and context descriptor structures */
581581
struct arm_smmu_strtab_l1_desc {
582-
u8 span;
583-
584582
struct arm_smmu_ste *l2ptr;
585-
dma_addr_t l2ptr_dma;
586583
};
587584

588585
struct arm_smmu_ctx_desc {

0 commit comments

Comments
 (0)