Skip to content

Commit cb343de

Browse files
en4bzzackr
authored andcommitted
drm/vmwgfx: Unreserve BO on error
Unlock BOs in reverse order. Add an acquire context so that lockdep doesn't complain. Fixes: d6667f0 ("drm/vmwgfx: Fix handling of dumb buffers") Signed-off-by: Ian Forbes <[email protected]> Signed-off-by: Zack Rusin <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 1f9910b commit cb343de

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

drivers/gpu/drm/vmwgfx/vmwgfx_kms.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,7 @@ vmw_du_cursor_plane_atomic_update(struct drm_plane *plane,
750750
struct vmw_plane_state *old_vps = vmw_plane_state_to_vps(old_state);
751751
struct vmw_bo *old_bo = NULL;
752752
struct vmw_bo *new_bo = NULL;
753+
struct ww_acquire_ctx ctx;
753754
s32 hotspot_x, hotspot_y;
754755
int ret;
755756

@@ -769,19 +770,26 @@ vmw_du_cursor_plane_atomic_update(struct drm_plane *plane,
769770
if (du->cursor_surface)
770771
du->cursor_age = du->cursor_surface->snooper.age;
771772

773+
ww_acquire_init(&ctx, &reservation_ww_class);
774+
772775
if (!vmw_user_object_is_null(&old_vps->uo)) {
773776
old_bo = vmw_user_object_buffer(&old_vps->uo);
774-
ret = ttm_bo_reserve(&old_bo->tbo, false, false, NULL);
777+
ret = ttm_bo_reserve(&old_bo->tbo, false, false, &ctx);
775778
if (ret != 0)
776779
return;
777780
}
778781

779782
if (!vmw_user_object_is_null(&vps->uo)) {
780783
new_bo = vmw_user_object_buffer(&vps->uo);
781784
if (old_bo != new_bo) {
782-
ret = ttm_bo_reserve(&new_bo->tbo, false, false, NULL);
783-
if (ret != 0)
785+
ret = ttm_bo_reserve(&new_bo->tbo, false, false, &ctx);
786+
if (ret != 0) {
787+
if (old_bo) {
788+
ttm_bo_unreserve(&old_bo->tbo);
789+
ww_acquire_fini(&ctx);
790+
}
784791
return;
792+
}
785793
} else {
786794
new_bo = NULL;
787795
}
@@ -803,10 +811,12 @@ vmw_du_cursor_plane_atomic_update(struct drm_plane *plane,
803811
hotspot_x, hotspot_y);
804812
}
805813

806-
if (old_bo)
807-
ttm_bo_unreserve(&old_bo->tbo);
808814
if (new_bo)
809815
ttm_bo_unreserve(&new_bo->tbo);
816+
if (old_bo)
817+
ttm_bo_unreserve(&old_bo->tbo);
818+
819+
ww_acquire_fini(&ctx);
810820

811821
du->cursor_x = new_state->crtc_x + du->set_gui_x;
812822
du->cursor_y = new_state->crtc_y + du->set_gui_y;

0 commit comments

Comments
 (0)