Re: [RFC PATCH 3/5] mm/vma: add support for peer to peer to device vma

2019-01-29 Thread Jason Gunthorpe
On Tue, Jan 29, 2019 at 02:11:23PM -0500, Jerome Glisse wrote: > On Tue, Jan 29, 2019 at 11:36:29AM -0700, Logan Gunthorpe wrote: > > > > > > On 2019-01-29 10:47 a.m., jgli...@redhat.com wrote: > > > > > + /* > > > + * Optional for device driver that want to allow peer to peer (p2p) > > > + *

Re: [RFC PATCH 3/5] mm/vma: add support for peer to peer to device vma

2019-01-29 Thread Jason Gunthorpe
On Tue, Jan 29, 2019 at 01:39:49PM -0700, Logan Gunthorpe wrote: > implement the mapping. And I don't think we should have 'special' vma's > for this (though we may need something to ensure we don't get mapping > requests mixed with different types of pages...). I think Jerome explained the point

Re: [RFC PATCH 3/5] mm/vma: add support for peer to peer to device vma

2019-01-29 Thread Jason Gunthorpe
On Tue, Jan 29, 2019 at 02:50:55PM -0500, Jerome Glisse wrote: > GPU driver do want more control :) GPU driver are moving things around > all the time and they have more memory than bar space (on newer platform > AMD GPU do resize the bar but it is not the rule for all GPUs). So > GPU driver do ac

Re: [RFC PATCH 3/5] mm/vma: add support for peer to peer to device vma

2019-01-29 Thread Jason Gunthorpe
On Tue, Jan 29, 2019 at 03:44:00PM -0500, Jerome Glisse wrote: > > But this API doesn't seem to offer any control - I thought that > > control was all coming from the mm/hmm notifiers triggering p2p_unmaps? > > The control is within the driver implementation of those callbacks. Seems like what

Re: [RFC PATCH 3/5] mm/vma: add support for peer to peer to device vma

2019-01-29 Thread Jason Gunthorpe
On Tue, Jan 29, 2019 at 06:17:43PM -0700, Logan Gunthorpe wrote: > This isn't answering my question at all... I specifically asked what is > backing the VMA when we are *not* using HMM. At least for RDMA what backs the VMA today is non-struct-page BAR memory filled in with io_remap_pfn. And we w

Re: [RFC PATCH 3/5] mm/vma: add support for peer to peer to device vma

2019-01-29 Thread Jason Gunthorpe
On Tue, Jan 29, 2019 at 07:08:06PM -0500, Jerome Glisse wrote: > On Tue, Jan 29, 2019 at 11:02:25PM +0000, Jason Gunthorpe wrote: > > On Tue, Jan 29, 2019 at 03:44:00PM -0500, Jerome Glisse wrote: > > > > > > But this API doesn't seem to offer any control - I thou

Re: [RFC PATCH 3/5] mm/vma: add support for peer to peer to device vma

2019-01-30 Thread Jason Gunthorpe
On Wed, Jan 30, 2019 at 06:26:53PM +0100, Christoph Hellwig wrote: > On Wed, Jan 30, 2019 at 10:55:43AM -0500, Jerome Glisse wrote: > > Even outside GPU driver, device driver like RDMA just want to share their > > doorbell to other device and they do not want to see those doorbell page > > use in d

Re: [RFC PATCH 3/5] mm/vma: add support for peer to peer to device vma

2019-01-30 Thread Jason Gunthorpe
On Wed, Jan 30, 2019 at 09:02:08AM +0100, Christoph Hellwig wrote: > On Tue, Jan 29, 2019 at 08:58:35PM +0000, Jason Gunthorpe wrote: > > On Tue, Jan 29, 2019 at 01:39:49PM -0700, Logan Gunthorpe wrote: > > > > > implement the mapping. And I don't think we should h

Re: [RFC PATCH 3/5] mm/vma: add support for peer to peer to device vma

2019-01-30 Thread Jason Gunthorpe
On Wed, Jan 30, 2019 at 10:17:27AM -0700, Logan Gunthorpe wrote: > > > On 2019-01-29 9:18 p.m., Jason Gunthorpe wrote: > > Every attempt to give BAR memory to struct page has run into major > > trouble, IMHO, so I like that this approach avoids that. > > > >

Re: [RFC PATCH 3/5] mm/vma: add support for peer to peer to device vma

2019-01-30 Thread Jason Gunthorpe
On Wed, Jan 30, 2019 at 09:00:06AM +0100, Christoph Hellwig wrote: > On Wed, Jan 30, 2019 at 04:18:48AM +0000, Jason Gunthorpe wrote: > > Every attempt to give BAR memory to struct page has run into major > > trouble, IMHO, so I like that this approach avoids that. > > Way l

Re: [RFC PATCH 3/5] mm/vma: add support for peer to peer to device vma

2019-01-30 Thread Jason Gunthorpe
On Wed, Jan 30, 2019 at 11:13:11AM -0700, Logan Gunthorpe wrote: > > > On 2019-01-30 10:44 a.m., Jason Gunthorpe wrote: > > I don't see why a special case with a VMA is really that different. > > Well one *really* big difference is the VMA changes necessaril

Re: [RFC PATCH 3/5] mm/vma: add support for peer to peer to device vma

2019-01-30 Thread Jason Gunthorpe
On Wed, Jan 30, 2019 at 02:22:34PM -0500, Jerome Glisse wrote: > For GPU it would not work, GPU might want to use main memory (because > it is running out of BAR space) it is a lot easier if the p2p_map > callback calls the right dma map function (for page or io) rather than > having to define som

Re: [RFC PATCH 3/5] mm/vma: add support for peer to peer to device vma

2019-01-30 Thread Jason Gunthorpe
On Wed, Jan 30, 2019 at 12:45:46PM -0700, Logan Gunthorpe wrote: > > > On 2019-01-30 12:06 p.m., Jason Gunthorpe wrote: > >> Way less problems than not having struct page for doing anything > >> non-trivial. If you map the BAR to userspace with remap_pfn_range >

Re: [RFC PATCH 3/5] mm/vma: add support for peer to peer to device vma

2019-01-30 Thread Jason Gunthorpe
On Wed, Jan 30, 2019 at 01:00:02PM -0700, Logan Gunthorpe wrote: > We never changed SGLs. We still use them to pass p2pdma pages, only we > need to be a bit careful where we send the entire SGL. I see no reason > why we can't continue to be careful once their in userspace if there's > something in

Re: [RFC PATCH 3/5] mm/vma: add support for peer to peer to device vma

2019-01-30 Thread Jason Gunthorpe
On Wed, Jan 30, 2019 at 12:48:33PM -0700, Logan Gunthorpe wrote: > > > On 2019-01-30 12:19 p.m., Jason Gunthorpe wrote: > > On Wed, Jan 30, 2019 at 11:13:11AM -0700, Logan Gunthorpe wrote: > >> > >> > >> On 2019-01-30 10:44 a.m., Jason Gunthorpe wrote: &

Re: [RFC PATCH 3/5] mm/vma: add support for peer to peer to device vma

2019-01-30 Thread Jason Gunthorpe
On Wed, Jan 30, 2019 at 03:43:32PM -0500, Jerome Glisse wrote: > On Wed, Jan 30, 2019 at 08:11:19PM +0000, Jason Gunthorpe wrote: > > On Wed, Jan 30, 2019 at 01:00:02PM -0700, Logan Gunthorpe wrote: > > > > > We never changed SGLs. We still use them to pass p2pdma pages,

Re: [RFC PATCH 3/5] mm/vma: add support for peer to peer to device vma

2019-01-30 Thread Jason Gunthorpe
On Wed, Jan 30, 2019 at 02:01:35PM -0700, Logan Gunthorpe wrote: > And I feel the GUP->SGL->DMA flow should still be what we are aiming > for. Even if we need a special GUP for special pages, and a special DMA > map; and the SGL still has to be homogenous *shrug* so what if the special GUP ca

Re: [RFC PATCH 3/5] mm/vma: add support for peer to peer to device vma

2019-01-30 Thread Jason Gunthorpe
On Wed, Jan 30, 2019 at 04:45:25PM -0500, Jerome Glisse wrote: > On Wed, Jan 30, 2019 at 08:50:00PM +0000, Jason Gunthorpe wrote: > > On Wed, Jan 30, 2019 at 03:43:32PM -0500, Jerome Glisse wrote: > > > On Wed, Jan 30, 2019 at 08:11:19PM +0000, Jason Gunthorpe wrote: > >

Re: [RFC PATCH 3/5] mm/vma: add support for peer to peer to device vma

2019-01-30 Thread Jason Gunthorpe
On Wed, Jan 30, 2019 at 05:30:27PM -0500, Jerome Glisse wrote: > > What is the problem in the HMM mirror that it needs this restriction? > > No restriction at all here. I think i just wasn't understood. Are you are talking about from the exporting side - where the thing creating the VMA can real

Re: [RFC PATCH 3/5] mm/vma: add support for peer to peer to device vma

2019-01-30 Thread Jason Gunthorpe
On Wed, Jan 30, 2019 at 05:47:05PM -0500, Jerome Glisse wrote: > On Wed, Jan 30, 2019 at 10:33:04PM +0000, Jason Gunthorpe wrote: > > On Wed, Jan 30, 2019 at 05:30:27PM -0500, Jerome Glisse wrote: > > > > > > What is the problem in the HMM mirror that it needs this r

Re: [RFC PATCH 3/5] mm/vma: add support for peer to peer to device vma

2019-01-30 Thread Jason Gunthorpe
On Wed, Jan 30, 2019 at 03:52:13PM -0700, Logan Gunthorpe wrote: > > > On 2019-01-30 2:50 p.m., Jason Gunthorpe wrote: > > On Wed, Jan 30, 2019 at 02:01:35PM -0700, Logan Gunthorpe wrote: > > > >> And I feel the GUP->SGL->DMA flow should still be what we ar

Re: [RFC PATCH 3/5] mm/vma: add support for peer to peer to device vma

2019-01-31 Thread Jason Gunthorpe
On Thu, Jan 31, 2019 at 09:13:55AM +0100, Christoph Hellwig wrote: > On Wed, Jan 30, 2019 at 03:52:13PM -0700, Logan Gunthorpe wrote: > > > *shrug* so what if the special GUP called a VMA op instead of > > > traversing the VMA PTEs today? Why does it really matter? It could > > > easily change to a

Re: [RFC PATCH 3/5] mm/vma: add support for peer to peer to device vma

2019-01-31 Thread Jason Gunthorpe
On Thu, Jan 31, 2019 at 02:35:14PM -0500, Jerome Glisse wrote: > > Basically invert the API flow - the DMA map would be done close to > > GUP, not buried in the driver. This absolutely doesn't work for every > > flow we have, but it does enable the ones that people seem to care > > about when talk

Re: [RFC PATCH 3/5] mm/vma: add support for peer to peer to device vma

2019-01-31 Thread Jason Gunthorpe
On Thu, Jan 31, 2019 at 12:19:31PM -0700, Logan Gunthorpe wrote: > > > On 2019-01-31 12:02 p.m., Jason Gunthorpe wrote: > > I still think the right direction is to build on what Logan has done - > > realize that he created a DMA-only SGL - make that a formal type of >

Re: [PATCH v4 01/26] mm/mmu_notifiers: pass private data down to alloc_notifier()

2020-02-24 Thread Jason Gunthorpe
On Mon, Feb 24, 2020 at 07:23:36PM +0100, Jean-Philippe Brucker wrote: > The new allocation scheme introduced by 2c7933f53f6b ("mm/mmu_notifiers: > add a get/put scheme for the registration") provides a convenient way > for users to attach notifier data to an mm. However, it would be even > better

Re: [PATCH v4 01/26] mm/mmu_notifiers: pass private data down to alloc_notifier()

2020-02-25 Thread Jason Gunthorpe
On Tue, Feb 25, 2020 at 10:24:39AM +0100, Jean-Philippe Brucker wrote: > On Mon, Feb 24, 2020 at 03:00:56PM -0400, Jason Gunthorpe wrote: > > On Mon, Feb 24, 2020 at 07:23:36PM +0100, Jean-Philippe Brucker wrote: > > > The new allocation scheme introduced by 2c7933f53f6b

Re: [PATCH v4 01/26] mm/mmu_notifiers: pass private data down to alloc_notifier()

2020-02-28 Thread Jason Gunthorpe
On Fri, Feb 28, 2020 at 03:39:35PM +0100, Jean-Philippe Brucker wrote: > > > + list_for_each_entry_rcu(bond, &io_mm->devices, mm_head) { > > > + /* > > > + * To ensure that we observe the initialization of io_mm fields > > > + * by io_mm_finalize() before the registration

Re: [PATCH v4 02/26] iommu/sva: Manage process address spaces

2020-02-28 Thread Jason Gunthorpe
On Fri, Feb 28, 2020 at 03:40:07PM +0100, Jean-Philippe Brucker wrote: > > > Device > > > + * 00:00.0 accesses address spaces X and Y, each corresponding to an > > > mm_struct. > > > + * Devices 00:01.* only access address space Y. In addition each > > > + * IOMMU_DOMAIN_DMA domain has a private ad

Re: [PATCH v4 01/26] mm/mmu_notifiers: pass private data down to alloc_notifier()

2020-02-28 Thread Jason Gunthorpe
On Fri, Feb 28, 2020 at 04:04:27PM +0100, Jean-Philippe Brucker wrote: > On Fri, Feb 28, 2020 at 10:48:44AM -0400, Jason Gunthorpe wrote: > > On Fri, Feb 28, 2020 at 03:39:35PM +0100, Jean-Philippe Brucker wrote: > > > > > + list_for_each_entry_rcu(bond,

Re: [PATCH v4 01/26] mm/mmu_notifiers: pass private data down to alloc_notifier()

2020-03-06 Thread Jason Gunthorpe
On Fri, Mar 06, 2020 at 10:56:14AM +0100, Jean-Philippe Brucker wrote: > I tried to keep it simple like that: normally mmu_notifier_get() is called > in bind(), and mmu_notifier_put() is called in unbind(). > > Multiple device drivers may call bind() with the same mm. Each bind() > calls mmu_noti

Re: [PATCH v4 01/26] mm/mmu_notifiers: pass private data down to alloc_notifier()

2020-03-06 Thread Jason Gunthorpe
On Fri, Mar 06, 2020 at 03:35:56PM +0100, Jean-Philippe Brucker wrote: > On Fri, Mar 06, 2020 at 09:09:19AM -0400, Jason Gunthorpe wrote: > > On Fri, Mar 06, 2020 at 10:56:14AM +0100, Jean-Philippe Brucker wrote: > > > I tried to keep it simple like that: normally mmu_notifi

Re: [PATCH v4 01/26] mm/mmu_notifiers: pass private data down to alloc_notifier()

2020-03-06 Thread Jason Gunthorpe
On Fri, Mar 06, 2020 at 05:15:19PM +0100, Jean-Philippe Brucker wrote: > On Fri, Mar 06, 2020 at 10:52:45AM -0400, Jason Gunthorpe wrote: > > On Fri, Mar 06, 2020 at 03:35:56PM +0100, Jean-Philippe Brucker wrote: > > > On Fri, Mar 06, 2020 at 09:09:19AM -0400, Jason Gunthorpe wro

Re: [PATCH v4 01/26] mm/mmu_notifiers: pass private data down to alloc_notifier()

2020-03-13 Thread Jason Gunthorpe
On Fri, Mar 13, 2020 at 07:49:29PM +0100, Jean-Philippe Brucker wrote: > On Fri, Mar 06, 2020 at 01:42:39PM -0400, Jason Gunthorpe wrote: > > On Fri, Mar 06, 2020 at 05:15:19PM +0100, Jean-Philippe Brucker wrote: > > > On Fri, Mar 06, 2020 at 10:52:45AM -0400, Jason Gunthorpe wro

Re: [PATCH v4 01/26] mm/mmu_notifiers: pass private data down to alloc_notifier()

2020-03-17 Thread Jason Gunthorpe
On Mon, Mar 16, 2020 at 08:46:59AM -0700, Christoph Hellwig wrote: > On Fri, Mar 06, 2020 at 09:09:19AM -0400, Jason Gunthorpe wrote: > > This is why release must do invalidate all - but it doesn't need to do > > any more - as no SPTE can be established without a mmget() - a

Re: [PATCH 0/2] iommu: Remove iommu_sva_ops::mm_exit()

2020-04-08 Thread Jason Gunthorpe
On Wed, Apr 08, 2020 at 11:35:52AM -0700, Jacob Pan wrote: > Hi Jean, > > On Wed, 8 Apr 2020 16:04:25 +0200 > Jean-Philippe Brucker wrote: > > > The IOMMU SVA API currently requires device drivers to implement an > > mm_exit() callback, which stops device jobs that do DMA. This function > > is

Re: [PATCH 0/2] iommu: Remove iommu_sva_ops::mm_exit()

2020-04-08 Thread Jason Gunthorpe
On Wed, Apr 08, 2020 at 04:04:25PM +0200, Jean-Philippe Brucker wrote: > The IOMMU SVA API currently requires device drivers to implement an > mm_exit() callback, which stops device jobs that do DMA. This function > is called in the release() MMU notifier, when an address space that is > shared wit

Re: [PATCH 0/2] iommu: Remove iommu_sva_ops::mm_exit()

2020-04-08 Thread Jason Gunthorpe
On Wed, Apr 08, 2020 at 02:35:52PM -0700, Jacob Pan wrote: > > On Wed, Apr 08, 2020 at 11:35:52AM -0700, Jacob Pan wrote: > > > Hi Jean, > > > > > > On Wed, 8 Apr 2020 16:04:25 +0200 > > > Jean-Philippe Brucker wrote: > > > > > > > The IOMMU SVA API currently requires device drivers to implem

Re: [PATCH 0/2] iommu: Remove iommu_sva_ops::mm_exit()

2020-04-09 Thread Jason Gunthorpe
On Wed, Apr 08, 2020 at 04:48:02PM -0700, Jacob Pan wrote: > > Yes, this is the proper way, when the DMA is stopped and no use of the > > PASID remains then you can drop the mmu notifier and release the PASID > > entirely. If that is linked to the lifetime of the FD then forget > > completely about

Re: [PATCH 0/2] iommu: Remove iommu_sva_ops::mm_exit()

2020-04-09 Thread Jason Gunthorpe
On Wed, Apr 08, 2020 at 04:49:01PM -0700, Fenghua Yu wrote: > > > Isn't the idea of mmu_notifier is to avoid holding the mm reference and > > > rely on the notifier to tell us when mm is going away? > > > > The notifier only holds a mmgrab(), not a mmget() - this allows > > exit_mmap to proceed,

Re: [PATCH 0/2] iommu: Remove iommu_sva_ops::mm_exit()

2020-04-09 Thread Jason Gunthorpe
On Thu, Apr 09, 2020 at 07:14:24AM -0700, Jacob Pan wrote: > > When the process is killed, mm release can happen before fds are > > released. If you look at do_exit() in kernel/exit.c: > > > > exit_mm() > > mmput() > >-> mmu release notifier > > ... > > exit_files() > >

Re: [PATCH 0/2] iommu: Remove iommu_sva_ops::mm_exit()

2020-04-09 Thread Jason Gunthorpe
On Thu, Apr 09, 2020 at 09:21:34AM -0700, Jacob Pan wrote: > On Thu, 9 Apr 2020 11:25:19 -0300 > Jason Gunthorpe wrote: > > > On Thu, Apr 09, 2020 at 07:14:24AM -0700, Jacob Pan wrote: > > > > When the process is killed, mm release can happen before fds are >

Re: [PATCH v5 01/25] mm/mmu_notifiers: pass private data down to alloc_notifier()

2020-04-14 Thread Jason Gunthorpe
by not having A->ctx be allocated memory, but inlined into the notifier struct But I can't think of a down side to not add a params either. Reviewed-by: Jason Gunthorpe Regards, Jason ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

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 v6 17/25] iommu/arm-smmu-v3: Implement iommu_sva_bind/unbind()

2020-05-01 Thread Jason Gunthorpe
On Fri, May 01, 2020 at 05:15:52AM -0700, Christoph Hellwig wrote: > > @@ -432,6 +432,7 @@ config ARM_SMMU_V3 > > tristate "ARM Ltd. System MMU Version 3 (SMMUv3) Support" > > depends on ARM64 > > select IOMMU_API > > + select IOMMU_SVA > > select IOMMU_IO_PGTABLE_LPAE > > sel

Re: [PATCH v3 hmm 08/11] drm/radeon: use mmu_notifier_get/put for struct radeon_mn

2019-08-15 Thread Jason Gunthorpe
On Thu, Aug 15, 2019 at 10:28:21AM +0200, Christian König wrote: > Am 07.08.19 um 01:15 schrieb Jason Gunthorpe: > > From: Jason Gunthorpe > > > > radeon is using a device global hash table to track what mmu_notifiers > > have been registered on struct mm. This is

Re: [PATCH v3 hmm 00/11] Add mmu_notifier_get/put for managing mmu notifier registrations

2019-08-16 Thread Jason Gunthorpe
On Tue, Aug 06, 2019 at 08:15:37PM -0300, Jason Gunthorpe wrote: > This series is already entangled with patches in the hmm & RDMA tree and > will require some git topic branches for the RDMA ODP stuff. I intend for > it to go through the hmm tree. > Jason Gunthorpe (11): >

Re: [PATCH v3 hmm 00/11] Add mmu_notifier_get/put for managing mmu notifier registrations

2019-08-21 Thread Jason Gunthorpe
On Tue, Aug 06, 2019 at 08:15:37PM -0300, Jason Gunthorpe wrote: > This series is already entangled with patches in the hmm & RDMA tree and > will require some git topic branches for the RDMA ODP stuff. I intend for > it to go through the hmm tree. The RDMA related patches have be

Re: remove DMA_ATTR_WRITE_BARRIER

2019-11-13 Thread Jason Gunthorpe
On Wed, Nov 13, 2019 at 08:32:12AM +0100, Christoph Hellwig wrote: > There is no implementation of the DMA_ATTR_WRITE_BARRIER flag left > now that the ia64 sn2 code has been removed. Drop the flag and > the calling convention to set it in the RDMA code. This looks OK, do you want it to go through

Re: remove DMA_ATTR_WRITE_BARRIER

2019-11-14 Thread Jason Gunthorpe
On Wed, Nov 13, 2019 at 08:32:12AM +0100, Christoph Hellwig wrote: > There is no implementation of the DMA_ATTR_WRITE_BARRIER flag left > now that the ia64 sn2 code has been removed. Drop the flag and the > calling convention to set it in the RDMA code. Applied to rdma.git for-next There were a

Re: [PATCH for-next 2/4] RDMA/hns: Add IOMMU enable support in hip08

2017-11-07 Thread Jason Gunthorpe
On Tue, Nov 07, 2017 at 10:45:29AM +0800, Wei Hu (Xavier) wrote: > We reconstruct the code as below: > It replaces dma_alloc_coherent with __get_free_pages and > dma_map_single functions. So, we can vmap serveral ptrs returned by > __get_free_pages, right? Can't you just use vmal

Re: [PATCH for-next 2/4] RDMA/hns: Add IOMMU enable support in hip08

2017-11-07 Thread Jason Gunthorpe
On Tue, Nov 07, 2017 at 07:58:05AM -0800, Christoph Hellwig wrote: > On Tue, Nov 07, 2017 at 08:48:38AM -0700, Jason Gunthorpe wrote: > > Can't you just use vmalloc and dma_map that? Other drivers follow that > > approach.. > > You can't easily due to the flushi

Re: use exact allocation for dma coherent memory

2019-06-19 Thread Jason Gunthorpe
On Mon, Jun 17, 2019 at 10:33:42AM +0200, Christoph Hellwig wrote: > > drivers/infiniband/hw/cxgb4/qp.c > >129 static int alloc_host_sq(struct c4iw_rdev *rdev, struct t4_sq *sq) > >130 { > >131 sq->queue = dma_alloc_coherent(&(rdev->lldi.pdev->dev), > > sq->memsize, > >1

[PATCH v3 hmm 04/11] misc/sgi-gru: use mmu_notifier_get/put for struct gru_mm_struct

2019-08-06 Thread Jason Gunthorpe
From: Jason Gunthorpe GRU is already using almost the same algorithm as get/put, it even helpfully has a 10 year old comment to make this algorithm common, which is finally happening. There are a few differences and fixes from this conversion: - GRU used rcu not srcu to read the hlist - Unclear

[PATCH v3 hmm 01/11] mm/mmu_notifiers: hoist do_mmu_notifier_register down_write to the caller

2019-08-06 Thread Jason Gunthorpe
From: Jason Gunthorpe This simplifies the code to not have so many one line functions and extra logic. __mmu_notifier_register() simply becomes the entry point to register the notifier, and the other one calls it under lock. Also add a lockdep_assert to check that the callers are holding the

[PATCH v3 hmm 03/11] mm/mmu_notifiers: add a get/put scheme for the registration

2019-08-06 Thread Jason Gunthorpe
From: Jason Gunthorpe Many places in the kernel have a flow where userspace will create some object and that object will need to connect to the subsystem's mmu_notifier subscription for the duration of its lifetime. In this case the subsystem is usually tracking multiple mm_structs and

[PATCH v3 hmm 07/11] RDMA/odp: remove ib_ucontext from ib_umem

2019-08-06 Thread Jason Gunthorpe
From: Jason Gunthorpe At this point the ucontext is only being stored to access the ib_device, so just store the ib_device directly instead. This is more natural and logical as the umem has nothing to do with the ucontext. Signed-off-by: Jason Gunthorpe --- drivers/infiniband/core/umem.c

[PATCH v3 hmm 06/11] RDMA/odp: use mmu_notifier_get/put for 'struct ib_ucontext_per_mm'

2019-08-06 Thread Jason Gunthorpe
From: Jason Gunthorpe This is a significant simplification, no extra list is kept per FD, and the interval tree is now shared between all the ucontexts, reducing overhead if there are multiple ucontexts active. Signed-off-by: Jason Gunthorpe --- drivers/infiniband/core/umem_odp.c| 170

[PATCH v3 hmm 02/11] mm/mmu_notifiers: do not speculatively allocate a mmu_notifier_mm

2019-08-06 Thread Jason Gunthorpe
From: Jason Gunthorpe A prior commit e0f3c3f78da2 ("mm/mmu_notifier: init notifier if necessary") made an attempt at doing this, but had to be reverted as calling the GFP_KERNEL allocator under the i_mmap_mutex causes deadlock, see commit 35cfa2b0b491 ("mm/mmu_notifier: allocate

[PATCH v3 hmm 11/11] mm/mmu_notifiers: remove unregister_no_release

2019-08-06 Thread Jason Gunthorpe
From: Jason Gunthorpe mmu_notifier_unregister_no_release() and mmu_notifier_call_srcu() no longer have any users, they have all been converted to use mmu_notifier_put(). So delete this difficult to use interface. Signed-off-by: Jason Gunthorpe --- include/linux/mmu_notifier.h | 5 - mm

[PATCH v3 hmm 08/11] drm/radeon: use mmu_notifier_get/put for struct radeon_mn

2019-08-06 Thread Jason Gunthorpe
From: Jason Gunthorpe radeon is using a device global hash table to track what mmu_notifiers have been registered on struct mm. This is better served with the new get/put scheme instead. radeon has a bug where it was not blocking notifier release() until all the BO's had been invalidated.

[PATCH v3 hmm 00/11] Add mmu_notifier_get/put for managing mmu notifier registrations

2019-08-06 Thread Jason Gunthorpe
From: Jason Gunthorpe This series introduces a new registration flow for mmu_notifiers based on the idea that the user would like to get a single refcounted piece of memory for a mm, keyed to its use. For instance many users of mmu_notifiers use an interval tree or similar to dispatch

[PATCH v3 hmm 10/11] drm/amdkfd: use mmu_notifier_put

2019-08-06 Thread Jason Gunthorpe
From: Jason Gunthorpe The sequence of mmu_notifier_unregister_no_release(), mmu_notifier_call_srcu() is identical to mmu_notifier_put() with the free_notifier callback. As this is the last user of those APIs, converting it means we can drop them. Signed-off-by: Jason Gunthorpe --- drivers

[PATCH v3 hmm 09/11] drm/amdkfd: fix a use after free race with mmu_notifer unregister

2019-08-06 Thread Jason Gunthorpe
From: Jason Gunthorpe When using mmu_notifer_unregister_no_release() the caller must ensure there is a SRCU synchronize before the mn memory is freed, otherwise use after free races are possible, for instance: CPU0 CPU1

[PATCH v3 hmm 05/11] hmm: use mmu_notifier_get/put for 'struct hmm'

2019-08-06 Thread Jason Gunthorpe
From: Jason Gunthorpe This is a significant simplification, it eliminates all the remaining 'hmm' stuff in mm_struct, eliminates krefing along the critical notifier paths, and takes away all the ugly locking and abuse of page_table_lock. mmu_notifier_get() provides the single stru

Re: [PATCH v3 hmm 10/11] drm/amdkfd: use mmu_notifier_put

2019-08-07 Thread Jason Gunthorpe
On Tue, Aug 06, 2019 at 11:47:44PM +, Kuehling, Felix wrote: > On 2019-08-06 19:15, Jason Gunthorpe wrote: > > From: Jason Gunthorpe > > > > The sequence of mmu_notifier_unregister_no_release(), > > mmu_notifier_call_srcu() is identical to mmu_notifier_put()

Re: [PATCH v3 hmm 04/11] misc/sgi-gru: use mmu_notifier_get/put for struct gru_mm_struct

2019-08-14 Thread Jason Gunthorpe
On Thu, Aug 08, 2019 at 12:25:56PM +0200, Christoph Hellwig wrote: > Looks good, > > Reviewed-by: Christoph Hellwig Dimitri, are you OK with this patch? Thanks, Jason ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundatio

Re: [PATCH v3 hmm 08/11] drm/radeon: use mmu_notifier_get/put for struct radeon_mn

2019-08-14 Thread Jason Gunthorpe
On Tue, Aug 06, 2019 at 08:15:45PM -0300, Jason Gunthorpe wrote: > From: Jason Gunthorpe > > radeon is using a device global hash table to track what mmu_notifiers > have been registered on struct mm. This is better served with the new > get/put scheme instead. > > radeon h

Re: [PATCH v3 hmm 03/11] mm/mmu_notifiers: add a get/put scheme for the registration

2019-08-14 Thread Jason Gunthorpe
On Wed, Aug 14, 2019 at 02:20:31PM -0700, Ralph Campbell wrote: > > On 8/6/19 4:15 PM, Jason Gunthorpe wrote: > > From: Jason Gunthorpe > > > > Many places in the kernel have a flow where userspace will create some > > object and that object will need

Re: [patch RFC 38/38] irqchip: Add IMS array driver - NOT FOR MERGING

2020-08-21 Thread Jason Gunthorpe
On Fri, Aug 21, 2020 at 02:25:02AM +0200, Thomas Gleixner wrote: > +static void ims_mask_irq(struct irq_data *data) > +{ > + struct msi_desc *desc = irq_data_get_msi_desc(data); > + struct ims_array_slot __iomem *slot = desc->device_msi.priv_iomem; > + u32 __iomem *ctrl = &slot->ctrl; >

Re: [patch RFC 38/38] irqchip: Add IMS array driver - NOT FOR MERGING

2020-08-21 Thread Jason Gunthorpe
On Fri, Aug 21, 2020 at 09:47:43PM +0200, Thomas Gleixner wrote: > On Fri, Aug 21 2020 at 09:45, Jason Gunthorpe wrote: > > On Fri, Aug 21, 2020 at 02:25:02AM +0200, Thomas Gleixner wrote: > >> +static void ims_mask_irq(struct irq_data *data) > >> +{ &g

Re: [patch RFC 38/38] irqchip: Add IMS array driver - NOT FOR MERGING

2020-08-21 Thread Jason Gunthorpe
On Sat, Aug 22, 2020 at 01:47:12AM +0200, Thomas Gleixner wrote: > On Fri, Aug 21 2020 at 17:17, Jason Gunthorpe wrote: > > On Fri, Aug 21, 2020 at 09:47:43PM +0200, Thomas Gleixner wrote: > >> So if I understand correctly then the queue memory where the MSI > >>

Re: [patch RFC 38/38] irqchip: Add IMS array driver - NOT FOR MERGING

2020-08-22 Thread Jason Gunthorpe
On Sat, Aug 22, 2020 at 03:34:45AM +0200, Thomas Gleixner wrote: > >> One question is whether the device can see partial updates to that > >> memory due to the async 'swap' of context from the device CPU. > > > > It is worse than just partial updates.. The device operation is much > > more like you

Re: [patch V2 34/46] PCI/MSI: Make arch_.*_msi_irq[s] fallbacks selectable

2020-08-28 Thread Jason Gunthorpe
On Fri, Aug 28, 2020 at 12:21:42PM +0100, Lorenzo Pieralisi wrote: > On Thu, Aug 27, 2020 at 01:20:40PM -0500, Bjorn Helgaas wrote: > > [...] > > > And I can't figure out what's special about tegra, rcar, and xilinx > > that makes them need it as well. Is there something I could grep for > > to

Re: [patch V2 34/46] PCI/MSI: Make arch_.*_msi_irq[s] fallbacks selectable

2020-08-28 Thread Jason Gunthorpe
On Fri, Aug 28, 2020 at 01:47:59PM +0100, Marc Zyngier wrote: > > So the arch_setup_msi_irq/etc is not really an arch hook, but some > > infrastructure to support those 4 PCI root port drivers. > > I happen to have a *really old* patch addressing Tegra [1], which > I was never able to test (no HW

Re: [patch V2 24/46] PCI: vmd: Mark VMD irqdomain with DOMAIN_BUS_VMD_MSI

2020-08-31 Thread Jason Gunthorpe
On Wed, Aug 26, 2020 at 01:16:52PM +0200, Thomas Gleixner wrote: > From: Thomas Gleixner > > Devices on the VMD bus use their own MSI irq domain, but it is not > distinguishable from regular PCI/MSI irq domains. This is required > to exclude VMD devices from getting the irq domain pointer set by

Re: [patch V2 46/46] irqchip: Add IMS (Interrupt Message Storm) driver - NOT FOR MERGING

2020-08-31 Thread Jason Gunthorpe
On Wed, Aug 26, 2020 at 01:17:14PM +0200, Thomas Gleixner wrote: > + * ims_queue_info - Information to create an IMS queue domain > + * @queue_lock: Callback which informs the device driver that > + * an interrupt management operation starts. > + * @queue_sync_unlock:

Re: [trivial PATCH] treewide: Convert switch/case fallthrough; to break;

2020-09-09 Thread Jason Gunthorpe
On Wed, Sep 09, 2020 at 01:06:39PM -0700, Joe Perches wrote: > fallthrough to a separate case/default label break; isn't very readable. > > Convert pseudo-keyword fallthrough; statements to a simple break; when > the next label is case or default and the only statement in the next > label block is

Re: [PATCH] iommu/omap: Fix regression in probe for NULL pointer dereference

2022-03-31 Thread Jason Gunthorpe
eturning 0 instead of ERR_PTR(-ENODEV) > as noted by Jason Gunthorpe . > > Looks like the regression already happened with an earlier commit > 6785eb9105e3 ("iommu/omap: Convert to probe/release_device() call-backs") > that changed the function return type and missed convertin

Re: [PATCH] vfio: Stop using iommu_present()

2022-04-05 Thread Jason Gunthorpe
d-off-by: Robin Murphy > --- > drivers/vfio/vfio.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) Reviewed-by: Jason Gunthorpe Jason ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH] RDMA/usnic: Refactor usnic_uiom_alloc_pd()

2022-04-06 Thread Jason Gunthorpe
On Wed, Apr 06, 2022 at 10:39:47PM +0100, Robin Murphy wrote: > On 2022-04-06 20:54, kernel test robot wrote: > > Hi Robin, > > > > I love your patch! Yet something to improve: > > > > [auto build test ERROR on rdma/for-next] > > [also build test ERROR on v5.18-rc1 next-20220406] > > [If your pat

Re: [PATCH] iommu/arm-smmu-v3: Align size in __arm_smmu_tlb_inv_range

2022-04-19 Thread Jason Gunthorpe
On Fri, Apr 15, 2022 at 07:03:20PM -0700, Nicolin Chen wrote: > diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c > b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c > index d816759a6bcf..e280568bb513 100644 > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c > @@ -183,7 +183,7 @@

Re: [PATCH] iommu/arm-smmu-v3: Fix size calculation in arm_smmu_mm_invalidate_range()

2022-04-19 Thread Jason Gunthorpe
tch fixes the issue by doing the calculation correctly. > > Fixes: 2f7e8c553e98d ("iommu/arm-smmu-v3: Hook up ATC invalidation to mm ops") > Cc: sta...@vger.kernel.org > Signed-off-by: Nicolin Chen > --- > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 9

Re: [PATCH v6 20/21] PCI/P2PDMA: Introduce pci_mmap_p2pmem()

2022-05-27 Thread Jason Gunthorpe
On Thu, Apr 07, 2022 at 09:47:16AM -0600, Logan Gunthorpe wrote: > +static void pci_p2pdma_unmap_mappings(void *data) > +{ > + struct pci_dev *pdev = data; > + struct pci_p2pdma *p2pdma = rcu_dereference_protected(pdev->p2pdma, 1); > + > + /* Ensure no new pages can be allocated in mapp

Re: [PATCH v6 20/21] PCI/P2PDMA: Introduce pci_mmap_p2pmem()

2022-05-27 Thread Jason Gunthorpe
On Fri, May 27, 2022 at 09:35:07AM -0600, Logan Gunthorpe wrote: > > > On 2022-05-27 06:55, Jason Gunthorpe wrote: > > On Thu, Apr 07, 2022 at 09:47:16AM -0600, Logan Gunthorpe wrote: > >> +static void pci_p2pdma_unmap_mappings(void *data) > >> +{ &g

Re: [PATCH v6 20/21] PCI/P2PDMA: Introduce pci_mmap_p2pmem()

2022-06-01 Thread Jason Gunthorpe
On Fri, May 27, 2022 at 04:41:08PM -0600, Logan Gunthorpe wrote: > > > > IIRC this is the last part: > > > > https://lore.kernel.org/linux-mm/20220524190632.3304-1-alex.sie...@amd.com/ > > > > And the earlier bit with Christoph's pieces looks like it might get > > merged to v5.19.. > > > > The

Re: [PATCH v6 20/21] PCI/P2PDMA: Introduce pci_mmap_p2pmem()

2022-06-02 Thread Jason Gunthorpe
On Thu, Jun 02, 2022 at 10:16:10AM -0600, Logan Gunthorpe wrote: > > Just stuff the pages into the mmap, and your driver unprobe will > > automatically block until all the mmaps are closed - no different than > > having an open file descriptor or something. > > Oh is that what we want? Yes, it i

Re: [PATCH v6 20/21] PCI/P2PDMA: Introduce pci_mmap_p2pmem()

2022-06-02 Thread Jason Gunthorpe
On Thu, Jun 02, 2022 at 10:45:55AM -0600, Logan Gunthorpe wrote: > > > > On 2022-06-02 10:30, Jason Gunthorpe wrote: > > On Thu, Jun 02, 2022 at 10:16:10AM -0600, Logan Gunthorpe wrote: > > > >>> Just stuff the pages into the mmap, and your driver unprobe

Re: [PATCH v6 20/21] PCI/P2PDMA: Introduce pci_mmap_p2pmem()

2022-06-02 Thread Jason Gunthorpe
On Thu, Jun 02, 2022 at 10:49:15AM -0600, Logan Gunthorpe wrote: > > > On 2022-06-02 10:30, Jason Gunthorpe wrote: > > On Thu, Jun 02, 2022 at 10:16:10AM -0600, Logan Gunthorpe wrote: > > > >>> Just stuff the pages into the mmap, and your driver unprobe will &g

Re: [PATCH v7 20/21] PCI/P2PDMA: Introduce pci_mmap_p2pmem()

2022-06-29 Thread Jason Gunthorpe
On Wed, Jun 29, 2022 at 10:00:09AM -0600, Logan Gunthorpe wrote: > > > > On 2022-06-29 00:48, Christoph Hellwig wrote: > > On Wed, Jun 15, 2022 at 10:12:32AM -0600, Logan Gunthorpe wrote: > >> A pseudo mount is used to allocate an inode for each PCI device. The > >> inode's address_space is used

Re: [RFC PATCH v2] uacce: Add uacce_ctrl misc device

2021-01-26 Thread Jason Gunthorpe
On Tue, Jan 26, 2021 at 01:26:45AM +, Song Bao Hua (Barry Song) wrote: > > On Mon, Jan 25, 2021 at 11:35:22PM +, Song Bao Hua (Barry Song) wrote: > > > > > > On Mon, Jan 25, 2021 at 10:21:14PM +, Song Bao Hua (Barry Song) > > > > wrote: > > > > > mlock, while certainly be able to prev

Re: [RFC PATCH v2] uacce: Add uacce_ctrl misc device

2021-02-01 Thread Jason Gunthorpe
On Fri, Jan 29, 2021 at 10:09:03AM +, Tian, Kevin wrote: > > SVA is not doom to work with IO page fault only. If we have SVA+pin, > > we would get both sharing address and stable I/O latency. > > Isn't it like a traditional MAP_DMA API (imply pinning) plus specifying > cpu_va of the memory po

Re: [PATCH 11/12] platform-msi: Add platform check for subdevice irq domain

2021-02-04 Thread Jason Gunthorpe
On Wed, Feb 03, 2021 at 12:56:44PM -0800, Megha Dey wrote: > +bool arch_support_pci_device_ims(struct pci_dev *pdev) > +{ Consistent language please, we are not using IMS elsewhere, this feature is called device_msi in Linux. Jason ___ iommu mailing lis

Re: [RFC PATCH v3 1/2] mempinfd: Add new syscall to provide memory pin

2021-02-08 Thread Jason Gunthorpe
On Mon, Feb 08, 2021 at 09:14:28AM +0100, David Hildenbrand wrote: > People are constantly struggling with the effects of long term pinnings > under user space control, like we already have with vfio and RDMA. > > And here we are, adding yet another, easier way to mess with core MM in the > same

Re: [RFC PATCH v3 1/2] mempinfd: Add new syscall to provide memory pin

2021-02-08 Thread Jason Gunthorpe
On Mon, Feb 08, 2021 at 08:35:31PM +, Song Bao Hua (Barry Song) wrote: > > > > From: Jason Gunthorpe [mailto:j...@ziepe.ca] > > Sent: Tuesday, February 9, 2021 7:34 AM > > To: David Hildenbrand > > Cc: Wangzhou (B) ; linux-ker...@vger.kernel.org; > > iom

Re: [RFC PATCH v3 1/2] mempinfd: Add new syscall to provide memory pin

2021-02-09 Thread Jason Gunthorpe
On Tue, Feb 09, 2021 at 03:01:42AM +, Song Bao Hua (Barry Song) wrote: > On the other hand, wouldn't it be the benefit of hardware accelerators > to have a lower and more stable latency zip/encryption than CPU? No, I don't think so. If this is an important problem then it should apply equall

Re: [RFC PATCH v3 1/2] mempinfd: Add new syscall to provide memory pin

2021-02-10 Thread Jason Gunthorpe
On Tue, Feb 09, 2021 at 10:22:47PM +, Song Bao Hua (Barry Song) wrote: > The problem is that SVA declares we can use any memory of a process > to do I/O. And in real scenarios, we are unable to customize most > applications to make them use the pool. So we are looking for some > extension gene

Re: [Patch v8 03/10] vfio/type1: Report iommu nesting info to userspace

2021-03-02 Thread Jason Gunthorpe
On Wed, Mar 03, 2021 at 04:35:38AM +0800, Liu Yi L wrote: > diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c > index 4bb162c1d649..3a5c84d4f19b 100644 > +++ b/drivers/vfio/vfio_iommu_type1.c > @@ -63,22 +63,24 @@ MODULE_PARM_DESC(dma_entry_limit, >"Maxi

Re: [Patch v8 04/10] vfio/type1: Support binding guest page tables to PASID

2021-03-02 Thread Jason Gunthorpe
On Wed, Mar 03, 2021 at 04:35:39AM +0800, Liu Yi L wrote: > > +static int vfio_dev_bind_gpasid_fn(struct device *dev, void *data) > +{ > + struct domain_capsule *dc = (struct domain_capsule *)data; > + unsigned long arg = *(unsigned long *)dc->data; > + > + return iommu_uapi_sva_bind_

Re: [Patch v8 04/10] vfio/type1: Support binding guest page tables to PASID

2021-03-02 Thread Jason Gunthorpe
On Tue, Mar 02, 2021 at 09:13:19AM -0800, Jacob Pan wrote: > Hi Jason, > > On Tue, 2 Mar 2021 08:56:28 -0400, Jason Gunthorpe wrote: > > > On Wed, Mar 03, 2021 at 04:35:39AM +0800, Liu Yi L wrote: > > > > > > +static int vfio_dev_bind_gpas

Re: [Patch v8 04/10] vfio/type1: Support binding guest page tables to PASID

2021-03-03 Thread Jason Gunthorpe
On Wed, Mar 03, 2021 at 11:42:12AM -0800, Jacob Pan wrote: > Hi Jason, > > On Tue, 2 Mar 2021 13:15:51 -0400, Jason Gunthorpe wrote: > > > On Tue, Mar 02, 2021 at 09:13:19AM -0800, Jacob Pan wrote: > > > Hi Jason, > > > > > > On Tue, 2 Mar 2021

  1   2   3   4   5   6   7   8   9   10   >