lkml.org 
[lkml]   [2023]   [May]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH v7 2/4] iommu: Move global PASID allocation from SVA to core
Date
> From: Jacob Pan <jacob.jun.pan@linux.intel.com>
> Sent: Wednesday, May 24, 2023 1:35 AM
>
> /* Allocate a PASID for the mm within range (inclusive) */
> -static int iommu_sva_alloc_pasid(struct mm_struct *mm, ioasid_t min,
> ioasid_t max)
> +static int iommu_sva_alloc_pasid(struct mm_struct *mm, struct device *dev)
> {
> + ioasid_t pasid;
> int ret = 0;
>
> - if (min == IOMMU_PASID_INVALID ||
> - max == IOMMU_PASID_INVALID ||
> - min == 0 || max < min)
> - return -EINVAL;
> -
> if (!arch_pgtable_dma_compat(mm))
> return -EBUSY;
>
> mutex_lock(&iommu_sva_lock);
> /* Is a PASID already associated with this mm? */
> if (mm_valid_pasid(mm)) {
> - if (mm->pasid < min || mm->pasid > max)
> + if (mm->pasid > dev->iommu->max_pasids)

">" should be ">="

> +ioasid_t iommu_alloc_global_pasid_dev(struct device *dev)
> +{
> + int ret;
> + ioasid_t max;
> +
> + max = dev->iommu->max_pasids;
> + ret = ida_alloc_range(&iommu_global_pasid_ida,
> IOMMU_FIRST_GLOBAL_PASID, max, GFP_KERNEL);

max is inclusive. Here should minus one.

otherwise looks good to me,

Reviewed-by: Kevin Tian <kevin.tian@intel.com>

\
 
 \ /
  Last update: 2023-05-25 08:30    [W:0.231 / U:0.648 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site