mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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 v3 05/11] gpu: nova-core: gsp: logbuffer: add LogBuffers::init_arguments()
Date: Mon, 30 Nov 2026 17:42:31 +0900	[thread overview]
Message-ID: <20261130-nova-r000-staging-v3-5-55aceca8e958@nvidia.com> (raw)
In-Reply-To: <20261130-nova-r000-staging-v3-0-55aceca8e958@nvidia.com>

From: John Hubbard <jhubbard@nvidia.com>

`Gsp::new()` names each log buffer in the init argument array itself,
which requires the buffers to be visible outside of their module.

Move that code into `LogBuffers::init_arguments()`, using a new
`LibosInitArgs` writer type to fill the arguments while transparently
keeping track of the current position.

No functional change.

Signed-off-by: John Hubbard <jhubbard@nvidia.com>
Co-developed-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
 drivers/gpu/nova-core/gsp.rs           | 57 +++++++++++++++++++++-------------
 drivers/gpu/nova-core/gsp/logbuffer.rs | 21 +++++++++++--
 2 files changed, 54 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/nova-core/gsp.rs b/drivers/gpu/nova-core/gsp.rs
index bf0028e52e3c..28bd76626cf6 100644
--- a/drivers/gpu/nova-core/gsp.rs
+++ b/drivers/gpu/nova-core/gsp.rs
@@ -98,6 +98,38 @@ fn init(view: CoherentView<'_, Self>, start: DmaAddress) -> Result<()> {
     }
 }
 
+/// Writer for the `LibosMemoryRegionInitArgument` array passed to the GSP bootloader.
+struct LibosInitArgs<'a> {
+    buf: CoherentBox<'a, [LibosMemoryRegionInitArgument]>,
+    len: usize,
+}
+
+impl<'a> LibosInitArgs<'a> {
+    /// Allocates a zeroed `LibosMemoryRegionInitArgument` array for `dev`.
+    fn new(dev: &'a device::Device<device::Bound>) -> Result<Self> {
+        Ok(Self {
+            buf: CoherentBox::zeroed_slice(
+                dev,
+                GSP_PAGE_SIZE / size_of::<LibosMemoryRegionInitArgument>(),
+                GFP_KERNEL,
+            )?,
+            len: 0,
+        })
+    }
+
+    /// Appends an entry to the array.
+    fn push(&mut self, arg: impl Init<LibosMemoryRegionInitArgument>) -> Result {
+        self.buf.init_at(self.len, arg)?;
+        self.len += 1;
+        Ok(())
+    }
+
+    /// Consumes the writer and returns the underlying coherent DMA allocation.
+    fn finish(self) -> Coherent<'a, [LibosMemoryRegionInitArgument]> {
+        self.buf.into()
+    }
+}
+
 /// GSP runtime data.
 #[pin_data]
 pub(crate) struct Gsp<'gsp> {
@@ -131,27 +163,10 @@ pub(crate) fn new(
                 cmdq <- Cmdq::new(dev, bar),
                 rmargs: Coherent::init(dev, GFP_KERNEL, GspArgumentsPadded::new(&cmdq))?,
                 libos: {
-                    let mut libos = CoherentBox::zeroed_slice(
-                        dev,
-                        GSP_PAGE_SIZE / size_of::<LibosMemoryRegionInitArgument>(),
-                        GFP_KERNEL,
-                    )?;
-
-                    libos.init_at(
-                        0,
-                        LibosMemoryRegionInitArgument::new("LOGINIT", &log_buffers.loginit.0),
-                    )?;
-                    libos.init_at(
-                        1,
-                        LibosMemoryRegionInitArgument::new("LOGINTR", &log_buffers.logintr.0),
-                    )?;
-                    libos.init_at(
-                        2,
-                        LibosMemoryRegionInitArgument::new("LOGRM", &log_buffers.logrm.0),
-                    )?;
-                    libos.init_at(3, LibosMemoryRegionInitArgument::new("RMARGS", rmargs))?;
-
-                    libos.into()
+                    let mut libos = LibosInitArgs::new(dev)?;
+                    log_buffers.init_arguments(&mut libos)?;
+                    libos.push(LibosMemoryRegionInitArgument::new("RMARGS", rmargs))?;
+                    libos.finish()
                 },
                 logs <- log_buffers.into_debugfs_scope(),
             }))
diff --git a/drivers/gpu/nova-core/gsp/logbuffer.rs b/drivers/gpu/nova-core/gsp/logbuffer.rs
index 5455d990ffb4..8ae80fa682a3 100644
--- a/drivers/gpu/nova-core/gsp/logbuffer.rs
+++ b/drivers/gpu/nova-core/gsp/logbuffer.rs
@@ -20,6 +20,8 @@
 
 use crate::{
     gsp::{
+        LibosInitArgs,
+        LibosMemoryRegionInitArgument,
         PteArray,
         GSP_PAGE_SIZE, //
     },
@@ -90,11 +92,11 @@ pub(super) struct LogBuffers<'a> {
     /// Device the buffers belong to.
     dev: &'a device::Device<device::Bound>,
     /// Init log buffer.
-    pub(super) loginit: LogBuffer<'a>,
+    loginit: LogBuffer<'a>,
     /// Interrupts log buffer.
-    pub(super) logintr: LogBuffer<'a>,
+    logintr: LogBuffer<'a>,
     /// RM log buffer.
-    pub(super) logrm: LogBuffer<'a>,
+    logrm: LogBuffer<'a>,
 }
 
 impl<'a> LogBuffers<'a> {
@@ -108,6 +110,19 @@ pub(super) fn new(dev: &'a device::Device<device::Bound>) -> Result<Self> {
         })
     }
 
+    /// Appends the log buffers to `libos`, under the names that GSP-RM looks them up by.
+    pub(super) fn init_arguments(&self, libos: &mut LibosInitArgs<'_>) -> Result {
+        libos.push(LibosMemoryRegionInitArgument::new(
+            "LOGINIT",
+            &self.loginit.0,
+        ))?;
+        libos.push(LibosMemoryRegionInitArgument::new(
+            "LOGINTR",
+            &self.logintr.0,
+        ))?;
+        libos.push(LibosMemoryRegionInitArgument::new("LOGRM", &self.logrm.0))
+    }
+
     /// Exposes the buffers in debugfs, in a directory named after their device.
     pub(super) fn into_debugfs_scope(self) -> impl PinInit<debugfs::Scope<Self>> + 'a {
         let dev = self.dev;

-- 
2.56.1


  parent reply	other threads:[~2026-11-30  8:42 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30  8:42 [PATCH v3 00/11] gpu: nova-core: gsp: preparatory patches for the r000 firmware Alexandre Courbot
2026-11-30  8:42 ` [PATCH v3 01/11] gpu: nova-core: gsp: add the r000 queue element header Alexandre Courbot
2026-11-30  8:42 ` [PATCH v3 02/11] gpu: nova-core: gsp: rename and move the static configuration type Alexandre Courbot
2026-11-30  8:42 ` [PATCH v3 03/11] gpu: nova-core: gsp: return the static GPU configuration from boot Alexandre Courbot
2026-11-30  8:42 ` [PATCH v3 04/11] gpu: nova-core: gsp: add the short name and GID to the GSP_INIT reply Alexandre Courbot
2026-11-30  8:42 ` Alexandre Courbot [this message]
2026-11-30 10:36   ` [PATCH v3 05/11] gpu: nova-core: gsp: logbuffer: add LogBuffers::init_arguments() Eliot Courtney
2026-11-30  8:42 ` [PATCH v3 06/11] gpu: nova-core: gsp: logbuffer: make LogBuffer generic over its size Alexandre Courbot
2026-11-30  8:42 ` [PATCH v3 07/11] gpu: nova-core: gsp: logbuffer: add RetainedLogBuffers::is_empty() Alexandre Courbot
2026-11-30  8:42 ` [PATCH v3 08/11] gpu: nova-core: gsp: cmdq: reduce visibility of gsp-level constants Alexandre Courbot
2026-11-30  8:42 ` [PATCH v3 09/11] gpu: nova-core: gsp: compute the msgq entry offset in MsgqTxHeader::new() Alexandre Courbot
2026-11-30  8:42 ` [PATCH v3 10/11] gpu: nova-core: gsp: take all the msgq layout values from Cmdq " Alexandre Courbot
2026-11-30  8:42 ` [PATCH v3 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-v3-5-55aceca8e958@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®