All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v8] drm/vmwgfx: Reserve ttm object before resv usage
@ 2026-11-20 21:23 Maaz Mombasawala
  2026-11-20 21:41 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Maaz Mombasawala @ 2026-11-20 21:23 UTC (permalink / raw)
  To: dri-devel
  Cc: bcm-kernel-feedback-list, ian.forbes, zack.rusin,
	Maaz Mombasawala

We hit dma_resv_assert_held warnings, reserve the TTM buffer object when
it's being used to avoid them. Also reserve the backing guest_memory_bo
to avoid race conditions when vmw_bo_free() is cleaning up the bo.

Signed-off-by: Maaz Mombasawala <maaz.mombasawala@broadcom.com>
Fixes: 7b0062036c3b ("drm/vmwgfx: Implement virtual crc generation")
Cc: Zack Rusin <zack.rusin@broadcom.com>
Cc: Broadcom internal kernel review list <bcm-kernel-feedback-list@broadcom.com>
Cc: dri-devel@lists.freedesktop.org
---
 drivers/gpu/drm/vmwgfx/vmwgfx_vkms.c | 29 +++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_vkms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_vkms.c
index 8ce10cf9c19e..91afa8a0bd9f 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_vkms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_vkms.c
@@ -114,6 +114,7 @@ crc_generate_worker(struct work_struct *work)
 	u64 frame_start, frame_end;
 	u32 crc32 = 0;
 	struct vmw_surface *surf = 0;
+	bool valid_crc = false;
 
 	spin_lock_irq(&du->vkms.crc_state_lock);
 	crc_pending = du->vkms.crc_pending;
@@ -131,6 +132,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,10 +140,35 @@ crc_generate_worker(struct work_struct *work)
 			return;
 		}
 
-		compute_crc(crtc, surf, &crc32);
+		if (surf->res.guest_memory_bo) {
+			struct vmw_resource *res = &surf->res;
+
+			mutex_lock(&res->dev_priv->cmdbuf_mutex);
+			ret = vmw_resource_reserve(res, false, true);
+			if (ret != 0)
+				goto no_res_reserve;
+			ret = ttm_bo_reserve(&res->guest_memory_bo->tbo, false,
+					     false, NULL);
+			if (ret != 0) {
+				drm_warn(&vmw->drm, "%s: failed reserve\n",
+					 __func__);
+				goto no_tbo_reserve;
+			}
+			compute_crc(crtc, surf, &crc32);
+			valid_crc = true;
+			ttm_bo_unreserve(&res->guest_memory_bo->tbo);
+no_tbo_reserve:
+			vmw_resource_unreserve(res, true, false, false, NULL,
+					       0);
+no_res_reserve:
+			mutex_unlock(&res->dev_priv->cmdbuf_mutex);
+		}
 		vmw_surface_unreference(&surf);
 	}
 
+	if (!valid_crc)
+		return;
+
 	spin_lock_irq(&du->vkms.crc_state_lock);
 	frame_start = du->vkms.frame_start;
 	frame_end = du->vkms.frame_end;
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-20 21:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20 21:23 [PATCH v8] drm/vmwgfx: Reserve ttm object before resv usage Maaz Mombasawala
2026-11-20 21:41 ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.