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 06/11] gpu: nova-core: gsp: logbuffer: make LogBuffer generic over its size
Date: Mon, 30 Nov 2026 00:11:05 +0900 [thread overview]
Message-ID: <20261130-nova-r000-staging-v2-6-afd079026a61@nvidia.com> (raw)
In-Reply-To: <20261130-nova-r000-staging-v2-0-afd079026a61@nvidia.com>
From: John Hubbard <jhubbard@nvidia.com>
The r000 firmware has more log buffers than r570, of two sizes.
Make `LogBuffer` generic over its number of pages. An array length
cannot be computed from a const parameter, so the buffer becomes an
array of pages instead of an array of bytes, and a snapshot is copied
page by page.
No functional change.
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
drivers/gpu/nova-core/gsp/logbuffer.rs | 38 +++++++++++++++++++++-------------
1 file changed, 24 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/nova-core/gsp/logbuffer.rs b/drivers/gpu/nova-core/gsp/logbuffer.rs
index a825cb57dba5..40fb6682d83d 100644
--- a/drivers/gpu/nova-core/gsp/logbuffer.rs
+++ b/drivers/gpu/nova-core/gsp/logbuffer.rs
@@ -32,7 +32,6 @@
/// Number of GSP pages to use in a RM log buffer.
const RM_LOG_BUFFER_NUM_PAGES: usize = 0x10;
-const LOG_BUFFER_SIZE: usize = RM_LOG_BUFFER_NUM_PAGES * GSP_PAGE_SIZE;
/// The logging buffers are byte queues that contain encoded printf-like
/// messages from GSP-RM. They need to be decoded by a special application
@@ -48,9 +47,17 @@
/// then pp points to index into the buffer where the next logging entry will
/// be written. Therefore, the logging data is valid if:
/// 1 <= pp < sizeof(buffer)/sizeof(u64)
-pub(super) struct LogBuffer<'a>(pub(super) Coherent<'a, [u8; LOG_BUFFER_SIZE]>);
+pub(super) struct LogBuffer<'a, const NUM_PAGES: usize>(
+ pub(super) Coherent<'a, [[u8; GSP_PAGE_SIZE]; NUM_PAGES]>,
+);
-impl<'a> LogBuffer<'a> {
+/// A log buffer at the default size, [`RM_LOG_BUFFER_NUM_PAGES`] pages.
+///
+/// Matches the registry defaults for the init, interrupt and RM tasks
+/// (`NV_REG_STR_RM_GSP_LOG_BUFFER_SIZE_TASK_*_DEFAULT`).
+type TaskLogBuffer<'a> = LogBuffer<'a, RM_LOG_BUFFER_NUM_PAGES>;
+
+impl<'a, const NUM_PAGES: usize> LogBuffer<'a, NUM_PAGES> {
/// Creates a new `LogBuffer` mapped on `dev`.
fn new(dev: &'a device::Device<device::Bound>) -> Result<Self> {
let obj = Self(Coherent::zeroed(dev, GFP_KERNEL)?);
@@ -59,9 +66,9 @@ fn new(dev: &'a device::Device<device::Bound>) -> Result<Self> {
let pte_view = io_project!(
obj.0,
- [build: size_of::<u64>()..][build: ..RM_LOG_BUFFER_NUM_PAGES * size_of::<u64>()]
+ [build: 0][build: size_of::<u64>()..][build: ..NUM_PAGES * size_of::<u64>()]
)
- .try_cast::<PteArray<RM_LOG_BUFFER_NUM_PAGES>>()?;
+ .try_cast::<PteArray<NUM_PAGES>>()?;
PteArray::init(pte_view, start_addr)?;
Ok(obj)
@@ -69,7 +76,7 @@ fn new(dev: &'a device::Device<device::Bound>) -> Result<Self> {
/// Copies the buffer, or returns an empty vector if the GSP never wrote to it.
fn snapshot(&self) -> Result<VVec<u8>> {
- let put = io_project!(self.0, [build: ..size_of::<u64>()])
+ let put = io_project!(self.0, [build: 0][build: ..size_of::<u64>()])
.try_cast::<u64>()?
.read_val();
if put == 0 {
@@ -80,8 +87,11 @@ fn snapshot(&self) -> Result<VVec<u8>> {
// GSP that failed to boot may still be writing.
dma_mb(Read);
- let mut snapshot = VVec::zeroed(LOG_BUFFER_SIZE, GFP_KERNEL)?;
- io_project!(self.0, [build: ..]).copy_to_slice(&mut snapshot);
+ let mut snapshot = VVec::zeroed(NUM_PAGES * GSP_PAGE_SIZE, GFP_KERNEL)?;
+ for (i, page) in snapshot.chunks_exact_mut(GSP_PAGE_SIZE).enumerate() {
+ // PANIC: `snapshot` holds `NUM_PAGES` pages, so `i` is below `NUM_PAGES`.
+ io_project!(self.0, [panic: i][build: ..]).copy_to_slice(page);
+ }
// The copy reads "put" again, unordered against the data, so keep the value read above.
snapshot[..size_of::<u64>()].copy_from_slice(&put.to_ne_bytes());
@@ -94,11 +104,11 @@ pub(super) struct LogBuffers<'a> {
/// Device the buffers belong to.
dev: &'a device::Device<device::Bound>,
/// Init log buffer.
- loginit: LogBuffer<'a>,
+ loginit: TaskLogBuffer<'a>,
/// Interrupts log buffer.
- logintr: LogBuffer<'a>,
+ logintr: TaskLogBuffer<'a>,
/// RM log buffer.
- logrm: LogBuffer<'a>,
+ logrm: TaskLogBuffer<'a>,
}
impl<'a> LogBuffers<'a> {
@@ -109,9 +119,9 @@ impl<'a> LogBuffers<'a> {
pub(super) fn new(dev: &'a device::Device<device::Bound>) -> Result<Self> {
Ok(Self {
dev,
- loginit: LogBuffer::new(dev)?,
- logintr: LogBuffer::new(dev)?,
- logrm: LogBuffer::new(dev)?,
+ loginit: TaskLogBuffer::new(dev)?,
+ logintr: TaskLogBuffer::new(dev)?,
+ logrm: TaskLogBuffer::new(dev)?,
})
}
--
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 ` Alexandre Courbot [this message]
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 ` [PATCH v2 10/11] gpu: nova-core: gsp: take all the msgq layout values from Cmdq " Alexandre Courbot
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-6-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®