Skip to content

Commit

Permalink
drm/nouveau: require reservations for nouveau_fence_sync and nouveau_…
Browse files Browse the repository at this point in the history
…bo_fence

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>
  • Loading branch information
Maarten Lankhorst committed Sep 1, 2014
1 parent d0b3c3b commit bdaf7dd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 2 additions & 0 deletions drivers/gpu/drm/nouveau/nouveau_bo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 13 additions & 4 deletions drivers/gpu/drm/nouveau/nouveau_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -717,19 +717,28 @@ 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);
fence = nouveau_fence_ref(new_bo->bo.sync_obj);
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)
Expand Down

0 comments on commit bdaf7dd

Please sign in to comment.