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 GpuVmCore::sm_map() Date: Sun, 22 Mar 2026 03:35:24 +1000 Message-ID: In-Reply-To: <20260320-gpuvm-rust-v5-6-76fd44f17a87@google.com> References: <20260320-gpuvm-rust-v5-0-76fd44f17a87@google.com> <20260320-gpuvm-rust-v5-6-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 Adds the map operation, completing the split/merge functionality. **`OpMap::insert` drops the gpuva guard immediately:** ```rust pub fn insert(self, va: GpuVaAlloc, va_data: impl PinInit) ->= OpMapped<'op, T> { let va =3D va.prepare(va_data); unsafe { bindings::drm_gpuva_map(self.vm_bo.gpuvm().as_raw(), va, self.= op) }; let _gpuva_guard =3D self.vm_bo().lock_gpuva(); unsafe { bindings::drm_gpuva_link(va, self.vm_bo.as_raw()) }; OpMapped { _invariant: self._invariant } } ``` The guard is correctly scoped =E2=80=94 it's taken just for the `drm_gpuva_= link` call and dropped when the function returns. The `_gpuva_guard` naming= with underscore prefix would normally indicate an unused variable, but the= `let` binding keeps it alive until end of scope. This is correct but could= be clearer with a named binding like `let gpuva_guard =3D ...` (matching t= he style in `remap()` from patch 5 which uses `let gpuva_guard =3D`). Actua= lly looking again, patch 5's `remap()` does use `gpuva_guard` without under= score. Minor inconsistency. **The `SmMapData` =E2=86=92 `SmData` cast is sound** due to `#[repr(C)]` on= `SmMapData` ensuring `sm_data` is at offset 0. The `sm_step_unmap` and `sm= _step_remap` callbacks cast the pointer to `SmData`, which works whether th= e actual data is `SmData` (from `sm_unmap`) or `SmMapData` (from `sm_map`).= This is well-designed. **`OpMapRequest` has public fields** =E2=80=94 this is a clean API choice f= or constructing the request. **Overall the series is in good shape** for a v5. The main actionable items= are: 1. Fix the SAFETY comment typo in `GpuVa::obj()` ("gem.offset" =E2=86=92 "g= em.obj") 2. Consider adding `#[repr(C)]` to `SmData` for robustness 3. Document the `null` ww_acquire_ctx limitation on `obtain()` more promine= ntly 4. Consider requiring `T: Send` for `GpuVm: Send` --- Generated by Claude Code Patch Reviewer