From: Alexandre Courbot <acourbot@nvidia.com>
To: Danilo Krummrich <dakr@kernel.org>,
Alice Ryhl <aliceryhl@google.com>,
David Airlie <airlied@gmail.com>,
Simona Vetter <simona@ffwll.ch>
Cc: John Hubbard <jhubbard@nvidia.com>,
Alistair Popple <apopple@nvidia.com>,
Timur Tabi <ttabi@nvidia.com>,
Eliot Courtney <ecourtney@nvidia.com>,
Zhi Wang <zhiw@nvidia.com>,
nova-gpu@lists.linux.dev, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org,
Alexandre Courbot <acourbot@nvidia.com>
Subject: [PATCH v2 10/11] gpu: nova-core: gsp: take all the msgq layout values from Cmdq in MsgqTxHeader::new()
Date: Mon, 30 Nov 2026 00:11:09 +0900 [thread overview]
Message-ID: <20261130-nova-r000-staging-v2-10-afd079026a61@nvidia.com> (raw)
In-Reply-To: <20261130-nova-r000-staging-v2-0-afd079026a61@nvidia.com>
The queue size, RX header offset and slot count are layout constants
just like the entry offset, so stop passing them as parameters.
No functional change.
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
drivers/gpu/nova-core/gsp/cmdq.rs | 13 +++++++------
drivers/gpu/nova-core/gsp/fw.rs | 23 +++++++++--------------
2 files changed, 16 insertions(+), 20 deletions(-)
diff --git a/drivers/gpu/nova-core/gsp/cmdq.rs b/drivers/gpu/nova-core/gsp/cmdq.rs
index 54b5d94d1328..10f6ddcf3eb5 100644
--- a/drivers/gpu/nova-core/gsp/cmdq.rs
+++ b/drivers/gpu/nova-core/gsp/cmdq.rs
@@ -7,8 +7,6 @@
pub(super) mod gmc;
pub(super) mod rpc;
-use core::mem;
-
use kernel::{
device,
dma::{
@@ -176,11 +174,8 @@ struct DmaGspMem<'a> {
impl<'a> DmaGspMem<'a> {
/// Allocate a new instance and map it for `dev`.
fn new(dev: &'a device::Device<device::Bound>, bar: Bar0<'a>) -> Result<Self> {
- const MSGQ_SIZE: u32 = cv!(size_of::<Msgq>());
- const RX_HDR_OFF: u32 = cv!(mem::offset_of!(Msgq, rx));
-
let mut gsp_mem = CoherentBox::<'_, GspMem>::zeroed(dev, GFP_KERNEL)?;
- gsp_mem.cpuq.tx = MsgqTxHeader::new(MSGQ_SIZE, RX_HDR_OFF, MSGQ_NUM_PAGES);
+ gsp_mem.cpuq.tx = MsgqTxHeader::new();
gsp_mem.cpuq.rx = MsgqRxHeader::new();
let gsp_mem: Coherent<'_, _> = gsp_mem.into();
@@ -476,6 +471,12 @@ impl<'cmdq> Cmdq<'cmdq> {
/// Size of a queue slot. An element spans one or more slots.
pub(super) const MSG_SIZE: usize = GSP_PAGE_SIZE;
+ /// Total size of a queue, headers included.
+ pub(super) const MSGQ_SIZE: usize = size_of::<Msgq>();
+
+ /// Offset of the RX header of a queue from its TX header.
+ pub(super) const MSGQ_RX_HDR_OFFSET: usize = core::mem::offset_of!(Msgq, rx);
+
/// Offset of the ring buffer of a queue from its TX header.
pub(super) const MSGQ_ENTRY_OFFSET: usize = core::mem::offset_of!(Msgq, msgq);
diff --git a/drivers/gpu/nova-core/gsp/fw.rs b/drivers/gpu/nova-core/gsp/fw.rs
index 2ddc2e8f6274..10674939f524 100644
--- a/drivers/gpu/nova-core/gsp/fw.rs
+++ b/drivers/gpu/nova-core/gsp/fw.rs
@@ -50,7 +50,10 @@
Chipset, //
},
gsp::{
- cmdq::Cmdq, //
+ cmdq::{
+ Cmdq,
+ MSGQ_NUM_PAGES, //
+ },
GSP_PAGE_SIZE,
},
mctp::{
@@ -702,24 +705,16 @@ fn id8(name: &str) -> u64 {
pub(crate) struct MsgqTxHeader(bindings::msgqTxHeader);
impl MsgqTxHeader {
- /// Create a new TX queue header.
- ///
- /// # Arguments
- ///
- /// * `msgq_size` - Total size of the message queue structure, in bytes.
- /// * `rx_hdr_offset` - Offset, in bytes, of the start of the RX header in the message queue
- /// structure.
- /// * `msg_count` - Number of messages that can be sent, i.e. the number of memory pages
- /// allocated for the message queue in the message queue structure.
- pub(crate) fn new(msgq_size: u32, rx_hdr_offset: u32, msg_count: u32) -> Self {
+ /// Create a new TX queue header, describing the queue layout defined by [`Cmdq`].
+ pub(crate) fn new() -> Self {
Self(bindings::msgqTxHeader {
version: 0,
- size: msgq_size,
+ size: cv!(Cmdq::MSGQ_SIZE),
msgSize: cv!(Cmdq::MSG_SIZE),
- msgCount: msg_count,
+ msgCount: MSGQ_NUM_PAGES,
writePtr: 0,
flags: 1,
- rxHdrOff: rx_hdr_offset,
+ rxHdrOff: cv!(Cmdq::MSGQ_RX_HDR_OFFSET),
entryOff: cv!(Cmdq::MSGQ_ENTRY_OFFSET),
})
}
--
2.56.1
next prev parent reply other threads:[~2026-11-29 15:11 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 15:10 [PATCH v2 00/11] gpu: nova-core: gsp: preparatory patches for the r000 firmware Alexandre Courbot
2026-11-29 15:11 ` [PATCH v2 01/11] gpu: nova-core: gsp: add the r000 queue element header Alexandre Courbot
2026-11-29 15:11 ` [PATCH v2 02/11] gpu: nova-core: gsp: rename and move the static configuration type Alexandre Courbot
2026-11-29 15:11 ` [PATCH v2 03/11] gpu: nova-core: gsp: return the static GPU configuration from boot Alexandre Courbot
2026-11-29 15:11 ` [PATCH v2 04/11] gpu: nova-core: gsp: add the short name and GID to the GSP_INIT reply Alexandre Courbot
2026-11-29 15:11 ` [PATCH v2 05/11] gpu: nova-core: gsp: logbuffer: add LogBuffers::init_arguments() Alexandre Courbot
2026-11-29 15:11 ` [PATCH v2 06/11] gpu: nova-core: gsp: logbuffer: make LogBuffer generic over its size Alexandre Courbot
2026-11-29 15:11 ` [PATCH v2 07/11] gpu: nova-core: gsp: logbuffer: add RetainedLogBuffers::is_empty() Alexandre Courbot
2026-11-29 15:11 ` [PATCH v2 08/11] gpu: nova-core: gsp: cmdq: reduce visibility of gsp-level constants Alexandre Courbot
2026-11-29 15:11 ` [PATCH v2 09/11] gpu: nova-core: gsp: compute the msgq entry offset in MsgqTxHeader::new() Alexandre Courbot
2026-11-29 15:11 ` Alexandre Courbot [this message]
2026-11-29 15:11 ` [PATCH v2 11/11] gpu: nova-core: firmware: tlv: add method to load the file referenced by a TLV Alexandre Courbot
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=20261130-nova-r000-staging-v2-10-afd079026a61@nvidia.com \
--to=acourbot@nvidia.com \
--cc=airlied@gmail.com \
--cc=aliceryhl@google.com \
--cc=apopple@nvidia.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=ecourtney@nvidia.com \
--cc=jhubbard@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nova-gpu@lists.linux.dev \
--cc=simona@ffwll.ch \
--cc=ttabi@nvidia.com \
--cc=zhiw@nvidia.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®