drm/nouveau: hold mutex while syncing to kernel channel
authorMaarten Lankhorst <maarten.lankhorst@canonical.com>
Tue, 14 Jan 2014 15:48:58 +0000 (16:48 +0100)
committerBen Skeggs <bskeggs@redhat.com>
Thu, 23 Jan 2014 03:39:14 +0000 (13:39 +1000)
Not holding the mutex potentially causes corruption of the kernel
channel when page flipping.

Cc: stable@vger.kernel.org #3.13
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/nouveau_display.c

index 25ea82f8def3cb883a06aef6e9da59ea4cbffaf7..8b757483a1070382ce9c0eae1e217df19c216f86 100644 (file)
@@ -603,6 +603,14 @@ nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
        if (!s)
                return -ENOMEM;
 
+       if (new_bo != old_bo) {
+               ret = nouveau_bo_pin(new_bo, TTM_PL_FLAG_VRAM);
+               if (ret)
+                       goto fail_free;
+       }
+
+       mutex_lock(&chan->cli->mutex);
+
        /* synchronise rendering channel with the kernel's channel */
        spin_lock(&new_bo->bo.bdev->fence_lock);
        fence = nouveau_fence_ref(new_bo->bo.sync_obj);
@@ -612,13 +620,6 @@ nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
        if (ret)
                goto fail_free;
 
-       if (new_bo != old_bo) {
-               ret = nouveau_bo_pin(new_bo, TTM_PL_FLAG_VRAM);
-               if (ret)
-                       goto fail_free;
-       }
-
-       mutex_lock(&chan->cli->mutex);
        ret = ttm_bo_reserve(&old_bo->bo, true, false, false, NULL);
        if (ret)
                goto fail_unpin;