[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20260112170434.GH745888@ziepe.ca>
Date: Mon, 12 Jan 2026 13:04:34 -0400
From: Jason Gunthorpe <jgg@...pe.ca>
To: Christian König <christian.koenig@....com>
Cc: Simona Vetter <simona.vetter@...ll.ch>,
Leon Romanovsky <leon@...nel.org>,
Sumit Semwal <sumit.semwal@...aro.org>,
Alex Williamson <alex@...zbot.org>,
Kevin Tian <kevin.tian@...el.com>, Joerg Roedel <joro@...tes.org>,
Will Deacon <will@...nel.org>, Robin Murphy <robin.murphy@....com>,
linux-rdma@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-media@...r.kernel.org, dri-devel@...ts.freedesktop.org,
linaro-mm-sig@...ts.linaro.org, kvm@...r.kernel.org,
iommu@...ts.linux.dev
Subject: Re: [PATCH 0/4] dma-buf: add revoke mechanism to invalidate shared
buffers
On Mon, Jan 12, 2026 at 05:12:36PM +0100, Christian König wrote:
> > static struct dma_buf_attach_ops ib_umem_dmabuf_attach_pinned_ops = {
> > .allow_peer2peer = true,
> > .move_notify = ib_umem_dmabuf_unsupported_move_notify,
> > };
> >
> > So we can't just allow it to attach to exporters that are going to
> > start calling move_notify while pinned.
>
> The point is exporters are already doing this.
:( So obviously this doesn't work fully correctly..
> > Which is why we are coming to negotiation because at least the above
> > isn't going to work if move_notify is called for revoke reasons, and
> > we'd like to block attaching exporters that need revoke for the above.
>
> Ah, yes that makes sense. This is clearly a new requirement.
>
> So basically for PCIe hotplug was a rare event were we said we have
> some problems with non-ODP but we can live with that, but for this
> use case here it's more like a perfectly normal condition that
> userspace can trigger.
Yes that seems to be exactly the case. I didn't know about the PCI RAS
case until now :(
> So the exporter wants to reject importers which can't handle a
> mapping invalidation while the BO is pinned, correct?
Yes. I think at a minimum exporters where it is a normal use case
should block it so unpriv user space cannot trigger incorrect behavior
/ ignored invalidation. ie VFIO will trigger this based on unpriv user
system calls.
I supposed we have to retain the PCI RAS misbehavior for now at least.
It would probably be uAPI regression to start blocking some of the
existing ones.
It also seems we should invest in the RDMA side to minimize where this
is used.
> > So, would you be happier with this if we documented that move_notify
> > can be called for pinned importers for revoke purposes and figure out
> > something to mark the above as special so exporters can fail pin if
> > they are going to call move_notify?
>
> That would work for me. I mean it is already current practice, we
> just never fully documented it.
OK
> > Then this series would transform into documentation, making VFIO
> > accept pin and continue to call move_notify as it does right now, and
> > some logic to reject the RDMA non-ODP importer.
>
> I think we just need to expose this with flags or similar from the
> importer side. As far as I know RDMA without ODP is currently the
> only one really needing this (except for cross device scanout, but
> that is special anyway).
I did not see any other importers with an obvious broken move_notify,
so I hope this is right. Even iommufd has a working move_notify
(disruptive, but working).
How do you feel about an enum in the ops:
+enum dma_buf_move_notify_level {
+ /*
+ * The importer can pause HW access while move_notify is running
+ * and cleanly handle dynamic changes to the DMA mapping without
+ * any disruption.
+ */
+ DMA_BUF_MOVE_NOTIFY_FAULTING = 0,
+ /*
+ * The importer can stop HW access and disruptively fail any
+ * of its DMA activity. move_notify should only be called if the
+ * exporter is experiencing an unusual error and can accept
+ * that the importer will be disrupted.
+ */
+ DMA_BUF_MOVE_NOTIFY_REVOKING,
+ /*
+ * move_notify is not supported at all and must not be called. Do not
+ * introduce new drivers using this, it has significant draw backs
+ * around PCI error handling and other cases. It has the most limited
+ * set of compatible importers.
+ */
+ DMA_BUF_MOVE_NOTIFY_UNSUPPORTED,
+};
+
/**
* struct dma_buf_attach_ops - importer operations for an attachment
*
@@ -457,6 +480,8 @@ struct dma_buf_attach_ops {
*/
bool allow_peer2peer;
+ enum dma_buf_move_notify_level move_notify_level;
+
/**
* @move_notify: [optional] notification that the DMA-buf is moving
*
Jason
Powered by blists - more mailing lists