[PATCH RFC v7 3/7] iommu/arm-smmu-v3: Plumb the CD table into the CD helpers

Nicolin Chen nicolinc at nvidia.com
Fri Oct 30 13:54:52 PDT 2026


On Fri, Oct 30, 2026 at 08:09:35PM +0800, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan at nxp.com>
> 
> Refactor the CD table allocation, freeing, lookup and STE-building helpers
> to take a struct arm_smmu_ctx_desc_cfg pointer instead of always deriving
> it from struct arm_smmu_master. Add master wrappers so existing callers
> keep the same behaviour.
> 
> Prepare for domain-owned CD tables, where non-PASID streams will point
> their STE at a CD table stored in the IOMMU domain rather than in the
> master.
> 
> No functional change.
> 
> Signed-off-by: Peng Fan <peng.fan at nxp.com>

Reviewed-by: Nicolin Chen <nicolinc at nvidia.com>

With some nits:

> -struct arm_smmu_cd *arm_smmu_get_cd_ptr(struct arm_smmu_master *master,
> -					u32 ssid)
> +static struct arm_smmu_cd *
> +arm_smmu_get_cd_ptr_in(struct arm_smmu_ctx_desc_cfg *cd_table, u32 ssid)

Just keep "arm_smmu_get_cd_ptr", and change master to cd_table.

> +struct arm_smmu_cd *arm_smmu_get_cd_ptr(struct arm_smmu_master *master,
> +					u32 ssid)

arm_smmu_master_get_cd_ptr

> +static int arm_smmu_alloc_master_cd_tables(struct arm_smmu_master *master)

arm_smmu_master_alloc_cd_tables

And in the other patch:
arm_smmu_domain_alloc_cd_tables

> +static void arm_smmu_free_master_cd_tables(struct arm_smmu_master *master)

arm_smmu_master_free_cd_tables

> +{
> +	arm_smmu_free_cd_tables(master->smmu, &master->cd_table);
> +}

Maybe fold in the condition.

	if (arm_smmu_cdtab_allocated(&master->cd_table))
		arm_smmu_free_cd_tables(master->smmu, &master->cd_table);

Nicolin



More information about the linux-arm-kernel mailing list