[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20210415141845.06e5a1cf@jacob-builder>
Date: Thu, 15 Apr 2021 14:18:45 -0700
From: Jacob Pan <jacob.jun.pan@...ux.intel.com>
To: Christoph Hellwig <hch@...radead.org>
Cc: LKML <linux-kernel@...r.kernel.org>,
iommu@...ts.linux-foundation.org, Joerg Roedel <joro@...tes.org>,
Lu Baolu <baolu.lu@...ux.intel.com>,
Jean-Philippe Brucker <jean-philippe@...aro.com>,
"Tian, Kevin" <kevin.tian@...el.com>,
Dave Jiang <dave.jiang@...el.com>,
Raj Ashok <ashok.raj@...el.com>, vkoul@...nel.org,
Jason Gunthorpe <jgg@...dia.com>, zhangfei.gao@...aro.org,
jacob.jun.pan@...ux.intel.com
Subject: Re: [PATCH v2 2/2] iommu/sva: Remove mm parameter from SVA bind API
Hi Christoph,
On Thu, 15 Apr 2021 07:44:59 +0100, Christoph Hellwig <hch@...radead.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
Powered by blists - more mailing lists