[PATCH v4 6/6] gpu: nova-core: gsp: logbuffer: add LIBOS3 log buffers and state monitor buffer
From: Alexandre Courbot
Date: Tue Dec 01 2026 - 03:16:26 EST
From: John Hubbard <jhubbard@xxxxxxxxxx>
GSP-RM runs on LibOS, and each LibOS task logs into a buffer that the
driver provides and names in the init argument array. On GA102 and
later, the r000 firmware runs LIBOS3, version 3 of LibOS, which has six
logging tasks. LIBOS3 also expects one more page, the state monitor
buffer, in which GSP-RM reports its own state. On Turing and GA100 the
r000 firmware runs LIBOS2, which maps only the init and RM log buffers
and skips the names that it does not have.
Nova-core allocates log buffers for three of the six tasks, and no state
monitor buffer.
Allocate the three missing log buffers and the state monitor buffer, and
name every log buffer in the init argument array. Give each new log a
debugfs file next to the existing ones, and retain it after unbind under
the same module parameter as the existing ones.
This is part of the r000 support. As it comes before the switch, the
r570 firmware is passed the three new log buffers too, and nothing uses
the state monitor buffer until the switch.
Signed-off-by: John Hubbard <jhubbard@xxxxxxxxxx>
Co-developed-by: Alexandre Courbot <acourbot@xxxxxxxxxx>
Signed-off-by: Alexandre Courbot <acourbot@xxxxxxxxxx>
---
drivers/gpu/nova-core/gsp.rs | 3 ++
drivers/gpu/nova-core/gsp/logbuffer.rs | 64 ++++++++++++++++++++++++++++++++--
2 files changed, 64 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/nova-core/gsp.rs b/drivers/gpu/nova-core/gsp.rs
index 28bd76626cf6..27ff2e8b7f5e 100644
--- a/drivers/gpu/nova-core/gsp.rs
+++ b/drivers/gpu/nova-core/gsp.rs
@@ -143,6 +143,8 @@ pub(crate) struct Gsp<'gsp> {
pub(crate) cmdq: Cmdq<'gsp>,
/// RM arguments.
rmargs: Coherent<'gsp, GspArgumentsPadded>,
+ /// Buffer in which GSP-RM reports its own state.
+ rm_state_monitor: Coherent<'gsp, [u8; GSP_PAGE_SIZE]>,
}
impl<'gsp> Gsp<'gsp> {
@@ -162,6 +164,7 @@ pub(crate) fn new(
Ok(try_pin_init!(Self {
cmdq <- Cmdq::new(dev, bar),
rmargs: Coherent::init(dev, GFP_KERNEL, GspArgumentsPadded::new(&cmdq))?,
+ rm_state_monitor: Coherent::zeroed(dev, GFP_KERNEL)?,
libos: {
let mut libos = LibosInitArgs::new(dev)?;
log_buffers.init_arguments(&mut libos)?;
diff --git a/drivers/gpu/nova-core/gsp/logbuffer.rs b/drivers/gpu/nova-core/gsp/logbuffer.rs
index 124e6aee2c63..5a9d5bd9992f 100644
--- a/drivers/gpu/nova-core/gsp/logbuffer.rs
+++ b/drivers/gpu/nova-core/gsp/logbuffer.rs
@@ -51,10 +51,14 @@ pub(super) struct LogBuffer<'a, const NUM_PAGES: usize>(
/// A log buffer at the default size, [`RM_LOG_BUFFER_NUM_PAGES`] pages.
///
-/// Matches the registry defaults for the init, interrupt and RM tasks
+/// Matches the registry defaults for the init, interrupt, RM and MNOC tasks
/// (`NV_REG_STR_RM_GSP_LOG_BUFFER_SIZE_TASK_*_DEFAULT`).
type TaskLogBuffer<'a> = LogBuffer<'a, RM_LOG_BUFFER_NUM_PAGES>;
+/// A single-page log buffer, the size of the logs of the root task and of the RM state monitor
+/// task.
+type SmallLogBuffer<'a> = LogBuffer<'a, 1>;
+
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> {
@@ -98,6 +102,10 @@ fn snapshot(&self) -> Result<VVec<u8>> {
}
}
+/// The log buffers to which GSP-RM writes its debug output, one per LIBOS3 task.
+///
+/// The r000 firmware runs LIBOS3 on GA102 and later, and LIBOS2 on Turing and GA100. LIBOS2 maps
+/// only the init and RM log buffers, and skips the names that it does not have.
pub(super) struct LogBuffers<'a> {
/// Device the buffers belong to.
dev: &'a device::Device<device::Bound>,
@@ -107,6 +115,12 @@ pub(super) struct LogBuffers<'a> {
logintr: TaskLogBuffer<'a>,
/// RM log buffer.
logrm: TaskLogBuffer<'a>,
+ /// MNOC log buffer.
+ logmnoc: TaskLogBuffer<'a>,
+ /// Root task log buffer.
+ logroot: SmallLogBuffer<'a>,
+ /// RM state monitor task log buffer.
+ logrmon: SmallLogBuffer<'a>,
}
impl<'a> LogBuffers<'a> {
@@ -117,6 +131,9 @@ pub(super) fn new(dev: &'a device::Device<device::Bound>) -> Result<Self> {
loginit: TaskLogBuffer::new(dev)?,
logintr: TaskLogBuffer::new(dev)?,
logrm: TaskLogBuffer::new(dev)?,
+ logmnoc: TaskLogBuffer::new(dev)?,
+ logroot: SmallLogBuffer::new(dev)?,
+ logrmon: SmallLogBuffer::new(dev)?,
})
}
@@ -130,7 +147,19 @@ pub(super) fn init_arguments(&self, libos: &mut LibosInitArgs<'_>) -> Result {
"LOGINTR",
&self.logintr.0,
))?;
- libos.push(LibosMemoryRegionInitArgument::new("LOGRM", &self.logrm.0))
+ libos.push(LibosMemoryRegionInitArgument::new("LOGRM", &self.logrm.0))?;
+ libos.push(LibosMemoryRegionInitArgument::new(
+ "LOGMNOC",
+ &self.logmnoc.0,
+ ))?;
+ libos.push(LibosMemoryRegionInitArgument::new(
+ "LOGROOT",
+ &self.logroot.0,
+ ))?;
+ libos.push(LibosMemoryRegionInitArgument::new(
+ "LOGRMON",
+ &self.logrmon.0,
+ ))
}
/// Exposes the buffers in debugfs, in a directory named after their device.
@@ -145,6 +174,9 @@ pub(super) fn into_debugfs_scope(self) -> impl PinInit<debugfs::Scope<Self>> + '
dir.read_binary_file(c"loginit", &logs.loginit.0);
dir.read_binary_file(c"logintr", &logs.logintr.0);
dir.read_binary_file(c"logrm", &logs.logrm.0);
+ dir.read_binary_file(c"logmnoc", &logs.logmnoc.0);
+ dir.read_binary_file(c"logroot", &logs.logroot.0);
+ dir.read_binary_file(c"logrmon", &logs.logrmon.0);
})
}
@@ -159,6 +191,9 @@ fn retain(&self) -> Result {
loginit: self.loginit.snapshot()?,
logintr: self.logintr.snapshot()?,
logrm: self.logrm.snapshot()?,
+ logmnoc: self.logmnoc.snapshot()?,
+ logroot: self.logroot.snapshot()?,
+ logrmon: self.logrmon.snapshot()?,
};
if logs.is_empty() {
@@ -181,6 +216,15 @@ fn retain(&self) -> Result {
if !logs.logrm.is_empty() {
dir.read_binary_file(c"logrm", &logs.logrm);
}
+ if !logs.logmnoc.is_empty() {
+ dir.read_binary_file(c"logmnoc", &logs.logmnoc);
+ }
+ if !logs.logroot.is_empty() {
+ dir.read_binary_file(c"logroot", &logs.logroot);
+ }
+ if !logs.logrmon.is_empty() {
+ dir.read_binary_file(c"logrmon", &logs.logrmon);
+ }
}))?;
retained.push(scope)
@@ -205,6 +249,12 @@ struct RetainedLogBuffers {
logintr: VVec<u8>,
/// RM log buffer, empty if never written to.
logrm: VVec<u8>,
+ /// MNOC log buffer, empty if never written to.
+ logmnoc: VVec<u8>,
+ /// Root task log buffer, empty if never written to.
+ logroot: VVec<u8>,
+ /// RM state monitor task log buffer, empty if never written to.
+ logrmon: VVec<u8>,
}
impl RetainedLogBuffers {
@@ -215,9 +265,17 @@ fn is_empty(&self) -> bool {
loginit,
logintr,
logrm,
+ logmnoc,
+ logroot,
+ logrmon,
} = self;
- loginit.is_empty() && logintr.is_empty() && logrm.is_empty()
+ loginit.is_empty()
+ && logintr.is_empty()
+ && logrm.is_empty()
+ && logmnoc.is_empty()
+ && logroot.is_empty()
+ && logrmon.is_empty()
}
}
--
2.56.1