Re: [PATCH v2 02/10] iommu/arm-smmu-v3: Pass in IOTLB cache tag to CD and STE

Jason Gunthorpe
2026-01-26T20:54:05Z

On Wed, Jan 21, 2026 at 05:24:20PM -0800, Nicolin Chen wrote:
> Now, struct arm_smmu_attach_state has the IOTLB cache tags copied from the
> cd->asid or s2_cfg->vmid of an smmu_domain.
>
> Pass it down to arm_smmu_make_s1_cd() and arm_smmu_make_s2_domain_ste() to
> set in the CD and STE, removing the references of smmu_domain for its asid
> or vmid.
>
> Note the two set_dev_pasid callbacks finalize CDs in arm_smmu_set_pasid().
> So, it is safe for arm_smmu_make_sva_cd() and arm_smmu_make_s1_cd() to use
> a dummy iotlb tag (asid=0) because arm_smmu_set_pasid() will fix it.

Maybe it is time to fix that up?

I think if you make arm_smmu_set_pasid() take in a function pointer of signature:

void (*func)(struct arm_smmu_cd *target,
struct arm_smmu_master *master,
struct arm_smmu_domain *smmu_domain,
struct arm_smmu_inv *tag)

It can accept both arm_smmu_make_s1_cd() and arm_smmu_make_sva_cd()
then call them at the right point once the tag is finally known.

It may have been tortured like this because of the (removed) BTM
support, but when we bring that back the ASID for BTM should come from
arm_smmu_domain_get_iotlb_tag().

Otherwise this looks OK

Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>

Jason