io_uring: uring_cmd: add multishot support for-6.18/io_uring
authorMing Lei <ming.lei@redhat.com>
Thu, 21 Aug 2025 04:02:07 +0000 (12:02 +0800)
committerJens Axboe <axboe@kernel.dk>
Thu, 21 Aug 2025 11:41:00 +0000 (05:41 -0600)
commit55dc643dd2ad15e755a706980692a374de1bb7a8
treeffc2ecdadd3301f4af698c74edb2d9faff22703b
parent1a8ceff033519eac7bb5ab1d910e9b0340835c0d
io_uring: uring_cmd: add multishot support

Add UAPI flag IORING_URING_CMD_MULTISHOT for supporting multishot
uring_cmd operations with provided buffer.

This enables drivers to post multiple completion events from a single
uring_cmd submission, which is useful for:

- Notifying userspace of device events (e.g., interrupt handling)
- Supporting devices with multiple event sources (e.g., multi-queue devices)
- Avoiding the need for device poll() support when events originate
  from multiple sources device-wide

The implementation adds two new APIs:
- io_uring_cmd_select_buffer(): selects a buffer from the provided
  buffer group for multishot uring_cmd
- io_uring_mshot_cmd_post_cqe(): posts a CQE after event data is
  pushed to the provided buffer

Multishot uring_cmd must be used with buffer select (IOSQE_BUFFER_SELECT)
and is mutually exclusive with IORING_URING_CMD_FIXED for now.

The ublk driver will be the first user of this functionality:

https://github.com/ming1/linux/commits/ublk-devel/

Signed-off-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20250821040210.1152145-3-ming.lei@redhat.com
[axboe: fold in fix for !CONFIG_IO_URING]
Signed-off-by: Jens Axboe <axboe@kernel.dk>
include/linux/io_uring/cmd.h
include/uapi/linux/io_uring.h
io_uring/opdef.c
io_uring/uring_cmd.c