* [PATCH v2 0/2] gpu: nova-core: gsp: fix misc cmdq issues
@ 2026-11-12 6:14 Eliot Courtney
2026-11-12 6:14 ` [PATCH v2 1/2] gpu: nova-core: gsp: cmdq: wrap the sequence number on overflow Eliot Courtney
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Eliot Courtney @ 2026-11-12 6:14 UTC (permalink / raw)
To: Danilo Krummrich, Alice Ryhl, David Airlie, Simona Vetter,
Alexandre Courbot
Cc: John Hubbard, Alistair Popple, Timur Tabi, nova-gpu, dri-devel,
linux-kernel, Eliot Courtney
Fix two cmdq issues.
This is based on drm-rust-next.
Signed-off-by: Eliot Courtney <ecourtney@nvidia.com>
---
Changes in v2:
- Simplify the comment in patch #2 and check that `MSGQ_NUM_PAGES`
divides `1 << 32` (Alex). I used `%` since `is_multiple_of()` is out
due to MSRV.
- Add reviewed-by tags
- Link to v1: https://patch.msgid.link/20261111-msgq-64-pages-v1-0-d8c56b6fdd6c@nvidia.com
---
Eliot Courtney (2):
gpu: nova-core: gsp: cmdq: wrap the sequence number on overflow
gpu: nova-core: gsp: cmdq: increase MSGQ_NUM_PAGES to 64
drivers/gpu/nova-core/gsp/cmdq.rs | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
---
base-commit: 7ecd9ee29f7bfbe9a293952fbc83c3f8bd7205dd
change-id: 20261109-msgq-64-pages-bab32c03d627
Best regards,
--
Eliot Courtney <ecourtney@nvidia.com>
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH v2 1/2] gpu: nova-core: gsp: cmdq: wrap the sequence number on overflow
2026-11-12 6:14 [PATCH v2 0/2] gpu: nova-core: gsp: fix misc cmdq issues Eliot Courtney
@ 2026-11-12 6:14 ` Eliot Courtney
2026-11-12 6:14 ` [PATCH v2 2/2] gpu: nova-core: gsp: cmdq: increase MSGQ_NUM_PAGES to 64 Eliot Courtney
2026-11-12 13:08 ` [PATCH v2 0/2] gpu: nova-core: gsp: fix misc cmdq issues Alexandre Courbot
2 siblings, 0 replies; 5+ messages in thread
From: Eliot Courtney @ 2026-11-12 6:14 UTC (permalink / raw)
To: Danilo Krummrich, Alice Ryhl, David Airlie, Simona Vetter,
Alexandre Courbot
Cc: John Hubbard, Alistair Popple, Timur Tabi, nova-gpu, dri-devel,
linux-kernel, Eliot Courtney
The sequence number can (eventually) overflow, in which case we should
just wrap it around.
Fixes: 75f6b1de8133 ("gpu: nova-core: gsp: Add GSP command queue bindings and handling")
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Eliot Courtney <ecourtney@nvidia.com>
---
drivers/gpu/nova-core/gsp/cmdq.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/nova-core/gsp/cmdq.rs b/drivers/gpu/nova-core/gsp/cmdq.rs
index 5f3de456042e..33074bb53e8c 100644
--- a/drivers/gpu/nova-core/gsp/cmdq.rs
+++ b/drivers/gpu/nova-core/gsp/cmdq.rs
@@ -578,7 +578,7 @@ fn send_command_element<E: CommandElement>(&mut self, command: E) -> Result<u32>
// All set - update the write pointer and inform the GSP of the new command.
let elem_count = dst.header.element_count();
- self.seq += 1;
+ self.seq = self.seq.wrapping_add(1);
self.gsp_mem.advance_cpu_write_ptr(elem_count);
Ok(seq)
--
2.56.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH v2 2/2] gpu: nova-core: gsp: cmdq: increase MSGQ_NUM_PAGES to 64
2026-11-12 6:14 [PATCH v2 0/2] gpu: nova-core: gsp: fix misc cmdq issues Eliot Courtney
2026-11-12 6:14 ` [PATCH v2 1/2] gpu: nova-core: gsp: cmdq: wrap the sequence number on overflow Eliot Courtney
@ 2026-11-12 6:14 ` Eliot Courtney
2026-11-12 13:07 ` Alexandre Courbot
2026-11-12 13:08 ` [PATCH v2 0/2] gpu: nova-core: gsp: fix misc cmdq issues Alexandre Courbot
2 siblings, 1 reply; 5+ messages in thread
From: Eliot Courtney @ 2026-11-12 6:14 UTC (permalink / raw)
To: Danilo Krummrich, Alice Ryhl, David Airlie, Simona Vetter,
Alexandre Courbot
Cc: John Hubbard, Alistair Popple, Timur Tabi, nova-gpu, dri-devel,
linux-kernel, Eliot Courtney
In the msgq v2 protocol, which the r000 firmware uses, the queue
pointers are kept in u32 registers and increase monotonically until they
wrap at 2^32.
`MSGQ_NUM_PAGES` is currently 63 and does not divide 2^32. This means
that on msgq v2, the slot can jump backwards when the counters wrap.
For example:
(2^32 - 2) % 63 == 2
(2^32 - 1) % 63 == 3
0 % 63 == 0 (slot 0 instead of slot 4)
The writer can then overwrite slots before the reader has read them.
Increase `MSGQ_NUM_PAGES` to 64 and check at compile time that
`MSGQ_NUM_PAGES` divides 2^32.
Signed-off-by: Eliot Courtney <ecourtney@nvidia.com>
---
drivers/gpu/nova-core/gsp/cmdq.rs | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/nova-core/gsp/cmdq.rs b/drivers/gpu/nova-core/gsp/cmdq.rs
index 33074bb53e8c..8d34acaef9ea 100644
--- a/drivers/gpu/nova-core/gsp/cmdq.rs
+++ b/drivers/gpu/nova-core/gsp/cmdq.rs
@@ -84,7 +84,12 @@ trait CommandElement {
}
/// Number of GSP pages making the [`Msgq`].
-pub(crate) const MSGQ_NUM_PAGES: u32 = 0x3f;
+pub(crate) const MSGQ_NUM_PAGES: u32 = 64;
+
+// The queue pointers are wrapping `u32` counters, and the slot is
+// `counter % MSGQ_NUM_PAGES`. For slots to remain contiguous when a counter
+// wraps, `MSGQ_NUM_PAGES` must divide `1 << 32`.
+static_assert!((1u64 << u32::BITS) % cv!(MSGQ_NUM_PAGES => u64) == 0);
/// Circular buffer of a [`Msgq`].
///
--
2.56.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH v2 2/2] gpu: nova-core: gsp: cmdq: increase MSGQ_NUM_PAGES to 64
2026-11-12 6:14 ` [PATCH v2 2/2] gpu: nova-core: gsp: cmdq: increase MSGQ_NUM_PAGES to 64 Eliot Courtney
@ 2026-11-12 13:07 ` Alexandre Courbot
0 siblings, 0 replies; 5+ messages in thread
From: Alexandre Courbot @ 2026-11-12 13:07 UTC (permalink / raw)
To: Eliot Courtney
Cc: Danilo Krummrich, Alice Ryhl, David Airlie, Simona Vetter,
John Hubbard, Alistair Popple, Timur Tabi, nova-gpu, dri-devel,
linux-kernel
On Thu Nov 12, 2026 at 3:14 PM JST, Eliot Courtney wrote:
> In the msgq v2 protocol, which the r000 firmware uses, the queue
> pointers are kept in u32 registers and increase monotonically until they
> wrap at 2^32.
>
> `MSGQ_NUM_PAGES` is currently 63 and does not divide 2^32. This means
> that on msgq v2, the slot can jump backwards when the counters wrap.
> For example:
>
> (2^32 - 2) % 63 == 2
> (2^32 - 1) % 63 == 3
> 0 % 63 == 0 (slot 0 instead of slot 4)
>
> The writer can then overwrite slots before the reader has read them.
>
> Increase `MSGQ_NUM_PAGES` to 64 and check at compile time that
> `MSGQ_NUM_PAGES` divides 2^32.
>
> Signed-off-by: Eliot Courtney <ecourtney@nvidia.com>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 0/2] gpu: nova-core: gsp: fix misc cmdq issues
2026-11-12 6:14 [PATCH v2 0/2] gpu: nova-core: gsp: fix misc cmdq issues Eliot Courtney
2026-11-12 6:14 ` [PATCH v2 1/2] gpu: nova-core: gsp: cmdq: wrap the sequence number on overflow Eliot Courtney
2026-11-12 6:14 ` [PATCH v2 2/2] gpu: nova-core: gsp: cmdq: increase MSGQ_NUM_PAGES to 64 Eliot Courtney
@ 2026-11-12 13:08 ` Alexandre Courbot
2 siblings, 0 replies; 5+ messages in thread
From: Alexandre Courbot @ 2026-11-12 13:08 UTC (permalink / raw)
To: Danilo Krummrich, Alice Ryhl, David Airlie, Simona Vetter,
Eliot Courtney
Cc: John Hubbard, Alistair Popple, Timur Tabi, nova-gpu, dri-devel,
linux-kernel
On Thu, 12 Nov 2026 15:14:52 +0900, Eliot Courtney wrote:
> Fix two cmdq issues.
>
> This is based on drm-rust-next.
Applied to drm-rust-next, thanks!
[1/2] gpu: nova-core: gsp: cmdq: wrap the sequence number on overflow
commit: 75c25f42536d91fcabd6042dd8872400601f4f7c
[2/2] gpu: nova-core: gsp: cmdq: increase MSGQ_NUM_PAGES to 64
commit: 0ff9e5b9ff6736c37593cd7db89f4593ec4f8e86
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-12 13:12 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-12 6:14 [PATCH v2 0/2] gpu: nova-core: gsp: fix misc cmdq issues Eliot Courtney
2026-11-12 6:14 ` [PATCH v2 1/2] gpu: nova-core: gsp: cmdq: wrap the sequence number on overflow Eliot Courtney
2026-11-12 6:14 ` [PATCH v2 2/2] gpu: nova-core: gsp: cmdq: increase MSGQ_NUM_PAGES to 64 Eliot Courtney
2026-11-12 13:07 ` Alexandre Courbot
2026-11-12 13:08 ` [PATCH v2 0/2] gpu: nova-core: gsp: fix misc cmdq issues Alexandre Courbot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.