[PATCH v3 9/9] gpu: nova-core: gsp: add FaultMethodBufferSize RM control command
From: Eliot Courtney
Date: Wed Mar 25 2026 - 09:07:41 EST
Add `CeGetFaultMethodBufferSizeParams` which wraps the bindings.
Add `FaultMethodBufferSize` RM control command which returns the fault
method buffer size we should use. This is needed for channel allocation.
Finally, print out the fault method buffer size on GSP boot.
Signed-off-by: Eliot Courtney <ecourtney@xxxxxxxxxx>
---
drivers/gpu/nova-core/gsp/boot.rs | 11 +++++++++++
drivers/gpu/nova-core/gsp/commands.rs | 2 --
drivers/gpu/nova-core/gsp/fw/rm.rs | 25 ++++++++++++++++++++---
drivers/gpu/nova-core/gsp/rm/commands.rs | 34 ++++++++++++++++++++++++++++----
4 files changed, 63 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/nova-core/gsp/boot.rs b/drivers/gpu/nova-core/gsp/boot.rs
index e55210ebb6d1..8a4ad4c6ea98 100644
--- a/drivers/gpu/nova-core/gsp/boot.rs
+++ b/drivers/gpu/nova-core/gsp/boot.rs
@@ -33,6 +33,10 @@
gpu::Chipset,
gsp::{
commands,
+ rm::commands::{
+ FaultMethodBufferSize,
+ RmControl, //
+ },
sequencer::{
GspSequencer,
GspSequencerParams, //
@@ -232,6 +236,13 @@ pub(crate) fn boot(
Err(e) => dev_warn!(pdev, "GPU name unavailable: {:?}\n", e),
}
+ match RmControl::new(info.client(), info.subdevice(), FaultMethodBufferSize)
+ .send(&self.cmdq, bar)
+ {
+ Ok(size) => dev_info!(pdev, "Fault method buffer size: {} bytes\n", size),
+ Err(e) => dev_warn!(pdev, "Failed to get fault method buffer size: {:?}\n", e),
+ }
+
Ok(())
}
}
diff --git a/drivers/gpu/nova-core/gsp/commands.rs b/drivers/gpu/nova-core/gsp/commands.rs
index 8c9599aa227b..56655bade9ab 100644
--- a/drivers/gpu/nova-core/gsp/commands.rs
+++ b/drivers/gpu/nova-core/gsp/commands.rs
@@ -285,13 +285,11 @@ pub(crate) fn gpu_name(&self) -> core::result::Result<&str, GpuNameError> {
}
/// Returns the client handle allocated by GSP-RM.
- #[expect(dead_code)]
pub(crate) fn client(&self) -> Handle<Client> {
self.client
}
/// Returns the subdevice handle allocated by GSP-RM.
- #[expect(dead_code)]
pub(crate) fn subdevice(&self) -> Handle<Subdevice> {
self.subdevice
}
diff --git a/drivers/gpu/nova-core/gsp/fw/rm.rs b/drivers/gpu/nova-core/gsp/fw/rm.rs
index 1c6e8b4c4865..73913541d9d4 100644
--- a/drivers/gpu/nova-core/gsp/fw/rm.rs
+++ b/drivers/gpu/nova-core/gsp/fw/rm.rs
@@ -8,9 +8,12 @@
}, //
};
-use crate::gsp::commands::{
- Client,
- Handle, //
+use crate::{
+ gsp::commands::{
+ Client,
+ Handle, //
+ },
+ num, //
};
use super::{
@@ -85,3 +88,19 @@ unsafe impl FromBytes for GspRmControl {}
// SAFETY: This struct contains no padding.
unsafe impl AsBytes for GspRmControl {}
+
+/// Wrapper for [`bindings::NV2080_CTRL_CE_GET_FAULT_METHOD_BUFFER_SIZE_PARAMS`].
+#[repr(transparent)]
+pub(crate) struct CeGetFaultMethodBufferSizeParams(
+ bindings::NV2080_CTRL_CE_GET_FAULT_METHOD_BUFFER_SIZE_PARAMS,
+);
+
+impl CeGetFaultMethodBufferSizeParams {
+ /// Returns the CE fault method buffer size in bytes.
+ pub(crate) fn size(&self) -> usize {
+ num::u32_as_usize(self.0.size)
+ }
+}
+
+// SAFETY: This struct only contains integer types for which all bit patterns are valid.
+unsafe impl FromBytes for CeGetFaultMethodBufferSizeParams {}
diff --git a/drivers/gpu/nova-core/gsp/rm/commands.rs b/drivers/gpu/nova-core/gsp/rm/commands.rs
index 8845ca0a0225..de290f4845f4 100644
--- a/drivers/gpu/nova-core/gsp/rm/commands.rs
+++ b/drivers/gpu/nova-core/gsp/rm/commands.rs
@@ -1,8 +1,14 @@
// SPDX-License-Identifier: GPL-2.0
-use core::array;
+use core::{
+ array,
+ mem::size_of, //
+};
-use kernel::prelude::*;
+use kernel::{
+ prelude::*,
+ transmute::FromBytes, //
+};
use crate::{
driver::Bar0,
@@ -14,7 +20,8 @@
},
commands::{
Client,
- Handle, //
+ Handle,
+ Subdevice, //
},
fw::{
rm::*,
@@ -75,7 +82,6 @@ pub(crate) struct RmControl<T>
cmd: T,
}
-#[expect(unused)]
impl<T: RmControlCommand> RmControl<T> {
/// Creates a new RM control command.
pub(crate) fn new(client: Handle<Client>, object: Handle<T::Target>, cmd: T) -> Self {
@@ -139,3 +145,23 @@ pub(crate) trait RmControlCommand {
/// reply type.
fn parse_reply(&self, params: &[u8]) -> Result<Self::Reply>;
}
+
+/// RM control command for querying the fault method buffer size. This is required for setting up
+/// channels.
+pub(crate) struct FaultMethodBufferSize;
+
+impl RmControlCommand for FaultMethodBufferSize {
+ const FUNCTION: RmControlMsgFunction = RmControlMsgFunction::CeGetFaultMethodBufferSize;
+ const LEN: usize = size_of::<CeGetFaultMethodBufferSizeParams>();
+ type Reply = usize;
+ type Target = Subdevice;
+
+ fn write_payload(&self, dst: &mut SBufferIter<array::IntoIter<&mut [u8], 2>>) -> Result {
+ dst.write_all(&[0u8; Self::LEN])
+ }
+
+ fn parse_reply(&self, params: &[u8]) -> Result<Self::Reply> {
+ let reply = CeGetFaultMethodBufferSizeParams::from_bytes(params).ok_or(EINVAL)?;
+ Ok(reply.size())
+ }
+}
--
2.53.0