* [PATCH 1/3] drm/nouveau: add reservation to nouveau_gem_ioctl_cpu_prep
@ 2012-10-12 15:06 Maarten Lankhorst
2012-10-18 16:30 ` Thomas Hellstrom
0 siblings, 1 reply; 2+ messages in thread
From: Maarten Lankhorst @ 2012-10-12 15:06 UTC (permalink / raw)
To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
Cc: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
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-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
---
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 5e2f521..18342b0 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -837,17 +837,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;
}
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH 1/3] drm/nouveau: add reservation to nouveau_gem_ioctl_cpu_prep
2012-10-12 15:06 [PATCH 1/3] drm/nouveau: add reservation to nouveau_gem_ioctl_cpu_prep Maarten Lankhorst
@ 2012-10-18 16:30 ` Thomas Hellstrom
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Hellstrom @ 2012-10-18 16:30 UTC (permalink / raw)
To: Maarten Lankhorst; +Cc: nouveau, dri-devel
So this is a typical case where a NO_WAIT can indeed become a WAIT
because of the use of a reservation instead of a spinlock.
(See the remove_fence_lock discussion)
/Thomas
On 10/12/2012 05:06 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 5e2f521..18342b0 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
> @@ -837,17 +837,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;
> }
>
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-10-18 16:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-12 15:06 [PATCH 1/3] drm/nouveau: add reservation to nouveau_gem_ioctl_cpu_prep Maarten Lankhorst
2012-10-18 16:30 ` Thomas Hellstrom
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.