All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhi Wang <zhiw@nvidia.com>
To: Eliot Courtney <ecourtney@nvidia.com>
Cc: Danilo Krummrich <dakr@kernel.org>,
	Alice Ryhl <aliceryhl@google.com>,
	Alexandre Courbot <acourbot@nvidia.com>,
	Simona Vetter <simona@ffwll.ch>, Benno Lossin <lossin@kernel.org>,
	Gary Guo <gary@garyguo.net>,
	nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org
Subject: Re: [PATCH 2/4] gpu: nova-core: gsp: add sync and async command queue API to `Cmdq`
Date: Wed, 25 Feb 2026 21:42:07 +0200	[thread overview]
Message-ID: <20260225214207.078e3186@inno-dell> (raw)
In-Reply-To: <20260225-cmdq-locking-v1-2-bbf6b4156706@nvidia.com>

On Wed, 25 Feb 2026 22:41:49 +0900
Eliot Courtney <ecourtney@nvidia.com> wrote:

> Add sync and async command queue API and the type infrastructure to
> know what reply is expected from each `CommandToGsp`.
> 

snip

> +        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.

> {
> +                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_async_command<M>(&mut self, bar: &Bar0,
> command: M) -> Result
> +    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.rs
> b/drivers/gpu/nova-core/gsp/commands.rs index
> 1683ebb4c685..b42e32dcc55c 100644 ---
> a/drivers/gpu/nova-core/gsp/commands.rs +++
> b/drivers/gpu/nova-core/gsp/commands.rs @@ -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> {
> 


WARNING: multiple messages have this Message-ID (diff)
From: Zhi Wang <zhiw@nvidia.com>
To: Eliot Courtney <ecourtney@nvidia.com>
Cc: Danilo Krummrich <dakr@kernel.org>,
	Alice Ryhl <aliceryhl@google.com>,
	Alexandre Courbot <acourbot@nvidia.com>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	Benno Lossin <lossin@kernel.org>, Gary Guo <gary@garyguo.net>,
	<nouveau@lists.freedesktop.org>,
	<dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>,
	<rust-for-linux@vger.kernel.org>
Subject: Re: [PATCH 2/4] gpu: nova-core: gsp: add sync and async command queue API to `Cmdq`
Date: Wed, 25 Feb 2026 21:42:07 +0200	[thread overview]
Message-ID: <20260225214207.078e3186@inno-dell> (raw)
In-Reply-To: <20260225-cmdq-locking-v1-2-bbf6b4156706@nvidia.com>

On Wed, 25 Feb 2026 22:41:49 +0900
Eliot Courtney <ecourtney@nvidia.com> wrote:

> Add sync and async command queue API and the type infrastructure to
> know what reply is expected from each `CommandToGsp`.
> 

snip

> +        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.

> {
> +                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_async_command<M>(&mut self, bar: &Bar0,
> command: M) -> Result
> +    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.rs
> b/drivers/gpu/nova-core/gsp/commands.rs index
> 1683ebb4c685..b42e32dcc55c 100644 ---
> a/drivers/gpu/nova-core/gsp/commands.rs +++
> b/drivers/gpu/nova-core/gsp/commands.rs @@ -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> {
> 


  reply	other threads:[~2026-02-25 19:42 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-25 13:41 [PATCH 0/4] gpu: nova-core: gsp: add locking to Cmdq Eliot Courtney
2026-02-25 13:41 ` [PATCH 1/4] gpu: nova-core: gsp: fix stale doc comments on command queue methods Eliot Courtney
2026-02-25 19:42   ` Zhi Wang
2026-02-25 19:42     ` Zhi Wang
2026-02-25 13:41 ` [PATCH 2/4] gpu: nova-core: gsp: add sync and async command queue API to `Cmdq` Eliot Courtney
2026-02-25 19:42   ` Zhi Wang [this message]
2026-02-25 19:42     ` Zhi Wang
2026-02-26  0:42     ` Eliot Courtney
2026-02-26  0:42       ` Eliot Courtney
2026-02-25 13:41 ` [PATCH 3/4] gpu: nova-core: gsp: make `Cmdq` a pinned type Eliot Courtney
2026-02-25 19:43   ` Zhi Wang
2026-02-25 19:43     ` Zhi Wang
2026-02-25 13:41 ` [PATCH 4/4] gpu: nova-core: gsp: add mutex locking to Cmdq Eliot Courtney
2026-02-25 19:48   ` Zhi Wang
2026-02-25 19:48     ` Zhi Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260225214207.078e3186@inno-dell \
    --to=zhiw@nvidia.com \
    --cc=acourbot@nvidia.com \
    --cc=aliceryhl@google.com \
    --cc=dakr@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=ecourtney@nvidia.com \
    --cc=gary@garyguo.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=nouveau@lists.freedesktop.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=simona@ffwll.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.