All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Hellstrom <thellstrom@vmware.com>
To: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 2/5] drm/nouveau: add reservation to nouveau_gem_ioctl_cpu_prep
Date: Tue, 21 Jan 2014 16:17:44 +0100	[thread overview]
Message-ID: <52DE8F98.3020305@vmware.com> (raw)
In-Reply-To: <1390309482-17313-2-git-send-email-maarten.lankhorst@canonical.com>

Maarten, for this and the other patches in this series,

I seem to recall we have this discussion before?
IIRC I stated that reservation was a too heavy-weight lock to hold to
determine whether a buffer was idle? It's a pretty nasty thing to build in.

/Thomas


On 01/21/2014 02:04 PM, Maarten Lankhorst wrote:
> Apart from some code inside ttm itself and nouveau_bo_vma_del,
> this is the only place where ttm_bo_wait is used without a reservation.
> Fix this so we can remove the fence_lock later on.
>
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
> ---
>  drivers/gpu/drm/nouveau/nouveau_gem.c | 22 ++++++++++++++++++----
>  1 file changed, 18 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
> index 78a27f8ad7d9..24e9c58da8aa 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
> @@ -894,17 +894,31 @@ nouveau_gem_ioctl_cpu_prep(struct drm_device *dev, void *data,
>  	struct drm_gem_object *gem;
>  	struct nouveau_bo *nvbo;
>  	bool no_wait = !!(req->flags & NOUVEAU_GEM_CPU_PREP_NOWAIT);
> -	int ret = -EINVAL;
> +	int ret;
> +	struct nouveau_fence *fence = NULL;
>  
>  	gem = drm_gem_object_lookup(dev, file_priv, req->handle);
>  	if (!gem)
>  		return -ENOENT;
>  	nvbo = nouveau_gem_object(gem);
>  
> -	spin_lock(&nvbo->bo.bdev->fence_lock);
> -	ret = ttm_bo_wait(&nvbo->bo, true, true, no_wait);
> -	spin_unlock(&nvbo->bo.bdev->fence_lock);
> +	ret = ttm_bo_reserve(&nvbo->bo, true, false, false, 0);
> +	if (!ret) {
> +		spin_lock(&nvbo->bo.bdev->fence_lock);
> +		ret = ttm_bo_wait(&nvbo->bo, true, true, true);
> +		if (!no_wait && ret)
> +			fence = nouveau_fence_ref(nvbo->bo.sync_obj);
> +		spin_unlock(&nvbo->bo.bdev->fence_lock);
> +
> +		ttm_bo_unreserve(&nvbo->bo);
> +	}
>  	drm_gem_object_unreference_unlocked(gem);
> +
> +	if (fence) {
> +		ret = nouveau_fence_wait(fence, true, no_wait);
> +		nouveau_fence_unref(&fence);
> +	}
> +
>  	return ret;
>  }
>  

  reply	other threads:[~2014-01-21 15:17 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-21 13:04 [PATCH 1/5] drm/ttm: kill off some members to ttm_validate_buffer Maarten Lankhorst
2014-01-21 13:04 ` [PATCH 2/5] drm/nouveau: add reservation to nouveau_gem_ioctl_cpu_prep Maarten Lankhorst
2014-01-21 15:17   ` Thomas Hellstrom [this message]
2014-01-21 15:29     ` Maarten Lankhorst
2014-01-21 17:44       ` Thomas Hellstrom
2014-01-22  8:19         ` Maarten Lankhorst
2014-01-22  9:40           ` Thomas Hellstrom
2014-01-22  9:55             ` Maarten Lankhorst
2014-01-22 10:27               ` Thomas Hellstrom
2014-01-22 10:58                 ` Maarten Lankhorst
2014-01-22 12:11                   ` Thomas Hellstrom
2014-01-22 12:38                     ` Maarten Lankhorst
2014-01-22 12:52                       ` Thomas Hellstrom
2014-01-22 15:09                         ` Daniel Vetter
2014-01-22 15:30                           ` Thomas Hellstrom
2014-01-22 15:41                           ` Thomas Hellstrom
2014-01-22 12:43                     ` Maarten Lankhorst
2014-01-21 13:04 ` [PATCH 3/5] drm/nouveau: require reservations for nouveau_fence_sync and nouveau_bo_fence Maarten Lankhorst
2014-01-21 13:04 ` [PATCH 4/5] drm/ttm: call ttm_bo_wait while inside a reservation Maarten Lankhorst
2014-01-21 13:04 ` [PATCH 5/5] drm/ttm: kill fence_lock Maarten Lankhorst
2014-01-21 14:40   ` [PATCH v2] " Maarten Lankhorst

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=52DE8F98.3020305@vmware.com \
    --to=thellstrom@vmware.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=maarten.lankhorst@canonical.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 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.