From: "Zhang, Jerry (Junwei)" <Jerry.Zhang@amd.com>
To: "Christian König" <ckoenig.leichtzumerken@gmail.com>,
daniel@ffwll.ch, sumit.semwal@linaro.org,
dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org,
linaro-mm-sig@lists.linaro.org, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 2/4] dma-buf: lock the reservation object during (un)map_dma_buf v2
Date: Thu, 28 Jun 2018 17:53:59 +0800 [thread overview]
Message-ID: <5B34B037.50105@amd.com> (raw)
In-Reply-To: <20180622141103.1787-3-christian.koenig@amd.com>
On 06/22/2018 10:11 PM, 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.
>
> v2: reordered
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
looks good for me.
Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com>
Jerry
> ---
> drivers/dma-buf/dma-buf.c | 9 ++++++---
> include/linux/dma-buf.h | 4 ++++
> 2 files changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
> index dc94e76e2e2a..49f23b791eb8 100644
> --- a/drivers/dma-buf/dma-buf.c
> +++ b/drivers/dma-buf/dma-buf.c
> @@ -665,7 +665,9 @@ struct sg_table *dma_buf_map_attachment(struct dma_buf_attachment *attach,
> if (WARN_ON(!attach || !attach->dmabuf))
> return ERR_PTR(-EINVAL);
>
> - sg_table = attach->dmabuf->ops->map_dma_buf(attach, direction);
> + reservation_object_lock(attach->dmabuf->resv, NULL);
> + sg_table = dma_buf_map_attachment_locked(attach, direction);
> + reservation_object_unlock(attach->dmabuf->resv);
> if (!sg_table)
> sg_table = ERR_PTR(-ENOMEM);
>
> @@ -715,8 +717,9 @@ void dma_buf_unmap_attachment(struct dma_buf_attachment *attach,
> if (WARN_ON(!attach || !attach->dmabuf || !sg_table))
> return;
>
> - attach->dmabuf->ops->unmap_dma_buf(attach, sg_table,
> - direction);
> + reservation_object_lock(attach->dmabuf->resv, NULL);
> + dma_buf_unmap_attachment_locked(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 a25e754ae2f7..024658d1f22e 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 *,
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
WARNING: multiple messages have this Message-ID (diff)
From: "Zhang, Jerry (Junwei)" <Jerry.Zhang@amd.com>
To: "Christian König" <ckoenig.leichtzumerken@gmail.com>,
daniel@ffwll.ch, sumit.semwal@linaro.org,
dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org,
linaro-mm-sig@lists.linaro.org, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 2/4] dma-buf: lock the reservation object during (un)map_dma_buf v2
Date: Thu, 28 Jun 2018 17:53:59 +0800 [thread overview]
Message-ID: <5B34B037.50105@amd.com> (raw)
In-Reply-To: <20180622141103.1787-3-christian.koenig@amd.com>
On 06/22/2018 10:11 PM, 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.
>
> v2: reordered
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
looks good for me.
Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com>
Jerry
> ---
> drivers/dma-buf/dma-buf.c | 9 ++++++---
> include/linux/dma-buf.h | 4 ++++
> 2 files changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
> index dc94e76e2e2a..49f23b791eb8 100644
> --- a/drivers/dma-buf/dma-buf.c
> +++ b/drivers/dma-buf/dma-buf.c
> @@ -665,7 +665,9 @@ struct sg_table *dma_buf_map_attachment(struct dma_buf_attachment *attach,
> if (WARN_ON(!attach || !attach->dmabuf))
> return ERR_PTR(-EINVAL);
>
> - sg_table = attach->dmabuf->ops->map_dma_buf(attach, direction);
> + reservation_object_lock(attach->dmabuf->resv, NULL);
> + sg_table = dma_buf_map_attachment_locked(attach, direction);
> + reservation_object_unlock(attach->dmabuf->resv);
> if (!sg_table)
> sg_table = ERR_PTR(-ENOMEM);
>
> @@ -715,8 +717,9 @@ void dma_buf_unmap_attachment(struct dma_buf_attachment *attach,
> if (WARN_ON(!attach || !attach->dmabuf || !sg_table))
> return;
>
> - attach->dmabuf->ops->unmap_dma_buf(attach, sg_table,
> - direction);
> + reservation_object_lock(attach->dmabuf->resv, NULL);
> + dma_buf_unmap_attachment_locked(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 a25e754ae2f7..024658d1f22e 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 *,
>
next prev parent reply other threads:[~2018-06-28 9:53 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-22 14:10 First step towards unpinned DMA-buf operation Christian König
2018-06-22 14:10 ` Christian König
2018-06-22 14:11 ` [PATCH 1/4] dma-buf: add dma_buf_(un)map_attachment_locked variants v2 Christian König
2018-06-22 14:11 ` Christian König
2018-06-25 8:15 ` Daniel Vetter
2018-06-25 8:15 ` Daniel Vetter
2018-06-28 9:44 ` Zhang, Jerry (Junwei)
2018-06-28 9:44 ` Zhang, Jerry (Junwei)
2018-06-28 9:53 ` Zhang, Jerry (Junwei)
2018-06-28 9:53 ` Zhang, Jerry (Junwei)
2018-07-03 11:37 ` Christian König
2018-07-03 11:37 ` Christian König
2018-06-22 14:11 ` [PATCH 2/4] dma-buf: lock the reservation object during (un)map_dma_buf v2 Christian König
2018-06-22 14:11 ` Christian König
2018-06-25 8:22 ` Daniel Vetter
2018-06-25 8:22 ` Daniel Vetter
2018-06-25 9:12 ` Daniel Vetter
2018-06-25 9:12 ` Daniel Vetter
2018-07-03 11:46 ` Christian König
2018-07-03 11:46 ` Christian König
2018-07-03 12:52 ` Daniel Vetter
2018-07-03 12:52 ` Daniel Vetter
2018-07-03 13:02 ` Christian König
2018-07-03 13:02 ` Christian König
2018-07-03 13:11 ` Daniel Vetter
2018-07-03 13:11 ` Daniel Vetter
2018-07-03 13:31 ` Christian König
2018-07-03 13:31 ` Christian König
2018-06-28 9:53 ` Zhang, Jerry (Junwei) [this message]
2018-06-28 9:53 ` Zhang, Jerry (Junwei)
2018-06-22 14:11 ` [PATCH 3/4] drm/amdgpu: add independent DMA-buf export v3 Christian König
2018-06-22 14:11 ` Christian König
2018-06-28 9:58 ` Zhang, Jerry (Junwei)
2018-06-28 9:58 ` Zhang, Jerry (Junwei)
2018-07-03 11:35 ` Christian König
2018-07-03 11:35 ` Christian König
2018-06-22 14:11 ` [PATCH 4/4] drm/amdgpu: add independent DMA-buf import v4 Christian König
2018-06-22 14:11 ` Christian König
2018-06-22 14:20 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/4] dma-buf: add dma_buf_(un)map_attachment_locked variants v2 Patchwork
2018-06-22 14:39 ` ✗ Fi.CI.BAT: failure " Patchwork
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=5B34B037.50105@amd.com \
--to=jerry.zhang@amd.com \
--cc=ckoenig.leichtzumerken@gmail.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-media@vger.kernel.org \
--cc=sumit.semwal@linaro.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.