diff options
author | Maarten Lankhorst <maarten.lankhorst@canonical.com> | 2014-01-21 07:00:24 -0500 |
---|---|---|
committer | Maarten Lankhorst <maarten.lankhorst@canonical.com> | 2014-09-01 04:16:42 -0400 |
commit | d0b3c3b6c26c6eed1ba3fa37242dfc8942b5e997 (patch) | |
tree | d0c0edaf033b87080f1617bc2ed82f7d12b0b802 /drivers/gpu/drm/nouveau/nouveau_gem.c | |
parent | 04cd214516d8a6f0f8c0116185d6e360df0860d2 (diff) |
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: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Acked-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/nouveau/nouveau_gem.c')
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_gem.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c index 292a677bfed4..0054315eb879 100644 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c | |||
@@ -884,17 +884,31 @@ nouveau_gem_ioctl_cpu_prep(struct drm_device *dev, void *data, | |||
884 | struct drm_gem_object *gem; | 884 | struct drm_gem_object *gem; |
885 | struct nouveau_bo *nvbo; | 885 | struct nouveau_bo *nvbo; |
886 | bool no_wait = !!(req->flags & NOUVEAU_GEM_CPU_PREP_NOWAIT); | 886 | bool no_wait = !!(req->flags & NOUVEAU_GEM_CPU_PREP_NOWAIT); |
887 | int ret = -EINVAL; | 887 | int ret; |
888 | struct nouveau_fence *fence = NULL; | ||
888 | 889 | ||
889 | gem = drm_gem_object_lookup(dev, file_priv, req->handle); | 890 | gem = drm_gem_object_lookup(dev, file_priv, req->handle); |
890 | if (!gem) | 891 | if (!gem) |
891 | return -ENOENT; | 892 | return -ENOENT; |
892 | nvbo = nouveau_gem_object(gem); | 893 | nvbo = nouveau_gem_object(gem); |
893 | 894 | ||
894 | spin_lock(&nvbo->bo.bdev->fence_lock); | 895 | ret = ttm_bo_reserve(&nvbo->bo, true, false, false, NULL); |
895 | ret = ttm_bo_wait(&nvbo->bo, true, true, no_wait); | 896 | if (!ret) { |
896 | spin_unlock(&nvbo->bo.bdev->fence_lock); | 897 | spin_lock(&nvbo->bo.bdev->fence_lock); |
898 | ret = ttm_bo_wait(&nvbo->bo, true, true, true); | ||
899 | if (!no_wait && ret) | ||
900 | fence = nouveau_fence_ref(nvbo->bo.sync_obj); | ||
901 | spin_unlock(&nvbo->bo.bdev->fence_lock); | ||
902 | |||
903 | ttm_bo_unreserve(&nvbo->bo); | ||
904 | } | ||
897 | drm_gem_object_unreference_unlocked(gem); | 905 | drm_gem_object_unreference_unlocked(gem); |
906 | |||
907 | if (fence) { | ||
908 | ret = nouveau_fence_wait(fence, true, no_wait); | ||
909 | nouveau_fence_unref(&fence); | ||
910 | } | ||
911 | |||
898 | return ret; | 912 | return ret; |
899 | } | 913 | } |
900 | 914 | ||