From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot To: dri-devel-reviews@example.com Subject: Claude review: rust: gpuvm: add GpuVm::obtain() Date: Sun, 22 Mar 2026 03:35:23 +1000 Message-ID: In-Reply-To: <20260320-gpuvm-rust-v5-3-76fd44f17a87@google.com> References: <20260320-gpuvm-rust-v5-0-76fd44f17a87@google.com> <20260320-gpuvm-rust-v5-3-76fd44f17a87@google.com> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Patch Review Introduces `GpuVmBo`, `GpuVmBoAlloc`, and the `obtain()` path. **Key concern =E2=80=94 resv lock in `obtain()`:** ```rust if ptr::eq(ptr, me.as_raw()) && me.gpuvm().is_extobj(me.obj()) { let resv_lock =3D me.gpuvm().raw_resv(); // TODO: Use a proper lock guard here once a dma_resv lock abstraction = exists. unsafe { bindings::dma_resv_lock(resv_lock, ptr::null_mut()) }; unsafe { bindings::drm_gpuvm_bo_extobj_add(ptr) }; unsafe { bindings::dma_resv_unlock(resv_lock) }; } ``` Passing `null` for `ww_acquire_ctx` means this cannot participate in deadlo= ck avoidance. If a driver calls `obtain()` while already holding another re= sv lock in a ww transaction, this will deadlock. The TODO acknowledges this= but it should be documented more prominently as a limitation, possibly wit= h a `// WARNING` or a doc comment on `obtain()` itself. **`GpuVmBoAlloc::Drop` =E2=80=94 could use `drm_gpuvm_bo_destroy_not_in_lis= ts()`:** ```rust fn drop(&mut self) { // TODO: Call drm_gpuvm_bo_destroy_not_in_lists() directly. unsafe { bindings::drm_gpuvm_bo_put_deferred(self.as_raw()) }; } ``` The TODO is noted. Using `drm_gpuvm_bo_put_deferred` here works but does un= necessary refcount work for an object known to have refcount=3D1 and not be= in any lists. **ALLOC_FN optimization is clever:** ```rust pub(super) const ALLOC_FN: Option *mut bindings::= drm_gpuvm_bo> =3D { ... if base.size() !=3D rust.size() || base.align() !=3D rust.align() { Some(Self::vm_bo_alloc) } else { None } }; ``` This correctly avoids overriding when the Rust wrapper has no extra fields.= However, the `FREE_FN` check uses `needs_drop::()` which is independ= ent =E2=80=94 when `VmBoData` has a trivial type but non-default layout, yo= u'd get `ALLOC_FN =3D Some` but `FREE_FN =3D None`, meaning the C side woul= d `kfree()` a larger allocation which is fine since it was `kmalloc`'d. Thi= s works correctly. --- Generated by Claude Code Patch Reviewer