Commit d0b3c3b6 authored by Maarten Lankhorst's avatar Maarten Lankhorst

drm/nouveau: add reservation to nouveau_gem_ioctl_cpu_prep

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.

After the switch to rcu the reservation lock will be
removed again.
Signed-off-by: default avatarMaarten Lankhorst <maarten.lankhorst@canonical.com>
Acked-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent 04cd2145
...@@ -884,17 +884,31 @@ nouveau_gem_ioctl_cpu_prep(struct drm_device *dev, void *data, ...@@ -884,17 +884,31 @@ nouveau_gem_ioctl_cpu_prep(struct drm_device *dev, void *data,
struct drm_gem_object *gem; struct drm_gem_object *gem;
struct nouveau_bo *nvbo; struct nouveau_bo *nvbo;
bool no_wait = !!(req->flags & NOUVEAU_GEM_CPU_PREP_NOWAIT); 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); gem = drm_gem_object_lookup(dev, file_priv, req->handle);
if (!gem) if (!gem)
return -ENOENT; return -ENOENT;
nvbo = nouveau_gem_object(gem); nvbo = nouveau_gem_object(gem);
spin_lock(&nvbo->bo.bdev->fence_lock); ret = ttm_bo_reserve(&nvbo->bo, true, false, false, NULL);
ret = ttm_bo_wait(&nvbo->bo, true, true, no_wait); if (!ret) {
spin_unlock(&nvbo->bo.bdev->fence_lock); 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); drm_gem_object_unreference_unlocked(gem);
if (fence) {
ret = nouveau_fence_wait(fence, true, no_wait);
nouveau_fence_unref(&fence);
}
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment