Re: [PATCH v5 02/25] iommu/sva: Manage process address spaces

2020-04-21 Thread Christoph Hellwig
On Mon, Apr 20, 2020 at 11:14:37AM -0700, Fenghua Yu wrote: > > Agreed, perhaps Fenghua can consider that in his patchset. It would > > help align life cycles as well. > > https://lkml.org/lkml/2020/3/30/910> > > Seems we depend on each other: my patch defines pasid in mm_struct. > I can free

Re: [PATCH v5 02/25] iommu/sva: Manage process address spaces

2020-04-20 Thread Fenghua Yu
On Mon, Apr 20, 2020 at 10:48:50AM -0700, Jacob Pan wrote: > On Mon, 20 Apr 2020 10:57:27 -0300 > Jason Gunthorpe wrote: > > > On Mon, Apr 20, 2020 at 09:42:13AM +0200, Jean-Philippe Brucker wrote: > > > On Thu, Apr 16, 2020 at 05:13:31AM -0700, Christoph Hellwig wrote: > > > > On Thu, Apr 16,

Re: [PATCH v5 02/25] iommu/sva: Manage process address spaces

2020-04-20 Thread Felix Kuehling
Am 2020-04-20 um 1:44 p.m. schrieb Jacob Pan: >> The bottom line is, when you allocate a PASID for a context, you want >> to know how small it needs to be for all the devices that want to use >> it. If you make it too big, some device will not be able to use it. >> If you make it too small, you

Re: [PATCH v5 02/25] iommu/sva: Manage process address spaces

2020-04-20 Thread Jacob Pan
On Mon, 20 Apr 2020 10:57:27 -0300 Jason Gunthorpe wrote: > On Mon, Apr 20, 2020 at 09:42:13AM +0200, Jean-Philippe Brucker wrote: > > On Thu, Apr 16, 2020 at 05:13:31AM -0700, Christoph Hellwig wrote: > > > On Thu, Apr 16, 2020 at 10:54:02AM +0200, Jean-Philippe Brucker > > > wrote: > > > >

Re: [PATCH v5 02/25] iommu/sva: Manage process address spaces

2020-04-20 Thread Jacob Pan
On Mon, 20 Apr 2020 11:00:28 -0400 Felix Kuehling wrote: > Am 2020-04-20 um 8:40 a.m. schrieb Christian König: > > Am 20.04.20 um 13:55 schrieb Christoph Hellwig: > >> On Mon, Apr 20, 2020 at 01:44:56PM +0200, Christian König wrote: > >>> Am 20.04.20 um 10:10 schrieb Christoph Hellwig: >

Re: [PATCH v5 02/25] iommu/sva: Manage process address spaces

2020-04-20 Thread Christian König
Am 20.04.20 um 13:55 schrieb Christoph Hellwig: On Mon, Apr 20, 2020 at 01:44:56PM +0200, Christian König wrote: Am 20.04.20 um 10:10 schrieb Christoph Hellwig: On Mon, Apr 20, 2020 at 09:42:13AM +0200, Jean-Philippe Brucker wrote: Right, I can see the appeal. I still like having a single mmu

Re: [PATCH v5 02/25] iommu/sva: Manage process address spaces

2020-04-20 Thread Felix Kuehling
Am 2020-04-20 um 8:40 a.m. schrieb Christian König: > Am 20.04.20 um 13:55 schrieb Christoph Hellwig: >> On Mon, Apr 20, 2020 at 01:44:56PM +0200, Christian König wrote: >>> Am 20.04.20 um 10:10 schrieb Christoph Hellwig: On Mon, Apr 20, 2020 at 09:42:13AM +0200, Jean-Philippe Brucker wrote:

Re: [PATCH v5 02/25] iommu/sva: Manage process address spaces

2020-04-20 Thread Jason Gunthorpe
On Mon, Apr 20, 2020 at 09:42:13AM +0200, Jean-Philippe Brucker wrote: > On Thu, Apr 16, 2020 at 05:13:31AM -0700, Christoph Hellwig wrote: > > On Thu, Apr 16, 2020 at 10:54:02AM +0200, Jean-Philippe Brucker wrote: > > > On Thu, Apr 16, 2020 at 12:28:52AM -0700, Christoph Hellwig wrote: > > > > >

