From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm/vmwgfx: Reserve ttm object before resv usage
Date: Sat, 16 May 2026 10:17:49 +1000 [thread overview]
Message-ID: <review-patch3-20260514224819.3631763-4-maaz.mombasawala@broadcom.com> (raw)
In-Reply-To: <20260514224819.3631763-4-maaz.mombasawala@broadcom.com>
Patch Review
**vmw_bo_free reservation concern:** The added `ttm_bo_reserve`/`ttm_bo_unreserve` pair wraps `vmw_resource_mob_detach` in the buffer object destructor:
```c
+ ttm_bo_reserve(bo, false, false, NULL);
vmw_resource_mob_detach(res);
+ ttm_bo_unreserve(bo);
```
This is inside `vmw_bo_free`, which is the TTM buffer object destruction callback. At this point the buffer object refcount is already 0 (confirmed by the `WARN_ON(kref_read(&vbo->tbo.base.refcount) != 0)` at the top of `vmw_bo_free`). Calling `ttm_bo_reserve` on an object with refcount 0 is potentially problematic — `ttm_bo_reserve` calls `__ttm_bo_reserve` which does `ww_mutex_lock` on the reservation object. If another thread is concurrently trying to lock this (e.g., during eviction), the object could be in an inconsistent state. The return value of `ttm_bo_reserve` is also not checked here (the `(void)` cast on `vmw_resource_reserve` above suggests ignoring errors is intentional for this path, but the reserve call itself could fail).
Compare with `vmw_resource_release` (vmwgfx_resource.c:129) which does `ttm_bo_reserve` but has `BUG_ON(ret)` — at least there the BO has a valid refcount.
Consider whether `dma_resv_assert_held` is the right thing to assert in `vmw_resource_mob_detach`, or whether the assertion should be conditionally relaxed for the destructor path.
**vkms CRC worker reservation — reasonable fix:**
```c
+ 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);
```
This is a valid fix since `compute_crc` calls `vmw_bo_map_and_cache`, which likely needs the reservation held. However, looking at the `goto done` path:
```c
+done:
+
vmw_surface_unreference(&surf);
```
There's a blank line after the `done:` label — minor style nit. More importantly, when the reservation fails the CRC is silently skipped with only a warning. This is acceptable for a CRC worker (best-effort), but the CRC subsystem will get stale/missing CRC entries for the affected frames.
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-05-16 0:17 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-14 22:48 [PATCH v3 0/5] Fix some issues from igt runs Maaz Mombasawala
2026-05-14 22:48 ` [PATCH v3 1/5] drm/vmwgfx: Add some checks to vmw_cursor_plane_atomic_update Maaz Mombasawala
2026-05-16 0:17 ` Claude review: " Claude Code Review Bot
2026-05-14 22:48 ` [PATCH v3 2/5] drm/vmwgfx: Check vrefresh in drm_mode_setcrtc Maaz Mombasawala
2026-05-16 0:17 ` Claude review: " Claude Code Review Bot
2026-05-14 22:48 ` [PATCH v3 3/5] drm/vmwgfx: Reserve ttm object before resv usage Maaz Mombasawala
2026-05-16 0:17 ` Claude Code Review Bot [this message]
2026-05-14 22:48 ` [PATCH v3 4/5] drm/vmwgfx: Change ttm refs for dumb buffers Maaz Mombasawala
2026-05-15 5:49 ` Zack Rusin
2026-05-16 0:17 ` Claude review: " Claude Code Review Bot
2026-05-14 22:48 ` [PATCH v3 5/5] drm/vmwgfx: Remove duplicates in vmwgfx_bo.h Maaz Mombasawala
2026-05-16 0:17 ` Claude review: " Claude Code Review Bot
2026-05-16 0:17 ` Claude review: Fix some issues from igt runs Claude Code Review Bot
-- strict thread matches above, loose matches on Subject: below --
2026-05-12 0:27 [PATCH v2 0/5] " Maaz Mombasawala
2026-05-12 0:27 ` [PATCH v2 3/5] drm/vmwgfx: Reserve ttm object before resv usage Maaz Mombasawala
2026-05-16 4:26 ` Claude review: " Claude Code Review Bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=review-patch3-20260514224819.3631763-4-maaz.mombasawala@broadcom.com \
--to=claude-review@example.com \
--cc=dri-devel-reviews@example.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox