[PATCH v12 02/12] iommu/arm-smmu-v3: Init the vmid_map ida before the stream table setup

John Garry john.garry at arm.com
Mon Nov 16 01:30:45 PST 2026


On 11/2/26 05:19, 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 at nvidia.com>
> Reviewed-by: Mostafa Saleh <smostafa at google.com>
> Tested-by: Breno Leitao <leitao at kernel.org>
> Tested-by: Cristian Prundeanu <cpru at amazon.com>
> Tested-by: Shuai Xue <xueshuai at linux.alibaba.com>
> Signed-off-by: Nicolin Chen <nicolinc at nvidia.com>

Regardless of nitpick, below:

Reviewed-by: John Garry <john.garry at arm.com>

> ---
>   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 6d4520c473086..5cabbe5652dc6 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);


You can just have:
	if (smmu->features & ARM_SMMU_FEAT_2_LVL_STRTAB)
		return arm_smmu_init_strtab_2lvl(smmu);
	return arm_smmu_init_strtab_linear(smmu);

It seems to work ok for later changes in the series.

> -	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)




More information about the linux-arm-kernel mailing list