]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
drm/nouveau: require reservations for nouveau_fence_sync and nouveau_bo_fence
authorMaarten Lankhorst <maarten.lankhorst@canonical.com>
Tue, 21 Jan 2014 12:02:14 +0000 (13:02 +0100)
committerMaarten Lankhorst <maarten.lankhorst@canonical.com>
Mon, 1 Sep 2014 08:16:43 +0000 (10:16 +0200)
This will ensure we always hold the required lock when calling those functions.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Acked-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/nouveau_bo.c
drivers/gpu/drm/nouveau/nouveau_display.c

index 0591ca0734e35f941fb20ddff1e074c4058f390d..ed966f51e29b5c3c32d6be1b0307a28a0d0bde52 100644 (file)
@@ -1463,6 +1463,8 @@ nouveau_bo_fence(struct nouveau_bo *nvbo, struct nouveau_fence *fence)
        struct nouveau_fence *new_fence = nouveau_fence_ref(fence);
        struct nouveau_fence *old_fence = NULL;
 
+       lockdep_assert_held(&nvbo->bo.resv->lock.base);
+
        spin_lock(&nvbo->bo.bdev->fence_lock);
        old_fence = nvbo->bo.sync_obj;
        nvbo->bo.sync_obj = new_fence;
index 65b4fd53dd4e13186c2d33a072b380e2b8a1fdd1..54b1f3d8fc7f08c16a1c6e691d1d6f835db7d94a 100644 (file)
@@ -717,6 +717,9 @@ nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
        }
 
        mutex_lock(&cli->mutex);
+       ret = ttm_bo_reserve(&new_bo->bo, true, false, false, NULL);
+       if (ret)
+               goto fail_unpin;
 
        /* synchronise rendering channel with the kernel's channel */
        spin_lock(&new_bo->bo.bdev->fence_lock);
@@ -724,12 +727,18 @@ nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
        spin_unlock(&new_bo->bo.bdev->fence_lock);
        ret = nouveau_fence_sync(fence, chan);
        nouveau_fence_unref(&fence);
-       if (ret)
+       if (ret) {
+               ttm_bo_unreserve(&new_bo->bo);
                goto fail_unpin;
+       }
 
-       ret = ttm_bo_reserve(&old_bo->bo, true, false, false, NULL);
-       if (ret)
-               goto fail_unpin;
+       if (new_bo != old_bo) {
+               ttm_bo_unreserve(&new_bo->bo);
+
+               ret = ttm_bo_reserve(&old_bo->bo, true, false, false, NULL);
+               if (ret)
+                       goto fail_unpin;
+       }
 
        /* Initialize a page flip struct */
        *s = (struct nouveau_page_flip_state)