Skip to content

Commit 2ef4fb9

Browse files
committed
drm/vmwgfx: Make sure bo's are unpinned before putting them back
During cotable resize we pin the backup buffer to make sure the trylock doesn't fail. We were never unpinning the backup buffer resulting in every subsequent cotable resize trying to release a pinned bo. After we copy the old backup to the new we can release the pin. Mob's are always pinned so we just have to make sure we unpin them before releasing them. Reviewed-by: Thomas Hellström (Intel) <thomas_os@shipmail.org> Fixes: d1a73c6 ("drm/vmwgfx: Make sure we unpin no longer needed buffers") Link: https://patchwork.freedesktop.org/patch/msgid/20210413205938.788366-1-zackr@vmware.com Signed-off-by: Zack Rusin <zackr@vmware.com>
1 parent 68ce556 commit 2ef4fb9

3 files changed

Lines changed: 19 additions & 8 deletions

File tree

drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,11 +481,15 @@ static int vmw_cotable_resize(struct vmw_resource *res, size_t new_size)
481481
vmw_bo_unreference(&old_buf);
482482
res->id = vcotbl->type;
483483

484+
/* Release the pin acquired in vmw_bo_init */
485+
ttm_bo_unpin(bo);
486+
484487
return 0;
485488

486489
out_map_new:
487490
ttm_bo_kunmap(&old_map);
488491
out_wait:
492+
ttm_bo_unpin(bo);
489493
ttm_bo_unreserve(bo);
490494
vmw_bo_unreference(&buf);
491495

drivers/gpu/drm/vmwgfx/vmwgfx_drv.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,11 +1522,8 @@ static inline void vmw_bo_unreference(struct vmw_buffer_object **buf)
15221522
struct vmw_buffer_object *tmp_buf = *buf;
15231523

15241524
*buf = NULL;
1525-
if (tmp_buf != NULL) {
1526-
if (tmp_buf->base.pin_count > 0)
1527-
ttm_bo_unpin(&tmp_buf->base);
1525+
if (tmp_buf != NULL)
15281526
ttm_bo_put(&tmp_buf->base);
1529-
}
15301527
}
15311528

15321529
static inline struct vmw_buffer_object *

drivers/gpu/drm/vmwgfx/vmwgfx_mob.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,16 @@ static void vmw_mob_pt_setup(struct vmw_mob *mob,
9494
struct vmw_piter data_iter,
9595
unsigned long num_data_pages);
9696

97+
98+
static inline void vmw_bo_unpin_unlocked(struct ttm_buffer_object *bo)
99+
{
100+
int ret = ttm_bo_reserve(bo, false, true, NULL);
101+
BUG_ON(ret != 0);
102+
ttm_bo_unpin(bo);
103+
ttm_bo_unreserve(bo);
104+
}
105+
106+
97107
/*
98108
* vmw_setup_otable_base - Issue an object table base setup command to
99109
* the device
@@ -277,7 +287,7 @@ static int vmw_otable_batch_setup(struct vmw_private *dev_priv,
277287
&batch->otables[i]);
278288
}
279289

280-
ttm_bo_unpin(batch->otable_bo);
290+
vmw_bo_unpin_unlocked(batch->otable_bo);
281291
ttm_bo_put(batch->otable_bo);
282292
batch->otable_bo = NULL;
283293
return ret;
@@ -341,9 +351,9 @@ static void vmw_otable_batch_takedown(struct vmw_private *dev_priv,
341351
BUG_ON(ret != 0);
342352

343353
vmw_bo_fence_single(bo, NULL);
354+
ttm_bo_unpin(bo);
344355
ttm_bo_unreserve(bo);
345356

346-
ttm_bo_unpin(batch->otable_bo);
347357
ttm_bo_put(batch->otable_bo);
348358
batch->otable_bo = NULL;
349359
}
@@ -530,7 +540,7 @@ static void vmw_mob_pt_setup(struct vmw_mob *mob,
530540
void vmw_mob_destroy(struct vmw_mob *mob)
531541
{
532542
if (mob->pt_bo) {
533-
ttm_bo_unpin(mob->pt_bo);
543+
vmw_bo_unpin_unlocked(mob->pt_bo);
534544
ttm_bo_put(mob->pt_bo);
535545
mob->pt_bo = NULL;
536546
}
@@ -646,7 +656,7 @@ int vmw_mob_bind(struct vmw_private *dev_priv,
646656
out_no_cmd_space:
647657
vmw_fifo_resource_dec(dev_priv);
648658
if (pt_set_up) {
649-
ttm_bo_unpin(mob->pt_bo);
659+
vmw_bo_unpin_unlocked(mob->pt_bo);
650660
ttm_bo_put(mob->pt_bo);
651661
mob->pt_bo = NULL;
652662
}

0 commit comments

Comments
 (0)