[PATCH v3 0/3] gpu: nova-core: retain the GSP-RM log buffers

From: Vladislav Zaharov

Date: Sat Sep 12 2026 - 03:24:16 EST


The GSP-RM log buffers are exposed through debugfs, but the entries are
owned by the Gpu that probe() builds, and the buffers themselves are DMA
allocations that cannot outlive the device. They are therefore gone as
soon as the GPU is unbound, and in particular as soon as probe() fails -
which is the case todo.rst singled out, and the one where a GSP log is
worth having.

Patch 1 is a fix this series needs: init() builds the Registration before
the guard that clears the debugfs root, so a registration that fails
leaves the root behind with nothing left to remove it, and the next load
finds the name taken. Patch 2 adds a gsp_keep_logs module parameter: when
it is set, whatever the GSP wrote is copied into memory owned by the
module and exposed under a "retained" directory until the module is
unloaded. Patch 3 drops the now completed task from todo.rst.

Changes since v2:
- rebase onto current drm-rust-next, where Coherent carries the lifetime
of the bound device; the live log buffers borrow the device rather
than holding a reference to it, and only the copies keep one
- make gsp_keep_logs a bool, now that module parameters support it
- add the dma_rmb() discussed on v1, as dma_mb(Read), between reading
the "put" pointer and copying the buffer
- build the debugfs guard before the Registration (patch 1), so that a
failed module init cannot leave either directory behind
- keep nothing when CONFIG_DEBUG_FS is off, where a Dir is a zero-sized
type and the copies could never be read back
- take the snapshots before acquiring the global lock, rather than
holding it across three 64 KiB allocations

Testing was done on top of drm-rust-next with the TLV firmware images
installed. On a GB203:

- with gsp_keep_logs unset, no "retained" directory is created and the
entries disappear on unbind, as before;
- with gsp_keep_logs=1, retained/<BDF>/{loginit,logintr,logrm} hold
the contents the live entries had, all 64 KiB of each readable;
- binding the GPU again recreates the live entries without disturbing
the copies, and unbinding it a second time replaces them, leaving
exactly one set behind;
- with a failure injected after the GSP has booted, probe() fails with
-EINVAL, the driver stays unbound, and the logs of that attempt are
still readable;
- with a failure injected into the Registration instead, the module
fails to load and leaves no debugfs directory behind, where before
patch 1 the next load would have found the name taken;
- the copies are released on module unload, and three load/unload
cycles leave nothing behind;
- 1, Y and y turn it on, 0 and N turn it off, and a value that is
neither is refused at load time.

The parameter does need a value: the Rust bool param ops do not set
KERNEL_PARAM_OPS_FL_NOARG, so a bare gsp_keep_logs is refused, where the
C bool would have taken it.

No warnings, oopses or refcount complaints in dmesg throughout. Built and
checked with CLIPPY=1 and rustfmtcheck. checkpatch --strict is clean
apart from the MAINTAINERS note for the new file, which is already
covered by the existing "F: drivers/gpu/nova-core/" pattern.

John Hubbard's r000 series adds three more log buffers in gsp.rs.
Whichever of the two lands second needs a small rebase; the retained
copies extend to the new buffers by adding them to RetainedLogBuffers.

v2: https://lore.kernel.org/nova-gpu/20260815050826.306717-1-vladazaharova2018@xxxxxxxxx/
v1: https://lore.kernel.org/nova-gpu/20260812113752.532537-1-vladazaharova2018@xxxxxxxxx/

Vladislav Zaharov (3):
gpu: nova-core: build the debugfs guard before registering the driver
gpu: nova-core: gsp: retain the GSP-RM log buffers after unbind
Documentation: nova: remove completed GSP log buffer task

Documentation/gpu/nova/core/todo.rst | 12 --
drivers/gpu/nova-core/gsp.rs | 100 ++-------
drivers/gpu/nova-core/gsp/logbuffer.rs | 267 +++++++++++++++++++++++++
drivers/gpu/nova-core/nova_core.rs | 36 +++-
4 files changed, 320 insertions(+), 95 deletions(-)
create mode 100644 drivers/gpu/nova-core/gsp/logbuffer.rs


base-commit: 73e5616f3d197c1af5a04a481fe0f13aa3913bd1
--
2.55.0