From: Jacob Pan <jacob.jun.pan@linux.intel.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: vkoul@kernel.org, "Tian, Kevin" <kevin.tian@intel.com>,
Dave Jiang <dave.jiang@intel.com>,
Raj Ashok <ashok.raj@intel.com>,
LKML <linux-kernel@vger.kernel.org>,
iommu@lists.linux-foundation.org,
Jason Gunthorpe <jgg@nvidia.com>,
zhangfei.gao@linaro.org,
Jean-Philippe Brucker <jean-philippe@linaro.com>
Subject: Re: [PATCH v2 2/2] iommu/sva: Remove mm parameter from SVA bind API
Date: Thu, 15 Apr 2021 14:18:45 -0700 [thread overview]
Message-ID: <20210415141845.06e5a1cf@jacob-builder> (raw)
In-Reply-To: <20210415064459.GB1938497@infradead.org>
Hi Christoph,
On Thu, 15 Apr 2021 07:44:59 +0100, Christoph Hellwig <hch@infradead.org>
wrote:
> > *
> > * Returns 0 on success and < 0 on error.
> > @@ -28,6 +28,9 @@ int iommu_sva_alloc_pasid(struct mm_struct *mm,
> > ioasid_t min, ioasid_t max) int ret = 0;
> > ioasid_t pasid;
> >
> > + if (mm != current->mm)
> > + return -EINVAL;
> > +
>
> Why not remove the parameter entirely?
It was removed in my v1 but thought it would be cleaner if we treat
iommu_sva_alloc_pasid() as a leaf function of iommu_sva_bind_device(). Then
we don't have to do get_task_mm() every time. But to your point below, it
is better to get low-level driver handle it.
>
> > @@ -2989,8 +2990,11 @@ iommu_sva_bind_device(struct device *dev, struct
> > mm_struct *mm, unsigned int fla return ERR_PTR(-ENODEV);
> >
> > /* Supervisor SVA does not need the current mm */
> > - if ((flags & IOMMU_SVA_BIND_SUPERVISOR) && mm)
> > - return ERR_PTR(-EINVAL);
> > + if (!(flags & IOMMU_SVA_BIND_SUPERVISOR)) {
> > + mm = get_task_mm(current);
> > + if (!mm)
> > + return ERR_PTR(-EINVAL);
> > + }
>
> I don't see why we need the reference. I think we should just stop
> passing the mm to ->sva_bind and let the low-level driver deal with
> any reference to current->mm where needed.
The mm users reference is just for precaution, in case low level driver use
kthread etc.
I agree it is cleaner to just remove mm here, let the low-level driver deal
with it.
Let me give it a spin.
Thanks,
Jacob
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
WARNING: multiple messages have this Message-ID (diff)
From: Jacob Pan <jacob.jun.pan@linux.intel.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
iommu@lists.linux-foundation.org, Joerg Roedel <joro@8bytes.org>,
Lu Baolu <baolu.lu@linux.intel.com>,
Jean-Philippe Brucker <jean-philippe@linaro.com>,
"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, jacob.jun.pan@linux.intel.com
Subject: Re: [PATCH v2 2/2] iommu/sva: Remove mm parameter from SVA bind API
Date: Thu, 15 Apr 2021 14:18:45 -0700 [thread overview]
Message-ID: <20210415141845.06e5a1cf@jacob-builder> (raw)
In-Reply-To: <20210415064459.GB1938497@infradead.org>
Hi Christoph,
On Thu, 15 Apr 2021 07:44:59 +0100, Christoph Hellwig <hch@infradead.org>
wrote:
> > *
> > * Returns 0 on success and < 0 on error.
> > @@ -28,6 +28,9 @@ int iommu_sva_alloc_pasid(struct mm_struct *mm,
> > ioasid_t min, ioasid_t max) int ret = 0;
> > ioasid_t pasid;
> >
> > + if (mm != current->mm)
> > + return -EINVAL;
> > +
>
> Why not remove the parameter entirely?
It was removed in my v1 but thought it would be cleaner if we treat
iommu_sva_alloc_pasid() as a leaf function of iommu_sva_bind_device(). Then
we don't have to do get_task_mm() every time. But to your point below, it
is better to get low-level driver handle it.
>
> > @@ -2989,8 +2990,11 @@ iommu_sva_bind_device(struct device *dev, struct
> > mm_struct *mm, unsigned int fla return ERR_PTR(-ENODEV);
> >
> > /* Supervisor SVA does not need the current mm */
> > - if ((flags & IOMMU_SVA_BIND_SUPERVISOR) && mm)
> > - return ERR_PTR(-EINVAL);
> > + if (!(flags & IOMMU_SVA_BIND_SUPERVISOR)) {
> > + mm = get_task_mm(current);
> > + if (!mm)
> > + return ERR_PTR(-EINVAL);
> > + }
>
> I don't see why we need the reference. I think we should just stop
> passing the mm to ->sva_bind and let the low-level driver deal with
> any reference to current->mm where needed.
The mm users reference is just for precaution, in case low level driver use
kthread etc.
I agree it is cleaner to just remove mm here, let the low-level driver deal
with it.
Let me give it a spin.
Thanks,
Jacob
next prev parent reply other threads:[~2021-04-15 21:16 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-14 15:27 [PATCH v2 0/2] Simplify and restrict IOMMU SVA APIs Jacob Pan
2021-04-14 15:27 ` Jacob Pan
2021-04-14 15:27 ` [PATCH v2 1/2] iommu/sva: Tighten SVA bind API with explicit flags Jacob Pan
2021-04-14 15:27 ` Jacob Pan
2021-04-15 6:40 ` Christoph Hellwig
2021-04-15 6:40 ` Christoph Hellwig
2021-04-15 18:53 ` Jacob Pan
2021-04-15 18:53 ` Jacob Pan
2021-04-14 15:27 ` [PATCH v2 2/2] iommu/sva: Remove mm parameter from SVA bind API Jacob Pan
2021-04-14 15:27 ` Jacob Pan
2021-04-15 6:44 ` Christoph Hellwig
2021-04-15 6:44 ` Christoph Hellwig
2021-04-15 21:18 ` Jacob Pan [this message]
2021-04-15 21:18 ` Jacob Pan
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=20210415141845.06e5a1cf@jacob-builder \
--to=jacob.jun.pan@linux.intel.com \
--cc=ashok.raj@intel.com \
--cc=dave.jiang@intel.com \
--cc=hch@infradead.org \
--cc=iommu@lists.linux-foundation.org \
--cc=jean-philippe@linaro.com \
--cc=jgg@nvidia.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.