Skip to content

Commit 796b556

Browse files
committed
Merge tag 'vmwgfx-fixes-2021-04-14' of gitlab.freedesktop.org:zack/vmwgfx into drm-fixes
vmwgfx fixes for regressions in 5.12 Here's a set of 3 patches fixing ugly regressions in the vmwgfx driver. We broke lock initialization code and ended up using spinlocks before initialization breaking lockdep. Also there was a bit of a fallout from drm changes which made the core validate that unreferenced buffers have been unpinned. vmwgfx pinning code predates a lot of the core drm and wasn't written to account for those semantics. Fortunately changes required to fix it are not too intrusive. The changes have been validated by our internal ci. Signed-off-by: Zack Rusin <zackr@vmware.com> Signed-off-by: Dave Airlie <airlied@redhat.com> From: Zack Rusin <zackr@vmware.com> Link: https://patchwork.freedesktop.org/patch/msgid/f7add0a2-162e-3bd2-b1be-344a94f2acbf@vmware.com
2 parents 4d2e128 + 2ef4fb9 commit 796b556

4 files changed

Lines changed: 27 additions & 13 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.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -712,24 +712,23 @@ static int vmw_driver_load(struct vmw_private *dev_priv, u32 pci_id)
712712
dev_priv->last_read_seqno = (uint32_t) -100;
713713
dev_priv->drm.dev_private = dev_priv;
714714

715-
ret = vmw_setup_pci_resources(dev_priv, pci_id);
716-
if (ret)
717-
return ret;
718-
ret = vmw_detect_version(dev_priv);
719-
if (ret)
720-
goto out_no_pci_or_version;
721-
722715
mutex_init(&dev_priv->cmdbuf_mutex);
723-
mutex_init(&dev_priv->release_mutex);
724716
mutex_init(&dev_priv->binding_mutex);
725-
mutex_init(&dev_priv->global_kms_state_mutex);
726717
ttm_lock_init(&dev_priv->reservation_sem);
727718
spin_lock_init(&dev_priv->resource_lock);
728719
spin_lock_init(&dev_priv->hw_lock);
729720
spin_lock_init(&dev_priv->waiter_lock);
730721
spin_lock_init(&dev_priv->cap_lock);
731722
spin_lock_init(&dev_priv->cursor_lock);
732723

724+
ret = vmw_setup_pci_resources(dev_priv, pci_id);
725+
if (ret)
726+
return ret;
727+
ret = vmw_detect_version(dev_priv);
728+
if (ret)
729+
goto out_no_pci_or_version;
730+
731+
733732
for (i = vmw_res_context; i < vmw_res_max; ++i) {
734733
idr_init(&dev_priv->res_idr[i]);
735734
INIT_LIST_HEAD(&dev_priv->res_lru[i]);

drivers/gpu/drm/vmwgfx/vmwgfx_drv.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,6 @@ struct vmw_private {
529529
struct vmw_overlay *overlay_priv;
530530
struct drm_property *hotplug_mode_update_property;
531531
struct drm_property *implicit_placement_property;
532-
struct mutex global_kms_state_mutex;
533532
spinlock_t cursor_lock;
534533
struct drm_atomic_state *suspend_state;
535534

@@ -592,7 +591,6 @@ struct vmw_private {
592591
bool refuse_hibernation;
593592
bool suspend_locked;
594593

595-
struct mutex release_mutex;
596594
atomic_t num_fifo_resources;
597595

598596
/*
@@ -1524,9 +1522,8 @@ static inline void vmw_bo_unreference(struct vmw_buffer_object **buf)
15241522
struct vmw_buffer_object *tmp_buf = *buf;
15251523

15261524
*buf = NULL;
1527-
if (tmp_buf != NULL) {
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 & 0 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,6 +287,7 @@ static int vmw_otable_batch_setup(struct vmw_private *dev_priv,
277287
&batch->otables[i]);
278288
}
279289

290+
vmw_bo_unpin_unlocked(batch->otable_bo);
280291
ttm_bo_put(batch->otable_bo);
281292
batch->otable_bo = NULL;
282293
return ret;
@@ -340,6 +351,7 @@ static void vmw_otable_batch_takedown(struct vmw_private *dev_priv,
340351
BUG_ON(ret != 0);
341352

342353
vmw_bo_fence_single(bo, NULL);
354+
ttm_bo_unpin(bo);
343355
ttm_bo_unreserve(bo);
344356

345357
ttm_bo_put(batch->otable_bo);
@@ -528,6 +540,7 @@ static void vmw_mob_pt_setup(struct vmw_mob *mob,
528540
void vmw_mob_destroy(struct vmw_mob *mob)
529541
{
530542
if (mob->pt_bo) {
543+
vmw_bo_unpin_unlocked(mob->pt_bo);
531544
ttm_bo_put(mob->pt_bo);
532545
mob->pt_bo = NULL;
533546
}
@@ -643,6 +656,7 @@ int vmw_mob_bind(struct vmw_private *dev_priv,
643656
out_no_cmd_space:
644657
vmw_fifo_resource_dec(dev_priv);
645658
if (pt_set_up) {
659+
vmw_bo_unpin_unlocked(mob->pt_bo);
646660
ttm_bo_put(mob->pt_bo);
647661
mob->pt_bo = NULL;
648662
}

0 commit comments

Comments
 (0)