From: Daniel Vetter <daniel-/w4YWyX8dFk@public.gmane.org>
To: "Christian König"
<ckoenig.leichtzumerken-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: linaro-mm-sig-cunTk1MwBs8s++Sfvej+rw@public.gmane.org,
amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
linux-media-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 3/5] dma-buf: lock the reservation object during (un)map_dma_buf
Date: Mon, 18 Jun 2018 10:22:24 +0200 [thread overview]
Message-ID: <20180618082224.GW3438@phenom.ffwll.local> (raw)
In-Reply-To: <20180601120020.11520-3-christian.koenig-5C7GfCeVMHo@public.gmane.org>
On Fri, Jun 01, 2018 at 02:00:18PM +0200, Christian König wrote:
> First step towards unpinned DMA buf operation.
>
> I've checked the DRM drivers to potential locking of the reservation
> object, but essentially we need to audit all implementations of the
> dma_buf _ops for this to work.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
Agreed in principle, but I expect a fireworks show with just this patch
applied. It's not just that we need to audit all the implementations of
dma-buf-ops, we also need to audit all the callers.
No idea yet how to go about merging this, but for a start might be good to
throw this at the intel-gfx CI (just Cc: the intel-gfx mailing lists, but
make sure your series applies without amd-staging-next stuff which isn't
in drm.git yet).
-Daniel
> ---
> drivers/dma-buf/dma-buf.c | 4 ++++
> include/linux/dma-buf.h | 4 ++++
> 2 files changed, 8 insertions(+)
>
> diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
> index e4c657d9fad7..4f0708cb58a7 100644
> --- a/drivers/dma-buf/dma-buf.c
> +++ b/drivers/dma-buf/dma-buf.c
> @@ -631,7 +631,9 @@ struct sg_table *dma_buf_map_attachment(struct dma_buf_attachment *attach,
> if (WARN_ON(!attach || !attach->dmabuf))
> return ERR_PTR(-EINVAL);
>
> + reservation_object_lock(attach->dmabuf->resv, NULL);
> sg_table = attach->dmabuf->ops->map_dma_buf(attach, direction);
> + reservation_object_unlock(attach->dmabuf->resv);
> if (!sg_table)
> sg_table = ERR_PTR(-ENOMEM);
>
> @@ -658,8 +660,10 @@ void dma_buf_unmap_attachment(struct dma_buf_attachment *attach,
> if (WARN_ON(!attach || !attach->dmabuf || !sg_table))
> return;
>
> + reservation_object_lock(attach->dmabuf->resv, NULL);
> attach->dmabuf->ops->unmap_dma_buf(attach, sg_table,
> direction);
> + reservation_object_unlock(attach->dmabuf->resv);
> }
> EXPORT_SYMBOL_GPL(dma_buf_unmap_attachment);
>
> diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h
> index d17cadd76802..d2ba7a027a78 100644
> --- a/include/linux/dma-buf.h
> +++ b/include/linux/dma-buf.h
> @@ -118,6 +118,8 @@ struct dma_buf_ops {
> * any other kind of sharing that the exporter might wish to make
> * available to buffer-users.
> *
> + * This is called with the dmabuf->resv object locked.
> + *
> * Returns:
> *
> * A &sg_table scatter list of or the backing storage of the DMA buffer,
> @@ -138,6 +140,8 @@ struct dma_buf_ops {
> * It should also unpin the backing storage if this is the last mapping
> * of the DMA buffer, it the exporter supports backing storage
> * migration.
> + *
> + * This is called with the dmabuf->resv object locked.
> */
> void (*unmap_dma_buf)(struct dma_buf_attachment *,
> struct sg_table *,
> --
> 2.14.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
next prev parent reply other threads:[~2018-06-18 8:22 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-01 12:00 [PATCH 1/5] dma_buf: remove device parameter from attach callback Christian König
[not found] ` <20180601120020.11520-1-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-06-01 12:00 ` [PATCH 2/5] dma-buf: remove kmap_atomic interface Christian König
[not found] ` <20180601120020.11520-2-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-06-18 8:18 ` Daniel Vetter
2018-06-19 14:47 ` Christian König
2018-06-19 15:35 ` Daniel Vetter
[not found] ` <CAKMK7uEvhMF92ifA=7xQ=9GR3NofZNExCDTHZTtikmujJTZ89A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-06-20 12:46 ` Christian König
[not found] ` <c0552d8a-1c64-c99b-6ef8-83e253c49d30-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-06-20 12:52 ` Daniel Vetter
[not found] ` <CAKMK7uHHZn=H6px-yiXy7tVmmQy6GHrwGtG+B7or1ThsrriFDA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-06-20 14:04 ` Christian König
[not found] ` <5d337ffc-6c4c-dafb-abb2-151d9d4aeaea-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-06-20 14:21 ` Christian König
[not found] ` <3994b9d0-85fe-6495-5528-282f7b46a53f-5C7GfCeVMHo@public.gmane.org>
2018-06-21 6:26 ` Daniel Vetter
[not found] ` <CAKMK7uFbvuikxSMgzquzXgcyVVonhWu3HNfrOR2s7RGB7k21ow-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-06-21 6:30 ` Daniel Vetter
[not found] ` <CAKMK7uG7dtj136GAg6E9rVHm4dAg0a-A6EA=911fBi8YpVDbcA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-06-21 10:59 ` Christian König
2018-06-20 6:10 ` Sumit Semwal
[not found] ` <CAO_48GG=whv7R5J1E-xHdZJYFsfYwgnyDq8CzKZktro60m1c+g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-06-20 6:22 ` Christian König
2018-06-01 12:00 ` [PATCH 3/5] dma-buf: lock the reservation object during (un)map_dma_buf Christian König
[not found] ` <20180601120020.11520-3-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-06-18 8:22 ` Daniel Vetter [this message]
[not found] ` <20180618082224.GW3438-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2018-06-18 12:43 ` Christian König
2018-06-01 12:00 ` [PATCH 4/5] dma-buf: add dma_buf_(un)map_attachment_locked variants Christian König
2018-06-18 8:27 ` Daniel Vetter
2018-06-01 12:00 ` [PATCH 5/5] drm/amdgpu: add independent DMA-buf export v3 Christian König
[not found] ` <20180601120020.11520-5-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-06-18 8:28 ` Daniel Vetter
[not found] ` <20180618082857.GY3438-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2018-06-22 13:39 ` Christian König
[not found] ` <64382bf8-9539-6fa5-3f95-a3b627e4684d-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-06-25 7:46 ` Daniel Vetter
2018-06-01 12:11 ` [PATCH 1/5] dma_buf: remove device parameter from attach callback Christian König
[not found] ` <651a24e0-ac58-e5cb-d95f-c9a88bf552dc-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-06-01 14:02 ` Michel Dänzer
[not found] ` <df02be8b-530e-b691-35f1-ed657d71a508-otUistvHUpPR7s880joybQ@public.gmane.org>
2018-06-01 15:17 ` Christian König
[not found] ` <64e8f2dd-5b09-397f-05ac-67646dfb5394-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-06-01 15:30 ` Michel Dänzer
2018-06-06 11:24 ` Christian König
2018-06-18 8:14 ` Daniel Vetter
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=20180618082224.GW3438@phenom.ffwll.local \
--to=daniel-/w4ywyx8dfk@public.gmane.org \
--cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
--cc=ckoenig.leichtzumerken-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
--cc=linaro-mm-sig-cunTk1MwBs8s++Sfvej+rw@public.gmane.org \
--cc=linux-media-u79uwXL29TY76Z2rM5mHXA@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox