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, 04 Jun 2026 12:29:53 +1000 Message-ID: In-Reply-To: <20260602172807.1051806-3-lyude@redhat.com> References: <20260602172807.1051806-1-lyude@redhat.com> <20260602172807.1051806-3-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 This is the largest patch and adds the core vmap functionality. The design = is well thought out. **`make_vmap` guard lifetime**: The explicit `drop(guard)` before the iomem= error path is correct =E2=80=94 `raw_vunmap` re-acquires the lock internal= ly: ```rust let guard =3D DmaResvGuard::new(self); to_result(unsafe { bindings::drm_gem_shmem_vmap_locked(self.as_raw_shmem(), map.as_mut_ptr= ()) })?; drop(guard); ``` Good defensive pattern. **VMap::Drop reconstruction**: The `drop` reconstructs an `iosys_map` to pa= ss to `raw_vunmap`: ```rust self.owner.raw_vunmap(bindings::iosys_map { is_iomem: false, __bindgen_anon_1: bindings::iosys_map__bindgen_ty_1 { vaddr: self.addr = }, }) ``` This works because `make_vmap` already validated `!is_iomem` before constru= cting the `VMap`. The invariant is maintained. **IoCapable implementations**: The `impl_vmap_io_capable!` macro implements= `ptr::read`/`ptr::write` through raw pointer casts: ```rust unsafe fn io_read(&self, address: usize) -> $ty { let ptr =3D address as *mut $ty; unsafe { ptr::read(ptr) } } ``` The safety is delegated to the `Io` trait's `io_read`/`io_write` contract (= alignment, bounds). This is correct. **Minor**: The `VMap` struct's `addr` field is `*mut c_void` =E2=80=94 this= raw pointer doesn't implement `Send`/`Sync`, but `VMap` doesn't explicitly= implement them either. Since the GEM object backing the mapping is thread-= safe, and the mapping itself is valid for the lifetime of the owner, this m= ight need explicit `Send`/`Sync` impls if callers need to share the mapping= across threads. However, this may be intentionally restrictive for now. **Tests**: Good coverage =E2=80=94 `compile_time_vmap_sizes` validates the = size check and `vmap_io` tests read/write through the mapping. The byte-lev= el verification of a `write32` is a nice touch. --- Generated by Claude Code Patch Reviewer