io_uring dma-buf support for 7.4
Subsystems (2)
Jens Axboe
maintainerHi Linus,
This adds native dma-buf support to the I/O path, exposed through io_uring. It's been in development for a while and should be ready to go now. Since it depends on both the io_uring and block trees, I've deferred sending it out until those were merged. This pull request contains:
- dma-buf file I/O infrastructure: a dma_buf_io_ctx created through a new ->init_dma_buf_io_ctx file operation, and a dma_buf_io_map holding the device DMA mapping. The two are split so a mapping can be invalidated and re-established underneath a live context, with the map counting in-flight requests so it can be torn down safely.
- A new iov_iter type for dmabuf maps, and a dma map backed bio type for the block layer, with raw block device support on top.
- nvme-pci backend implementing dma-buf backed requests, including SGL support.
- io_uring dmabuf backed registered buffers, built on a reworked buffer registration structure with an extended update path, regbuf import flags, an uncloneable flag for buffer types that can't be cloned, and cloning support for registered dma-bufs.
Note that this conflicts with block/fops.c in your tree, as the dma-buf rejection in the buffered write fallback landed next to the NOWAIT and i_rwsem changes from the block pull. Fixup is trivial, it's just adding the iov_iter_is_dmabuf_map() check in the changed blkdev_buffered_write().
Please pull!
The following changes since commit e889b0e4cafddb3d68c3595dc01b7128fd35fbef:
io_uring/io-wq: don't call try_to_wake_up() twice in io_wq_worker_wake() (2026-10-12 10:19:52 -0600)
are available in the Git repository at:
https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux.git tags/for-7.4/io_uring-dmabuf-20261023
for you to fetch changes up to 45b716456dd99488a0cef58482120dc0474aa696:
io_uring/dma-buf: don't fail fixed buffers without dma-buf support (2026-10-22 09:27:00 -0600)
----------------------------------------------------------------
for-7.4/io_uring-dmabuf-20261023
----------------------------------------------------------------
Anuj Gupta (3):
nvme-pci: rename nvme_pci_sgl_set_data to nvme_pci_dma_iter_set_sgl
nvme-pci: add SGL support for the dmabuf path io_uring/dma-buf: don't fail fixed buffers without dma-buf support
Keith Busch (2):
block: reject dma-bufs larger than 4GiB
nvme-pci: detach dma-bufs only on removal
Pavel Begunkov (15):
dma-buf: introduce initial file I/O infrastructure
iov_iter: add iterator type for dmabuf maps
block: always adjust bi_offset on bio_advance_iter
block: introduce dma map backed bio type
block: add dma-buf support for raw bdev
nvme-pci: implement dma-buf backed requests io_uring/rsrc: introduce buf registration structure io_uring/rsrc: extend buffer update io_uring/rsrc: add uncloneable regbuf flag io_uring/rsrc: add regbuf import flags io_uring/rsrc: add dmabuf backed registered buffers
block: fix indention for dma-buf checks
dma-buf-io: fix typos in kernel docs
dma-buf-io: document dma_buf_io_init_map io_uring/dma-buf: allow cloning registered dma-bufs
block/bio.c | 15 +- block/blk-merge.c | 52 +++++++ block/blk-mq.c | 6 + block/fops.c | 29 +++- drivers/dma-buf/Makefile | 2 +- drivers/dma-buf/dma-buf-io.c | 241 ++++++++++++++++++++++++++++++++ drivers/md/dm-io-rewind.c | 6 +- drivers/nvme/host/Makefile | 1 + drivers/nvme/host/core.c | 12 ++ drivers/nvme/host/nvme.h | 2 + drivers/nvme/host/pci-dmabuf.c | 169 ++++++++++++++++++++++ drivers/nvme/host/pci-dmabuf.h | 75 ++++++++++ drivers/nvme/host/pci.c | 247 ++++++++++++++++++++++++++++++++- include/linux/bio.h | 21 +-- include/linux/blk-mq.h | 7 + include/linux/blk_types.h | 14 +- include/linux/blkdev.h | 2 + include/linux/bvec.h | 3 +- include/linux/dma-buf-io.h | 126 +++++++++++++++++ include/linux/fs.h | 2 + include/linux/io_uring_types.h | 5 + include/linux/iov_iter.h | 2 + include/linux/uio.h | 11 ++ include/uapi/linux/io_uring.h | 31 ++++- io_uring/Makefile | 1 + io_uring/dma-buf.c | 71 ++++++++++ io_uring/dma-buf.h | 76 ++++++++++ io_uring/rsrc.c | 178 ++++++++++++++++++------ io_uring/rsrc.h | 31 ++++- io_uring/rw.c | 33 +++-- lib/iov_iter.c | 29 +++- 31 files changed, 1414 insertions(+), 86 deletions(-) create mode 100644 drivers/dma-buf/dma-buf-io.c create mode 100644 drivers/nvme/host/pci-dmabuf.c create mode 100644 drivers/nvme/host/pci-dmabuf.h create mode 100644 include/linux/dma-buf-io.h create mode 100644 io_uring/dma-buf.c create mode 100644 io_uring/dma-buf.h
Signature · 1 line
Jens Axboe
Quoted 2 lines · Jens Axboe
This adds native dma-buf support to the I/O path
So while doing the trivial resolution, and looking at the code, I note that blkdev_buffered_write() grew a
inode_lock_shared
..
inode_unlock_sharedin it. But looking at the two call sites (in blkdev_write_iter()), _one_ of them already has that inode_lock_shared() on what seems to be the exact same inode (bdev_file_inode(iocb->ki_filp))
These all went through you in the original block pull:
1b1be9ea4e34 block: take the inode lock for buffered write fallback 2fec4fd97cc3 block: take i_rwsem for the direct I/O write fallback
am I missing something? That nested locking looks not just unnecessary, it looks like deadlock city. I'm surprised lockdep hasn't complained, but I'm assuming hardly anybody actually uses this path.
Linus
Jens Axboe
maintainerQuoted 15 lines · Linus Torvalds
Quoted 2 lines · Jens Axboe
This adds native dma-buf support to the I/O path
So while doing the trivial resolution, and looking at the code, I note that
blkdev_buffered_write()grew ainode_lock_shared .. inode_unlock_sharedin it. But looking at the two call sites (in
blkdev_write_iter()), _one_ of them already has thatinode_lock_shared()on what seems to be the exact same inode (bdev_file_inode(iocb->ki_filp))
Quoted 8 lines
These all went through you in the original block pull:
1b1be9ea4e34block: take the inode lock for buffered write fallback2fec4fd97cc3block: takei_rwsemfor the direct I/O write fallbackam I missing something? That nested locking looks not just unnecessary, it looks like deadlock city. I'm surprised lockdep hasn't complained, but I'm assuming hardly anybody actually uses this path.
Someone did actually report it recently, after it had been in for-next for a long time. There is a fix queued up for it:
since this morning! It'll go out later this week, pre -rc1.
Signature · 1 line
Jens Axboe