From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot To: dri-devel-reviews@example.com Subject: Claude review: gpu: nova-core: convert to new dma::Coherent API Date: Sun, 22 Mar 2026 03:23:44 +1000 Message-ID: In-Reply-To: <20260320194626.36263-9-dakr@kernel.org> References: <20260320194626.36263-1-dakr@kernel.org> <20260320194626.36263-9-dakr@kernel.org> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 Patch Review Final cleanup converting all remaining `CoherentAllocation` usage to `Coherent`. **`from_data` safety concern in `dma.rs`**: ```rust unsafe { dma_obj.as_mut()[..data.len()].copy_from_slice(data) }; ``` `dma_obj` is a `DmaObject` which `Deref`s to `Coherent<[u8]>`. The `as_mut()` call is `Coherent::as_mut(&self)` returning `&mut [u8]`. The safety justification ("we are the only users and we haven't made the device aware of the handle yet") is valid. However, the allocation may be larger than `data.len()` due to page alignment in `DmaObject::new()`, so the `[..data.len()]` slice is correct. **`DerefMut` for `DmaObject` inconsistency**: The patch changes `Deref::Target` to `Coherent<[u8]>` explicitly but doesn't touch the `DerefMut` impl, which still references `CoherentAllocation`. While this resolves to the same type via the type alias, it's inconsistent. Either both should use the new name or the `DerefMut` should also be updated. Minor nit. **`dma_read!`/`dma_write!` simplification in `gsp/fw.rs`**: The conversion from `dma_read!(qs, [0]?.field)` to `dma_read!(qs, .field)` is clean and removes the fallible index + unwrap pattern that was previously needed when treating a single-element `CoherentAllocation` as a slice. This is a substantial readability improvement. **Added `FromBytes` for `PteArray`**: The new `unsafe impl FromBytes for PteArray {}` is correct since `PteArray` is `[u64; N]` which has no invalid bit patterns. **`IntoSafeCast` removal in `falcon.rs`**: The import of `IntoSafeCast` is dropped and the `dma_handle_with_offset` call is replaced with: ```rust dma_obj.dma_handle() + DmaAddress::from(load_offsets.src_start) ``` This is simpler and avoids the fallible `dma_handle_with_offset` call. The arithmetic correctness depends on `src_start` being within bounds, which should be guaranteed by the caller context. --- Generated by Claude Code Patch Reviewer