Re: [PATCH v5 02/25] iommu/sva: Manage process address spaces

2020-04-20 Thread Christian König
Am 20.04.20 um 10:10 schrieb Christoph Hellwig: On Mon, Apr 20, 2020 at 09:42:13AM +0200, Jean-Philippe Brucker wrote: Right, I can see the appeal. I still like having a single mmu notifier per mm because it ensures we allocate a single PASID per mm (as required by x86). I suppose one

Re: [PATCH v5 02/25] iommu/sva: Manage process address spaces

2020-04-20 Thread Christoph Hellwig
On Mon, Apr 20, 2020 at 01:44:56PM +0200, Christian König wrote: > Am 20.04.20 um 10:10 schrieb Christoph Hellwig: > > On Mon, Apr 20, 2020 at 09:42:13AM +0200, Jean-Philippe Brucker wrote: > > > Right, I can see the appeal. I still like having a single mmu notifier per > > > mm because it ensures

Re: [PATCH v5 02/25] iommu/sva: Manage process address spaces

2020-04-20 Thread Christoph Hellwig
On Mon, Apr 20, 2020 at 09:42:13AM +0200, Jean-Philippe Brucker wrote: > Right, I can see the appeal. I still like having a single mmu notifier per > mm because it ensures we allocate a single PASID per mm (as required by > x86). I suppose one alternative is to maintain a hashtable of mm->pasid, >

Re: [PATCH v5 02/25] iommu/sva: Manage process address spaces

2020-04-20 Thread Jean-Philippe Brucker
On Thu, Apr 16, 2020 at 05:13:31AM -0700, Christoph Hellwig wrote: > On Thu, Apr 16, 2020 at 10:54:02AM +0200, Jean-Philippe Brucker wrote: > > On Thu, Apr 16, 2020 at 12:28:52AM -0700, Christoph Hellwig wrote: > > > > + rcu_read_lock(); > > > > + hlist_for_each_entry_rcu(bond,

Re: [PATCH v5 02/25] iommu/sva: Manage process address spaces

2020-04-16 Thread Christoph Hellwig
On Thu, Apr 16, 2020 at 10:54:02AM +0200, Jean-Philippe Brucker wrote: > On Thu, Apr 16, 2020 at 12:28:52AM -0700, Christoph Hellwig wrote: > > > + rcu_read_lock(); > > > + hlist_for_each_entry_rcu(bond, _mm->devices, mm_node) > > > + io_mm->ops->invalidate(bond->sva.dev, io_mm->pasid,

Re: [PATCH v5 02/25] iommu/sva: Manage process address spaces

2020-04-16 Thread Jean-Philippe Brucker
On Thu, Apr 16, 2020 at 12:28:52AM -0700, Christoph Hellwig wrote: > > + rcu_read_lock(); > > + hlist_for_each_entry_rcu(bond, _mm->devices, mm_node) > > + io_mm->ops->invalidate(bond->sva.dev, io_mm->pasid, io_mm->ctx, > > + start, end - start); > >

Re: [PATCH v5 02/25] iommu/sva: Manage process address spaces

2020-04-16 Thread Christoph Hellwig
> + rcu_read_lock(); > + hlist_for_each_entry_rcu(bond, _mm->devices, mm_node) > + io_mm->ops->invalidate(bond->sva.dev, io_mm->pasid, io_mm->ctx, > +start, end - start); > + rcu_read_unlock(); > +} What is the reason that the devices

[PATCH v5 02/25] iommu/sva: Manage process address spaces

2020-04-14 Thread Jean-Philippe Brucker
Add a small library to help IOMMU drivers manage process address spaces bound to their devices. Register an MMU notifier to track modification on each address space bound to one or more devices. IOMMU drivers must implement the io_mm_ops and can then use the helpers provided by this library to