From: Bastien Curutchet <bastien.curutchet@bootlin.com>
To: "Sumit Semwal" <sumit.semwal@linaro.org>,
"Christian König" <christian.koenig@amd.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org,
linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org,
Bastien Curutchet <bastien.curutchet@bootlin.com>
Subject: [PATCH 1/3] dma-buf: Allow heap that doesn't provide map_buf/unmap_buf
Date: Thu, 10 Apr 2025 16:53:18 +0200 [thread overview]
Message-ID: <20250410-uio-dma-v1-1-6468ace2c786@bootlin.com> (raw)
In-Reply-To: <20250410-uio-dma-v1-0-6468ace2c786@bootlin.com>
dma_buf_export() rejects the creation of dma_buf that don't implement
the map/unmap_buf operations while these operations aren't needed if the
buffer isn't shared by the user.
Allow dma_buf to be created even if these operations aren't implemented.
Add a check of their existence before using them.
Signed-off-by: Bastien Curutchet <bastien.curutchet@bootlin.com>
---
drivers/dma-buf/dma-buf.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index 5baa83b855156516a0a766bee0789b122473efb3..398418bd9731ad7a3a1f12eaea6a155fa77a22fe 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -631,8 +631,6 @@ struct dma_buf *dma_buf_export(const struct dma_buf_export_info *exp_info)
int ret;
if (WARN_ON(!exp_info->priv || !exp_info->ops
- || !exp_info->ops->map_dma_buf
- || !exp_info->ops->unmap_dma_buf
|| !exp_info->ops->release))
return ERR_PTR(-EINVAL);
@@ -796,6 +794,9 @@ static struct sg_table *__map_dma_buf(struct dma_buf_attachment *attach,
struct sg_table *sg_table;
signed long ret;
+ if (!attach->dmabuf->ops->map_dma_buf)
+ return ERR_PTR(-EINVAL);
+
sg_table = attach->dmabuf->ops->map_dma_buf(attach, direction);
if (IS_ERR_OR_NULL(sg_table))
return sg_table;
@@ -1002,7 +1003,8 @@ static void __unmap_dma_buf(struct dma_buf_attachment *attach,
/* uses XOR, hence this unmangles */
mangle_sg_table(sg_table);
- attach->dmabuf->ops->unmap_dma_buf(attach, sg_table, direction);
+ if (attach->dmabuf->ops->unmap_dma_buf)
+ attach->dmabuf->ops->unmap_dma_buf(attach, sg_table, direction);
}
/**
--
2.49.0
next prev parent reply other threads:[~2025-04-10 14:53 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-10 14:53 [PATCH 0/3] uio/dma-buf: Give UIO users access to DMA addresses Bastien Curutchet
2025-04-10 14:53 ` Bastien Curutchet [this message]
2025-04-10 14:53 ` [PATCH 2/3] dma-buf: Add DMA_BUF_IOCTL_GET_DMA_ADDR Bastien Curutchet
2025-04-11 18:34 ` Nicolas Dufresne
2025-04-29 6:39 ` Simona Vetter
2025-04-29 8:12 ` Christian König
2025-04-10 14:53 ` [PATCH 3/3] uio: Add UIO_DMABUF_HEAP Bastien Curutchet
2025-04-11 18:41 ` Nicolas Dufresne
2025-04-10 16:29 ` [PATCH 0/3] uio/dma-buf: Give UIO users access to DMA addresses Christian König
2025-04-10 19:43 ` Thomas Petazzoni
[not found] ` <b596c9af-c0e3-4557-b45a-462a33179235@amd.com>
2025-04-11 8:14 ` Bastien Curutchet
2025-04-11 12:41 ` Christian König
2025-04-14 8:17 ` Thomas Petazzoni
2025-04-14 8:59 ` Christian König
2025-04-14 5:55 ` Christoph Hellwig
2025-04-14 8:24 ` Thomas Petazzoni
2025-04-14 9:11 ` Christian König
2025-04-14 11:52 ` Thomas Petazzoni
2025-04-14 11:24 ` Christoph Hellwig
2025-04-14 11:48 ` Thomas Petazzoni
2025-04-14 17:08 ` Andrew Davis
2025-04-14 19:21 ` Thomas Petazzoni
2025-04-14 20:13 ` Andrew Davis
2025-04-22 18:16 ` Jason Gunthorpe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250410-uio-dma-v1-1-6468ace2c786@bootlin.com \
--to=bastien.curutchet@bootlin.com \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gregkh@linuxfoundation.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=sumit.semwal@linaro.org \
--cc=thomas.petazzoni@bootlin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®