]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
gpu: nova-core: gsp: fix incorrect advancing of write pointer
authorEliot Courtney <ecourtney@nvidia.com>
Thu, 29 Jan 2026 07:44:59 +0000 (16:44 +0900)
committerAlexandre Courbot <acourbot@nvidia.com>
Tue, 24 Feb 2026 23:16:55 +0000 (08:16 +0900)
We should modulo not bitwise-and here. The current code could, for
example, set wptr to MSGQ_NUM_PAGES which is not valid.

Fixes: 75f6b1de8133 ("gpu: nova-core: gsp: Add GSP command queue bindings and handling")
Signed-off-by: Eliot Courtney <ecourtney@nvidia.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Link: https://patch.msgid.link/20260129-nova-core-cmdq1-v3-1-2ede85493a27@nvidia.com
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
drivers/gpu/nova-core/gsp/cmdq.rs

index 46819a82a51adc58423502d9d45730923b843656..f139aad7af3fdc5f0899c6466bc477325c1cc0b4 100644 (file)
@@ -384,7 +384,7 @@ impl DmaGspMem {
 
     // Informs the GSP that it can process `elem_count` new pages from the command queue.
     fn advance_cpu_write_ptr(&mut self, elem_count: u32) {
-        let wptr = self.cpu_write_ptr().wrapping_add(elem_count) & MSGQ_NUM_PAGES;
+        let wptr = self.cpu_write_ptr().wrapping_add(elem_count) % MSGQ_NUM_PAGES;
         let gsp_mem = self.0.start_ptr_mut();
 
         // SAFETY: