[PATCH v4 02/10] iommu/arm-smmu-v3: Pass in arm_smmu_make_cd_fn to arm_smmu_set_pasid()

Jason Gunthorpe jgg at nvidia.com
Thu Apr 9 16:17:52 PDT 2026


On Thu, Mar 19, 2026 at 12:51:48PM -0700, Nicolin Chen wrote:
> To install a domain (CD) to a substream, the common flow in the driver is:
>  - Make an S1 or SVA CD outside arm_smmu_asid_lock
>  - Invoke arm_smmu_set_pasid() where it takes arm_smmu_asid_lock, and fix
>    the ASID in the CD.
> 
> The reason for such a flow is for the timing of arm_smmu_asid_lock, since
> it was too early to take the mutex outside the function.
> 
> Tidy it up by passing in a function pointer for CD making,, which supports
> both existing functions: arm_smmu_make_s1_cd() and arm_smmu_make_sva_cd().
> 
> Then arm_smmu_set_pasid() can make a CD inside the lock where ASID is safe
> to access.
> 
> Suggested-by: Jason Gunthorpe <jgg at nvidia.com>
> Signed-off-by: Nicolin Chen <nicolinc at nvidia.com>
> ---
>  drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h   |  7 ++++++-
>  .../iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c   |  4 ++--
>  drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c   | 19 ++++---------------
>  3 files changed, 12 insertions(+), 18 deletions(-)

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

Jason



More information about the linux-arm-kernel mailing list