dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Maarten Lankhorst <maarten.lankhorst@canonical.com>
To: Lauri Peltonen <lpeltonen@nvidia.com>,
	Ben Skeggs <bskeggs@redhat.com>,
	Daniel Vetter <daniel.vetter@ffwll.ch>,
	Colin Cross <ccross@android.com>,
	Dave Airlie <airlied@redhat.com>
Cc: Stephen Warren <swarren@nvidia.com>,
	nouveau@lists.freedesktop.org, James Jones <jajones@nvidia.com>,
	dri-devel@lists.freedesktop.org,
	Thierry Reding <treding@nvidia.com>,
	Ken Adams <kadams@nvidia.com>
Subject: Re: [RFC PATCH 7/7] drm/prime: Support explicit fence on export
Date: Sat, 27 Sep 2014 08:49:39 +0200	[thread overview]
Message-ID: <54265E03.80705@canonical.com> (raw)
In-Reply-To: <1411725612-10455-8-git-send-email-lpeltonen@nvidia.com>



On 26-09-14 12:00, Lauri Peltonen wrote:
> Allow user space to provide an explicit sync fence fd when exporting
> a dma-buf from gem handle.  The fence will be stored as the explicit
> fence to the reservation object.
> 
> Signed-off-by: Lauri Peltonen <lpeltonen@nvidia.com>
> ---
>  drivers/gpu/drm/drm_prime.c | 41 +++++++++++++++++++++++++++++++++--------
>  include/uapi/drm/drm.h      |  9 ++++++++-
>  2 files changed, 41 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
> index 2807a77..c69df2e 100644
> --- a/drivers/gpu/drm/drm_prime.c
> +++ b/drivers/gpu/drm/drm_prime.c
> @@ -28,8 +28,10 @@
>  
>  #include <linux/export.h>
>  #include <linux/dma-buf.h>
> +#include <linux/reservation.h>
>  #include <drm/drmP.h>
>  #include "drm_internal.h"
> +#include "../../staging/android/sync.h"
>  
>  /*
>   * DMA-BUF/GEM Object references and lifetime overview:
> @@ -329,7 +331,7 @@ static const struct dma_buf_ops drm_gem_prime_dmabuf_ops =  {
>   * drm_gem_prime_export - helper library implemention of the export callback
>   * @dev: drm_device to export from
>   * @obj: GEM object to export
> - * @flags: flags like DRM_CLOEXEC
> + * @flags: flags like DRM_CLOEXEC or DRM_SYNC_FD
>   *
>   * This is the implementation of the gem_prime_export functions for GEM drivers
>   * using the PRIME helpers.
> @@ -385,7 +387,7 @@ static struct dma_buf *export_and_register_object(struct drm_device *dev,
>   * @dev: dev to export the buffer from
>   * @file_priv: drm file-private structure
>   * @handle: buffer handle to export
> - * @flags: flags like DRM_CLOEXEC
> + * @flags: flags like DRM_CLOEXEC or DRM_SYNC_FD
>   * @prime_fd: pointer to storage for the fd id of the create dma-buf
>   *
>   * This is the PRIME export function which must be used mandatorily by GEM
> @@ -401,6 +403,24 @@ int drm_gem_prime_handle_to_fd(struct drm_device *dev,
>  	struct drm_gem_object *obj;
>  	int ret = 0;
>  	struct dma_buf *dmabuf;
> +	struct fence *fence = NULL;
> +
> +	if (flags & DRM_SYNC_FD) {
> +#ifdef CONFIG_SYNC
> +		struct sync_fence *sf = sync_fence_fdget(*prime_fd);
> +		if (!sf)
> +			return -ENOENT;
> +		if (sf->num_fences != 1) {
> +			sync_fence_put(sf);
> +			return -EINVAL;
> +		}
> +		fence = fence_get(sf->cbs[0].sync_pt);
> +		sync_fence_put(sf);
> +		flags &= ~DRM_SYNC_FD;
> +#else
> +		return -ENODEV;
> +#endif
> +	}
>  
>  	mutex_lock(&file_priv->prime.lock);
>  	obj = drm_gem_object_lookup(dev, file_priv, handle);
> @@ -453,6 +473,14 @@ out_have_obj:
>  		goto fail_put_dmabuf;
>  
>  out_have_handle:
> +	if (fence) {
> +		if (!dmabuf->resv) {
> +			ret = -ENODEV;
> +			goto fail_put_dmabuf;
> +		}
This is never true. A default resv gets allocated, see dma_buf's create function.

~Maarten

~Maarten

  reply	other threads:[~2014-09-27  6:49 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-26 10:00 [RFC] Explicit synchronization for Nouveau Lauri Peltonen
2014-09-26 10:00 ` [RFC PATCH 2/7] drm/nouveau: Split nouveau_fence_sync Lauri Peltonen
2014-09-26 10:00 ` [RFC PATCH 4/7] drm/nouveau: Support fence fd's at kickoff Lauri Peltonen
2014-09-26 10:00 ` [RFC PATCH 5/7] libdrm: nouveau: Support fence fds Lauri Peltonen
2014-09-26 10:00 ` [RFC PATCH 6/7] drm/nouveau: Support marking buffers for explicit sync Lauri Peltonen
2014-09-27  6:52   ` Maarten Lankhorst
     [not found] ` <1411725612-10455-1-git-send-email-lpeltonen-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2014-09-26 10:00   ` [RFC PATCH 1/7] android: Support creating sync fence from drm fences Lauri Peltonen
2014-09-27  7:00     ` Maarten Lankhorst
2014-09-26 10:00   ` [RFC PATCH 3/7] drm/nouveau: Add fence fd helpers Lauri Peltonen
2014-09-26 10:00   ` [RFC PATCH 7/7] drm/prime: Support explicit fence on export Lauri Peltonen
2014-09-27  6:49     ` Maarten Lankhorst [this message]
     [not found]     ` <1411725612-10455-8-git-send-email-lpeltonen-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2014-09-29  7:46       ` Daniel Vetter
2014-10-01 15:52         ` Lauri Peltonen
2014-09-29  7:43 ` [RFC] Explicit synchronization for Nouveau Daniel Vetter
2014-09-29 15:42   ` Jerome Glisse
     [not found]     ` <20140929154217.GA2851-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-09-29 17:20       ` Daniel Vetter
2014-09-29 17:20       ` James Jones
2014-09-30  8:21         ` Daniel Vetter
2014-10-01 15:14   ` Lauri Peltonen
     [not found]     ` <20141001151416.GC25206-GyFFdlxoGbnFT5IIyIEb6QC/G2K4zDHf@public.gmane.org>
2014-10-01 15:58       ` Maarten Lankhorst
2014-10-01 17:27     ` Daniel Vetter
     [not found]       ` <20141001172721.GQ12343-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2014-10-02 14:59         ` Lauri Peltonen
2014-10-02 20:44           ` Daniel Vetter
2014-10-03 21:56             ` Rom Lemarchand
     [not found]               ` <CAABpnA_r1Vu8pGtxqXO8Ufg5KMhkUy_9RPic-VActaJQyLRm_w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-10-06 12:25                 ` Lauri Peltonen
     [not found]                   ` <20141006122540.GA7974-GyFFdlxoGbnFT5IIyIEb6QC/G2K4zDHf@public.gmane.org>
2014-10-08  9:10                     ` 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=54265E03.80705@canonical.com \
    --to=maarten.lankhorst@canonical.com \
    --cc=airlied@redhat.com \
    --cc=bskeggs@redhat.com \
    --cc=ccross@android.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jajones@nvidia.com \
    --cc=kadams@nvidia.com \
    --cc=lpeltonen@nvidia.com \
    --cc=nouveau@lists.freedesktop.org \
    --cc=swarren@nvidia.com \
    --cc=treding@nvidia.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