We hit dma_resv_assert_held warnings in several places, reserve the ttm
base object when it's being used to avoid them.

Signed-off-by: Maaz Mombasawala <[email protected]>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_bo.c   |  2 ++
 drivers/gpu/drm/vmwgfx/vmwgfx_vkms.c | 12 ++++++++++++
 2 files changed, 14 insertions(+)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c
index 9c7a73c0b0dc..6817e0b8ce99 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c
@@ -55,7 +55,9 @@ static void vmw_bo_free(struct ttm_buffer_object *bo)
                        /* Reserve and switch the backing mob. */
                        mutex_lock(&res->dev_priv->cmdbuf_mutex);
                        (void)vmw_resource_reserve(res, false, true);
+                       ttm_bo_reserve(bo, false, false, NULL);
                        vmw_resource_mob_detach(res);
+                       ttm_bo_unreserve(bo);
                        if (res->dirty)
                                res->func->dirty_free(res);
                        if (res->coherent)
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_vkms.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_vkms.c
index 7b8163b5e501..da6ccd5e318e 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_vkms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_vkms.c
@@ -131,6 +131,7 @@ crc_generate_worker(struct work_struct *work)
        spin_unlock_irq(&du->vkms.crc_state_lock);
 
        if (surf) {
+               int ret;
                if (vmw_surface_sync(vmw, surf)) {
                        drm_warn(
                                crtc->dev,
@@ -138,7 +139,18 @@ crc_generate_worker(struct work_struct *work)
                        return;
                }
 
+               ret = ttm_bo_reserve(&surf->res.guest_memory_bo->tbo, false, 
false, NULL);
+               if (ret != 0) {
+                       drm_warn(&vmw->drm, "%s: failed reserve\n", __func__);
+                       goto done;
+               }
+
                compute_crc(crtc, surf, &crc32);
+
+               ttm_bo_unreserve(&surf->res.guest_memory_bo->tbo);
+
+done:
+
                vmw_surface_unreference(&surf);
        }
 
-- 
2.54.0

Reply via email to