[RFC PATCH 01/12] dma-buf: Introduce dma_buf_get_pfn_unlocked() kAPI
Jason Gunthorpe
jgg at nvidia.com
Mon Jan 20 17:59:01 UTC 2025
On Mon, Jan 20, 2025 at 01:14:12PM +0100, Christian König wrote:
What is going wrong with your email? You replied to Simona, but
Simona Vetter <simona.vetter at ffwll.ch> is dropped from the To/CC
list??? I added the address back, but seems like a weird thing to
happen.
> Please take another look at what is proposed here. The function is called
> dma_buf_get_pfn_*unlocked* !
I don't think Simona and I are defending the implementation in this
series. This series needs work.
We have been talking about what the implementation should be. I think
we've all been clear on the idea that the DMA buf locking rules should
apply to any description of the memory, regardless of if the address
are CPU, DMA, or private.
I agree that the idea of any "get unlocked" concept seems nonsensical
and wrong within dmabuf.
> Inserting PFNs into CPU (or probably also IOMMU) page tables have a
> different semantics than what DMA-buf usually does, because as soon as the
> address is written into the page table it is made public.
Not really.
The KVM/CPU is fully compatible with move semantics, it has
restartable page faults and can implement dmabuf's move locking
scheme. It can use the resv lock, the fences, move_notify and so on to
implement it. It is a bug if this series isn't doing that.
The iommu cannot support move semantics. It would need the existing
pin semantics (ie we call dma_buf_pin() and don't support
move_notify). To work with VFIO we would need to formalize the revoke
semantics that Simona was discussing.
We already implement both of these modalities in rdma, the locking API
is fine and workable with CPU pfns just as well.
I've imagined a staged flow here:
1) The new DMA API lands
2) We improve the new DMA API to be fully struct page free, including
setting up P2P
3) VFIO provides a dmbuf exporter using the new DMA API's P2P
support. We'd have to continue with the scatterlist hacks for now.
VFIO would be a move_notify exporter. This should work with RDMA
4) RDMA works to drop scatterlist from its internal flows and use the
new DMA API instead.
5) VFIO/RDMA implement a new non-scatterlist DMABUF op to
demonstrate the post-scatterlist world and deprecate the scatterlist
hacks.
6) We add revoke semantics to dmabuf, and VFIO/RDMA implements them
7) iommufd can import a pinnable revokable dmabuf using CPU pfns
through the non-scatterlist op.
8) Relevant GPU drivers implement the non-scatterlist op and RDMA
removes support for the deprecated scatterlist hacks.
Xu's series has jumped ahead a bit and is missing infrastructure to
build it properly.
Jason
More information about the dri-devel
mailing list