summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaarten Lankhorst <maarten.lankhorst@canonical.com>2014-05-14 13:38:23 (GMT)
committerMaarten Lankhorst <maarten.lankhorst@canonical.com>2014-09-02 14:41:50 (GMT)
commit59701f965442639e33b35cd2407d88948ea0b2b6 (patch)
tree1b370937e4831056290c60f6fd43237419fcb0a5
parentf2c24b83ae90292d315aa7ac029c6ce7929e01aa (diff)
downloadlinux-59701f965442639e33b35cd2407d88948ea0b2b6.tar.xz
drm/nouveau: use rcu in nouveau_gem_ioctl_cpu_prep
With the conversion to the reservation api this should be safe. Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com> Acked-by: Ben Skeggs <bskeggs@redhat.com>
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_gem.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
index a28b510..4120289 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -861,33 +861,29 @@ 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);
+ bool write = !!(req->flags & NOUVEAU_GEM_CPU_PREP_WRITE);
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);
- ret = ttm_bo_reserve(&nvbo->bo, true, false, false, NULL);
- if (!ret) {
- ret = ttm_bo_wait(&nvbo->bo, true, true, true);
- if (!no_wait && ret) {
- struct fence *excl;
-
- excl = reservation_object_get_excl(nvbo->bo.resv);
- fence = nouveau_fence_ref((struct nouveau_fence *)excl);
- }
+ if (no_wait)
+ ret = reservation_object_test_signaled_rcu(nvbo->bo.resv, write) ? 0 : -EBUSY;
+ else {
+ long lret;
- ttm_bo_unreserve(&nvbo->bo);
+ lret = reservation_object_wait_timeout_rcu(nvbo->bo.resv, write, true, 30 * HZ);
+ if (!lret)
+ ret = -EBUSY;
+ else if (lret > 0)
+ ret = 0;
+ else
+ ret = lret;
}
drm_gem_object_unreference_unlocked(gem);
- if (fence) {
- ret = nouveau_fence_wait(fence, true, no_wait);
- nouveau_fence_unref(&fence);
- }
-
return ret;
}