drm/ttm: fix ttm_bo_wait
authorChristian König <christian.koenig@amd.com>
Mon, 7 Nov 2016 21:16:15 +0000 (16:16 -0500)
committerSumit Semwal <sumit.semwal@linaro.org>
Tue, 8 Nov 2016 19:16:04 +0000 (00:46 +0530)
reservation_object_wait_timeout_rcu() should enable signaling even with a
zero timeout, but ttm_bo_wait() can also be called from atomic context and
then it is not a good idea to do this.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
  [sumits: fix checkpatch warnings]
Link: http://patchwork.freedesktop.org/patch/msgid/1478553376-18575-3-git-send-email-alexander.deucher@amd.com
drivers/gpu/drm/ttm/ttm_bo.c

index f6ff579e89184bead14c65a29c9315f4a2258af7..d5063618efa773757ff1608f3e0caf535ef2cc85 100644 (file)
@@ -1611,7 +1611,14 @@ EXPORT_SYMBOL(ttm_bo_unmap_virtual);
 int ttm_bo_wait(struct ttm_buffer_object *bo,
                bool interruptible, bool no_wait)
 {
-       long timeout = no_wait ? 0 : 15 * HZ;
+       long timeout = 15 * HZ;
+
+       if (no_wait) {
+               if (reservation_object_test_signaled_rcu(bo->resv, true))
+                       return 0;
+               else
+                       return -EBUSY;
+       }
 
        timeout = reservation_object_wait_timeout_rcu(bo->resv, true,
                                                      interruptible, timeout);