RE: [PATCH v10 2/7] iommu: Move global PASID allocation from SVA to core

From: Tian, Kevin
Date: Thu Jul 13 2023 - 03:43:09 EST


> From: Jacob Pan <jacob.jun.pan@xxxxxxxxxxxxxxx>
> Sent: Thursday, July 13, 2023 12:34 AM
>
> }
> +
> +ioasid_t iommu_alloc_global_pasid_dev(struct device *dev)
> +{
> + int ret;
> +
> + /* max_pasids == 0 means that the device does not support PASID */
> + if (!dev->iommu->max_pasids)
> + return IOMMU_PASID_INVALID;
> +
> + /*
> + * max_pasids is set up by vendor driver based on number of PASID
> bits
> + * supported but the IDA allocation is inclusive.
> + */
> + ret = ida_alloc_range(&iommu_global_pasid_ida,
> IOMMU_FIRST_GLOBAL_PASID,
> + dev->iommu->max_pasids - 1, GFP_KERNEL);
> + return ret < 0 ? IOMMU_PASID_INVALID : ret;
> +}
> +EXPORT_SYMBOL_GPL(iommu_alloc_global_pasid_dev);

nit. Just call it iommu_alloc_global_pasid.