[PATCH 14/15] gpu: nova-core: gsp: delete the r570 RPC commands
From: Alexandre Courbot
Date: Thu Dec 03 2026 - 07:15:16 EST
From: John Hubbard <jhubbard@xxxxxxxxxx>
With the switch to the r000 GSP firmware, the GSP_INIT and GSP_SUSPEND
GMC commands replaced the four RPC commands that the r570 boot and
shutdown paths sent (SetSystemInfo, SetRegistry, GetGspStaticInfo and
UnloadingGuestDriver), and the reply to GSP_INIT replaced the init-done
event.
Delete the unused r570 RPC commands module and its firmware payload
wrappers.
Signed-off-by: John Hubbard <jhubbard@xxxxxxxxxx>
Signed-off-by: Alexandre Courbot <acourbot@xxxxxxxxxx>
---
drivers/gpu/nova-core/gsp/commands.rs | 2 -
drivers/gpu/nova-core/gsp/commands/rpc.rs | 285 ------------------------------
drivers/gpu/nova-core/gsp/fw/commands.rs | 250 +-------------------------
3 files changed, 3 insertions(+), 534 deletions(-)
diff --git a/drivers/gpu/nova-core/gsp/commands.rs b/drivers/gpu/nova-core/gsp/commands.rs
index df920e3d8322..cf522a90eae4 100644
--- a/drivers/gpu/nova-core/gsp/commands.rs
+++ b/drivers/gpu/nova-core/gsp/commands.rs
@@ -2,8 +2,6 @@
// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
pub(crate) mod gmc;
-#[expect(dead_code)]
-pub(crate) mod rpc;
use core::{
ffi::FromBytesUntilNulError,
diff --git a/drivers/gpu/nova-core/gsp/commands/rpc.rs b/drivers/gpu/nova-core/gsp/commands/rpc.rs
deleted file mode 100644
index 084214d69f1f..000000000000
--- a/drivers/gpu/nova-core/gsp/commands/rpc.rs
+++ /dev/null
@@ -1,285 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
-
-use core::{
- array,
- convert::Infallible, //
-};
-
-use kernel::{
- device,
- pci,
- prelude::*,
- transmute::{
- AsBytes,
- FromBytes, //
- }, //
-};
-
-use crate::{
- gpu::Chipset,
- gsp::{
- cmdq::{
- rpc::{
- CommandToGsp,
- MessageFromGsp, //
- },
- Cmdq,
- NoReply, //
- },
- commands::{
- GspStaticInfo,
- PowerStateLevel, //
- },
- fw::{
- self,
- MsgFunction, //
- },
- },
- sbuffer::SBufferIter,
- vgpu::VgpuState, //
-};
-
-/// The `GspSetSystemInfo` command.
-pub(crate) struct SetSystemInfo<'a> {
- pdev: &'a pci::Device<device::Bound>,
- chipset: Chipset,
- vgpu_state: VgpuState,
-}
-
-impl<'a> SetSystemInfo<'a> {
- /// Creates a new `GspSetSystemInfo` command using the parameters of `pdev`.
- pub(crate) fn new(
- pdev: &'a pci::Device<device::Bound>,
- chipset: Chipset,
- vgpu_state: VgpuState,
- ) -> Self {
- Self {
- pdev,
- chipset,
- vgpu_state,
- }
- }
-}
-
-impl<'a> CommandToGsp for SetSystemInfo<'a> {
- const FUNCTION: MsgFunction = MsgFunction::GspSetSystemInfo;
- type Command = fw::commands::GspSetSystemInfo;
- type Reply = NoReply;
- type InitError = Error;
-
- fn init(&self) -> impl Init<Self::Command, Self::InitError> {
- Self::Command::init(self.pdev, self.chipset, self.vgpu_state)
- }
-}
-
-struct RegistryEntry {
- key: &'static str,
- value: u32,
-}
-
-/// The `SetRegistry` command.
-pub(crate) struct SetRegistry {
- entries: KVec<RegistryEntry>,
-}
-
-impl SetRegistry {
- /// Creates a new `SetRegistry` command, using a set of hardcoded entries.
- pub(crate) fn new(vgpu_state: VgpuState) -> Result<Self> {
- let mut entries = KVec::new();
-
- // RMSecBusResetEnable - enables PCI secondary bus reset
- entries.push(
- RegistryEntry {
- key: "RMSecBusResetEnable",
- value: 1,
- },
- GFP_KERNEL,
- )?;
-
- // RMForcePcieConfigSave - forces GSP-RM to preserve PCI configuration registers on
- // any PCI reset.
- entries.push(
- RegistryEntry {
- key: "RMForcePcieConfigSave",
- value: 1,
- },
- GFP_KERNEL,
- )?;
-
- // RMDevidCheckIgnore - allows GSP-RM to boot even if the PCI dev ID is not found
- // in the internal product name database.
- entries.push(
- RegistryEntry {
- key: "RMDevidCheckIgnore",
- value: 1,
- },
- GFP_KERNEL,
- )?;
-
- if matches!(vgpu_state, VgpuState::Enabled { .. }) {
- // RMSetSriovMode - required when vGPU is enabled.
- entries.push(
- RegistryEntry {
- key: "RMSetSriovMode",
- value: 1,
- },
- GFP_KERNEL,
- )?;
- }
-
- Ok(Self { entries })
- }
-}
-
-impl CommandToGsp for SetRegistry {
- const FUNCTION: MsgFunction = MsgFunction::SetRegistry;
- type Command = fw::commands::PackedRegistryTable;
- type Reply = NoReply;
- type InitError = Infallible;
-
- fn init(&self) -> impl Init<Self::Command, Self::InitError> {
- Self::Command::init(self.entries.len() as u32, self.size() as u32)
- }
-
- fn variable_payload_len(&self) -> usize {
- let mut key_size = 0;
- for entry in self.entries.iter() {
- key_size += entry.key.len() + 1; // +1 for NULL terminator
- }
- self.entries.len() * size_of::<fw::commands::PackedRegistryEntry>() + key_size
- }
-
- fn init_variable_payload(
- &self,
- dst: &mut SBufferIter<core::array::IntoIter<&mut [u8], 2>>,
- ) -> Result {
- let string_data_start_offset = size_of::<Self::Command>()
- + self.entries.len() * size_of::<fw::commands::PackedRegistryEntry>();
-
- // Array for string data.
- let mut string_data = KVec::new();
-
- for entry in self.entries.iter() {
- dst.write_all(
- fw::commands::PackedRegistryEntry::new(
- (string_data_start_offset + string_data.len()) as u32,
- entry.value,
- )
- .as_bytes(),
- )?;
-
- let key_bytes = entry.key.as_bytes();
- string_data.extend_from_slice(key_bytes, GFP_KERNEL)?;
- string_data.push(0, GFP_KERNEL)?;
- }
-
- dst.write_all(string_data.as_slice())
- }
-}
-
-/// Message type for GSP initialization done notification.
-struct GspInitDone;
-
-// SAFETY: `GspInitDone` is a zero-sized type with no bytes, therefore it
-// trivially has no uninitialized bytes.
-unsafe impl FromBytes for GspInitDone {}
-
-impl MessageFromGsp for GspInitDone {
- const FUNCTION: MsgFunction = MsgFunction::GspInitDone;
- type InitError = Infallible;
- type Message = ();
-
- fn read(
- _msg: &Self::Message,
- _sbuffer: &mut SBufferIter<array::IntoIter<&[u8], 2>>,
- ) -> Result<Self, Self::InitError> {
- Ok(GspInitDone)
- }
-}
-
-/// Waits for GSP initialization to complete.
-pub(crate) fn wait_gsp_init_done(cmdq: &Cmdq<'_>) -> Result {
- cmdq.await_rpc_msg::<GspInitDone>().map(|_| ())
-}
-
-/// The `GetGspStaticInfo` command.
-pub(crate) struct GetGspStaticInfo;
-
-impl CommandToGsp for GetGspStaticInfo {
- const FUNCTION: MsgFunction = MsgFunction::GetGspStaticInfo;
- type Command = fw::commands::GspStaticConfigInfo;
- type Reply = GspStaticInfo;
- type InitError = Infallible;
-
- fn init(&self) -> impl Init<Self::Command, Self::InitError> {
- Self::Command::init_zeroed()
- }
-}
-
-impl MessageFromGsp for GspStaticInfo {
- const FUNCTION: MsgFunction = MsgFunction::GetGspStaticInfo;
- type Message = fw::commands::GspStaticConfigInfo;
- type InitError = Error;
-
- fn read(
- msg: &Self::Message,
- _sbuffer: &mut SBufferIter<array::IntoIter<&[u8], 2>>,
- ) -> Result<Self, Self::InitError> {
- let mut usable_fb_regions = KVec::new();
- for region in msg.usable_fb_regions() {
- usable_fb_regions.push(region, GFP_KERNEL)?;
- }
- let total_fb_end = msg.total_fb_end().ok_or(EINVAL)?;
-
- Ok(GspStaticInfo {
- gpu_name: msg.gpu_name_str(),
- gpu_short_name: msg.gpu_short_name_str(),
- gpu_gid: msg.gpu_gid(),
- bar1_pde_base: msg.bar1_pde_base(),
- usable_fb_regions,
- total_fb_end,
- })
- }
-}
-
-/// The `UnloadingGuestDriver` command, used to shut down the GSP.
-///
-/// Only used within the `gsp` module.
-pub(crate) struct UnloadingGuestDriver {
- level: PowerStateLevel,
-}
-
-impl UnloadingGuestDriver {
- /// Creates a new `UnloadingGuestDriver` command for the given [`PowerStateLevel`].
- pub(crate) fn new(level: PowerStateLevel) -> Self {
- Self { level }
- }
-}
-
-impl CommandToGsp for UnloadingGuestDriver {
- const FUNCTION: MsgFunction = MsgFunction::UnloadingGuestDriver;
- type Command = fw::commands::UnloadingGuestDriver;
- type Reply = UnloadingGuestDriverReply;
- type InitError = Infallible;
-
- fn init(&self) -> impl Init<Self::Command, Self::InitError> {
- fw::commands::UnloadingGuestDriver::new(self.level)
- }
-}
-
-/// The reply from the GSP to the [`UnloadingGuestDriver`] command.
-pub(crate) struct UnloadingGuestDriverReply;
-
-impl MessageFromGsp for UnloadingGuestDriverReply {
- const FUNCTION: MsgFunction = MsgFunction::UnloadingGuestDriver;
- type InitError = Infallible;
- type Message = ();
-
- fn read(
- _msg: &Self::Message,
- _sbuffer: &mut SBufferIter<array::IntoIter<&[u8], 2>>,
- ) -> Result<Self, Self::InitError> {
- Ok(UnloadingGuestDriverReply)
- }
-}
diff --git a/drivers/gpu/nova-core/gsp/fw/commands.rs b/drivers/gpu/nova-core/gsp/fw/commands.rs
index f83a04bc0816..f72b4c94efe6 100644
--- a/drivers/gpu/nova-core/gsp/fw/commands.rs
+++ b/drivers/gpu/nova-core/gsp/fw/commands.rs
@@ -11,11 +11,7 @@
bitfield,
device,
pci,
- prelude::*,
- transmute::{
- AsBytes,
- FromBytes, //
- }, //
+ prelude::*, //
};
use crate::{
@@ -32,230 +28,13 @@
Required,
TruncatingArray, //
},
- GSP_PAGE_SIZE, //
},
- num::IntoSafeCast,
vgpu::VgpuState, //
};
-use super::r570_144 as bindings;
+use super::bindings;
-/// Payload of the `GspSetSystemInfo` command.
-#[repr(transparent)]
-pub(crate) struct GspSetSystemInfo {
- inner: bindings::GspSystemInfo,
-}
-static_assert!(size_of::<GspSetSystemInfo>() < GSP_PAGE_SIZE);
-
-impl GspSetSystemInfo {
- /// Builds the VF topology passed to GSP-RM as part of the system information.
- fn build_vf_info(
- dev: &pci::Device<device::Bound>,
- vgpu_state: VgpuState,
- ) -> Result<bindings::GSP_VF_INFO> {
- let VgpuState::Enabled { total_vfs } = vgpu_state else {
- return Ok(Zeroable::zeroed());
- };
-
- let sriov = dev
- .config_space_extended()?
- .find_ext_capability::<pci::ExtSriovRegs>()?
- .ok_or(ENODEV)?;
-
- let mut vf_bars = sriov.vf_bars()?;
- let bar0 = vf_bars.next().ok_or(EINVAL)?;
- let bar1 = vf_bars.next().ok_or(EINVAL)?;
- let bar2 = vf_bars.next().ok_or(EINVAL)?;
-
- Ok(bindings::GSP_VF_INFO {
- totalVFs: u32::from(total_vfs.get()),
- firstVFOffset: u32::from(sriov.first_vf_offset()),
- FirstVFBar0Address: bar0.address,
- FirstVFBar1Address: bar1.address,
- FirstVFBar2Address: bar2.address,
- b64bitBar0: u8::from(bar0.is_64bit),
- b64bitBar1: u8::from(bar1.is_64bit),
- b64bitBar2: u8::from(bar2.is_64bit),
- ..Zeroable::zeroed()
- })
- }
-
- /// Returns an in-place initializer for the `GspSetSystemInfo` command.
- pub(crate) fn init<'a>(
- dev: &'a pci::Device<device::Bound>,
- chipset: Chipset,
- vgpu_state: VgpuState,
- ) -> impl Init<Self, Error> + 'a {
- type InnerGspSystemInfo = bindings::GspSystemInfo;
- let pci_config_mirror_range = chipset.pci_config_mirror_range();
- let init_inner = try_init!(InnerGspSystemInfo {
- gpuPhysAddr: dev.resource_start(0)?,
- gpuPhysFbAddr: dev.resource_start(1)?,
- gpuPhysInstAddr: dev.resource_start(3)?,
- nvDomainBusDeviceFunc: u64::from(DomainBusDevice::new(dev)),
-
- // Using TASK_SIZE in r535_gsp_rpc_set_system_info() seems wrong because
- // TASK_SIZE is per-task. That's probably a design issue in GSP-RM though.
- maxUserVa: (1 << 47) - 4096,
- pciConfigMirrorBase: pci_config_mirror_range.start,
- pciConfigMirrorSize: pci_config_mirror_range.end - pci_config_mirror_range.start,
-
- PCIDeviceID: (u32::from(dev.device_id()) << 16) | u32::from(dev.vendor_id().as_raw()),
- PCISubDeviceID: (u32::from(dev.subsystem_device_id()) << 16)
- | u32::from(dev.subsystem_vendor_id()),
- PCIRevisionID: u32::from(dev.revision_id()),
- bIsPrimary: 0,
- bPreserveVideoMemoryAllocations: 0,
- gspVFInfo: Self::build_vf_info(dev, vgpu_state)?,
- ..Zeroable::init_zeroed()
- });
-
- try_init!(GspSetSystemInfo {
- inner <- init_inner,
- })
- }
-}
-
-// SAFETY: These structs don't meet the no-padding requirements of AsBytes but
-// that is not a problem because they are not used outside the kernel.
-unsafe impl AsBytes for GspSetSystemInfo {}
-
-// SAFETY: These structs don't meet the no-padding requirements of FromBytes but
-// that is not a problem because they are not used outside the kernel.
-unsafe impl FromBytes for GspSetSystemInfo {}
-
-#[repr(transparent)]
-pub(crate) struct PackedRegistryEntry(bindings::PACKED_REGISTRY_ENTRY);
-
-impl PackedRegistryEntry {
- pub(crate) fn new(offset: u32, value: u32) -> Self {
- Self({
- bindings::PACKED_REGISTRY_ENTRY {
- nameOffset: offset,
-
- // We only support DWORD types for now. Support for other types
- // will come later if required.
- type_: cv!(bindings::REGISTRY_TABLE_ENTRY_TYPE_DWORD),
- __bindgen_padding_0: Default::default(),
- data: value,
- length: 0,
- }
- })
- }
-}
-
-// SAFETY: Padding is explicit and will not contain uninitialized data.
-unsafe impl AsBytes for PackedRegistryEntry {}
-
-/// Payload of the `SetRegistry` command.
-#[repr(transparent)]
-pub(crate) struct PackedRegistryTable {
- inner: bindings::PACKED_REGISTRY_TABLE,
-}
-
-impl PackedRegistryTable {
- pub(crate) fn init(num_entries: u32, size: u32) -> impl Init<Self> {
- type InnerPackedRegistryTable = bindings::PACKED_REGISTRY_TABLE;
- let init_inner = init!(InnerPackedRegistryTable {
- numEntries: num_entries,
- size,
- entries: Default::default()
- });
-
- init!(PackedRegistryTable { inner <- init_inner })
- }
-}
-
-// SAFETY: Padding is explicit and will not contain uninitialized data.
-unsafe impl AsBytes for PackedRegistryTable {}
-
-// SAFETY: This struct only contains integer types for which all bit patterns
-// are valid.
-unsafe impl FromBytes for PackedRegistryTable {}
-
-/// Payload of the `GetGspStaticInfo` command and message.
-#[repr(transparent)]
-#[derive(Zeroable)]
-pub(crate) struct GspStaticConfigInfo(bindings::GspStaticConfigInfo_t);
-
-impl GspStaticConfigInfo {
- /// Returns a bytes array containing the (hopefully) zero-terminated name of this GPU.
- pub(crate) fn gpu_name_str(&self) -> [u8; GspStaticInfo::MAX_GPU_NAME_LEN] {
- self.0.gpuNameString
- }
-
- /// Returns a bytes array containing the (hopefully) zero-terminated short name of this GPU.
- pub(crate) fn gpu_short_name_str(&self) -> [u8; GspStaticInfo::MAX_GPU_NAME_LEN] {
- self.0.gpuShortNameString
- }
-
- /// Returns the 16-byte SHA-1 GPU identifier supplied by GSP-RM.
- ///
- /// GSP-RM reports the GID in binary SHA-1 form, which occupies the first 16 bytes of the
- /// GID info payload.
- pub(crate) fn gpu_gid(&self) -> [u8; GspStaticInfo::GID_LEN] {
- let mut gid = [0u8; GspStaticInfo::GID_LEN];
- gid.copy_from_slice(&self.0.gidInfo.data[..GspStaticInfo::GID_LEN]);
- gid
- }
-
- /// Returns the BAR1 Page Directory Entry base address.
- ///
- /// This is the root page table address for BAR1 virtual memory,
- /// set up by GSP-RM firmware.
- pub(crate) fn bar1_pde_base(&self) -> u64 {
- self.0.bar1PdeBase
- }
-
- /// Returns an iterator over valid FB regions from GSP firmware data.
- fn fb_regions(
- &self,
- ) -> impl Iterator<Item = &bindings::NV2080_CTRL_CMD_FB_GET_FB_REGION_FB_REGION_INFO> {
- let fb_info = &self.0.fbRegionInfoParams;
- fb_info
- .fbRegion
- .iter()
- .take(fb_info.numFBRegions.into_safe_cast())
- .filter(|reg| reg.limit >= reg.base)
- }
-
- /// Iterates over usable FB regions from GSP firmware data.
- ///
- /// Each yielded region is a [`Range<u64>`] suitable for driver memory allocation.
- /// Usable regions are those that satisfy all the following properties:
- /// - Are not reserved for firmware internal use.
- /// - Are not protected (hardware-enforced access restrictions).
- /// - Support compression (can use GPU memory compression for bandwidth).
- /// - Support ISO (isochronous memory for display requiring guaranteed bandwidth).
- pub(crate) fn usable_fb_regions(&self) -> impl Iterator<Item = Range<u64>> + '_ {
- self.fb_regions().filter_map(|reg| {
- // Filter: not reserved, not protected, supports compression and ISO.
- if reg.reserved == 0
- && reg.bProtected == 0
- && reg.supportCompressed != 0
- && reg.supportISO != 0
- {
- reg.limit.checked_add(1).map(|end| reg.base..end)
- } else {
- None
- }
- })
- }
-
- /// Computes the exclusive end of the FB physical address space.
- pub(crate) fn total_fb_end(&self) -> Option<u64> {
- self.fb_regions().map(|reg| reg.limit).max()?.checked_add(1)
- }
-}
-
-// SAFETY: Padding is explicit and will not contain uninitialized data.
-unsafe impl AsBytes for GspStaticConfigInfo {}
-
-// SAFETY: This struct only contains integer types for which all bit patterns
-// are valid.
-unsafe impl FromBytes for GspStaticConfigInfo {}
-
-/// Power level requested to the [`UnloadingGuestDriver`] command.
+/// Power level that a `GSP_SUSPEND` request names.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u32)]
#[expect(unused)]
@@ -295,29 +74,6 @@ fn from(level: PowerStateLevel) -> Self {
}
}
-/// Payload of the `UnloadingGuestDriver` command and message.
-#[repr(transparent)]
-#[derive(Clone, Copy, Debug, Zeroable)]
-pub(crate) struct UnloadingGuestDriver(bindings::rpc_unloading_guest_driver_v1F_07);
-
-impl UnloadingGuestDriver {
- pub(crate) fn new(level: PowerStateLevel) -> Self {
- Self(bindings::rpc_unloading_guest_driver_v1F_07 {
- bInPMTransition: u8::from(level.is_power_transition()),
- bGc6Entering: 0,
- newLevel: level as u32,
- ..Zeroable::zeroed()
- })
- }
-}
-
-// SAFETY: Padding is explicit and will not contain uninitialized data.
-unsafe impl AsBytes for UnloadingGuestDriver {}
-
-// SAFETY: This struct only contains integer types for which all bit patterns
-// are valid.
-unsafe impl FromBytes for UnloadingGuestDriver {}
-
/// The host CPU architecture.
#[derive(Clone, Copy)]
enum HostArch {
--
2.56.1