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: drm: gem: Add vmap functions to shmem bindings Date: Thu, 23 Apr 2026 08:05:55 +1000 Message-ID: In-Reply-To: <20260421235346.672794-6-lyude@redhat.com> References: <20260421235346.672794-1-lyude@redhat.com> <20260421235346.672794-6-lyude@redhat.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 **1. Clone for VMapOwned calls unwrap_unchecked**:=20 ```rust impl Clone for VMapOwned { fn clone(&self) -> Self { unsafe { self.owner.owned_vmap().unwrap_unchecked() } } } ``` The safety comment says "We have a successful vmap already, so this can't f= ail." This relies on the fact that `drm_gem_shmem_vmap_locked` uses a refco= unt (`vmap_use_count`) and will succeed if there's already an active vmap. = This is true for the non-iomem path but should be documented more carefully= =E2=80=94 if the existing vmap was non-iomem, the cloned one will also be = non-iomem (since it's the same cached mapping). The real risk is that betwe= en clone attempts the vmap could theoretically be released and re-acquired = as iomem, but since we hold a reference (`self` exists), the refcount preve= nts that. The reasoning is sound but subtle. **2. VMap::From uses mem::forget**:=20 ```rust impl<'a, D: DriverObject, const SIZE: usize> From> for= VMapOwned { fn from(value: VMapRef<'a, D, SIZE>) -> Self { let this =3D Self { addr: value.addr, owner: value.owner.into(), }; mem::forget(value); this } } ``` This is correct =E2=80=94 the `mem::forget` prevents double-vunmap since we= 're transferring ownership of the mapping. Good pattern. **3. No Send/Sync for VMapRef**: `Send` and `Sync` are only implemented for= `VMapOwned`, not `VMapRef`. This is correct since `VMapRef` borrows from t= he object and the lifetime prevents sending across threads. **4. Tests are well-structured**: The kunit tests verify compile-time size = checking and basic I/O operations. The test for `vmap::<{ PAGE_SIZE + 200 }= >().is_err()` is a good sanity check. The `vmap_io` test verifying byte-lev= el reads within a u32 write is good for catching endianness assumptions =E2= =80=94 though the expected byte values (`0xFF` at all four positions) would= be the same on both big and little endian for `0xFFFFFFFF`, so it doesn't = actually test endianness. A value like `0xDEADBEEF` would be more revealing= , but this is minor. **5. ENOTSUPP for iomem**: The use of `ENOTSUPP` (which is the internal ker= nel variant, not `EOPNOTSUPP`) is fine for internal kernel use. The comment= `// XXX: We don't currently support iomem allocations` appropriately flags= this as a known limitation. --- Generated by Claude Code Patch Reviewer