From: Lu Baolu <baolu.lu@linux.intel.com>
To: Jacob Pan <jacob.jun.pan@linux.intel.com>,
LKML <linux-kernel@vger.kernel.org>,
iommu@lists.linux-foundation.org, Joerg Roedel <joro@8bytes.org>,
Jean-Philippe Brucker <jean-philippe@linaro.com>
Cc: "Tian, Kevin" <kevin.tian@intel.com>,
Dave Jiang <dave.jiang@intel.com>,
Raj Ashok <ashok.raj@intel.com>,
vkoul@kernel.org, Jason Gunthorpe <jgg@nvidia.com>,
zhangfei.gao@linaro.org
Subject: Re: [PATCH 2/2] iommu/sva: Remove mm parameter from SVA bind API
Date: Fri, 9 Apr 2021 20:45:22 +0800 [thread overview]
Message-ID: <f29495e1-e3a0-8c45-bfca-067c1e996eca@linux.intel.com> (raw)
In-Reply-To: <1617901736-24788-2-git-send-email-jacob.jun.pan@linux.intel.com>
Hi,
On 2021/4/9 1:08, Jacob Pan wrote:
> /**
> * iommu_sva_alloc_pasid - Allocate a PASID for the mm
> - * @mm: the mm
> * @min: minimum PASID value (inclusive)
> * @max: maximum PASID value (inclusive)
> *
> - * Try to allocate a PASID for this mm, or take a reference to the existing one
> - * provided it fits within the [@min, @max] range. On success the PASID is
> - * available in mm->pasid, and must be released with iommu_sva_free_pasid().
> + * Try to allocate a PASID for the current mm, or take a reference to the
> + * existing one provided it fits within the [@min, @max] range. On success
> + * the PASID is available in the current mm->pasid, and must be released with
> + * iommu_sva_free_pasid().
> * @min must be greater than 0, because 0 indicates an unused mm->pasid.
> *
> * Returns 0 on success and < 0 on error.
> */
> -int iommu_sva_alloc_pasid(struct mm_struct *mm, ioasid_t min, ioasid_t max)
> +int iommu_sva_alloc_pasid(ioasid_t min, ioasid_t max)
> {
> int ret = 0;
> ioasid_t pasid;
> + struct mm_struct *mm;
>
> if (min == INVALID_IOASID || max == INVALID_IOASID ||
> min == 0 || max < min)
> return -EINVAL;
>
> mutex_lock(&iommu_sva_lock);
> + mm = get_task_mm(current);
How could we allocate a supervisor PASID through iommu_sva_alloc_pasid()
if we always use current->mm here?
> + if (!mm) {
> + ret = -EINVAL;
> + goto out_unlock;
> + }
> if (mm->pasid) {
> if (mm->pasid >= min && mm->pasid <= max)
> ioasid_get(mm->pasid);
> @@ -45,22 +51,32 @@ int iommu_sva_alloc_pasid(struct mm_struct *mm, ioasid_t min, ioasid_t max)
> else
> mm->pasid = pasid;
> }
> + mmput(mm);
> +out_unlock:
> mutex_unlock(&iommu_sva_lock);
> return ret;
> }
> EXPORT_SYMBOL_GPL(iommu_sva_alloc_pasid);
Best regards,
baolu
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2021-04-09 12:45 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-08 17:08 [PATCH 1/2] iommu/sva: Tighten SVA bind API with explicit flags Jacob Pan
2021-04-08 17:08 ` [PATCH 2/2] iommu/sva: Remove mm parameter from SVA bind API Jacob Pan
2021-04-09 10:11 ` Jean-Philippe Brucker
2021-04-09 18:03 ` Jacob Pan
2021-04-14 0:09 ` Jacob Pan
2021-04-14 6:22 ` Lu Baolu
2021-04-14 11:26 ` Jason Gunthorpe
2021-04-15 5:33 ` Lu Baolu
2021-04-15 11:59 ` Jason Gunthorpe
2021-04-09 12:45 ` Lu Baolu [this message]
2021-04-09 18:08 ` Jacob Pan
2021-04-09 10:22 ` [PATCH 1/2] iommu/sva: Tighten SVA bind API with explicit flags Jean-Philippe Brucker
2021-04-09 21:57 ` Jacob Pan
2021-04-09 12:24 ` Lu Baolu
2021-04-13 22:13 ` Jacob Pan
2021-04-13 13:02 ` kernel test robot
2021-04-14 4:11 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f29495e1-e3a0-8c45-bfca-067c1e996eca@linux.intel.com \
--to=baolu.lu@linux.intel.com \
--cc=ashok.raj@intel.com \
--cc=dave.jiang@intel.com \
--cc=iommu@lists.linux-foundation.org \
--cc=jacob.jun.pan@linux.intel.com \
--cc=jean-philippe@linaro.com \
--cc=jgg@nvidia.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=vkoul@kernel.org \
--cc=zhangfei.gao@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox