Re: [PATCH RFC 06/11] iommu/sva: Use attach/detach_pasid_dev in SVA interfaces

2022-03-21 Thread Lu Baolu
On 2022/3/21 20:05, Jason Gunthorpe wrote: On Sun, Mar 20, 2022 at 02:40:25PM +0800, Lu Baolu wrote: +/** + * iommu_sva_bind_device() - Bind a process address space to a device + * @dev: the device + * @mm: the mm to bind, caller must hold a reference to it + * @drvdata: opaque data pointer to

Re: [PATCH RFC 06/11] iommu/sva: Use attach/detach_pasid_dev in SVA interfaces

2022-03-21 Thread Lu Baolu
On 2022/3/21 19:33, Jean-Philippe Brucker wrote: On Sun, Mar 20, 2022 at 02:40:25PM +0800, Lu Baolu wrote: diff --git a/drivers/iommu/iommu-sva-lib.c b/drivers/iommu/iommu-sva-lib.c index 106506143896..47cf98e661ff 100644 --- a/drivers/iommu/iommu-sva-lib.c +++ b/drivers/iommu/iommu-sva-lib.c @@

Re: [PATCH RFC 06/11] iommu/sva: Use attach/detach_pasid_dev in SVA interfaces

2022-03-21 Thread Jason Gunthorpe via iommu
On Sun, Mar 20, 2022 at 02:40:25PM +0800, Lu Baolu wrote: > +/** > + * iommu_sva_bind_device() - Bind a process address space to a device > + * @dev: the device > + * @mm: the mm to bind, caller must hold a reference to it > + * @drvdata: opaque data pointer to pass to bind callback > + * > + * Cr

Re: [PATCH RFC 06/11] iommu/sva: Use attach/detach_pasid_dev in SVA interfaces

2022-03-21 Thread Jason Gunthorpe via iommu
On Mon, Mar 21, 2022 at 07:01:45PM +0800, Lu Baolu wrote: > > one domain can be attached by multiple devices, so this should not be > > a blind alloc. > > Indeed. Perhaps we could associate the SVA domain with the mm->pasid and > add a user counter inside the domain. This has the same problem as

Re: [PATCH RFC 06/11] iommu/sva: Use attach/detach_pasid_dev in SVA interfaces

2022-03-21 Thread Jean-Philippe Brucker
On Sun, Mar 20, 2022 at 02:40:25PM +0800, Lu Baolu wrote: > diff --git a/drivers/iommu/iommu-sva-lib.c b/drivers/iommu/iommu-sva-lib.c > index 106506143896..47cf98e661ff 100644 > --- a/drivers/iommu/iommu-sva-lib.c > +++ b/drivers/iommu/iommu-sva-lib.c > @@ -3,6 +3,8 @@ > * Helpers for IOMMU driv

Re: [PATCH RFC 06/11] iommu/sva: Use attach/detach_pasid_dev in SVA interfaces

2022-03-21 Thread Lu Baolu
On 2022/3/21 16:04, Tian, Kevin wrote: From: Lu Baolu Sent: Sunday, March 20, 2022 2:40 PM +struct iommu_sva * +iommu_sva_bind_device(struct device *dev, struct mm_struct *mm, void *drvdata) +{ + int ret = -EINVAL; + struct iommu_sva *handle; + struct iommu_domain *domain; + +

RE: [PATCH RFC 06/11] iommu/sva: Use attach/detach_pasid_dev in SVA interfaces

2022-03-21 Thread Tian, Kevin
> From: Lu Baolu > Sent: Sunday, March 20, 2022 2:40 PM > +struct iommu_sva * > +iommu_sva_bind_device(struct device *dev, struct mm_struct *mm, void > *drvdata) > +{ > + int ret = -EINVAL; > + struct iommu_sva *handle; > + struct iommu_domain *domain; > + > + handle = kzalloc(size