gpu: nova-core: gsp: add locking to Cmdq
Subsystems (4)
cover gpu: nova-core: gsp: add locking to Cmdq
Add locking to Cmdq. This is required e.g. for unloading the driver, which needs to send the UnloadingGuestDriver via the command queue on unbind which may be on a different thread.
We have commands that need a reply ("sync") and commands that don't ("async"). For sync commands we want to make sure that they don't get the reply of a different command back. The approach this patch series takes is by making sync commands block until they get a response. For now this should be ok, and we expect GSP to be fast anyway.
To do this, we need to know which commands expect a reply and which don't. John's existing series[1] adds IS_ASYNC which solves part of the problem, but we need to know a bit more. So instead, add an associated type called Reply which tells us what the reply is.
An alternative would be to define traits inheriting CommandToGsp, e.g. SyncCommand and AsyncCommand, instead of using the associated type. I implemented the associated type version because it feels more compositional rather than inherity so seemed a bit better to me. But both of these approaches work and are fine, IMO.
In summary, this patch series has three steps:
1. Add the type infrastructure to know what replies are expected for a command and update each caller to explicitly send a sync or async command.
2. Make Cmdq pinned so we can use Mutex
3. Add a Mutex to protect Cmdq by moving the relevant state to an inner struct.
[1]: https://lore.kernel.org/all/[email protected]/
---
Eliot Courtney (4):
gpu: nova-core: gsp: fix stale doc comments on command queue methods
gpu: nova-core: gsp: add sync and async command queue API to Cmdq
gpu: nova-core: gsp: make Cmdq a pinned type
gpu: nova-core: gsp: add mutex locking to Cmdq
drivers/gpu/nova-core/gsp.rs | 5 +- drivers/gpu/nova-core/gsp/boot.rs | 13 +- drivers/gpu/nova-core/gsp/cmdq.rs | 240 ++++++++++++++++++++++----------- drivers/gpu/nova-core/gsp/commands.rs | 23 ++-- drivers/gpu/nova-core/gsp/sequencer.rs | 2 +- 5 files changed, 182 insertions(+), 101 deletions(-)
---
base-commit: 4f938c7d3b25d87b356af4106c2682caf8c835a2
change-id: 20260225-cmdq-locking-d32928a2c2cf
prerequisite-message-id: <[email protected]>
prerequisite-patch-id: bd2da0d580038dbab7ef06c0508d157873796ff4
prerequisite-patch-id: f834078971a3a46babe131251353184ffd7ecc38
prerequisite-patch-id: db5049ec7fe4348eed9e54dd5a2c07c697a54c81
prerequisite-patch-id: bafdd38cb9aba355a796232e07d5bbcd6fc59ba5
prerequisite-patch-id: 72a8d4626458707ae4ed632c629ffb6728cee032
prerequisite-message-id: <[email protected]>
prerequisite-patch-id: 20003099ca19d81b6255c5e95148f6584c108a29
prerequisite-patch-id: d0f59ef489346e978a222755f9fb42dfe7af19e5
prerequisite-patch-id: 8844970d0e387488c70979a73732579ba174b46c
prerequisite-patch-id: e138a94ed48fa8d50d5ed1eb36524f98923ed478
prerequisite-patch-id: 4599a5e90d6665fa3acb7d4045de5d378ac28b4d
prerequisite-patch-id: 7975f5bcaf28a99202d86d755fc256cd25be9cc4
prerequisite-patch-id: ee694b609c76628508d12fbe9b8b5a8a9354bfc4
prerequisite-patch-id: 1bb2f05c6a409a39421586e8148f82fa62ce6875
prerequisite-patch-id: a932945cb83fb631ebff3ac76ffff4319cacaabe
Best regards,
Signature · 1 line
Eliot Courtney <[email protected]>
PATCH 1/4 gpu: nova-core: gsp: fix stale doc comments on command queue methods
Fix some inaccuracies / old doc comments.
--- drivers/gpu/nova-core/gsp/cmdq.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/gpu/nova-core/gsp/cmdq.rs +8 -9
@@ -528,6 +528,7 @@ fn notify_gsp(bar: &Bar0) {/// /// # 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.
@@ -710,22 +711,20 @@ fn wait_for_msg(&self, timeout: Delta) -> Result<GspMessage<'_>> {/// Receive a message from the GSP. /// -/// `init` is a closure tasked with processing the message. It receives a reference to the -/// message in the message queue, and a [`SBufferIter`] pointing to its variable-length -/// payload, if any. +/// 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 expected message is specified using the `M` generic parameter. If the pending message -/// is different, `EAGAIN` is returned and the unexpected message is dropped. -/// -/// This design is by no means final, but it is simple and will let us go through GSP -/// initialization. +/// 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 of the message was unrecognized. +/// - `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. pub (crate )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`.
Signature · 1 line
2.53.0
Re: [PATCH 1/4] gpu: nova-core: gsp: fix stale doc comments on command queue methods
On Wed, 25 Feb 2026 22:41:48 +0900
Eliot Courtney <[email protected]> wrote:
Quoted 59 lines
Fix some inaccuracies / old doc comments.
Signed-off-by Eliot Courtney <[email protected]>--- drivers/gpu/nova-core/gsp/cmdq.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/nova-core/gsp/cmdq.rsindex436d1ff20705..cfae5b35adec100644 ---a/drivers/gpu/nova-core/gsp/cmdq.rs
+++b/drivers/gpu/nova-core/gsp/cmdq.rsdrivers/gpu/nova-core/gsp/cmdq.rs +1
-0@@ -528,6 +528,7 @@ fn notify_gsp(bar: &Bar0) {/// /// # Errors /// +/// - `EMSGSIZE` if the command exceeds the maximum queue element size. /// -
ETIMEDOUTif space does not become available within the timeout. /// -EIOif the variable payload requested by
the command has not been entirely /// written to by its
[CommandToGsp::init_variable_payload] method. @@ -710,22 +711,20 @@fn wait_for_msg(&self, timeout: Delta) -> Result<GspMessage<'_>> { /// Receive a message from the GSP. ///- ///
initis a closure tasked with processing the message. It
receives a reference to the
- /// message in the message queue, and a [SBufferIter] pointing
to its variable-length(quoted diff) +1
-1- /// payload, if any. + /// The expected message type is specified using the `M` genericparameter. If the pending
+ /// message has a different function code,ERANGEis returned
and the message is consumed. ///
- /// The expected message is specified using theMgeneric
parameter. If the pending message
- /// is different,EAGAINis returned and the unexpected
message is dropped.(quoted diff) +0
-2- /// - /// This design is by no means final, but it is simple and willlet us go through GSP
(quoted diff) +1
-1- /// initialization. + /// The read pointer is always advanced past the message,regardless of whether it matched. ///
/// # Errors /// /// - `ETIMEDOUT` if `timeout` has elapsed before any messagebecomes available. /// -
EIOif there was some inconsistency (e.g.
message shorter than advertised) on the /// message queue.(quoted diff) +1
-1- /// - `EINVAL` if the function of the message was unrecognized. + /// - `EINVAL` if the function code of the message was notrecognized.
+ /// -ERANGEif the message had a recognized but non-matching
function code.(quoted diff) +2
-0+ /// + /// Error codes returned by [`MessageFromGsp::read`] arepropagated as-is. pub(crate) fn receive_msg<M: MessageFromGsp>(&mut self, timeout: Delta) -> Result<M> where
// This allows all error types, including `Infallible`, tobe used for
M::InitError.
PATCH 2/4 gpu: nova-core: gsp: add sync and async command queue API to `Cmdq`
In reply to Eliot CourtneyAdd sync and async command queue API and the type infrastructure to know what reply is expected from each CommandToGsp.
Use a marker type NoReply which does not implement MessageFromGsp to mark async commands which don't expect a response.
This prepares for adding locking to the queue.
--- drivers/gpu/nova-core/gsp/boot.rs | 5 ++-- drivers/gpu/nova-core/gsp/cmdq.rs | 54 ++++++++++++++++++++++++++++++++++- drivers/gpu/nova-core/gsp/commands.rs | 19 ++++++------ 3 files changed, 65 insertions(+), 13 deletions(-)
drivers/gpu/nova-core/gsp/boot.rs +3 -2
@@ -160,8 +160,9 @@ pub(crate) fn boot(dma_write! (wpr_meta[0 ] =GspFwWprMeta ::new (&gsp_fw, &fb_layout))?; self.cmdq - .send_command (bar, commands::SetSystemInfo ::new (pdev))?; - self.cmdq.send_command (bar, commands::SetRegistry ::new ())?; + .send_async_command (bar, commands::SetSystemInfo ::new (pdev))?; + self.cmdq + .send_async_command (bar, commands::SetRegistry ::new ())?; gsp_falcon.reset (bar)?;let libos_handle = self.libos.dma_handle ();
drivers/gpu/nova-core/gsp/cmdq.rs +53 -1
78 lines not on this page · raw message
drivers/gpu/nova-core/gsp/commands.rs +9 -10
@@ -26,7 +26,8 @@ command_size, Cmdq, CommandToGsp, - MessageFromGsp, // + MessageFromGsp, + NoReply, // }, fw::{ commands::*,
@@ -53,6 +54,7 @@ pub(crate) fn new(pdev: &'a pci::Device<device::Bound>) -> Self {impl <'a>CommandToGsp for SetSystemInfo <'a> {const FUNCTION :MsgFunction =MsgFunction ::GspSetSystemInfo ;type Command =GspSetSystemInfo ; +type Reply =NoReply ;type InitError =Error ;fn init (&self) ->impl Init <Self ::Command ,Self ::InitError > {
@@ -104,6 +106,7 @@ pub(crate) fn new() -> Self {impl CommandToGsp for SetRegistry {const FUNCTION :MsgFunction =MsgFunction ::SetRegistry ;type Command =PackedRegistryTable ; +type Reply =NoReply ;type InitError =Infallible ;fn init (&self) ->impl Init <Self ::Command ,Self ::InitError > {
@@ -183,6 +186,7 @@ pub(crate) fn wait_gsp_init_done(cmdq: &mut Cmdq) -> Result {impl CommandToGsp for GetGspStaticInfo {const FUNCTION :MsgFunction =MsgFunction ::GetGspStaticInfo ;type Command =GspStaticConfigInfo ; +type Reply =GetGspStaticInfoReply ;type InitError =Infallible ;fn init (&self) ->impl Init <Self ::Command ,Self ::InitError > {
@@ -236,15 +240,7 @@ pub(crate) fn gpu_name(&self) -> core::result::Result<&str, GpuNameError> {/// Send the [`GetGspInfo`] command and awaits for its reply. pub (crate )fn get_gsp_info (cmdq: &mut Cmdq , bar: &Bar0 ) ->Result <GetGspStaticInfoReply > { - cmdq.send_command (bar,GetGspStaticInfo )?; - -loop { -match cmdq.receive_msg ::<GetGspStaticInfoReply >(Delta ::from_secs (5 )) { -Ok (info) =>return Ok (info), -Err (ERANGE ) =>continue , -Err (e) =>return Err (e), - } - } + cmdq.send_sync_command (bar,GetGspStaticInfo ) }/// The `ContinuationRecord` command.
@@ -262,6 +258,7 @@ pub(crate) fn new(data: &'a [u8]) -> Self {impl <'a>CommandToGsp for ContinuationRecord <'a> {const FUNCTION :MsgFunction =MsgFunction ::ContinuationRecord ;type Command = (); +type Reply =NoReply ;type InitError =Infallible ;fn init (&self) ->impl Init <Self ::Command ,Self ::InitError > {
@@ -354,6 +351,7 @@ pub(crate) enum SplitCommand<'a, C: CommandToGsp> {impl <'a,C :CommandToGsp >CommandToGsp for SplitCommand <'a,C > {const FUNCTION :MsgFunction =C ::FUNCTION ;type Command =C ::Command ; +type Reply =C ::Reply ;type InitError =C ::InitError ;fn init (&self) ->impl Init <Self ::Command ,Self ::InitError > {
@@ -410,6 +408,7 @@ fn new(len: usize) -> Result<Self> {impl CommandToGsp for TestPayload {const FUNCTION :MsgFunction =MsgFunction ::Nop ;type Command = (); +type Reply =NoReply ;type InitError =Infallible ;fn init (&self) ->impl Init <Self ::Command ,Self ::InitError > {
Signature · 1 line
2.53.0
Re: [PATCH 2/4] gpu: nova-core: gsp: add sync and async command queue API to `Cmdq`
Quoted 3 lines · On Wed, 25 Feb 2026 22:41:49 +0900 Eliot Courtney <[email protected]> wrote:
Add sync and async command queue API and the type infrastructure to know what reply is expected from each
CommandToGsp.
snip
Review
Quoted 2 lines
(quoted diff) +2
-0+ loop { + match self.receive_msg::<M::Reply>(Delta::from_secs(10))
It turns out here the timeout is changed to 10s from 5s which was used in other places. Any problem you encountered during the debugging?
Z.
Quoted 115 lines
{
drivers/gpu/nova-core/gsp/cmdq.rs +12
-0+ 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.
+ /// -EIOif the variable payload requested by the command has
not been entirely
+ /// written to by its [CommandToGsp::init_variable_payload]
method.(quoted diff) +2
-0+ /// + /// Error codes returned by the command initializers arepropagated as-is.
+ pub(crate) fn send_async_command<M>(&mut self, bar: &Bar0,
command: M) -> Resultdrivers/gpu/nova-core/gsp/cmdq.rs +7
-0+ where + M: CommandToGsp<Reply = NoReply>, + Error: From<M::InitError>, + { + self.send_command (bar, command) + } +/// 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 diff --git
a/drivers/gpu/nova-core/gsp/commands.rsb/drivers/gpu/nova-core/gsp/commands.rsindex1683ebb4c685..b42e32dcc55c100644 ---a/drivers/gpu/nova-core/gsp/commands.rs+++b/drivers/gpu/nova-core/gsp/commands.rs@@ -26,7 +26,8 @@command_size, Cmdq,
CommandToGsp,drivers/gpu/nova-core/gsp/commands.rs +2
-1- MessageFromGsp, // + MessageFromGsp, + NoReply, // }, fw::{ commands::*,@@ -53,6 +54,7 @@ pub(crate) fn new(pdev: &'apci::Device<device::Bound>) -> Self { impl<'a> CommandToGsp for SetSystemInfo<'a> { const FUNCTION: MsgFunction =
MsgFunction::GspSetSystemInfo; type Command = GspSetSystemInfo;drivers/gpu/nova-core/gsp/commands.rs +4
-10+type Reply =NoReply ;type InitError =Error ;fn init (&self) ->impl Init <Self ::Command ,Self ::InitError > {@@ -104,6 +106,7 @@ pub(crate) fn new() -> Self {impl CommandToGsp for SetRegistry {const FUNCTION :MsgFunction =MsgFunction ::SetRegistry ;type Command =PackedRegistryTable ; +type Reply =NoReply ;type InitError =Infallible ;fn init (&self) ->impl Init <Self ::Command ,Self ::InitError > {@@ -183,6 +186,7 @@ pub(crate) fn wait_gsp_init_done(cmdq: &mut Cmdq) -> Result { impl CommandToGsp for GetGspStaticInfo {const FUNCTION :MsgFunction =MsgFunction ::GetGspStaticInfo ;type Command =GspStaticConfigInfo ; +type Reply =GetGspStaticInfoReply ;type InitError =Infallible ;fn init (&self) ->impl Init <Self ::Command ,Self ::InitError > {@@ -236,15 +240,7 @@ pub(crate) fn gpu_name(&self) -> core::result::Result<&str, GpuNameError> {/// Send the [`GetGspInfo`] command and awaits for its reply. pub (crate )fn get_gsp_info (cmdq: &mut Cmdq , bar: &Bar0 ) ->Result <GetGspStaticInfoReply > { - cmdq.send_command (bar,GetGspStaticInfo )?; - -loop { -match cmdq.receive_msg::<GetGspStaticInfoReply>(Delta::from_secs(5)) { -Ok (info) =>return Ok (info), -Err (ERANGE ) =>continue , -Err (e) =>return Err (e), - } - } + cmdq.send_sync_command (bar,GetGspStaticInfo ) }/// The
ContinuationRecordcommand.drivers/gpu/nova-core/gsp/commands.rs +3
-0@@ -262,6 +258,7 @@ pub(crate) fn new(data: &'a [u8]) -> Self {impl <'a>CommandToGsp for ContinuationRecord <'a> {const FUNCTION :MsgFunction =MsgFunction ::ContinuationRecord ;type Command = (); +type Reply =NoReply ;type InitError =Infallible ;fn init (&self) ->impl Init <Self ::Command ,Self ::InitError > {@@ -354,6 +351,7 @@ pub(crate) enum SplitCommand<'a, C: CommandToGsp> {impl <'a,C :CommandToGsp >CommandToGsp for SplitCommand <'a,C > {const FUNCTION :MsgFunction =C ::FUNCTION ;type Command =C ::Command ; +type Reply =C ::Reply ;type InitError =C ::InitError ;fn init (&self) ->impl Init <Self ::Command ,Self ::InitError > {@@ -410,6 +408,7 @@ fn new(len: usize) -> Result<Self> {impl CommandToGsp for TestPayload {const FUNCTION :MsgFunction =MsgFunction ::Nop ;type Command = (); +type Reply =NoReply ;type InitError =Infallible ;fn init (&self) ->impl Init <Self ::Command ,Self ::InitError > {
Re: [PATCH 2/4] gpu: nova-core: gsp: add sync and async command queue API to `Cmdq`
Quoted 7 lines · Zhi Wang
Quoted 3 lines · On Wed, 25 Feb 2026 22:41:49 +0900 Eliot Courtney <[email protected]> wrote:
Add sync and async command queue API and the type infrastructure to know what reply is expected from each
CommandToGsp.
Quoted 7 lines
snip
Review
Quoted 2 lines
(quoted diff) +2
-0+ loop { + match self.receive_msg::<M::Reply>(Delta::from_secs(10))It turns out here the timeout is changed to 10s from 5s which was used in other places. Any problem you encountered during the debugging?
No issues, but it /looked/ to me like the particular values didn't really matter so it would be fine and simpler to have a uniform 10 second timeout for now. Please LMK if you know this is wrong and the 5 second value is important and specifically chosen.
I think it's also fine to include the timeout as a parameter and would also fit the convention with receive_msg.
Thanks for the review~
PATCH 3/4 gpu: nova-core: gsp: make `Cmdq` a pinned type
In reply to Eliot CourtneyMake Cmdq a pinned type. This is needed to use Mutex, which is needed to add locking to Cmdq.
--- drivers/gpu/nova-core/gsp.rs | 5 +++-- drivers/gpu/nova-core/gsp/cmdq.rs | 9 ++++----- 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/gpu/nova-core/gsp.rs +3 -2
@@ -112,6 +112,7 @@ pub(crate) struct Gsp {/// RM log buffer. logrm: LogBuffer,/// Command queue. +#[pin] pub(crate) cmdq: Cmdq,/// RM arguments. rmargs: CoherentAllocation<GspArgumentsPadded>,
@@ -132,7 +133,7 @@ pub(crate) fn new(pdev: &pci::Device<device::Bound>) -> impl PinInit<Self, Error loginit: LogBuffer::new(dev)?, logintr: LogBuffer::new(dev)?, logrm: LogBuffer::new(dev)?, - cmdq: Cmdq::new(dev)?, + cmdq <- Cmdq::new(dev), rmargs: CoherentAllocation::<GspArgumentsPadded>::alloc_coherent( dev, 1,
@@ -149,7 +150,7 @@ pub(crate) fn new(pdev: &pci::Device<device::Bound>) -> impl PinInit<Self, Error libos[1 ] =LibosMemoryRegionInitArgument ::new ("LOGINTR" , &logintr.0 ) )?;dma_write! (libos[2 ] =LibosMemoryRegionInitArgument ::new ("LOGRM" , &logrm.0 ))?; -dma_write! (rmargs[0 ].inner = fw::GspArgumentsCached ::new (cmdq))?; +dma_write! (rmargs[0 ].inner = fw::GspArgumentsCached ::new (&cmdq))?;dma_write! (libos[3 ] =LibosMemoryRegionInitArgument ::new ("RMARGS" , rmargs))?; }, }))
drivers/gpu/nova-core/gsp/cmdq.rs +4 -5
@@ -474,6 +474,7 @@ pub(crate) fn command_size<M>(command: &M) -> usize/// /// Provides the ability to send commands and receive messages from the GSP using a shared memory /// area. +#[pin_data] pub (crate )struct Cmdq {/// Device this command queue belongs to. dev:ARef <device::Device >,
@@ -501,13 +502,11 @@ impl Cmdq {pub (crate )const NUM_PTES :usize =size_of ::<GspMem >() >>GSP_PAGE_SHIFT ;/// Creates a new command queue for `dev`. -pub (crate )fn new (dev: &device::Device <device::Bound >) ->Result <Cmdq > { -let gsp_mem =DmaGspMem ::new (dev)?; - -Ok (Cmdq { +pub (crate )fn new (dev: &device::Device <device::Bound >) ->impl PinInit <Self ,Error > + '_ { +try_pin_init! (Self { + gsp_mem:DmaGspMem ::new (dev)?, dev: dev.into (), seq:0 , - gsp_mem, }) }
Signature · 1 line
2.53.0
Re: [PATCH 3/4] gpu: nova-core: gsp: make `Cmdq` a pinned type
On Wed, 25 Feb 2026 22:41:50 +0900
Eliot Courtney <[email protected]> wrote:
Looks good to me.
Quoted 73 lines
Make
Cmdqa pinned type. This is needed to use Mutex, which is needed to add locking toCmdq.Signed-off-by Eliot Courtney <[email protected]>--- drivers/gpu/nova-core/gsp.rs | 5 +++-- drivers/gpu/nova-core/gsp/cmdq.rs | 9 ++++----- 2 files changed, 7 insertions(+), 7 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/nova-core/gsp.rsindex174feaca0a6b..a6f3918c20b1100644drivers/gpu/nova-core/gsp.rs +1
-0@@ -112,6 +112,7 @@ pub(crate) struct Gsp {/// RM log buffer. logrm: LogBuffer,/// Command queue. +#[pin] pub(crate) cmdq: Cmdq,/// RM arguments. rmargs: CoherentAllocation<GspArgumentsPadded>,@@ -132,7 +133,7 @@ pub(crate) fn new(pdev:&pci::Device<device::Bound>) -> impl PinInit<Self, Error loginit:
LogBuffer::new(dev)?, logintr:LogBuffer::new(dev)?,
logrm:LogBuffer::new(dev)?,drivers/gpu/nova-core/gsp.rs +1
-1- cmdq: Cmdq::new(dev)?, + cmdq <- Cmdq::new(dev), rmargs:CoherentAllocation::<GspArgumentsPadded>::alloc_coherent( dev,
1,drivers/gpu/nova-core/gsp.rs +0
-0@@ -149,7 +150,7 @@ pub(crate) fn new(pdev:&pci::Device<device::Bound>) -> impl PinInit<Self, Error libos[1] =
LibosMemoryRegionInitArgument::new("LOGINTR", &logintr.0) )?; dma_write!(libos[2] =
LibosMemoryRegionInitArgument::new("LOGRM", &logrm.0))?;
- dma_write!(rmargs[0].inner =fw::GspArgumentsCached::new(cmdq))?;
+ dma_write!(rmargs[0].inner =fw::GspArgumentsCached::new(&cmdq))?; dma_write!(libos[3] =LibosMemoryRegionInitArgument::new("RMARGS", rmargs))?; },}))(quoted diff) +0
-0
b/drivers/gpu/nova-core/gsp/cmdq.rsindexe1ca1bb9e07d..44c3e960c965100644 ---a/drivers/gpu/nova-core/gsp/cmdq.rs
+++b/drivers/gpu/nova-core/gsp/cmdq.rsdrivers/gpu/nova-core/gsp.rs +0
-0@@ -474,6 +474,7 @@ pub(crate) fn command_size<M>(command: &M) ->usize ///
/// Provides the ability to send commands and receive messages from
the GSP using a shared memory /// area.drivers/gpu/nova-core/gsp.rs +4
-5+#[pin_data] pub (crate )struct Cmdq {/// Device this command queue belongs to. dev:ARef <device::Device >,@@ -501,13 +502,11 @@ impl Cmdq {pub (crate )const NUM_PTES :usize =size_of ::<GspMem >() >>GSP_PAGE_SHIFT ;/// Creates a new command queue for `dev`. -pub (crate )fn new (dev: &device::Device <device::Bound >) ->Result <Cmdq > { -let gsp_mem =DmaGspMem ::new (dev)?; - -Ok (Cmdq { +pub (crate )fn new (dev: &device::Device <device::Bound >) ->impl PinInit <Self ,Error > + '_ { +try_pin_init! (Self { + gsp_mem:DmaGspMem ::new (dev)?, dev: dev.into (), seq:0 , - gsp_mem, })}
PATCH 4/4 gpu: nova-core: gsp: add mutex locking to Cmdq
In reply to Eliot CourtneyWrap Cmdq's mutable state in a new struct CmdqInner and wrap that in a Mutex. This lets Cmdq methods take &self instead of &mut self, which lets required commands be sent e.g. while unloading the driver.
The mutex is held over both send and receive in send_sync_command to make sure that it doesn't get the reply of some other command that could have been sent just beforehand.
--- drivers/gpu/nova-core/gsp/boot.rs | 8 +- drivers/gpu/nova-core/gsp/cmdq.rs | 260 ++++++++++++++++++--------------- drivers/gpu/nova-core/gsp/commands.rs | 4 +- drivers/gpu/nova-core/gsp/sequencer.rs | 2 +- 4 files changed, 152 insertions(+), 122 deletions(-)
drivers/gpu/nova-core/gsp/boot.rs +4 -4
@@ -128,7 +128,7 @@ fn run_fwsec_frts(/// /// Upon return, the GSP is up and running, and its runtime object given as return value. pub (crate )fn boot ( -mut self:Pin <&mut Self >, + self:Pin <&mut Self >, pdev: &pci::Device <device::Bound >, bar: &Bar0 , chipset: Chipset,
@@ -232,13 +232,13 @@ pub(crate) fn boot( dev: pdev.as_ref().into(), bar, }; -GspSequencer ::run (&mut self.cmdq, seq_params)?; +GspSequencer ::run (&self.cmdq, seq_params)?;// Wait until GSP is fully initialized. - commands::wait_gsp_init_done (&mut self.cmdq)?; + commands::wait_gsp_init_done (&self.cmdq)?;// Obtain and display basic GPU information. -let info = commands::get_gsp_info (&mut self.cmdq, bar)?; +let info = commands::get_gsp_info (&self.cmdq, bar)?;match info.gpu_name () {Ok (name) =>dev_info! (pdev.as_ref (),"GPU name: {}\n" , name),Err (e) =>dev_warn! (pdev.as_ref (),"GPU name unavailable: {:?}\n" , e),
drivers/gpu/nova-core/gsp/cmdq.rs +145 -115
356 lines not on this page · raw message
drivers/gpu/nova-core/gsp/commands.rs +2 -2
@@ -170,7 +170,7 @@ fn read( }/// Waits for GSP initialization to complete. -pub (crate )fn wait_gsp_init_done (cmdq: &mut Cmdq ) ->Result { +pub (crate )fn wait_gsp_init_done (cmdq: &Cmdq ) ->Result {loop {match cmdq.receive_msg ::<GspInitDone >(Delta ::from_secs (10 )) {Ok (_) =>break Ok (()),
@@ -239,7 +239,7 @@ pub(crate) fn gpu_name(&self) -> core::result::Result<&str, GpuNameError> { }/// Send the [`GetGspInfo`] command and awaits for its reply. -pub (crate )fn get_gsp_info (cmdq: &mut Cmdq , bar: &Bar0 ) ->Result <GetGspStaticInfoReply > { +pub (crate )fn get_gsp_info (cmdq: &Cmdq , bar: &Bar0 ) ->Result <GetGspStaticInfoReply > { cmdq.send_sync_command (bar,GetGspStaticInfo ) }
drivers/gpu/nova-core/gsp/sequencer.rs +1 -1
@@ -366,7 +366,7 @@ pub(crate) struct GspSequencerParams<'a> { }impl <'a>GspSequencer <'a> { -pub (crate )fn run (cmdq: &mut Cmdq , params:GspSequencerParams <'a>) ->Result { +pub (crate )fn run (cmdq: &Cmdq , params:GspSequencerParams <'a>) ->Result {let seq_info =loop {match cmdq.receive_msg ::<GspSequence >(Delta ::from_secs (10 )) {Ok (seq_info) =>break seq_info,
Signature · 1 line
2.53.0
Re: [PATCH 4/4] gpu: nova-core: gsp: add mutex locking to Cmdq
On Wed, 25 Feb 2026 22:41:51 +0900
Eliot Courtney <[email protected]> wrote:
Looks good to me.
Quoted 501 lines
Wrap
Cmdq's mutable state in a new structCmdqInnerand wrap that in a Mutex. This letsCmdqmethods take &self instead of &mut self, which lets required commands be sent e.g. while unloading the driver.The mutex is held over both send and receive in
send_sync_commandto make sure that it doesn't get the reply of some other command that could have been sent just beforehand.Signed-off-by Eliot Courtney <[email protected]>--- drivers/gpu/nova-core/gsp/boot.rs | 8 +- drivers/gpu/nova-core/gsp/cmdq.rs | 260 ++++++++++++++++++--------------- drivers/gpu/nova-core/gsp/commands.rs | 4 +- drivers/gpu/nova-core/gsp/sequencer.rs | 2 +- 4 files changed, 152insertions(+), 122 deletions(-)
(quoted diff) +0
-0
b/drivers/gpu/nova-core/gsp/boot.rsindex1cb21da855b9..cb583f57666a100644 ---a/drivers/gpu/nova-core/gsp/boot.rs
+++b/drivers/gpu/nova-core/gsp/boot.rs(quoted diff) +0
-0@@ -128,7 +128,7 @@ fn run_fwsec_frts( /// /// Upon return, the GSP is up and running, and its runtimeobject given as return value. pub(crate) fn boot(
drivers/gpu/nova-core/gsp/boot.rs +4
-4- mut self: Pin<&mut Self>, + self: Pin<&mut Self>, pdev: &pci::Device<device::Bound>, bar: &Bar0, chipset: Chipset,@@ -232,13 +232,13 @@ pub(crate) fn boot( dev: pdev.as_ref().into(), bar, }; -GspSequencer ::run (&mut self.cmdq, seq_params)?; +GspSequencer ::run (&self.cmdq, seq_params)?;// Wait until GSP is fully initialized. - commands::wait_gsp_init_done (&mut self.cmdq)?; + commands::wait_gsp_init_done (&self.cmdq)?;// Obtain and display basic GPU information. -let info = commands::get_gsp_info (&mut self.cmdq, bar)?; +let info = commands::get_gsp_info (&self.cmdq, bar)?;match info.gpu_name () {Ok (name) =>dev_info! (pdev.as_ref (),"GPU name: {}\n" ,name), Err(e) => dev_warn!(pdev.as_ref(), "GPU name unavailable:
{:?}\n", e), diff --gita/drivers/gpu/nova-core/gsp/cmdq.rsb/drivers/gpu/nova-core/gsp/cmdq.rsindex44c3e960c965..faf1e9d5072b100644 ---a/drivers/gpu/nova-core/gsp/cmdq.rs
+++b/drivers/gpu/nova-core/gsp/cmdq.rsdrivers/gpu/nova-core/gsp/cmdq.rs +5
-1@@ -16,8 +16,12 @@ }, dma_write, io::poll::read_poll_timeout, + new_mutex, prelude::*, - sync::aref::ARef, + sync::{ + aref::ARef, + Mutex, // + }, time::Delta, transmute::{AsBytes ,@@ -54,8 +58,8 @@/// Trait implemented by types representing a command to send to the GSP. ///
-/// The main purpose of this trait is to provide [Cmdq::send_command] with the information it -/// needs to send a given command. +/// 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. @@ -470,66 +474,15 @@ pub(crate) fn command_size<M>(command: &M) -> usize size_of::<M::Command>() +command.variable_payload_len()}drivers/gpu/nova-core/gsp/cmdq.rs +0
-3-/// GSP command queue. -/// -/// Provides the ability to send commands and receive messages from the GSP using a shared memory -/// area.
drivers/gpu/nova-core/gsp/cmdq.rs +2
-4-#[pin_data] -pub (crate )struct Cmdq { -/// Device this command queue belongs to. - dev:ARef <device::Device >, +/// Inner mutex protected state of [`Cmdq`]. +struct CmdqInner {/// Current command sequence number. seq:u32 ,/// Memory area shared with the GSP for communicating commands and messages.
gsp_mem: DmaGspMem,
}drivers/gpu/nova-core/gsp/cmdq.rs +0
-3-impl Cmdq { -/// Offset of the data after the PTEs. - const POST_PTE_OFFSET: usize = core::mem::offset_of!(GspMem,cpuq); -
(quoted diff) +0
-2- /// Offset of command queue ring buffer. - pub(crate) const CMDQ_OFFSET: usize =core::mem::offset_of!(GspMem, cpuq)
drivers/gpu/nova-core/gsp/cmdq.rs +0
-5- + core::mem::offset_of!(Msgq, msgq) - -Self ::POST_PTE_OFFSET ; - -/// Offset of message queue ring buffer. - pub(crate) const STATQ_OFFSET: usize =core::mem::offset_of!(GspMem, gspq)
drivers/gpu/nova-core/gsp/cmdq.rs +0
-5- + core::mem::offset_of!(Msgq, msgq) - -Self ::POST_PTE_OFFSET ; - -/// Number of page table entries for the GSP shared region. - pub(crate) const NUM_PTES: usize = size_of::<GspMem>() >>
GSP_PAGE_SHIFT; -(quoted diff) +0
-2- /// Creates a new command queue for `dev`. - pub(crate) fn new(dev: &device::Device<device::Bound>) -> implPinInit<Self, Error> + '_ {
drivers/gpu/nova-core/gsp/cmdq.rs +0
-10-try_pin_init! (Self { - gsp_mem:DmaGspMem ::new (dev)?, - dev: dev.into (), - seq:0 , - }) - } - -/// Computes the checksum for the message pointed to by `it`. -/// -/// A message is made of several parts, so `it` is an iterator over byte slices representing
drivers/gpu/nova-core/gsp/cmdq.rs +0
-6- /// these parts. - fn calculate_checksum<T: Iterator<Item = u8>>(it: T) -> u32 { - let sum64 = it - .enumerate() - .map(|(idx, byte)| (((idx % 8) * 8) as u32, byte)) - .fold(0, |acc, (rol, byte)| acc ^u64::from(byte).rotate_left(rol)); -
drivers/gpu/nova-core/gsp/cmdq.rs +0
-4- ((sum64 >>32 )as u32 ) ^ (sum64as u32 ) - } - -/// Notifies the GSP that we have updated the command queue pointers.
drivers/gpu/nova-core/gsp/cmdq.rs +1
-6-fn notify_gsp (bar: &Bar0 ) { - regs::NV_PGSP_QUEUE_HEAD ::default () - .set_address (0 ) - .write (bar); - } - +impl CmdqInner {/// Sends `command` to the GSP, without splitting it. /// /// # Errors @@ -540,7 +493,7 @@ fn notify_gsp(bar: &Bar0) {/// written to by its [`CommandToGsp::init_variable_payload`] method. ///
/// Error codes returned by the command initializers arepropagated as-is.
- fn send_single_command<M>(&mut self, bar: &Bar0, command: M) ->
Result
+ fn send_single_command<M>(&mut self, dev:&device::Device, bar:
&Bar0, command: M) -> Result whereM: CommandToGsp, // This allows all error types, including `Infallible`, to be used for `M::InitError`. @@ -583,7 +536,7 @@ fn send_single_command<M>(&mut self, bar: &Bar0, command: M) -> Result ]))); dev_dbg!(drivers/gpu/nova-core/gsp/cmdq.rs +1
-1- &self.dev, + dev, "GSP RPC: send: seq# {}, function={}, length=0x{:x}\n", self.seq, M::FUNCTION,@@ -610,73 +563,27 @@ fn send_single_command<M>(&mut self, bar:&Bar0, command: M) -> Result /// written to by its
[CommandToGsp::init_variable_payload] method. ////// Error codes returned by the command initializers arepropagated as-is.
(quoted diff) +1
-1- fn send_command<M>(&mut self, bar: &Bar0, command: M) -> Result + fn send_command<M>(&mut self, dev: &device::Device, bar: &Bar0,command: M) -> Result where
M: CommandToGsp, Error: From<M::InitError>, { let mut state = SplitState::new(&command)?;drivers/gpu/nova-core/gsp/cmdq.rs +1
-2- - self.send_single_command (bar, state.command (command))?; + self.send_single_command (dev, bar, state.command (command))?; while let Some(continuation) =
state.next_continuation_record(){ dev_dbg!(drivers/gpu/nova-core/gsp/cmdq.rs +1
-1- &self.dev, + dev, "GSP RPC: send continuation: size=0x{:x}\n", command_size(&continuation), );// Turbofish needed because the compiler cannot infer M here.
- self.send_single_command::<ContinuationRecord<'_>>(bar,
continuation)?;
+ self.send_single_command::<ContinuationRecord<'_>>(dev,
bar, continuation)?; }Ok(()) }drivers/gpu/nova-core/gsp/cmdq.rs +0
-5-/// Sends `command` to the GSP and waits for the reply. -/// -/// # Errors -/// -/// - `ETIMEDOUT` if space does not become available to send the command, or if the reply is
(quoted diff) +0
-2- /// not received within the timeout. - /// - `EIO` if the variable payload requested by the command hasnot been entirely
- /// written to by its [CommandToGsp::init_variable_payload]
method.(quoted diff) +0
-2- /// - /// Error codes returned by the command and reply initializersare propagated as-is.
- pub(crate) fn send_sync_command<M>(&mut self, bar: &Bar0,
command: M) -> Result<M::Reply>drivers/gpu/nova-core/gsp/cmdq.rs +0
-10- where - M: CommandToGsp, - M::Reply: MessageFromGsp, - Error: From<M::InitError>, - Error: From<<M::Reply as MessageFromGsp>::InitError>, - { - self.send_command (bar, command)?; - -loop { - match self.receive_msg::<M::Reply>(Delta::from_secs(10)){
drivers/gpu/nova-core/gsp/cmdq.rs +0
-12- 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.
- /// -EIOif the variable payload requested by the command has
not been entirely
- /// written to by its [CommandToGsp::init_variable_payload]
method.(quoted diff) +0
-2- /// - /// Error codes returned by the command initializers arepropagated as-is.
- pub(crate) fn send_async_command<M>(&mut self, bar: &Bar0,
command: M) -> Resultdrivers/gpu/nova-core/gsp/cmdq.rs +0
-7- where - M: CommandToGsp<Reply = NoReply>, - Error: From<M::InitError>, - { - self.send_command (bar, command) - } -/// 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 @@ -695,7 +602,7 @@ pub(crate) fn send_async_command<M>(&mut self, bar: &Bar0, command: M) -> Result
/// message queue. ////// Error codes returned by the message constructor arepropagated as-is.
- fnwait_for_msg(&self, timeout: Delta)-> Result<GspMessage<'_>>
{
+ fnwait_for_msg(&self, dev: &device::Device, 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()),(quoted diff) +0
-0@@ -712,7 +619,7 @@ fn wait_for_msg(&self, timeout: Delta) ->Result<GspMessage<'_>> { let (header,
slice_1) =GspMsgElement::from_bytes_prefix(slice_1).ok_or(EIO)?; dev_dbg!(drivers/gpu/nova-core/gsp/cmdq.rs +1
-1- self.dev, + dev, "GSP RPC: receive: seq# {}, function={:?},length=0x{:x}\n",
header.sequence(),
header.function(),(quoted diff) +0
-0@@ -747,7 +654,7 @@ fn wait_for_msg(&self, timeout: Delta) ->Result<GspMessage<'_>> { ])) != 0
{ dev_err!(drivers/gpu/nova-core/gsp/cmdq.rs +1
-1- self.dev, + dev, "GSP RPC: receive: Call {} - bad checksum\n", header.sequence () );@@ -776,12 +683,12 @@ fn wait_for_msg(&self, timeout: Delta) ->Result<GspMessage<'_>> { /// -
ERANGEif the message had a recognized but non-matching function code. ////// Error codes returned by [`MessageFromGsp::read`] arepropagated as-is.
- pub(crate) fn receive_msg<M: MessageFromGsp>(&mut self, timeout:
Delta) -> Result<M>
+ fn receive_msg<M: MessageFromGsp>(&mut self, dev:&device::Device, timeout: Delta) -> Result<M> where// This allows all error types, including `Infallible`, to be used for `M::InitError`. Error: From<M::InitError>, {drivers/gpu/nova-core/gsp/cmdq.rs +1
-1-let message = self.wait_for_msg (timeout)?; +let message = self.wait_for_msg (dev, timeout)?; let function = message.header.function().map_err(|_|EINVAL)?; // Extract the message. Store the result as we want to advance the read pointer even in @@ -802,9 +709,132 @@ pub(crate) fn receive_msg<M: MessageFromGsp>(&mut self, timeout: Delta) -> Resul result }drivers/gpu/nova-core/gsp/cmdq.rs +5
-0+} + +/// GSP command queue. +/// +/// Provides the ability to send commands and receive messages from the GSP using a shared memory +/// area.
drivers/gpu/nova-core/gsp/cmdq.rs +12
-0+#[pin_data] +pub (crate )struct Cmdq { +/// Device this command queue belongs to. + dev:ARef <device::Device >, +/// Inner mutex-protected state. +#[pin] + inner:Mutex <CmdqInner >, +} + +impl Cmdq { +/// Offset of the data after the PTEs. + const POST_PTE_OFFSET: usize = core::mem::offset_of!(GspMem,cpuq); +
(quoted diff) +2
-0+ /// Offset of command queue ring buffer. + pub(crate) const CMDQ_OFFSET: usize =core::mem::offset_of!(GspMem, cpuq)
drivers/gpu/nova-core/gsp/cmdq.rs +5
-0+ + core::mem::offset_of!(Msgq, msgq) + -Self ::POST_PTE_OFFSET ; + +/// Offset of message queue ring buffer. + pub(crate) const STATQ_OFFSET: usize =core::mem::offset_of!(GspMem, gspq)
drivers/gpu/nova-core/gsp/cmdq.rs +5
-0+ + core::mem::offset_of!(Msgq, msgq) + -Self ::POST_PTE_OFFSET ; + +/// Number of page table entries for the GSP shared region. + pub(crate) const NUM_PTES: usize = size_of::<GspMem>() >>
GSP_PAGE_SHIFT; +(quoted diff) +2
-0+ /// Creates a new command queue for `dev`. + pub(crate) fn new(dev: &device::Device<device::Bound>) -> implPinInit<Self, Error> + '_ {
drivers/gpu/nova-core/gsp/cmdq.rs +12
-0+try_pin_init! (Self { + inner <-new_mutex! (CmdqInner { + gsp_mem:DmaGspMem ::new (dev)?, + seq:0 , + }), + dev: dev.into (), + }) + } + +/// Computes the checksum for the message pointed to by `it`. +/// +/// A message is made of several parts, so `it` is an iterator over byte slices representing
drivers/gpu/nova-core/gsp/cmdq.rs +6
-0+ /// these parts. + fn calculate_checksum<T: Iterator<Item = u8>>(it: T) -> u32 { + let sum64 = it + .enumerate() + .map(|(idx, byte)| (((idx % 8) * 8) as u32, byte)) + .fold(0, |acc, (rol, byte)| acc ^u64::from(byte).rotate_left(rol)); +
drivers/gpu/nova-core/gsp/cmdq.rs +4
-0+ ((sum64 >>32 )as u32 ) ^ (sum64as u32 ) + } + +/// Notifies the GSP that we have updated the command queue pointers.
drivers/gpu/nova-core/gsp/cmdq.rs +9
-0+fn notify_gsp (bar: &Bar0 ) { + regs::NV_PGSP_QUEUE_HEAD ::default () + .set_address (0 ) + .write (bar); + } + +/// Sends `command` to the GSP and waits for the reply. +/// +/// The mutex is held for the entire send+receive cycle to ensure that no other command can
+ /// be interleaved. Messages with non-matching function codes
are silently consumed until thedrivers/gpu/nova-core/gsp/cmdq.rs +5
-0+/// expected reply arrives. +/// +/// # Errors +/// +/// - `ETIMEDOUT` if space does not become available to send the command, or if the reply is
(quoted diff) +2
-0+ /// not received within the timeout. + /// - `EIO` if the variable payload requested by the command hasnot been entirely
+ /// written to by its [CommandToGsp::init_variable_payload]
method.(quoted diff) +2
-0+ /// + /// Error codes returned by the command and reply initializersare propagated as-is.
+ pub(crate) fn send_sync_command<M>(&self, bar: &Bar0, command:
M) -> Result<M::Reply>drivers/gpu/nova-core/gsp/cmdq.rs +11
-0+ 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(&self.dev, bar, command)?; + + loop { + match inner.receive_msg::<M::Reply>(&self.dev,
Delta::from_secs(10)) {drivers/gpu/nova-core/gsp/cmdq.rs +12
-0+ 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.
+ /// -EIOif the variable payload requested by the command has
not been entirely
+ /// written to by its [CommandToGsp::init_variable_payload]
method.(quoted diff) +2
-0+ /// + /// Error codes returned by the command initializers arepropagated as-is.
+ pub(crate) fn send_async_command<M>(&self, bar: &Bar0, command:
M) -> Resultdrivers/gpu/nova-core/gsp/cmdq.rs +11
-0+ where + M: CommandToGsp<Reply = NoReply>, + Error: From<M::InitError>, + { + self.inner.lock().send_command(&self.dev, bar, 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>
(quoted diff) +2
-0+ where + // This allows all error types, including `Infallible`, tobe used for
M::InitError.drivers/gpu/nova-core/gsp/cmdq.rs +4
-0+ Error: From<M::InitError>, + { + self.inner.lock ().receive_msg (&self.dev, timeout) + }/// Returns the DMA handle of the command queue's shared memory region. pub(crate) fn
dma_handle(&self)-> DmaAddress {drivers/gpu/nova-core/gsp/cmdq.rs +1
-1- self.gsp_mem.0 .dma_handle () + self.inner.lock ().gsp_mem.0 .dma_handle () } }(quoted diff) +0
-0
b/drivers/gpu/nova-core/gsp/commands.rsindexb42e32dcc55c..7ceff2e6bd63100644 ---a/drivers/gpu/nova-core/gsp/commands.rs+++b/drivers/gpu/nova-core/gsp/commands.rs@@ -170,7 +170,7 @@ fn read(
}/// Waits for GSP initialization to complete.
drivers/gpu/nova-core/gsp/commands.rs +1
-2-pub (crate )fn wait_gsp_init_done (cmdq: &mut Cmdq ) ->Result { +pub (crate )fn wait_gsp_init_done (cmdq: &Cmdq ) ->Result {loop {match cmdq.receive_msg ::<GspInitDone >(Delta ::from_secs (10 )) {Ok (_) =>break Ok (()),@@ -239,7 +239,7 @@ pub(crate) fn gpu_name(&self) -> core::result::Result<&str, GpuNameError> { }/// Send the [`GetGspInfo`] command and awaits for its reply. -pub(crate) fn get_gsp_info(cmdq: &mut Cmdq, bar: &Bar0) ->Result<GetGspStaticInfoReply> { +pub(crate) fn get_gsp_info(cmdq:
&Cmdq, bar: &Bar0) -> Result<GetGspStaticInfoReply> {cmdq.send_sync_command(bar, GetGspStaticInfo)}(quoted diff) +0
-0
b/drivers/gpu/nova-core/gsp/sequencer.rsindex2fa2a0792cec..bc94b8567c6a100644 ---a/drivers/gpu/nova-core/gsp/sequencer.rs+++b/drivers/gpu/nova-core/gsp/sequencer.rs@@ -366,7 +366,7 @@ pub(crate) struct GspSequencerParams<'a> { }impl<'a> GspSequencer<'a> {
- pub(crate) fn run(cmdq: &mut Cmdq, params:
GspSequencerParams<'a>) -> Result {
+ pub(crate) fnrun(cmdq: &Cmdq, params: GspSequencerParams<'a>)
-> Result { letseq_info= loop {
match
cmdq.receive_msg::<GspSequence>(Delta::from_secs(10)) {Ok(seq_info)=> breakseq_info,