gpu: nova-core: gsp: prepare the command queue for r000 dual-message types
Subsystems (5)
Alexandre Courbot
maintainercover gpu: nova-core: gsp: prepare the command queue for r000 dual-message types
The upcoming r000 firmware support [1] introduces a new type of command named GMC alongside the existing and already supported RPC command type.
Since RPC was the only command type supported so far, it was embedded into the lowest command queue level: the message header actually includes the RPC header and the code considers them as one.
This makes the r000/GMC support difficult to land without a refactor, with the result of transport layer code being duplicated between the two message types, and no clear separation between the RPC and GMC code which are mixed together in the command queue. Merging the code that way would introduce quite some technical debt.
Thus, this series prepares a proper landing ground for a new message type by extracting all the RPC layer code and moving it into its own sub-modules, making the cmdq module completely agnostic of the type of message it transports. By the end of the series, the only mention of RPC in cmdq.rs is for the rpc sub-module.
With the transport and message layers properly separated, support for GMC can be added into sibling modules of rpc, and the transport layer can be converted once when doing the switch to r000.
This moves quite a bit of code around, but most of it is moved verbatim. No significant functional change is intended.
For the r000 series, this essentially means the following:
- Its patch 7 making allocate_command generic can be dropped as the transport layer makes no assumption about the message type.
- Patches adding GMC support will do it in dedicated gmc sub-modules, following the model set by RPC. These gmc sub-modules will start as dead_code as they are being built.
- The "switch to r000" patch will essentially operate on the transport layer level, i.e. cmdq.rs.
- There should be no need for extra post-switch RPC fixing, as the transport layer code will already be shared with GMC.
Overall, this should make the r000 series much easier to review and eventually land, while not creating new technical debt.
This series is based on drm-rust-next.
[1] https://lore.kernel.org/all/[email protected]/
---
Alexandre Courbot (10):
gpu: nova-core: gsp: cmdq: use element_count to advance queue pointer
gpu: nova-core: gsp: cmdq: validate checksum earlier on receive
gpu: nova-core: gsp: introduce and use proper RpcMessageHeader type
gpu: nova-core: gsp: cmdq: group the RPC-specific part of send_single_command
gpu: nova-core: gsp: cmdq: split the transport part of the send path
gpu: nova-core: gsp: cmdq: move the RPC send code into a sub-module
gpu: nova-core: gsp: cmdq: split the transport part of the receive path
gpu: nova-core: gsp: cmdq: move the RPC receive code into a sub-module
gpu: nova-core: gsp: move the RPC commands into a sub-module
gpu: nova-core: gsp: add rpc to RPC message send/receive methods
drivers/gpu/nova-core/gpu.rs | 2 +-
drivers/gpu/nova-core/gsp.rs | 4 +-
drivers/gpu/nova-core/gsp/boot.rs | 12 +-
drivers/gpu/nova-core/gsp/cmdq.rs | 331 ++----------------
drivers/gpu/nova-core/gsp/cmdq/rpc.rs | 378 +++++++++++++++++++++
.../nova-core/gsp/cmdq/{ => rpc}/continuation.rs | 0
drivers/gpu/nova-core/gsp/commands.rs | 312 +----------------
drivers/gpu/nova-core/gsp/commands/rpc.rs | 316 +++++++++++++++++
drivers/gpu/nova-core/gsp/fw.rs | 90 +++--
drivers/gpu/nova-core/gsp/sequencer.rs | 6 +-
10 files changed, 782 insertions(+), 669 deletions(-)---
base-commit: 896ed083362758b33c49a1b5e5a3423c5814d87e
change-id: 20260927-cmdq-rpc-ed5f850b207e
Best regards,
Signature · 1 line
Alexandre Courbot <[email protected]>
Alexandre Courbot
maintainerPATCH 1/10 gpu: nova-core: gsp: cmdq: use element_count to advance queue pointer
The transport layer of the command queue works in whole page units (aka. slots) - the size in bytes of the message is only relevant to the message layer.
After queueing a message, we computed the number of slots to advance the queue's write pointer by from the message size in bytes, borrowing information from a layer we are not supposed to access while also re-computing a number we already have since the number of slots of the message is in the transport-level header.
Therefore, use the correct information from our layer. This is necessary in order to extract the message layer code into its own module.
No functional change intended.
--- drivers/gpu/nova-core/gsp/cmdq.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/nova-core/gsp/cmdq.rs +2 -3
@@ -863,9 +863,8 @@ fn receive_msg<M: MessageFromGsp>(&mut self, timeout: Delta) -> Result<M> };// Advance the read pointer past this message. - self.gsp_mem.advance_cpu_read_ptr (u32::try_from ( - message.header.length ().div_ceil (GSP_PAGE_SIZE ), - )?); + self.gsp_mem + .advance_cpu_read_ptr (message.header.element_count ()); result }
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH 01/10] gpu: nova-core: gsp: cmdq: use element_count to advance queue pointer
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] gpu: nova-core: missing validation of GSP element_count causes DoS or queue corruption --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] gpu: nova-core: missing validation of GSP element_count causes DoS or queue corruption --
commit 4735296acba7b78deac091e3d6a7e814d360afff
Author: Alexandre Courbot <[email protected]>
gpu: nova-core: gsp: cmdq: use element_count to advance queue pointer
This commit changes the command queue message receiving logic to use the element_count from the transport-level header instead of recalculating the slot count from the message length.
drivers/gpu/nova-core/gsp/cmdq.rs fn receive_msg<M: MessageFromGsp>(&mut self, timeout: Delta) -> Result<M> · line 867
Quoted 13 lines
drivers/gpu/nova-core/gsp/cmdq.rs +2
-3@@ -863,9 +863,8 @@ fn receive_msg<M: MessageFromGsp>(&mut self, timeout: Delta) -> Result<M> };// Advance the read pointer past this message. - self.gsp_mem.advance_cpu_read_ptr (u32::try_from ( - message.header.length ().div_ceil (GSP_PAGE_SIZE ), - )?); + self.gsp_mem + .advance_cpu_read_ptr (message.header.element_count ());
[Severity: High]
Does this leave the driver vulnerable to a compromised or buggy GSP firmware?
By directly using the untrusted, DMA-mapped message.header.element_count() to advance the ring buffer read pointer without validation, this could potentially allow the hardware to trigger a denial of service or memory corruption.
If the hardware provides an element_count of 0, could it fail to advance the pointer and lead to an infinite retry loop when send_command() is called, causing a host lockup?
Conversely, if a maliciously large value is provided, could the read pointer advance past the write pointer, causing the driver to process uninitialized memory as legitimate messages? Should this value be validated against the available read area bounds before being passed to advance_cpu_read_ptr()?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Alexandre Courbot
maintainerPATCH 2/10 gpu: nova-core: gsp: cmdq: validate checksum earlier on receive
In reply to Alexandre CourbotThe checksum validation error message of wait_for_msg prints the message's sequence number before validating the checksum.
But the checksum is part of the transport layer, and it not validating indicates a corruption that could very well be in the RPC message header, meaning the value of this field cannot be trusted.
Furthermore, the transport layer is not supposed to know the kind of message it transports, and it accessing the RPC header is a layering violation.
Thus, move the checksum validation before we start looking at the message header, and drop that information from the error message.
--- drivers/gpu/nova-core/gsp/cmdq.rs | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-)
drivers/gpu/nova-core/gsp/cmdq.rs +11 -15
@@ -768,6 +768,17 @@ fn wait_for_msg(&self, timeout: Delta) -> Result<GspMessage<'_>> {// Extract the `GspMsgElement`. let (header, slice_1) =GspMsgElement ::from_bytes_prefix (slice_1).ok_or (EIO )?; +// Validate checksum. +if Cmdq ::calculate_checksum (SBufferIter ::new_reader ([ + header.as_bytes (), + slice_1, + slice_2, + ])) !=0 + { +dev_err! (&self.dev,"GSP receive: bad checksum\n" ); +return Err (EIO ); + } +dev_dbg! ( &self.dev,"GSP RPC: receive: seq# {}, function={:?}, length=0x{:x}\n" ,
@@ -796,21 +807,6 @@ fn wait_for_msg(&self, timeout: Delta) -> Result<GspMessage<'_>> { ) }; -// Validate checksum. -if Cmdq ::calculate_checksum (SBufferIter ::new_reader ([ - header.as_bytes (), - slice_1, - slice_2, - ])) !=0 - { -dev_err! ( - &self.dev, -"GSP RPC: receive: Call {} - bad checksum\n" , - header.sequence () - ); -return Err (EIO ); - } -Ok (GspMessage { header, contents: (slice_1, slice_2),
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH 02/10] gpu: nova-core: gsp: cmdq: validate checksum earlier on receive
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] gpu/nova: GSP message queue permanently wedges due to untruncated checksum calculation --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] gpu/nova: GSP message queue permanently wedges due to untruncated checksum calculation --
commit 5dd9973126ada78a1c8fff2d08bacb19190898fd
Author: Alexandre Courbot <[email protected]>
gpu: nova-core: gsp: cmdq: validate checksum earlier on receive
This commit moves the checksum validation of received messages to occur before the RPC message header is accessed.
Quoted 5 lines
drivers/gpu/nova-core/gsp/cmdq.rs +0
-0
drivers/gpu/nova-core/gsp/cmdq.rs fn wait_for_msg(&self, timeout: Delta) -> Result<GspMessage<'_>> { · line 777
Quoted 10 lines
drivers/gpu/nova-core/gsp/cmdq.rs +7
-0@@ -768,6 +768,17 @@ fn wait_for_msg(&self, timeout: Delta) -> Result<GspMessage<'_>> {// Extract the `GspMsgElement`. let (header, slice_1) =GspMsgElement ::from_bytes_prefix (slice_1).ok_or (EIO )?; +// Validate checksum. +if Cmdq ::calculate_checksum (SBufferIter ::new_reader ([ + header.as_bytes (), + slice_1, + slice_2, + ])) !=0 + {
[Severity: High]
Does this perform the checksum validation on slice_1 and slice_2 before they have been truncated to the actual message length?
If the read area spans more bytes than the actual message length, could the slices contain non-zero trailing data from subsequent messages or old uninitialized data in the circular buffer page?
If the checksum is calculated over the entire un-truncated read area, wait_for_msg() will return Err(EIO) without advancing the read pointer.
Could this cause the GSP message queue to wedge permanently, as subsequent calls will repeatedly read the exact same bytes and fail the checksum again?
Quoted 3 lines
drivers/gpu/nova-core/gsp/cmdq.rs +3
-0+dev_err! (&self.dev,"GSP receive: bad checksum\n" ); +return Err (EIO ); + }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Alexandre Courbot
maintainerPATCH 3/10 gpu: nova-core: gsp: introduce and use proper RpcMessageHeader type
In reply to Alexandre CourbotSo far, the GSP command queue transport and message layer code were intertwined, a design issue that goes as deep as the types themselves:
the generated bindings for GspMsgElement even include the RPC header at its end.
This makes it difficult to introduce the new GMC message type; thus this patch works around these limitations to make the RPC message header more explicit and allow it to be eventually handled by a different layer.
The RpcMessageHeader wrapping type is introduced following the same model as GspMsgElement, and can be obtained from the latter. The methods of GspMsgElement that actually query the RPC header are moved to RpcMessageHeader.
Regarding initialization, GspMsgElement leaves the RPC header zeroed, and the command queue code is now responsible for initializing it in a separate call.
The only functional change is that the RPC debug messages now display the size of the RPC payload instead of the whole message including its headers, as they are technically part of the message layer. This metric is arguably more useful as the headers have successfully been parsed by the time we can print these messages.
--- drivers/gpu/nova-core/gsp/cmdq.rs | 25 +++++++---- drivers/gpu/nova-core/gsp/fw.rs | 90 ++++++++++++++++++++++++--------------- 2 files changed, 71 insertions(+), 44 deletions(-)
drivers/gpu/nova-core/gsp/cmdq.rs +16 -9
@@ -50,6 +50,7 @@ MsgFunction, MsgqRxHeader, MsgqTxHeader, + RpcMessageHeader, GSP_MSG_QUEUE_ELEMENT_SIZE_MAX, // }, PteArray,
@@ -664,11 +665,16 @@ fn send_single_command<M>(&mut self, command: M) -> Resultlet (cmd, payload_1) =M ::Command ::from_bytes_mut_prefix (dst.contents.0 ).ok_or (EIO )?;// Fill the header and command in-place. -let msg_element =GspMsgElement ::init (self.seq, size_in_bytes,M ::FUNCTION ); +let msg_element_init =GspMsgElement ::init (self.seq, size_in_bytes); +let rpc_header_init =RpcMessageHeader ::init (size_in_bytes,M ::FUNCTION );// SAFETY: `msg_header` and `cmd` are valid references, and not touched if the initializer // fails. unsafe { - pin_init::raw_try_init (core::ptr::from_mut (dst.header), msg_element)?; + pin_init::raw_try_init (core::ptr::from_mut (dst.header), msg_element_init)?; + pin_init::raw_try_init ( + core::ptr::from_mut (dst.header.rpc_header_mut ()), + rpc_header_init, + )?; pin_init::raw_try_init (core::ptr::from_mut (cmd), command.init ())?; }
@@ -694,7 +700,7 @@ fn send_single_command<M>(&mut self, command: M) -> Result "GSP RPC: send: seq# {}, function={:?}, length=0x{:x}\n", self.seq, M::FUNCTION, - dst.header.length(), + size_in_bytes, );// All set - update the write pointer and inform the GSP of the new command.
@@ -779,16 +785,17 @@ fn wait_for_msg(&self, timeout: Delta) -> Result<GspMessage<'_>> {return Err (EIO ); } +let rpc_header = header.rpc_header (); +let payload_length = rpc_header.length (); +dev_dbg! ( &self.dev,"GSP RPC: receive: seq# {}, function={:?}, length=0x{:x}\n" , - header.sequence (), - header.function (), - header.length (), + rpc_header.sequence (), + rpc_header.function (), + payload_length, ); -let payload_length = header.payload_length (); -// Check that the driver read area is large enough for the message. if slice_1.len () + slice_2.len () < payload_length {return Err (EIO );
@@ -835,7 +842,7 @@ fn receive_msg<M: MessageFromGsp>(&mut self, timeout: Delta) -> Result<M> Error: From<M::InitError>, {let message = self.wait_for_msg (timeout)?; -let function = message.header.function ().map_err (|_|EINVAL )?; +let function = message.header.rpc_header ().function ().map_err (|_|EINVAL )?;// Extract the message. Store the result as we want to advance the read pointer even in // case of failure.
drivers/gpu/nova-core/gsp/fw.rs +55 -35
132 lines not on this page · raw message
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH 03/10] gpu: nova-core: gsp: introduce and use proper RpcMessageHeader type
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] gsp: spurious checksum failures due to untruncated message buffers --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] gsp: spurious checksum failures due to untruncated message buffers --
commit 1576576bd4ef9c21c59c6b207630d4431a81e34d
Author: Alexandre Courbot <[email protected]>
gpu: nova-core: gsp: introduce and use proper RpcMessageHeader type
This commit untangles the GSP command queue transport and message layer code by making the RPC message header more explicit. It introduces the RpcMessageHeader wrapping type to replace GspMsgElement for querying RPC header data. The initialization of the RPC header is now handled separately by the command queue code.
Quoted 3 lines
drivers/gpu/nova-core/gsp/cmdq.rs +0
-0
[ ... ]
Quoted 5 lines
drivers/gpu/nova-core/gsp/cmdq.rs +1
-0@@ -768,16 +774,28 @@ fn wait_for_msg(&self, timeout: Delta) -> Result<GspMessage<'_>> {// Extract the `GspMsgElement`. let (header, slice_1) =GspMsgElement ::from_bytes_prefix (slice_1).ok_or (EIO )?; +// Validate checksum.
drivers/gpu/nova-core/gsp/cmdq.rs fn wait_for_msg(&self, timeout: Delta) -> Result<GspMessage<'_>> { · line 787
Quoted 10 lines
drivers/gpu/nova-core/gsp/cmdq.rs +10
-0+if Cmdq ::calculate_checksum (SBufferIter ::new_reader ([ + header.as_bytes (), + slice_1, + slice_2, + ])) !=0 + { +dev_err! (&self.dev,"GSP receive: bad checksum\n" ); +return Err (EIO ); + } +
[Severity: High]
Does this code compute the checksum over the entire untruncated message buffers?
By moving Cmdq::calculate_checksum() to run before slice_1 and slice_2 are truncated to payload_length, it appears to process uninitialized page padding and any subsequent messages present in the ring buffer.
The previous code correctly computed the checksum over the exact message size after truncating the slices:
// Cut the message slices down to the actual length of the message.
let (slice_1, slice_2) = if slice_1.len() > payload_length {
...
};
// Validate checksum.
if Cmdq::calculate_checksum( ... ) != 0Could this result in the driver dropping valid GSP messages due to spurious checksum failures, stalling the command queue and preventing GPU initialization?
It appears this flaw persists in the final commit of the series (41ab580cce9e4df6dca3c50983301c4f117e6a64). Even though the code is refactored into wait_for_element() and wait_for_rpc_msg(), wait_for_element() still calls calculate_checksum() on the untruncated slices before returning the message to wait_for_rpc_msg() where the size truncation finally happens.
Quoted 41 lines
drivers/gpu/nova-core/gsp/cmdq.rs +6
-20+let rpc_header = header.rpc_header (); +let payload_length = rpc_header.length (); +dev_dbg! ( &self.dev,"GSP RPC: receive: seq# {}, function={:?}, length=0x{:x}\n" , - header.sequence (), - header.function (), - header.length (), + rpc_header.sequence (), + rpc_header.function (), + payload_length, ); -let payload_length = header.payload_length (); -// Check that the driver read area is large enough for the message. if slice_1.len () + slice_2.len () < payload_length {return Err (EIO );@@ -796,21 +814,6 @@ fn wait_for_msg(&self, timeout: Delta) -> Result<GspMessage<'_>> { ) }; -// Validate checksum. -if Cmdq ::calculate_checksum (SBufferIter ::new_reader ([ - header.as_bytes (), - slice_1, - slice_2, - ])) !=0 - { -dev_err! ( - &self.dev, -"GSP RPC: receive: Call {} - bad checksum\n" , - header.sequence () - ); -return Err (EIO ); - } -Ok (GspMessage { header, contents: (slice_1, slice_2),
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Alexandre Courbot
maintainerPATCH 4/10 gpu: nova-core: gsp: cmdq: group the RPC-specific part of send_single_command
In reply to Alexandre Courbotsend_single_command handles both the transport and message layers of the command, intertwining the logic of the two.
Reorder the code so the message layer logic is within the same contiguous block of code, so it can easily be moved.
No functional change intended.
--- drivers/gpu/nova-core/gsp/cmdq.rs | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-)
drivers/gpu/nova-core/gsp/cmdq.rs +17 -14
@@ -659,18 +659,21 @@ fn send_single_command<M>(&mut self, command: M) -> Result .gsp_mem .allocate_command (size_in_bytes,Self ::ALLOCATE_TIMEOUT )?; +// Fill the header. +let msg_element_init =GspMsgElement ::init (self.seq, size_in_bytes); +// SAFETY: `msg_header` is a valid reference, and not touched if the initializer fails. +unsafe { + pin_init::raw_try_init (core::ptr::from_mut (dst.header), msg_element_init)?; + } +// Extract area for the command itself. The GSP message header and the command header // together are guaranteed to fit entirely into a single page, so it's ok to only look // at `dst.contents.0` here. let (cmd, payload_1) =M ::Command ::from_bytes_mut_prefix (dst.contents.0 ).ok_or (EIO )?; - -// Fill the header and command in-place. -let msg_element_init =GspMsgElement ::init (self.seq, size_in_bytes);let rpc_header_init =RpcMessageHeader ::init (size_in_bytes,M ::FUNCTION ); -// SAFETY: `msg_header` and `cmd` are valid references, and not touched if the initializer -// fails. +// SAFETY: `rpc_header_mut()` and `cmd` are valid references, and not touched if the +// initializer fails. unsafe { - pin_init::raw_try_init (core::ptr::from_mut (dst.header), msg_element_init)?; pin_init::raw_try_init ( core::ptr::from_mut (dst.header.rpc_header_mut ()), rpc_header_init,
@@ -687,14 +690,6 @@ fn send_single_command<M>(&mut self, command: M) -> Result }drop (sbuffer); -// Compute checksum now that the whole message is ready. - dst.header - .set_checksum (Cmdq ::calculate_checksum (SBufferIter ::new_reader ([ - dst.header.as_bytes (), - dst.contents.0 , - dst.contents.1 , - ]))); -dev_dbg! ( &self.dev,"GSP RPC: send: seq# {}, function={:?}, length=0x{:x}\n" ,
@@ -703,6 +698,14 @@ fn send_single_command<M>(&mut self, command: M) -> Result size_in_bytes, ); +// Compute checksum now that the whole message is ready. + dst.header + .set_checksum (Cmdq ::calculate_checksum (SBufferIter ::new_reader ([ + dst.header.as_bytes (), + dst.contents.0 , + dst.contents.1 , + ]))); +// All set - update the write pointer and inform the GSP of the new command. let elem_count = dst.header.element_count (); self.seq +=1 ;
Signature · 1 line
2.55.0
Alexandre Courbot
maintainerPATCH 5/10 gpu: nova-core: gsp: cmdq: split the transport part of the send path
In reply to Alexandre CourbotMove the transport part of send_single_command into send_command_element, which allocates the queue slots, writes the element header, calls a closure to fill the remainder of the command, then computes the checksum, advances the write pointer and rings the doorbell.
The RPC part of send_single_command (writing the RPC header and the command payload) is passed as a closure, unchanged apart from its indentation. This sets things up for moving the RPC code into its own sub-module, leaving the transport agnostic of the message type.
No functional change intended.
--- drivers/gpu/nova-core/gsp/cmdq.rs | 118 ++++++++++++++++++++++++-------------- 1 file changed, 74 insertions(+), 44 deletions(-)
drivers/gpu/nova-core/gsp/cmdq.rs +74 -44
@@ -638,65 +638,35 @@ impl CmdqInner<'_> {/// Timeout for waiting for space on the command queue. const ALLOCATE_TIMEOUT :Delta =Delta ::from_secs (1 ); -/// Sends `command` to the GSP, without splitting it. +/// Allocates enough send slots to store a command of `sizes_in_bytes` length, initialize them +/// using `command_init`, and send the command to the GSP. /// /// # Errors /// /// - `EMSGSIZE` if the command exceeds the maximum queue element size. /// - `ETIMEDOUT` if space does not become available within the timeout. -/// - `EIO` if the variable payload requested by the command has not been entirely -/// written to by its [`CommandToGsp::init_variable_payload`] method. /// -/// Error codes returned by the command initializers are propagated as-is. -fn send_single_command <M >(&mut self, command:M ) ->Result -where -M :CommandToGsp , -// This allows all error types, including `Infallible`, to be used for `M::InitError`. -Error :From <M ::InitError >, - { -let size_in_bytes = command.size (); -let dst = self +/// Error codes returned by `command_init` are returned as-is. +fn send_command_element ( + &mut self, + size_in_bytes:usize , + command_init:impl FnOnce (&mut GspCommand <'_>) ->Result , + ) ->Result { +let mut dst = self .gsp_mem .allocate_command (size_in_bytes,Self ::ALLOCATE_TIMEOUT )?; +let seq = self.seq; +// Fill the header. -let msg_element_init =GspMsgElement ::init (self.seq, size_in_bytes); +let msg_element_init =GspMsgElement ::init (seq, size_in_bytes);// SAFETY: `msg_header` is a valid reference, and not touched if the initializer fails. unsafe { pin_init::raw_try_init (core::ptr::from_mut (dst.header), msg_element_init)?; } -// Extract area for the command itself. The GSP message header and the command header -// together are guaranteed to fit entirely into a single page, so it's ok to only look -// at `dst.contents.0` here. -let (cmd, payload_1) =M ::Command ::from_bytes_mut_prefix (dst.contents.0 ).ok_or (EIO )?; -let rpc_header_init =RpcMessageHeader ::init (size_in_bytes,M ::FUNCTION ); -// SAFETY: `rpc_header_mut()` and `cmd` are valid references, and not touched if the -// initializer fails. -unsafe { - pin_init::raw_try_init ( - core::ptr::from_mut (dst.header.rpc_header_mut ()), - rpc_header_init, - )?; - pin_init::raw_try_init (core::ptr::from_mut (cmd), command.init ())?; - } - -// Fill the variable-length payload, which may be empty. -let mut sbuffer =SBufferIter ::new_writer ([&mut payload_1[..], &mut dst.contents.1 [..]]); - command.init_variable_payload (&mut sbuffer)?; - -if !sbuffer.is_empty () { -return Err (EIO ); - } -drop (sbuffer); - -dev_dbg! ( - &self.dev, -"GSP RPC: send: seq# {}, function={:?}, length=0x{:x}\n" , - self.seq, -M ::FUNCTION , - size_in_bytes, - ); +// Initialize the message payload. +command_init (&mut dst)?;// Compute checksum now that the whole message is ready. dst.header
@@ -715,6 +685,66 @@ fn send_single_command<M>(&mut self, command: M) -> ResultOk (()) } +/// Sends `command` to the GSP, without splitting it. +/// +/// # Errors +/// +/// - `EMSGSIZE` if the command exceeds the maximum queue element size. +/// - `ETIMEDOUT` if space does not become available within the timeout. +/// - `EIO` if the variable payload requested by the command has not been entirely +/// written to by its [`CommandToGsp::init_variable_payload`] method. +/// +/// Error codes returned by the command initializers are propagated as-is. +fn send_single_command <M >(&mut self, command:M ) ->Result +where +M :CommandToGsp , +// This allows all error types, including `Infallible`, to be used for `M::InitError`. +Error :From <M ::InitError >, + { +let dev = self.dev; +let seq = self.seq; +let size_in_bytes = command.size (); + +let init = |dst: &mut GspCommand <'_>| { +// Extract area for the command itself. The GSP message header and the command header +// together are guaranteed to fit entirely into a single page, so it's ok to only look +// at `dst.contents.0` here. +let (cmd, payload_1) =M ::Command ::from_bytes_mut_prefix (dst.contents.0 ).ok_or (EIO )?; +let rpc_header_init =RpcMessageHeader ::init (size_in_bytes,M ::FUNCTION ); + +// SAFETY: `rpc_header_mut()` and `cmd` are valid references, and not touched if the +// initializer fails. +unsafe { + pin_init::raw_try_init ( + core::ptr::from_mut (dst.header.rpc_header_mut ()), + rpc_header_init, + )?; + pin_init::raw_try_init (core::ptr::from_mut (cmd), command.init ())?; + } + +// Fill the variable-length payload, which may be empty. +let mut sbuffer = +SBufferIter ::new_writer ([&mut payload_1[..], &mut dst.contents.1 [..]]); + command.init_variable_payload (&mut sbuffer)?; + +if !sbuffer.is_empty () { +return Err (EIO ); + } + +dev_dbg! ( + dev, +"GSP RPC: send: seq# {}, function={:?}, length=0x{:x}\n" , + seq, +M ::FUNCTION , + size_in_bytes, + ); + +Ok (()) + }; + + self.send_command_element (size_in_bytes, init) + } +/// Sends `command` to the GSP. /// /// The command may be split into multiple messages if it is large.
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH 05/10] gpu: nova-core: gsp: cmdq: split the transport part of the send path
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] gpu: nova-core: spurious checksum failure due to un-truncated slices - [High] gpu: nova-core…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] gpu: nova-core: spurious checksum failure due to un-truncated slices
- [High] gpu: nova-core: infinite loop via unvalidated element_count from GSP --
commit 90b2987a6783eb2acf6f7b5e9bf5e7fbc3108e1d
Author: Alexandre Courbot <[email protected]>
gpu: nova-core: gsp: cmdq: split the transport part of the send path
Move the transport part of send_single_command into send_command_element. The RPC part of send_single_command is passed as a closure to set up moving the RPC code into its own sub-module. No functional change intended.
Quoted 4 lines
drivers/gpu/nova-core/gsp/cmdq.rs +0
-0
[ ... ]
drivers/gpu/nova-core/gsp/cmdq.rs fn wait_for_msg(&self, timeout: Delta) -> Result<GspMessage<'_>> { · line 816
Quoted 11 lines
drivers/gpu/nova-core/gsp/cmdq.rs +7
-0@@ -768,16 +807,28 @@ fn wait_for_msg(&self, timeout: Delta) -> Result<GspMessage<'_>> {// Extract the `GspMsgElement`. let (header, slice_1) =GspMsgElement ::from_bytes_prefix (slice_1).ok_or (EIO )?; +// Validate checksum. +if Cmdq ::calculate_checksum (SBufferIter ::new_reader ([ + header.as_bytes (), + slice_1, + slice_2, + ])) !=0 + {
[Severity: High]
Does this code spuriously fail the checksum validation when the GSP leaves padding in the ring buffer or batches messages?
The patch moves the Cmdq::calculate_checksum call in wait_for_msg before slice_1 and slice_2 are truncated to the actual payload_length. Because calculate_checksum iterates and hashes all bytes in the slices, it will now hash the entire available read area (including trailing ring buffer data) instead of just the single message.
Quoted 3 lines
drivers/gpu/nova-core/gsp/cmdq.rs +3
-0+dev_err! (&self.dev,"GSP receive: bad checksum\n" ); +return Err (EIO ); + }
[ ... ]
drivers/gpu/nova-core/gsp/cmdq.rs fn receive_msg<M: MessageFromGsp>(&mut self, timeout: Delta) -> Result<M> · line 903
Quoted 9 lines
drivers/gpu/nova-core/gsp/cmdq.rs +2
-3@@ -863,9 +899,8 @@ fn receive_msg<M: MessageFromGsp>(&mut self, timeout: Delta) -> Result<M> };// Advance the read pointer past this message. - self.gsp_mem.advance_cpu_read_ptr (u32::try_from ( - message.header.length ().div_ceil (GSP_PAGE_SIZE ), - )?); + self.gsp_mem + .advance_cpu_read_ptr (message.header.element_count ());
[Severity: High]
Can an untrusted or erroneously crafted message header from the GSP cause an infinite loop here?
The patch changes the read pointer advancement in receive_msg to use message.header.element_count() (the raw elemCount field from the GSP) instead of safely deriving it from the bounded payload length.
If the GSP firmware provides an elemCount of 0 (or a multiple of MSGQ_NUM_PAGES, i.e., 63), advance_cpu_read_ptr adds 0 to the read pointer. If the driver then encounters an unexpected function code and retries, it will continuously re-read the exact same zero-advancing message, resulting in a deadlock.
Quoted 3 lines
drivers/gpu/nova-core/gsp/cmdq.rs +0
-0result }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
Alexandre Courbot
maintainerPATCH 6/10 gpu: nova-core: gsp: cmdq: move the RPC send code into a sub-module
In reply to Alexandre CourbotMove the types and code related to sending a RPC command into the rpc sub-module. The methods are still declared as members of CmdqInner and Cmdq; only they are now in their own sub-module.
This is a pure move commit, with no functional change intended.
---
drivers/gpu/nova-core/gsp/cmdq.rs | 214 +-----------------
drivers/gpu/nova-core/gsp/cmdq/rpc.rs | 248 +++++++++++++++++++++
.../nova-core/gsp/cmdq/{ => rpc}/continuation.rs | 0
drivers/gpu/nova-core/gsp/commands.rs | 2 +-
4 files changed, 251 insertions(+), 213 deletions(-)drivers/gpu/nova-core/gsp/cmdq.rs +2 -212
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0 +// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -mod continuation; +pub (crate )mod rpc;use core::mem;
@@ -35,11 +36,6 @@ }, }; -use continuation::{ -ContinuationRecord , -SplitState ,// -}; -use pin_init::pin_init_scope;use crate ::{
@@ -50,7 +46,6 @@ MsgFunction, MsgqRxHeader, MsgqTxHeader, - RpcMessageHeader, GSP_MSG_QUEUE_ELEMENT_SIZE_MAX, // }, PteArray,
@@ -67,68 +62,6 @@/// reply type are sent using [`Cmdq::send_command_no_wait`]. pub (crate )struct NoReply ; -/// Trait implemented by types representing a command to send to the GSP. -/// -/// The main purpose of this trait is to provide [`Cmdq`] with the information it needs to send -/// a given command. -/// -/// [`CommandToGsp::init`] in particular is responsible for initializing the command directly -/// into the space reserved for it in the command queue buffer. -/// -/// Some commands may be followed by a variable-length payload. For these, the -/// [`CommandToGsp::variable_payload_len`] and [`CommandToGsp::init_variable_payload`] need to be -/// defined as well. -pub (crate )trait CommandToGsp { -/// Function identifying this command to the GSP. -const FUNCTION :MsgFunction ; - -/// Type generated by [`CommandToGsp::init`], to be written into the command queue buffer. -type Command :FromBytes +AsBytes ; - -/// Type of the reply expected from the GSP, or [`NoReply`] for commands that don't -/// have a reply. -type Reply ; - -/// Error type returned by [`CommandToGsp::init`]. -type InitError ; - -/// In-place command initializer responsible for filling the command in the command queue -/// buffer. -fn init (&self) ->impl Init <Self ::Command ,Self ::InitError >; - -/// Size of the variable-length payload following the command structure generated by -/// [`CommandToGsp::init`]. -/// -/// Most commands don't have a variable-length payload, so this is zero by default. -fn variable_payload_len (&self) ->usize { -0 - } - -/// Method initializing the variable-length payload. -/// -/// The command buffer is circular, which means that we may need to jump back to its beginning -/// while in the middle of a command. For this reason, the variable-length payload is -/// initialized using a [`SBufferIter`]. -/// -/// This method will receive a buffer of the length returned by -/// [`CommandToGsp::variable_payload_len`], and must write every single byte of it. Leaving -/// unwritten space will lead to an error. -/// -/// Most commands don't have a variable-length payload, so this does nothing by default. -fn init_variable_payload ( - &self, - _dst: &mut SBufferIter <core::array::IntoIter <&mut [u8 ],2 >>, - ) ->Result { -Ok (()) - } - -/// Total size of the command (including its variable-length payload) without the -/// [`GspMsgElement`] header. -fn size (&self) ->usize { -size_of ::<Self ::Command >() + self.variable_payload_len () - } -} -/// Trait representing messages received from the GSP. /// /// This trait tells [`Cmdq::receive_msg`] how it can receive a given type of message.
@@ -558,58 +491,6 @@ fn notify_gsp(bar: Bar0<'_>) { bar.write_reg (regs::NV_PGSP_QUEUE_HEAD ::zeroed ().with_address (0u32 )); } -/// Sends `command` to the GSP and waits for the reply. -/// -/// Messages with non-matching function codes are silently consumed until the expected reply -/// arrives. -/// -/// The queue is locked for the entire send+receive cycle to ensure that no other command can -/// be interleaved. -/// -/// # Errors -/// -/// - `ETIMEDOUT` if space does not become available to send the command, or if the reply is -/// not received within the timeout. -/// - `EIO` if the variable payload requested by the command has not been entirely -/// written to by its [`CommandToGsp::init_variable_payload`] method. -/// -/// Error codes returned by the command and reply initializers are propagated as-is. -pub (crate )fn send_command <M >(&self, command:M ) ->Result <M ::Reply > -where -M :CommandToGsp , -M ::Reply :MessageFromGsp , -Error :From <M ::InitError >, -Error :From <<M ::Reply as MessageFromGsp >::InitError >, - { -let mut inner = self.inner.lock (); - inner.send_command (command)?; - -loop { -match inner.receive_msg ::<M ::Reply >(Self ::RECEIVE_TIMEOUT ) { -Ok (reply) =>break Ok (reply), -Err (ERANGE ) =>continue , -Err (e) =>break Err (e), - } - } - } - -/// Sends `command` to the GSP without waiting for a reply. -/// -/// # Errors -/// -/// - `ETIMEDOUT` if space does not become available within the timeout. -/// - `EIO` if the variable payload requested by the command has not been entirely -/// written to by its [`CommandToGsp::init_variable_payload`] method. -/// -/// Error codes returned by the command initializers are propagated as-is. -pub (crate )fn send_command_no_wait <M >(&self, command:M ) ->Result -where -M :CommandToGsp <Reply =NoReply >, -Error :From <M ::InitError >, - { - self.inner.lock ().send_command (command) - } -/// Receive a message from the GSP. /// /// See [`CmdqInner::receive_msg`] for details.
@@ -685,97 +566,6 @@ fn send_command_element(Ok (()) } -/// Sends `command` to the GSP, without splitting it. -/// -/// # Errors -/// -/// - `EMSGSIZE` if the command exceeds the maximum queue element size. -/// - `ETIMEDOUT` if space does not become available within the timeout. -/// - `EIO` if the variable payload requested by the command has not been entirely -/// written to by its [`CommandToGsp::init_variable_payload`] method. -/// -/// Error codes returned by the command initializers are propagated as-is. -fn send_single_command <M >(&mut self, command:M ) ->Result -where -M :CommandToGsp , -// This allows all error types, including `Infallible`, to be used for `M::InitError`. -Error :From <M ::InitError >, - { -let dev = self.dev; -let seq = self.seq; -let size_in_bytes = command.size (); - -let init = |dst: &mut GspCommand <'_>| { -// Extract area for the command itself. The GSP message header and the command header -// together are guaranteed to fit entirely into a single page, so it's ok to only look -// at `dst.contents.0` here. -let (cmd, payload_1) =M ::Command ::from_bytes_mut_prefix (dst.contents.0 ).ok_or (EIO )?; -let rpc_header_init =RpcMessageHeader ::init (size_in_bytes,M ::FUNCTION ); - -// SAFETY: `rpc_header_mut()` and `cmd` are valid references, and not touched if the -// initializer fails. -unsafe { - pin_init::raw_try_init ( - core::ptr::from_mut (dst.header.rpc_header_mut ()), - rpc_header_init, - )?; - pin_init::raw_try_init (core::ptr::from_mut (cmd), command.init ())?; - } - -// Fill the variable-length payload, which may be empty. -let mut sbuffer = -SBufferIter ::new_writer ([&mut payload_1[..], &mut dst.contents.1 [..]]); - command.init_variable_payload (&mut sbuffer)?; - -if !sbuffer.is_empty () { -return Err (EIO ); - } - -dev_dbg! ( - dev, -"GSP RPC: send: seq# {}, function={:?}, length=0x{:x}\n" , - seq, -M ::FUNCTION , - size_in_bytes, - ); - -Ok (()) - }; - - self.send_command_element (size_in_bytes, init) - } - -/// Sends `command` to the GSP. -/// -/// The command may be split into multiple messages if it is large. -/// -/// # Errors -/// -/// - `ETIMEDOUT` if space does not become available within the timeout. -/// - `EIO` if the variable payload requested by the command has not been entirely -/// written to by its [`CommandToGsp::init_variable_payload`] method. -/// -/// Error codes returned by the command initializers are propagated as-is. -fn send_command <M >(&mut self, command:M ) ->Result -where -M :CommandToGsp , -Error :From <M ::InitError >, - { -match SplitState ::new (command)? { -SplitState ::Single (command) => self.send_single_command (command), -SplitState ::Split (command,mut continuations) => { - self.send_single_command (command)?; - -while let Some (continuation) = continuations.next () { -// Turbofish needed because the compiler cannot infer M here. - self.send_single_command ::<ContinuationRecord <'_>>(continuation)?; - } - -Ok (()) - } - } - } -/// Wait for a message to become available on the message queue. /// /// This works purely at the transport layer and does not interpret or validate the message
drivers/gpu/nova-core/gsp/cmdq/rpc.rs new file +248 -0
248 lines not on this page · raw message
drivers/gpu/nova-core/gsp/cmdq/rpc/continuation.rs renamed from drivers/gpu/nova-core/gsp/cmdq/continuation.rs +0 -0
drivers/gpu/nova-core/gsp/commands.rs +1 -1
@@ -23,8 +23,8 @@ gpu::Chipset, gsp::{ cmdq::{ + rpc::CommandToGsp, Cmdq, -CommandToGsp , MessageFromGsp, NoReply, // },
Signature · 1 line
2.55.0
Alexandre Courbot
maintainerPATCH 7/10 gpu: nova-core: gsp: cmdq: split the transport part of the receive path
In reply to Alexandre Courbotwait_for_msg mixes two layers: the transport layer which polls the queue, extracts the element header and validates the checksum, and the RPC layer which reads the RPC header and trims the payload slices to the length advertised by the RPC header.
Move the transport layer into wait_for_element, and make wait_for_msg call it before validating the RPC layer. This sets things up for moving the RPC code into its own module, leaving the transport agnostic of the message type.
No functional change intended.
--- drivers/gpu/nova-core/gsp/cmdq.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
drivers/gpu/nova-core/gsp/cmdq.rs +15 -1
@@ -584,7 +584,7 @@ fn send_command_element(/// message queue. /// /// Error codes returned by the message constructor are propagated as-is. -fn wait_for_msg (&self, timeout:Delta ) ->Result <GspMessage <'_>> { +fn wait_for_element (&self, timeout:Delta ) ->Result <GspMessage <'_>> {// Wait for a message to arrive from the GSP. let (slice_1, slice_2) =read_poll_timeout ( || Ok(self.gsp_mem.driver_read_area()),
@@ -608,6 +608,18 @@ fn wait_for_msg(&self, timeout: Delta) -> Result<GspMessage<'_>> {return Err (EIO ); } +Ok (GspMessage { + header, + contents: (slice_1, slice_2), + }) + } + +fn wait_for_msg (&self, timeout:Delta ) ->Result <GspMessage <'_>> { +let GspMessage { + header, + contents: (slice_1, slice_2), + } = self.wait_for_element (timeout)?; +let rpc_header = header.rpc_header ();let payload_length = rpc_header.length ();
@@ -619,6 +631,8 @@ fn wait_for_msg(&self, timeout: Delta) -> Result<GspMessage<'_>> { payload_length, ); +// Validate the RPC layer before returning the message. +// Check that the driver read area is large enough for the message. if slice_1.len () + slice_2.len () < payload_length {return Err (EIO );
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH 07/10] gpu: nova-core: gsp: cmdq: split the transport part of the receive path
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] gpu/nova-core: checksum validation fails on untrimmed queue buffer slices - [High] gpu/nova-core…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] gpu/nova-core: checksum validation fails on untrimmed queue buffer slices
- [High] gpu/nova-core: unvalidated element_count from GSP allows arbitrary read pointer manipulation --
commit 4799dd94b859632b92a2a5821daacb47098f5faa
Author: Alexandre Courbot <[email protected]>
gpu: nova-core: gsp: cmdq: split the transport part of the receive path
This commit splits wait_for_msg into wait_for_element and wait_for_msg. The transport layer is moved into wait_for_element, while the RPC layer that trims the payload slices remains in wait_for_msg. This prepares the code for moving the RPC layer into its own module.
Quoted 4 lines
drivers/gpu/nova-core/gsp/cmdq.rs +0
-0
[ ... ]
Quoted 19 lines
drivers/gpu/nova-core/gsp/cmdq.rs +7
-1@@ -755,7 +584,7 @@ fn send_command<M>(&mut self, command: M) -> Result/// message queue. /// /// Error codes returned by the message constructor are propagated as-is. -fn wait_for_msg (&self, timeout:Delta ) ->Result <GspMessage <'_>> { +fn wait_for_element (&self, timeout:Delta ) ->Result <GspMessage <'_>> {// Wait for a message to arrive from the GSP. let (slice_1, slice_2) =read_poll_timeout ( || Ok(self.gsp_mem.driver_read_area()),@@ -768,15 +597,41 @@ fn wait_for_msg(&self, timeout: Delta) -> Result<GspMessage<'_>> {// Extract the `GspMsgElement`. let (header, slice_1) =GspMsgElement ::from_bytes_prefix (slice_1).ok_or (EIO )?; +// Validate checksum. + if Cmdq::calculate_checksum(SBufferIter::new_reader([ + header.as_bytes(), + slice_1, + slice_2, + ])) != 0
drivers/gpu/nova-core/gsp/cmdq.rs fn wait_for_msg(&self, timeout: Delta) -> Result<GspMessage<'_>> { · line 615
Quoted 10 lines
drivers/gpu/nova-core/gsp/cmdq.rs +10
-0+ { +dev_err! (&self.dev,"GSP receive: bad checksum\n" ); +return Err (EIO ); + } + +Ok (GspMessage { + header, + contents: (slice_1, slice_2), + }) + }
[Severity: High]
Does this code calculate the checksum over the entire available read area, including trailing padding or queued messages?
In the original wait_for_msg(), slice_1 and slice_2 were trimmed to the message payload_length before the checksum calculation. Since wait_for_element() performs validation before trimming, won't valid messages fail the checksum if there's extra data in the buffer?
[ ... ]
drivers/gpu/nova-core/gsp/cmdq.rs fn receive_msg<M: MessageFromGsp>(&mut self, timeout: Delta) -> Result<M> · line 710
Quoted 12 lines
drivers/gpu/nova-core/gsp/cmdq.rs +2
-3@@ -863,9 +703,8 @@ fn receive_msg<M: MessageFromGsp>(&mut self, timeout: Delta) -> Result<M> };// Advance the read pointer past this message. - self.gsp_mem.advance_cpu_read_ptr (u32::try_from ( - message.header.length ().div_ceil (GSP_PAGE_SIZE ), - )?); + self.gsp_mem + .advance_cpu_read_ptr (message.header.element_count ()); result }
[Severity: High]
Does this code allow an untrusted GSP to arbitrarily manipulate the host's ring buffer read pointer?
The element_count() value comes directly from the GSP message header and is never validated against the available read area or queue capacity, unlike payload_length.
Can a malicious GSP send a small payload but a huge element_count to force the kernel to process uninitialized memory or stale data?
(Note: In the final state of the patch series, this logic ends up in receive_rpc_msg(), but the vulnerability is introduced here).
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7
Alexandre Courbot
maintainerPATCH 8/10 gpu: nova-core: gsp: cmdq: move the RPC receive code into a sub-module
In reply to Alexandre CourbotMove the types and code related to receiving a RPC message into the rpc sub-module. The methods are still declared as members of CmdqInner and Cmdq; only they are now in their own sub-module.
This is a pure move commit, with no functional change intended.
--- drivers/gpu/nova-core/gsp/cmdq.rs | 130 -------------------------------- drivers/gpu/nova-core/gsp/cmdq/rpc.rs | 132 ++++++++++++++++++++++++++++++++- drivers/gpu/nova-core/gsp/commands.rs | 6 +- drivers/gpu/nova-core/gsp/sequencer.rs | 4 +- 4 files changed, 137 insertions(+), 135 deletions(-)
drivers/gpu/nova-core/gsp/cmdq.rs +0 -130
@@ -43,7 +43,6 @@ gsp::{ fw::{GspMsgElement , -MsgFunction ,MsgqRxHeader ,MsgqTxHeader ,GSP_MSG_QUEUE_ELEMENT_SIZE_MAX ,//
@@ -62,29 +61,6 @@/// reply type are sent using [`Cmdq::send_command_no_wait`]. pub (crate )struct NoReply ; -/// Trait representing messages received from the GSP. -/// -/// This trait tells [`Cmdq::receive_msg`] how it can receive a given type of message. -pub (crate )trait MessageFromGsp :Sized { -/// Function identifying this message from the GSP. -const FUNCTION :MsgFunction ; - -/// Error type returned by [`MessageFromGsp::read`]. -type InitError ; - -/// Type containing the raw message to be read from the message queue. -type Message :FromBytes ; - -/// Method reading the message from the message queue and returning it. -/// -/// From a `Self::Message` and a [`SBufferIter`], constructs an instance of `Self` and returns -/// it. -fn read ( - msg: &Self ::Message , - sbuffer: &mut SBufferIter <core::array::IntoIter <&[u8 ],2 >>, - ) ->Result <Self ,Self ::InitError >; -} -/// Number of GSP pages making the [`Msgq`]. pub (crate )const MSGQ_NUM_PAGES :u32 =0x3f ;
@@ -490,17 +466,6 @@ fn calculate_checksum<T: Iterator<Item = u8>>(it: T) -> u32 {fn notify_gsp (bar:Bar0 <'_>) { bar.write_reg (regs::NV_PGSP_QUEUE_HEAD ::zeroed ().with_address (0u32 )); } - -/// Receive a message from the GSP. -/// -/// See [`CmdqInner::receive_msg`] for details. -pub (crate )fn receive_msg <M :MessageFromGsp >(&self, timeout:Delta ) ->Result <M > -where -// This allows all error types, including `Infallible`, to be used for `M::InitError`. -Error :From <M ::InitError >, - { - self.inner.lock ().receive_msg (timeout) - } }/// Inner mutex protected state of [`Cmdq`].
@@ -613,99 +578,4 @@ fn wait_for_element(&self, timeout: Delta) -> Result<GspMessage<'_>> { contents: (slice_1, slice_2), }) } - -fn wait_for_msg (&self, timeout:Delta ) ->Result <GspMessage <'_>> { -let GspMessage { - header, - contents: (slice_1, slice_2), - } = self.wait_for_element (timeout)?; - -let rpc_header = header.rpc_header (); -let payload_length = rpc_header.length (); - -dev_dbg! ( - &self.dev, -"GSP RPC: receive: seq# {}, function={:?}, length=0x{:x}\n" , - rpc_header.sequence (), - rpc_header.function (), - payload_length, - ); - -// Validate the RPC layer before returning the message. - -// Check that the driver read area is large enough for the message. -if slice_1.len () + slice_2.len () < payload_length { -return Err (EIO ); - } - -// Cut the message slices down to the actual length of the message. -let (slice_1, slice_2) =if slice_1.len () > payload_length { -// PANIC: we checked above that `slice_1` is at least as long as `payload_length`. - (slice_1.split_at (payload_length).0 , &slice_2[0 ..0 ]) - }else { - ( - slice_1, -// PANIC: we checked above that `slice_1.len() + slice_2.len()` is at least as -// large as `payload_length`. - slice_2.split_at (payload_length - slice_1.len ()).0 , - ) - }; - -Ok (GspMessage { - header, - contents: (slice_1, slice_2), - }) - } - -/// Receive a message from the GSP. -/// -/// The expected message type is specified using the `M` generic parameter. If the pending -/// message has a different function code, `ERANGE` is returned and the message is consumed. -/// -/// The read pointer is always advanced past the message, regardless of whether it matched. -/// -/// # Errors -/// -/// - `ETIMEDOUT` if `timeout` has elapsed before any message becomes available. -/// - `EIO` if there was some inconsistency (e.g. message shorter than advertised) on the -/// message queue. -/// - `EINVAL` if the function code of the message was not recognized. -/// - `ERANGE` if the message had a recognized but non-matching function code. -/// -/// Error codes returned by [`MessageFromGsp::read`] are propagated as-is. -fn receive_msg <M :MessageFromGsp >(&mut self, timeout:Delta ) ->Result <M > -where -// This allows all error types, including `Infallible`, to be used for `M::InitError`. -Error :From <M ::InitError >, - { -let message = self.wait_for_msg (timeout)?; -let function = message.header.rpc_header ().function ().map_err (|_|EINVAL )?; - -// Extract the message. Store the result as we want to advance the read pointer even in -// case of failure. -let result =if function ==M ::FUNCTION { -let (cmd, contents_1) =M ::Message ::from_bytes_prefix (message.contents.0 ).ok_or (EIO )?; -let mut sbuffer =SBufferIter ::new_reader ([contents_1, message.contents.1 ]); - -M ::read (cmd, &mut sbuffer) - .map_err (|e| e.into ()) - .inspect (|_| { -if !sbuffer.is_empty () { -dev_warn! ( - &self.dev, -"GSP message {:?} has unprocessed data\n" , - function - ); - } - }) - }else { -Err (ERANGE ) - }; - -// Advance the read pointer past this message. - self.gsp_mem - .advance_cpu_read_ptr (message.header.element_count ()); - - result - } }
drivers/gpu/nova-core/gsp/cmdq/rpc.rs +131 -1
160 lines not on this page · raw message
drivers/gpu/nova-core/gsp/commands.rs +4 -2
@@ -23,9 +23,11 @@ gpu::Chipset, gsp::{ cmdq::{ - rpc::CommandToGsp, + rpc::{ +CommandToGsp , +MessageFromGsp ,// + }, Cmdq, - MessageFromGsp, NoReply, // }, fw::{
drivers/gpu/nova-core/gsp/sequencer.rs +2 -2
@@ -28,8 +28,8 @@ }, gsp::{ cmdq::{ - Cmdq, - MessageFromGsp, // + rpc::MessageFromGsp, + Cmdq, // }, fw, GspBootContext,
Signature · 1 line
2.55.0
Alexandre Courbot
maintainerPATCH 9/10 gpu: nova-core: gsp: move the RPC commands into a sub-module
In reply to Alexandre CourbotMove the types and code related to RPC commands into the rpc sub-module, and update their users to reference them from their new location.
This is a pure move commit, with no functional change intended.
--- drivers/gpu/nova-core/gpu.rs | 2 +- drivers/gpu/nova-core/gsp.rs | 4 +- drivers/gpu/nova-core/gsp/boot.rs | 12 +- drivers/gpu/nova-core/gsp/commands.rs | 314 +---------------------------- drivers/gpu/nova-core/gsp/commands/rpc.rs | 316 ++++++++++++++++++++++++++++++ 5 files changed, 326 insertions(+), 322 deletions(-)
drivers/gpu/nova-core/gpu.rs +1 -1
@@ -34,7 +34,7 @@ fsp::Fsp, gsp::{ self, - commands::GetGspStaticInfoReply, + commands::rpc::GetGspStaticInfoReply,Gsp ,GspBootContext ,// },
drivers/gpu/nova-core/gsp.rs +2 -2
@@ -220,8 +220,8 @@ pub(crate) fn new( }/// Query the GSP for the static GPU information. -pub (crate )fn get_static_info (&self) ->Result <commands::GetGspStaticInfoReply > { - self.cmdq.send_command (commands::GetGspStaticInfo ) +pub (crate )fn get_static_info (&self) ->Result <commands::rpc::GetGspStaticInfoReply > { + self.cmdq.send_command (commands::rpc::GetGspStaticInfo ) } }
drivers/gpu/nova-core/gsp/boot.rs +6 -6
@@ -43,9 +43,9 @@ pub(crate) fn boot(let gsp_fw =KBox ::pin_init (GspFirmware ::new (dev, chipset),GFP_KERNEL )?; self.cmdq - .send_command_no_wait (commands::SetSystemInfo ::new (pdev, chipset))?; + .send_command_no_wait (commands::rpc::SetSystemInfo ::new (pdev, chipset))?; self.cmdq - .send_command_no_wait (commands::SetRegistry ::new (ctx.vgpu.state ())?)?; + .send_command_no_wait (commands::rpc::SetRegistry ::new (ctx.vgpu.state ())?)?;// Perform the chipset-specific boot sequence, and retrieve the unload bundle. let unload_bundle = hal.boot(&self, &mut ctx, &gsp_fw)?.or_else(|| {
@@ -79,7 +79,7 @@ pub(crate) fn boot( hal.post_boot (&self, ctx, &gsp_fw)?;// Wait until GSP is fully initialized. - commands::wait_gsp_init_done (&self.cmdq)?; + commands::rpc::wait_gsp_init_done (&self.cmdq)?;Ok (unload_guard.dismiss ().1 ) }
@@ -88,10 +88,10 @@ pub(crate) fn boot(fn shutdown_gsp ( cmdq: &Cmdq <'_>, gsp_falcon: &Falcon <'_,Gsp >, - mode: commands::PowerStateLevel , + mode: commands::rpc::PowerStateLevel , ) ->Result {// Command to shut the GSP down. - cmdq.send_command (commands::UnloadingGuestDriver ::new (mode))?; + cmdq.send_command (commands::rpc::UnloadingGuestDriver ::new (mode))?;// Wait until GSP signals it is suspended. const LIBOS_INTERRUPT_PROCESSOR_SUSPENDED :u32 = bits::bit_u32 (31 );
@@ -118,7 +118,7 @@ pub(crate) fn unload(let mut res =Self ::shutdown_gsp ( &self.cmdq, ctx.gsp_falcon, - commands::PowerStateLevel ::Level0 , + commands::rpc::PowerStateLevel ::Level0 , ) .inspect_err (|e|dev_err! (dev,"GSP shutdown failed: {:?}\n" , e));
drivers/gpu/nova-core/gsp/commands.rs +1 -313
317 lines not on this page · raw message
drivers/gpu/nova-core/gsp/commands/rpc.rs new file +316 -0
316 lines not on this page · raw message
Signature · 1 line
2.55.0
Alexandre Courbot
maintainerPATCH 10/10 gpu: nova-core: gsp: add `rpc` to RPC message send/receive methods
In reply to Alexandre CourbotSince we are going to introduce a second type of message, add rpc to the names of the relevant command queue methods so we can distinguish between the two.
No functional change intended.
--- drivers/gpu/nova-core/gsp.rs | 2 +- drivers/gpu/nova-core/gsp/boot.rs | 6 +++--- drivers/gpu/nova-core/gsp/cmdq/rpc.rs | 30 +++++++++++++++--------------- drivers/gpu/nova-core/gsp/commands/rpc.rs | 2 +- drivers/gpu/nova-core/gsp/sequencer.rs | 2 +- 5 files changed, 21 insertions(+), 21 deletions(-)
drivers/gpu/nova-core/gsp.rs +1 -1
@@ -221,7 +221,7 @@ pub(crate) fn new(/// Query the GSP for the static GPU information. pub (crate )fn get_static_info (&self) ->Result <commands::rpc::GetGspStaticInfoReply > { - self.cmdq.send_command (commands::rpc::GetGspStaticInfo ) + self.cmdq.send_rpc_command (commands::rpc::GetGspStaticInfo ) } }
drivers/gpu/nova-core/gsp/boot.rs +3 -3
@@ -43,9 +43,9 @@ pub(crate) fn boot(let gsp_fw =KBox ::pin_init (GspFirmware ::new (dev, chipset),GFP_KERNEL )?; self.cmdq - .send_command_no_wait (commands::rpc::SetSystemInfo ::new (pdev, chipset))?; + .send_rpc_command_no_wait (commands::rpc::SetSystemInfo ::new (pdev, chipset))?; self.cmdq - .send_command_no_wait (commands::rpc::SetRegistry ::new (ctx.vgpu.state ())?)?; + .send_rpc_command_no_wait (commands::rpc::SetRegistry ::new (ctx.vgpu.state ())?)?;// Perform the chipset-specific boot sequence, and retrieve the unload bundle. let unload_bundle = hal.boot(&self, &mut ctx, &gsp_fw)?.or_else(|| {
@@ -91,7 +91,7 @@ fn shutdown_gsp( mode: commands::rpc::PowerStateLevel, ) -> Result {// Command to shut the GSP down. - cmdq.send_command(commands::rpc::UnloadingGuestDriver::new(mode))?; + cmdq.send_rpc_command(commands::rpc::UnloadingGuestDriver::new(mode))?;// Wait until GSP signals it is suspended. const LIBOS_INTERRUPT_PROCESSOR_SUSPENDED :u32 = bits::bit_u32 (31 );
drivers/gpu/nova-core/gsp/cmdq/rpc.rs +15 -15
@@ -135,7 +135,7 @@ impl CmdqInner<'_> {/// written to by its [`CommandToGsp::init_variable_payload`] method. /// /// Error codes returned by the command initializers are propagated as-is. -fn send_single_command <M >(&mut self, command:M ) ->Result +fn send_single_rpc_command <M >(&mut self, command:M ) ->Result where M :CommandToGsp ,// This allows all error types, including `Infallible`, to be used for `M::InitError`.
@@ -196,19 +196,19 @@ fn send_single_command<M>(&mut self, command: M) -> Result/// written to by its [`CommandToGsp::init_variable_payload`] method. /// /// Error codes returned by the command initializers are propagated as-is. -fn send_command <M >(&mut self, command:M ) ->Result +fn send_rpc_command <M >(&mut self, command:M ) ->Result where M :CommandToGsp ,Error :From <M ::InitError >, {match SplitState ::new (command)? { -SplitState ::Single (command) => self.send_single_command (command), +SplitState ::Single (command) => self.send_single_rpc_command (command),SplitState ::Split (command,mut continuations) => { - self.send_single_command (command)?; + self.send_single_rpc_command (command)?;while let Some (continuation) = continuations.next () {// Turbofish needed because the compiler cannot infer M here. - self.send_single_command ::<ContinuationRecord <'_>>(continuation)?; + self.send_single_rpc_command ::<ContinuationRecord <'_>>(continuation)?; }Ok (())
@@ -216,7 +216,7 @@ fn send_command<M>(&mut self, command: M) -> Result } } -fn wait_for_msg (&self, timeout:Delta ) ->Result <GspMessage <'_>> { +fn wait_for_rpc_msg (&self, timeout:Delta ) ->Result <GspMessage <'_>> {let GspMessage { header, contents: (slice_1, slice_2),
@@ -275,12 +275,12 @@ fn wait_for_msg(&self, timeout: Delta) -> Result<GspMessage<'_>> {/// - `ERANGE` if the message had a recognized but non-matching function code. /// /// Error codes returned by [`MessageFromGsp::read`] are propagated as-is. -fn receive_msg <M :MessageFromGsp >(&mut self, timeout:Delta ) ->Result <M > +fn receive_rpc_msg <M :MessageFromGsp >(&mut self, timeout:Delta ) ->Result <M >where // This allows all error types, including `Infallible`, to be used for `M::InitError`. Error :From <M ::InitError >, { -let message = self.wait_for_msg (timeout)?; +let message = self.wait_for_rpc_msg (timeout)?;let function = message.header.rpc_header ().function ().map_err (|_|EINVAL )?;// Extract the message. Store the result as we want to advance the read pointer even in
@@ -329,7 +329,7 @@ impl Cmdq<'_> {/// written to by its [`CommandToGsp::init_variable_payload`] method. /// /// Error codes returned by the command and reply initializers are propagated as-is. -pub (crate )fn send_command <M >(&self, command:M ) ->Result <M ::Reply > +pub (crate )fn send_rpc_command <M >(&self, command:M ) ->Result <M ::Reply >where M :CommandToGsp ,M ::Reply :MessageFromGsp ,
@@ -337,10 +337,10 @@ pub(crate) fn send_command<M>(&self, command: M) -> Result<M::Reply> Error: From<<M::Reply as MessageFromGsp>::InitError>, {let mut inner = self.inner.lock (); - inner.send_command (command)?; + inner.send_rpc_command (command)?;loop { -match inner.receive_msg ::<M ::Reply >(Self ::RECEIVE_TIMEOUT ) { +match inner.receive_rpc_msg ::<M ::Reply >(Self ::RECEIVE_TIMEOUT ) {Ok (reply) =>break Ok (reply),Err (ERANGE ) =>continue ,Err (e) =>break Err (e),
@@ -357,22 +357,22 @@ pub(crate) fn send_command<M>(&self, command: M) -> Result<M::Reply>/// written to by its [`CommandToGsp::init_variable_payload`] method. /// /// Error codes returned by the command initializers are propagated as-is. -pub (crate )fn send_command_no_wait <M >(&self, command:M ) ->Result +pub (crate )fn send_rpc_command_no_wait <M >(&self, command:M ) ->Result where M :CommandToGsp <Reply =NoReply >,Error :From <M ::InitError >, { - self.inner.lock ().send_command (command) + self.inner.lock ().send_rpc_command (command) }/// Receive a message from the GSP. /// /// See [`CmdqInner::receive_msg`] for details. -pub (crate )fn receive_msg <M :MessageFromGsp >(&self, timeout:Delta ) ->Result <M > +pub (crate )fn receive_rpc_msg <M :MessageFromGsp >(&self, timeout:Delta ) ->Result <M >where // This allows all error types, including `Infallible`, to be used for `M::InitError`. Error :From <M ::InitError >, { - self.inner.lock ().receive_msg (timeout) + self.inner.lock ().receive_rpc_msg (timeout) } }
drivers/gpu/nova-core/gsp/commands/rpc.rs +1 -1
@@ -191,7 +191,7 @@ fn read(/// Waits for GSP initialization to complete. pub (crate )fn wait_gsp_init_done (cmdq: &Cmdq <'_>) ->Result {loop { -match cmdq.receive_msg ::<GspInitDone >(Cmdq ::RECEIVE_TIMEOUT ) { +match cmdq.receive_rpc_msg ::<GspInitDone >(Cmdq ::RECEIVE_TIMEOUT ) {Ok (_) =>break Ok (()),Err (ERANGE ) =>continue ,Err (e) =>break Err (e),
drivers/gpu/nova-core/gsp/sequencer.rs +1 -1
@@ -344,7 +344,7 @@ pub(crate) fn run( bootloader_app_version: u32, ) -> Result { let seq_info = loop { - match cmdq.receive_msg::<GspSequence>(Cmdq::RECEIVE_TIMEOUT) { + match cmdq.receive_rpc_msg::<GspSequence>(Cmdq::RECEIVE_TIMEOUT) { Ok(seq_info) => break seq_info, Err(ERANGE) => continue, Err(e) => return Err(e),
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH 10/10] gpu: nova-core: gsp: add `rpc` to RPC message send/receive methods
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] rust: broken rustdoc intra-doc links after method renaming --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] rust: broken rustdoc intra-doc links after method renaming
--
commit 41ab580cce9e4df6dca3c50983301c4f117e6a64
Author: Alexandre Courbot <[email protected]>
gpu: nova-core: gsp: add rpc to RPC message send/receive methods
Since we are going to introduce a second type of message, add rpc to the names of the relevant command queue methods so we can distinguish between the two.
Quoted 4 lines
drivers/gpu/nova-core/gsp/cmdq/rpc.rs +0
-0
[ ... ]
drivers/gpu/nova-core/gsp/cmdq/rpc.rs fn send_command<M>(&mut self, command: M) -> Result · line 220
Quoted 7 lines
drivers/gpu/nova-core/gsp/cmdq/rpc.rs +1
-1@@ -216,7 +216,7 @@ fn send_command<M>(&mut self, command: M) -> Result } } -fn wait_for_msg (&self, timeout:Delta ) ->Result <GspMessage <'_>> { +fn wait_for_rpc_msg (&self, timeout:Delta ) ->Result <GspMessage <'_>> { let GspMessage {
[Severity: Low]
Are there stale rustdoc links in drivers/gpu/nova-core/gsp/cmdq.rs after this rename?
drivers/gpu/nova-core/gsp/cmdq.rs:
/// This is the type returned by [CmdqInner::wait_for_msg]. struct GspMessage<'a> {
Quoted 2 lines
drivers/gpu/nova-core/gsp/cmdq/rpc.rs +0
-0header, contents: (slice_1, slice_2),
[ ... ]
drivers/gpu/nova-core/gsp/cmdq/rpc.rs fn wait_for_msg(&self, timeout: Delta) -> Result<GspMessage<'_>> { · line 278
Quoted 6 lines
drivers/gpu/nova-core/gsp/cmdq/rpc.rs +1
-1@@ -275,12 +275,12 @@ fn wait_for_msg(&self, timeout: Delta) -> Result<GspMessage<'_>> {/// - `ERANGE` if the message had a recognized but non-matching function code. /// /// Error codes returned by [`MessageFromGsp::read`] are propagated as-is. -fn receive_msg <M :MessageFromGsp >(&mut self, timeout:Delta ) ->Result <M > +fn receive_rpc_msg <M :MessageFromGsp >(&mut self, timeout:Delta ) ->Result <M >
[Severity: Low]
Could this method rename break the intra-doc link for MessageFromGsp in this same file?
drivers/gpu/nova-core/gsp/cmdq/rpc.rs:
/// This trait tells [Cmdq::receive_msg] how it can receive a given type of message. pub(crate) trait MessageFromGsp: Sized {
Quoted 6 lines
drivers/gpu/nova-core/gsp/cmdq/rpc.rs +1
-1where // This allows all error types, including `Infallible`, to be used for `M::InitError`. Error: From<M::InitError>, { -let message = self.wait_for_msg (timeout)?; +let message = self.wait_for_rpc_msg (timeout)?;
[ ... ]
drivers/gpu/nova-core/gsp/cmdq/rpc.rs pub(crate) fn send_command<M>(&self, command: M) -> Result<M::Reply> · line 360
Quoted 6 lines
drivers/gpu/nova-core/gsp/cmdq/rpc.rs +1
-1@@ -357,22 +357,22 @@ pub(crate) fn send_command<M>(&self, command: M) -> Result<M::Reply>/// written to by its [`CommandToGsp::init_variable_payload`] method. /// /// Error codes returned by the command initializers are propagated as-is. -pub (crate )fn send_command_no_wait <M >(&self, command:M ) ->Result +pub (crate )fn send_rpc_command_no_wait <M >(&self, command:M ) ->Result
[Severity: Low]
Will this change leave a broken rustdoc link in drivers/gpu/nova-core/gsp/cmdq.rs?
drivers/gpu/nova-core/gsp/cmdq.rs:
/// Marker type representing the absence of a reply for a command. Commands using this as their /// reply type are sent using [Cmdq::send_command_no_wait].
pub(crate) struct NoReply;
drivers/gpu/nova-core/gsp/cmdq/rpc.rs pub(crate) fn send_command<M>(&self, command: M) -> Result<M::Reply> · line 371
Quoted 13 lines
drivers/gpu/nova-core/gsp/cmdq/rpc.rs +2
-2where M: CommandToGsp<Reply = NoReply>, Error: From<M::InitError>, { - self.inner.lock().send_command(command) + self.inner.lock().send_rpc_command(command) }/// Receive a message from the GSP. /// /// See [`CmdqInner::receive_msg`] for details. - pub(crate) fn receive_msg<M: MessageFromGsp>(&self, timeout: Delta) -> Result<M> + pub(crate) fn receive_rpc_msg<M: MessageFromGsp>(&self, timeout: Delta) -> Result<M>
[Severity: Low]
It looks like this method rename might have missed its own doc comment right above it:
/// See [`CmdqInner::receive_msg`] for details.
Quoted 8 lines
drivers/gpu/nova-core/gsp/cmdq/rpc.rs +1
-1where // This allows all error types, including `Infallible`, to be used for `M::InitError`. Error: From<M::InitError>, { - self.inner.lock ().receive_msg (timeout) + self.inner.lock ().receive_rpc_msg (timeout) } }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=10
Alexandre Courbot
maintainerQuoted 38 lines · Alexandre Courbot
The upcoming r000 firmware support [1] introduces a new type of command named GMC alongside the existing and already supported RPC command type.
Since RPC was the only command type supported so far, it was embedded into the lowest command queue level: the message header actually includes the RPC header and the code considers them as one.
This makes the r000/GMC support difficult to land without a refactor, with the result of transport layer code being duplicated between the two message types, and no clear separation between the RPC and GMC code which are mixed together in the command queue. Merging the code that way would introduce quite some technical debt.
Thus, this series prepares a proper landing ground for a new message type by extracting all the RPC layer code and moving it into its own sub-modules, making the
cmdqmodule completely agnostic of the type of message it transports. By the end of the series, the only mention of RPC incmdq.rsis for therpcsub-module.With the transport and message layers properly separated, support for GMC can be added into sibling modules of
rpc, and the transport layer can be converted once when doing the switch to r000.This moves quite a bit of code around, but most of it is moved verbatim. No significant functional change is intended.
For the r000 series, this essentially means the following:
- Its patch 7 making
allocate_commandgeneric can be dropped as the transport layer makes no assumption about the message type.
- Patches adding GMC support will do it in dedicatedgmcsub-modules, following the model set by RPC. Thesegmcsub-modules will start asdead_codeas they are being built.
- The "switch to r000" patch will essentially operate on the transport layer level, i.e.cmdq.rs.
- There should be no need for extra post-switch RPC fixing, as the transport layer code will already be shared with GMC.
Quoted 4 lines
Overall, this should make the r000 series much easier to review and eventually land, while not creating new technical debt.
This series is based on
drm-rust-next.
Sashiko has found a couple of serious issues, and I've found another I had overlooked, so please ignore this revision. I will send v2 shortly.