Re: [PATCH v6 08/12] iommu/sva: Use attach/detach_pasid_dev in SVA interfaces

2022-05-12 Thread Baolu Lu
On 2022/5/12 20:03, Jason Gunthorpe wrote: On Thu, May 12, 2022 at 07:59:41PM +0800, Baolu Lu wrote: On 2022/5/12 19:48, Jason Gunthorpe wrote: On Thu, May 12, 2022 at 01:17:08PM +0800, Baolu Lu wrote: On 2022/5/12 13:01, Tian, Kevin wrote: From: Baolu Lu Sent: Thursday, May 12, 2022 11:03

Re: [PATCH v6 08/12] iommu/sva: Use attach/detach_pasid_dev in SVA interfaces

2022-05-12 Thread Baolu Lu
On 2022/5/12 19:51, Jason Gunthorpe wrote: On Thu, May 12, 2022 at 11:02:39AM +0800, Baolu Lu wrote: + mutex_lock(>mutex); + domain = xa_load(>pasid_array, pasid); + if (domain && domain->type != type) + domain = NULL; + mutex_unlock(>mutex); +

Re: [PATCH v6 08/12] iommu/sva: Use attach/detach_pasid_dev in SVA interfaces

2022-05-12 Thread Jason Gunthorpe via iommu
On Thu, May 12, 2022 at 07:59:41PM +0800, Baolu Lu wrote: > On 2022/5/12 19:48, Jason Gunthorpe wrote: > > On Thu, May 12, 2022 at 01:17:08PM +0800, Baolu Lu wrote: > > > On 2022/5/12 13:01, Tian, Kevin wrote: > > > > > From: Baolu Lu > > > > > Sent: Thursday, May 12, 2022 11:03 AM > > > > > > >

Re: [PATCH v6 08/12] iommu/sva: Use attach/detach_pasid_dev in SVA interfaces

2022-05-12 Thread Baolu Lu
On 2022/5/12 19:48, Jason Gunthorpe wrote: On Thu, May 12, 2022 at 01:17:08PM +0800, Baolu Lu wrote: On 2022/5/12 13:01, Tian, Kevin wrote: From: Baolu Lu Sent: Thursday, May 12, 2022 11:03 AM On 2022/5/11 22:53, Jason Gunthorpe wrote: Also, given the current arrangement it might make sense

Re: [PATCH v6 08/12] iommu/sva: Use attach/detach_pasid_dev in SVA interfaces

2022-05-12 Thread Jason Gunthorpe via iommu
On Thu, May 12, 2022 at 11:02:39AM +0800, Baolu Lu wrote: > > > + mutex_lock(>mutex); > > > + domain = xa_load(>pasid_array, pasid); > > > + if (domain && domain->type != type) > > > + domain = NULL; > > > + mutex_unlock(>mutex); > > > +

Re: [PATCH v6 08/12] iommu/sva: Use attach/detach_pasid_dev in SVA interfaces

2022-05-12 Thread Jason Gunthorpe via iommu
On Thu, May 12, 2022 at 01:17:08PM +0800, Baolu Lu wrote: > On 2022/5/12 13:01, Tian, Kevin wrote: > > > From: Baolu Lu > > > Sent: Thursday, May 12, 2022 11:03 AM > > > > > > On 2022/5/11 22:53, Jason Gunthorpe wrote: > > > > > > Also, given the current arrangement it might make sense to have a

Re: [PATCH v6 08/12] iommu/sva: Use attach/detach_pasid_dev in SVA interfaces

2022-05-12 Thread Baolu Lu
On 2022/5/12 13:44, Tian, Kevin wrote: From: Baolu Lu Sent: Thursday, May 12, 2022 1:17 PM On 2022/5/12 13:01, Tian, Kevin wrote: From: Baolu Lu Sent: Thursday, May 12, 2022 11:03 AM On 2022/5/11 22:53, Jason Gunthorpe wrote: Also, given the current arrangement it might make sense to have

RE: [PATCH v6 08/12] iommu/sva: Use attach/detach_pasid_dev in SVA interfaces

2022-05-11 Thread Tian, Kevin
> From: Baolu Lu > Sent: Thursday, May 12, 2022 1:17 PM > > On 2022/5/12 13:01, Tian, Kevin wrote: > >> From: Baolu Lu > >> Sent: Thursday, May 12, 2022 11:03 AM > >> > >> On 2022/5/11 22:53, Jason Gunthorpe wrote: > > Also, given the current arrangement it might make sense to have a >

Re: [PATCH v6 08/12] iommu/sva: Use attach/detach_pasid_dev in SVA interfaces

2022-05-11 Thread Baolu Lu
On 2022/5/12 13:01, Tian, Kevin wrote: From: Baolu Lu Sent: Thursday, May 12, 2022 11:03 AM On 2022/5/11 22:53, Jason Gunthorpe wrote: Also, given the current arrangement it might make sense to have a struct iommu_domain_sva given that no driver is wrappering this in something else. Fair

RE: [PATCH v6 08/12] iommu/sva: Use attach/detach_pasid_dev in SVA interfaces

2022-05-11 Thread Tian, Kevin
> From: Baolu Lu > Sent: Thursday, May 12, 2022 11:03 AM > > On 2022/5/11 22:53, Jason Gunthorpe wrote: > >>> Also, given the current arrangement it might make sense to have a > >>> struct iommu_domain_sva given that no driver is wrappering this in > >>> something else. > >> Fair enough. How

Re: [PATCH v6 08/12] iommu/sva: Use attach/detach_pasid_dev in SVA interfaces

2022-05-11 Thread Baolu Lu
On 2022/5/11 22:53, Jason Gunthorpe wrote: Assuming we leave room for multi-device groups this logic should just be group = iommu_group_get(dev); if (!group) return -ENODEV; mutex_lock(>mutex); domain = xa_load(>pasid_array, mm->pasid);

Re: [PATCH v6 08/12] iommu/sva: Use attach/detach_pasid_dev in SVA interfaces

2022-05-11 Thread Jason Gunthorpe via iommu
On Wed, May 11, 2022 at 03:21:31PM +0800, Baolu Lu wrote: > On 2022/5/10 23:23, Jason Gunthorpe wrote: > > On Tue, May 10, 2022 at 02:17:34PM +0800, Lu Baolu wrote: > > > > > +/** > > > + * iommu_sva_bind_device() - Bind a process address space to a device > > > + * @dev: the device > > > + *

Re: [PATCH v6 08/12] iommu/sva: Use attach/detach_pasid_dev in SVA interfaces

2022-05-11 Thread Baolu Lu
On 2022/5/10 23:23, Jason Gunthorpe wrote: On Tue, May 10, 2022 at 02:17:34PM +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 mm_users + * @drvdata: opaque data

Re: [PATCH v6 08/12] iommu/sva: Use attach/detach_pasid_dev in SVA interfaces

2022-05-10 Thread Jason Gunthorpe via iommu
On Tue, May 10, 2022 at 02:17:34PM +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 mm_users > + * @drvdata: opaque data pointer to pass to bind callback > + * >

[PATCH v6 08/12] iommu/sva: Use attach/detach_pasid_dev in SVA interfaces

2022-05-10 Thread Lu Baolu
The existing iommu SVA interfaces are implemented by calling the SVA specific iommu ops provided by the IOMMU drivers. There's no need for any SVA specific ops in iommu_ops vector anymore as we can achieve this through the generic attach/detach_dev_pasid domain ops. This refactors the IOMMU SVA