From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: dri-devel@lists.freedesktop.org
Subject: [PATCH 04/12] dma-buf: lock the reservation object during (un)map_dma_buf v4
Date: Fri, 26 Apr 2019 14:36:30 +0200 [thread overview]
Message-ID: <20190426123638.40221-4-christian.koenig@amd.com> (raw)
In-Reply-To: <20190426123638.40221-1-christian.koenig@amd.com>
This way we always call the the map/unmap callbacks with the reservation
object held if pin/unpin is also implemented.
For static dma-buf exporters we still have the fallback of using cached sgt.
v2: reordered
v3: rebased on sgt caching
v4: use the cached sgt when possible
v5: cleanup further
Signed-off-by: Christian König <christian.koenig@amd.com>
---
drivers/dma-buf/dma-buf.c | 10 +++++-----
include/linux/dma-buf.h | 3 +++
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index a18d10c4425a..0aa97bb05636 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -691,13 +691,15 @@ struct sg_table *dma_buf_map_attachment(struct dma_buf_attachment *attach,
reservation_object_lock(attach->dmabuf->resv, NULL);
r = dma_buf_pin(attach->dmabuf);
- reservation_object_unlock(attach->dmabuf->resv);
- if (r)
+ if (r) {
+ reservation_object_unlock(attach->dmabuf->resv);
return ERR_PTR(r);
+ }
sg_table = attach->dmabuf->ops->map_dma_buf(attach, direction);
if (!sg_table)
sg_table = ERR_PTR(-ENOMEM);
+ reservation_object_unlock(attach->dmabuf->resv);
return sg_table;
}
@@ -725,10 +727,8 @@ void dma_buf_unmap_attachment(struct dma_buf_attachment *attach,
if (attach->sgt == sg_table)
return;
- attach->dmabuf->ops->unmap_dma_buf(attach, sg_table,
- direction);
-
reservation_object_lock(attach->dmabuf->resv, NULL);
+ attach->dmabuf->ops->unmap_dma_buf(attach, sg_table, direction);
dma_buf_unpin(attach->dmabuf);
reservation_object_unlock(attach->dmabuf->resv);
}
diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h
index b9d0719581cd..425a771d229c 100644
--- a/include/linux/dma-buf.h
+++ b/include/linux/dma-buf.h
@@ -144,6 +144,9 @@ struct dma_buf_ops {
* any other kind of sharing that the exporter might wish to make
* available to buffer-users.
*
+ * This is always called with the dmabuf->resv object locked when
+ * the pin/unpin callbacks are implemented.
+ *
* Returns:
*
* A &sg_table scatter list of or the backing storage of the DMA buffer,
--
2.17.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2019-04-26 12:36 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-26 12:36 [PATCH 01/12] dma-buf: add struct dma_buf_attach_info Christian König
2019-04-26 12:36 ` [PATCH 02/12] dma-buf: add explicit buffer pinning v2 Christian König
2019-04-29 8:40 ` Daniel Vetter
2019-04-30 13:42 ` Christian König
2019-04-30 13:59 ` Daniel Vetter
2019-04-30 14:26 ` Christian König
2019-04-30 14:34 ` Daniel Vetter
2019-04-30 14:41 ` Koenig, Christian
2019-04-30 15:22 ` Daniel Vetter
2019-04-26 12:36 ` [PATCH 03/12] dma-buf: start caching of sg_table objects Christian König
2019-04-29 8:54 ` Daniel Vetter
2019-04-30 14:18 ` Daniel Vetter
2019-04-26 12:36 ` Christian König [this message]
2019-04-26 12:36 ` [PATCH 05/12] dma-buf: add dma_buf_(un)map_attachment_locked variants v4 Christian König
2019-04-26 12:36 ` [PATCH 06/12] dma-buf: add optional invalidate_mappings callback v5 Christian König
2019-04-29 8:42 ` Daniel Vetter
2019-04-26 12:36 ` [PATCH 07/12] drm: remove prime sg_table caching Christian König
2019-04-26 12:36 ` [PATCH 08/12] drm/ttm: remove the backing store if no placement is given Christian König
2019-04-26 12:36 ` [PATCH 09/12] drm/ttm: use the parent resv for ghost objects Christian König
2019-04-26 12:36 ` [PATCH 10/12] drm/amdgpu: add independent DMA-buf export v3 Christian König
2019-04-30 14:16 ` Daniel Vetter
2019-05-03 12:35 ` Christian König
2019-05-06 8:04 ` Daniel Vetter
2019-05-06 10:05 ` Koenig, Christian
2019-05-06 15:10 ` Daniel Vetter
2019-04-26 12:36 ` [PATCH 11/12] drm/amdgpu: add independent DMA-buf import v4 Christian König
2019-04-26 12:36 ` [PATCH 12/12] drm/amdgpu: add DMA-buf invalidation callback v2 Christian König
2019-04-29 8:24 ` [PATCH 01/12] dma-buf: add struct dma_buf_attach_info Daniel Vetter
2019-04-30 12:40 ` Christian König
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=20190426123638.40221-4-christian.koenig@amd.com \
--to=ckoenig.leichtzumerken@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.