Re: [PATCH v11 01/11] iommu/arm-smmu-v3: Init the vmid_map ida before the stream table setup
From: Mostafa Saleh
Date: Tue Oct 20 2026 - 07:15:44 EST
On Mon, Oct 05, 2026 at 12:30:44PM -0700, Nicolin Chen wrote:
> The vmid_map ida is initialized after the stream table setup, along with
> the devres action that destroys it.
>
> An upcoming change will reserve the crashed kernel's in-use VMIDs in this
> ida, from a kdump kernel's stream table adoption that runs in place of the
> regular setup and returns early.
>
> Move the ida_init() and its devres registration to the entry of the whole
> function, so that the ida is ready by the time the adoption path runs.
>
> Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx>
> Tested-by: Breno Leitao <leitao@xxxxxxxxxx>
> Tested-by: Cristian Prundeanu <cpru@xxxxxxxxxx>
> Assisted-by: LLM
> Signed-off-by: Nicolin Chen <nicolinc@xxxxxxxxxx>
Reviewed-by: Mostafa Saleh <smostafa@xxxxxxxxxx>
Thanks,
Mostafa
> ---
> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> index 34e916ea339ff..792627e1c790e 100644
> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> @@ -4842,17 +4842,17 @@ static int arm_smmu_init_strtab(struct arm_smmu_device *smmu)
> {
> int ret;
>
> + ida_init(&smmu->vmid_map);
> + ret = devm_add_action_or_reset(smmu->dev, arm_smmu_destroy_vmid_map,
> + &smmu->vmid_map);
> + if (ret)
> + return ret;
> +
> if (smmu->features & ARM_SMMU_FEAT_2_LVL_STRTAB)
> ret = arm_smmu_init_strtab_2lvl(smmu);
> else
> ret = arm_smmu_init_strtab_linear(smmu);
> - if (ret)
> - return ret;
> -
> - ida_init(&smmu->vmid_map);
> -
> - return devm_add_action_or_reset(smmu->dev, arm_smmu_destroy_vmid_map,
> - &smmu->vmid_map);
> + return ret;
> }
>
> static int arm_smmu_init_structures(struct arm_smmu_device *smmu)
> --
> 2.43.0
>