From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot To: dri-devel-reviews@example.com Subject: Claude review: drm/gem/shmem: Introduce __drm_gem_shmem_free_sgt_locked() Date: Thu, 23 Apr 2026 08:05:54 +1000 Message-ID: In-Reply-To: <20260421235346.672794-3-lyude@redhat.com> References: <20260421235346.672794-1-lyude@redhat.com> <20260421235346.672794-3-lyude@redhat.com> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 Patch Review Extracts the sgt teardown logic into a new exported function. The refactoring is clean and the function is correctly guarded with `dma_resv_assert_held()`. **Naming mismatch in kdoc**: The kdoc comment header says `__drm_gem_shmem_release_sgt_locked` but the actual function is named `__drm_gem_shmem_free_sgt_locked`. The changelog mentions fixing this in V10, but the mismatch is still present: ```c /** * __drm_gem_shmem_release_sgt_locked - Unpin and DMA unmap pages, and release the * cached scatter/gather table for an shmem GEM object. ``` vs: ```c void __drm_gem_shmem_free_sgt_locked(struct drm_gem_shmem_object *shmem) ``` This should be `__drm_gem_shmem_free_sgt_locked` in the kdoc to match. **No NULL check on shmem->sgt**: The original code in `drm_gem_shmem_release` checks `if (shmem->sgt)` before calling the teardown. The new `__drm_gem_shmem_free_sgt_locked()` does not check for NULL and will crash if called with `shmem->sgt == NULL`. The call site in `drm_gem_shmem_release` preserves the NULL guard, but external callers (the Rust bindings in patch 4) need to be careful. The Rust side does call this only after a successful `drm_gem_shmem_get_pages_sgt_locked`, so it should be fine in practice, but a defensive NULL check (or at least a `WARN_ON(!shmem->sgt)`) in the exported function would be safer. **Kdoc says "Unpin" but function doesn't unpin**: The kdoc says "Unpin and DMA unmap pages" but the function only does DMA unmap + free the sgt structure. It does not call `drm_gem_shmem_put_pages_locked()`. This is accurate to the code behavior (the caller in `drm_gem_shmem_release` calls `put_pages_locked` separately), but the kdoc is misleading. --- Generated by Claude Code Patch Reviewer