[PATCH v2 09/31] gpu: nova-core: add LIBOS3 log buffers and state monitor buffer
From: John Hubbard
Date: Fri Aug 21 2026 - 21:59:35 EST
GSP-RM on the new firmware logs from six LIBOS3 tasks on GA102 and
later, where r570 logs from three, and it maps a small buffer during
init to report RM state for diagnostics. Turing and GA100 run LIBOS2,
where only the init and RM task logs exist. Two of the six task logs are
a single page, where the rest are 64KB.
Allocate the three missing log buffers and the state monitor buffer,
give the log buffer type a const page count so the single-page buffers
can exist, and expose the new log buffers through the debugfs directory
that already carries the others.
Nothing passes these to GSP-RM yet. The libos init arguments gain them
when the driver switches to the new firmware.
Assisted-by: Cursor:claude-opus-5
Reviewed-by: Timur Tabi <ttabi@xxxxxxxxxx>
Signed-off-by: John Hubbard <jhubbard@xxxxxxxxxx>
---
drivers/gpu/nova-core/gsp.rs | 66 ++++++++++++++++++++++++++----------
1 file changed, 49 insertions(+), 17 deletions(-)
diff --git a/drivers/gpu/nova-core/gsp.rs b/drivers/gpu/nova-core/gsp.rs
index f9a622edf299..de5cf3914949 100644
--- a/drivers/gpu/nova-core/gsp.rs
+++ b/drivers/gpu/nova-core/gsp.rs
@@ -82,7 +82,6 @@ pub(crate) fn dev(&self) -> &'gpu device::Device<device::Bound> {
/// 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;
/// Array of page table entries, as understood by the GSP bootloader.
#[repr(C)]
@@ -118,9 +117,20 @@ fn init(view: CoherentView<'_, Self>, start: DmaAddress) -> Result<()> {
/// 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)
-struct LogBuffer(Coherent<[u8; LOG_BUFFER_SIZE]>);
+struct LogBuffer<const NUM_PAGES: usize>(Coherent<[[u8; GSP_PAGE_SIZE]; NUM_PAGES]>);
-impl LogBuffer {
+/// Log buffer for a task that GSP-RM logs to at its default size.
+///
+/// Matches the registry defaults for the init, interrupt, RM, and MNOC tasks
+/// (`NV_REG_STR_RM_GSP_LOG_BUFFER_SIZE_TASK_*_DEFAULT`).
+type TaskLogBuffer = LogBuffer<RM_LOG_BUFFER_NUM_PAGES>;
+
+/// Log buffer for a task that GSP-RM gives a single page.
+///
+/// Matches the size GSP-RM hardcodes for the root and RM state monitor tasks.
+type SmallLogBuffer = LogBuffer<1>;
+
+impl<const NUM_PAGES: usize> LogBuffer<NUM_PAGES> {
/// Creates a new `LogBuffer` mapped on `dev`.
fn new(dev: &device::Device<device::Bound>) -> Result<Self> {
let obj = Self(Coherent::zeroed(dev, GFP_KERNEL)?);
@@ -129,22 +139,35 @@ fn new(dev: &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)
}
}
+/// Log buffers used by GSP-RM for debug logging.
+///
+/// r000+ firmware expects log buffers for all LIBOS3 tasks. Each buffer is
+/// registered as a libos memory region entry, identified by its id8 name.
+///
+/// The Open RM equivalents are `_kgspInitLibosLoggingStructures`, which allocates the buffers,
+/// and `kgspSetupLibosInitArgs_IMPL`, which builds the `pLibosInitArgs[]` array.
struct LogBuffers {
- /// Init log buffer.
- loginit: LogBuffer,
- /// Interrupts log buffer.
- logintr: LogBuffer,
- /// RM log buffer.
- logrm: LogBuffer,
+ /// Init task log buffer (LOGINIT).
+ loginit: TaskLogBuffer,
+ /// Interrupt task log buffer (LOGINTR).
+ logintr: TaskLogBuffer,
+ /// RM task log buffer (LOGRM).
+ logrm: TaskLogBuffer,
+ /// MNOC task log buffer (LOGMNOC).
+ logmnoc: TaskLogBuffer,
+ /// Root task log buffer (LOGROOT).
+ logroot: SmallLogBuffer,
+ /// RM state monitor task log buffer (LOGRMON).
+ logrmon: SmallLogBuffer,
}
/// GSP runtime data.
@@ -159,6 +182,8 @@ pub(crate) struct Gsp {
pub(crate) cmdq: Arc<Cmdq>,
/// RM arguments.
rmargs: Coherent<GspArgumentsPadded>,
+ /// RM state monitor buffer (required by r000+ GSP-RM for diagnostics).
+ rm_state_monitor: Coherent<[u8; GSP_PAGE_SIZE]>,
}
impl Gsp {
@@ -167,16 +192,17 @@ pub(crate) fn new(pdev: &pci::Device<device::Bound>) -> impl PinInit<Self, Error
pin_init::pin_init_scope(move || {
let dev = pdev.as_ref();
- let loginit = LogBuffer::new(dev)?;
- let logintr = LogBuffer::new(dev)?;
- let logrm = LogBuffer::new(dev)?;
+ let loginit = TaskLogBuffer::new(dev)?;
+ let logintr = TaskLogBuffer::new(dev)?;
+ let logrm = TaskLogBuffer::new(dev)?;
+ let logmnoc = TaskLogBuffer::new(dev)?;
+ let logroot = SmallLogBuffer::new(dev)?;
+ let logrmon = SmallLogBuffer::new(dev)?;
- // Initialise the logging structures. The OpenRM equivalents are in:
- // _kgspInitLibosLoggingStructures (allocates memory for buffers)
- // kgspSetupLibosInitArgs_IMPL (creates pLibosInitArgs[] array)
Ok(try_pin_init!(Self {
cmdq: Arc::pin_init(Cmdq::new(dev), GFP_KERNEL)?,
rmargs: Coherent::init(dev, GFP_KERNEL, GspArgumentsPadded::new(cmdq.as_ref()))?,
+ rm_state_monitor: Coherent::zeroed(dev, GFP_KERNEL)?,
libos: {
let mut libos = CoherentBox::zeroed_slice(
dev,
@@ -196,6 +222,9 @@ pub(crate) fn new(pdev: &pci::Device<device::Bound>) -> impl PinInit<Self, Error
loginit,
logintr,
logrm,
+ logmnoc,
+ logroot,
+ logrmon,
};
#[allow(static_mut_refs)]
@@ -212,6 +241,9 @@ pub(crate) fn new(pdev: &pci::Device<device::Bound>) -> impl PinInit<Self, Error
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);
})
},
}))
--
2.55.0