[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7b2017f4-02a3-482a-a173-bb16b895c0cb@amd.com>
Date: Thu, 4 Dec 2025 11:46:45 +0100
From: Christian König <christian.koenig@....com>
To: Pavel Begunkov <asml.silence@...il.com>, linux-block@...r.kernel.org,
io-uring@...r.kernel.org
Cc: Vishal Verma <vishal1.verma@...el.com>, tushar.gohad@...el.com,
Keith Busch <kbusch@...nel.org>, Jens Axboe <axboe@...nel.dk>,
Christoph Hellwig <hch@....de>, Sagi Grimberg <sagi@...mberg.me>,
Alexander Viro <viro@...iv.linux.org.uk>,
Christian Brauner <brauner@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Sumit Semwal <sumit.semwal@...aro.org>, linux-kernel@...r.kernel.org,
linux-nvme@...ts.infradead.org, linux-fsdevel@...r.kernel.org,
linux-media@...r.kernel.org, dri-devel@...ts.freedesktop.org,
linaro-mm-sig@...ts.linaro.org
Subject: Re: [RFC v2 01/11] file: add callback for pre-mapping dmabuf
On 11/23/25 23:51, Pavel Begunkov wrote:
> Add a file callback that maps a dmabuf for the given file and returns
> an opaque token of type struct dma_token representing the mapping.
I'm really scratching my head what you mean with that?
And why the heck would we need to pass a DMA-buf to a struct file?
Regards,
Christian.
> The
> implementation details are hidden from the caller, and the implementors
> are normally expected to extend the structure.
>
> The callback callers will be able to pass the token with an IO request,
> which implemented in following patches as a new iterator type. The user
> should release the token once it's not needed by calling the provided
> release callback via appropriate helpers.
>
> Signed-off-by: Pavel Begunkov <asml.silence@...il.com>
> ---
> include/linux/dma_token.h | 35 +++++++++++++++++++++++++++++++++++
> include/linux/fs.h | 4 ++++
> 2 files changed, 39 insertions(+)
> create mode 100644 include/linux/dma_token.h
>
> diff --git a/include/linux/dma_token.h b/include/linux/dma_token.h
> new file mode 100644
> index 000000000000..9194b34282c2
> --- /dev/null
> +++ b/include/linux/dma_token.h
> @@ -0,0 +1,35 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef _LINUX_DMA_TOKEN_H
> +#define _LINUX_DMA_TOKEN_H
> +
> +#include <linux/dma-buf.h>
> +
> +struct dma_token_params {
> + struct dma_buf *dmabuf;
> + enum dma_data_direction dir;
> +};
> +
> +struct dma_token {
> + void (*release)(struct dma_token *);
> +};
> +
> +static inline void dma_token_release(struct dma_token *token)
> +{
> + token->release(token);
> +}
> +
> +static inline struct dma_token *
> +dma_token_create(struct file *file, struct dma_token_params *params)
> +{
> + struct dma_token *res;
> +
> + if (!file->f_op->dma_map)
> + return ERR_PTR(-EOPNOTSUPP);
> + res = file->f_op->dma_map(file, params);
> +
> + WARN_ON_ONCE(!IS_ERR(res) && !res->release);
> +
> + return res;
> +}
> +
> +#endif
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index c895146c1444..0ce9a53fabec 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -2262,6 +2262,8 @@ struct dir_context {
> struct iov_iter;
> struct io_uring_cmd;
> struct offset_ctx;
> +struct dma_token;
> +struct dma_token_params;
>
> typedef unsigned int __bitwise fop_flags_t;
>
> @@ -2309,6 +2311,8 @@ struct file_operations {
> int (*uring_cmd_iopoll)(struct io_uring_cmd *, struct io_comp_batch *,
> unsigned int poll_flags);
> int (*mmap_prepare)(struct vm_area_desc *);
> + struct dma_token *(*dma_map)(struct file *,
> + struct dma_token_params *);
> } __randomize_layout;
>
> /* Supports async buffered reads */
Powered by blists - more mailing lists