diff options
author | Maarten Lankhorst <maarten.lankhorst@canonical.com> | 2014-05-14 09:38:23 -0400 |
---|---|---|
committer | Maarten Lankhorst <maarten.lankhorst@canonical.com> | 2014-09-02 10:41:50 -0400 |
commit | 59701f965442639e33b35cd2407d88948ea0b2b6 (patch) | |
tree | 1b370937e4831056290c60f6fd43237419fcb0a5 | |
parent | f2c24b83ae90292d315aa7ac029c6ce7929e01aa (diff) |
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.c | 28 |
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 a28b5102c4a5..4120289ff53e 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, | |||
861 | struct drm_gem_object *gem; | 861 | struct drm_gem_object *gem; |
862 | struct nouveau_bo *nvbo; | 862 | struct nouveau_bo *nvbo; |
863 | bool no_wait = !!(req->flags & NOUVEAU_GEM_CPU_PREP_NOWAIT); | 863 | bool no_wait = !!(req->flags & NOUVEAU_GEM_CPU_PREP_NOWAIT); |
864 | bool write = !!(req->flags & NOUVEAU_GEM_CPU_PREP_WRITE); | ||
864 | int ret; | 865 | int ret; |
865 | struct nouveau_fence *fence = NULL; | ||
866 | 866 | ||
867 | gem = drm_gem_object_lookup(dev, file_priv, req->handle); | 867 | gem = drm_gem_object_lookup(dev, file_priv, req->handle); |
868 | if (!gem) | 868 | if (!gem) |
869 | return -ENOENT; | 869 | return -ENOENT; |
870 | nvbo = nouveau_gem_object(gem); | 870 | nvbo = nouveau_gem_object(gem); |
871 | 871 | ||
872 | ret = ttm_bo_reserve(&nvbo->bo, true, false, false, NULL); | 872 | if (no_wait) |
873 | if (!ret) { | 873 | ret = reservation_object_test_signaled_rcu(nvbo->bo.resv, write) ? 0 : -EBUSY; |
874 | ret = ttm_bo_wait(&nvbo->bo, true, true, true); | 874 | else { |
875 | if (!no_wait && ret) { | 875 | long lret; |
876 | struct fence *excl; | ||
877 | |||
878 | excl = reservation_object_get_excl(nvbo->bo.resv); | ||
879 | fence = nouveau_fence_ref((struct nouveau_fence *)excl); | ||
880 | } | ||
881 | 876 | ||
882 | ttm_bo_unreserve(&nvbo->bo); | 877 | lret = reservation_object_wait_timeout_rcu(nvbo->bo.resv, write, true, 30 * HZ); |
878 | if (!lret) | ||
879 | ret = -EBUSY; | ||
880 | else if (lret > 0) | ||
881 | ret = 0; | ||
882 | else | ||
883 | ret = lret; | ||
883 | } | 884 | } |
884 | drm_gem_object_unreference_unlocked(gem); | 885 | drm_gem_object_unreference_unlocked(gem); |
885 | 886 | ||
886 | if (fence) { | ||
887 | ret = nouveau_fence_wait(fence, true, no_wait); | ||
888 | nouveau_fence_unref(&fence); | ||
889 | } | ||
890 | |||
891 | return ret; | 887 | return ret; |
892 | } | 888 | } |
893 | 889 | ||