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: fix stack overflow in GSP memory allocation Date: Fri, 13 Feb 2026 18:06:47 +1000 Message-ID: In-Reply-To: <20260212-drm-rust-next-v1-1-409398b12e61@proton.me> References: <20260212-drm-rust-next-v1-1-409398b12e61@proton.me> <20260212-drm-rust-next-v1-1-409398b12e61@proton.me> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Patch Review **rustfmt failure**: The kernel test robot already reported this. The indenta= tion of the `.dma_handle()` chain in `cmdq.rs` does not match `rustfmt` expec= tations: > + for i in 0..NUM_PAGES { > + let pte_value =3D gsp_mem > + .dma_handle() > + .checked_add(num::usize_as_u64(i) << GSP_PAGE_SHIFT) > + .ok_or(EOVERFLOW)?; The `.dma_handle()` has 20 spaces of indentation (double-indented) whereas `r= ustfmt` wants 16 (single continuation indent). This needs to be fixed before = the patch can be merged. **Unused import**: The patch adds `use core::iter::Iterator` to `gsp.rs`, but= nothing in the file uses `Iterator` as a named type. The `Iterator` trait is= already in scope via the prelude. Was this perhaps left over from an earlier= iteration of the patch? > +use core::iter::Iterator; **Misleading constant name in cmdq.rs**: The locally-defined `NUM_PAGES` does= n't represent a number of pages =E2=80=94 it's the number of PTE entries that= fit in one GSP page: > + const NUM_PAGES: usize =3D GSP_PAGE_SIZE / size_of::(); This evaluates to 512 (4096 / 8), which is the number of u64 entries, not pag= es. The name was inherited from the old `PteArray` generic parameter, which a= lso misnamed it. Something like `NUM_PTES` or `PTE_COUNT` would be clearer an= d would match the existing `Cmdq::NUM_PTES` constant defined elsewhere in the= same file. Not a correctness issue, but worth cleaning up since the code is = being rewritten anyway. **Comment typo in gsp.rs**: There's a double space in the comment: > + // As in [`DmaGspMem`], this is a one by one GSP Page write to th= e memory Minor nit =E2=80=94 "a one" should be "a one". **Inconsistent approaches between the two call sites**: In `gsp.rs`, the PTE = writes are done through a byte slice obtained from `as_slice_mut`, writing `t= o_ne_bytes()`. In `cmdq.rs`, the writes go through raw pointer arithmetic and= `field_write`. Both work, but the `gsp.rs` approach is simpler and doesn't r= equire unsafe code beyond the initial `as_slice_mut` call. Is there a reason = the `cmdq.rs` site couldn't use the same pattern? The `LogBuffer` allocates `= CoherentAllocation` so it naturally uses byte-level access, while `GspMem= ` is a typed allocation =E2=80=94 but even so, the `field_write` approach see= ms more complex than necessary for writing individual array elements. **Correctness**: Setting aside the style concerns, the logic in both call sit= es correctly reproduces the behavior of the removed `PteArray::new` =E2=80=94= computing `base_dma_addr + i * GSP_PAGE_SIZE` for each PTE entry and writing= it to the appropriate location in the DMA buffer. The overflow checking via = `checked_add` is preserved. The error propagation with `?` on `ok_or(EOVERFLO= W)` inside the loop correctly returns early if any PTE address overflows, mat= ching the old behavior. --- Generated by Claude Code Patch Reviewer