Skip to content

Commit aba5970

Browse files
committed
Merge tag 'drm-fixes-2021-04-18' of git://anongit.freedesktop.org/drm/drm
Pull vmwgfx fixes from Dave Airlie: "This contains two regression fixes for vmwgfx, one due to a refactor which meant locks were being used before initialisation, and the other in fixing up some warnings from the core when destroying pinned buffers. vmwgfx: - fixed unpinning before destruction - lockdep init reordering" * tag 'drm-fixes-2021-04-18' of git://anongit.freedesktop.org/drm/drm: drm/vmwgfx: Make sure bo's are unpinned before putting them back drm/vmwgfx: Fix the lockdep breakage drm/vmwgfx: Make sure we unpin no longer needed buffers
2 parents 194cf48 + 796b556 commit aba5970

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)