[PATCH v3 2/9] gpu: nova-core: gsp: add NvStatus enum for RM control errors

Eliot Courtney
2026-03-25T12:14:04Z

Add NvStatus enum that wraps the raw NV_STATUS u32 codes returned by RM
control RPCs.

Signed-off-by: Eliot Courtney <ecourtney@nvidia.com>
---
drivers/gpu/nova-core/gsp/fw.rs | 401 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 401 insertions(+)

diff --git a/drivers/gpu/nova-core/gsp/fw.rs b/drivers/gpu/nova-core/gsp/fw.rs
index 0c8a74f0e8ac..cb4bda253193 100644
--- a/drivers/gpu/nova-core/gsp/fw.rs
+++ b/drivers/gpu/nova-core/gsp/fw.rs
@@ -97,6 +97,407 @@ pub(in crate::gsp) fn advance_cpu_write_ptr(qs: &Coherent<GspMem>, count: u32) {
pub(crate) const GSP_MSG_QUEUE_ELEMENT_SIZE_MAX: usize =
num::u32_as_usize(bindings::GSP_MSG_QUEUE_ELEMENT_SIZE_MAX);

+/// Status code returned by GSP-RM RPCs.
+#[derive(Copy, Clone, Debug, PartialEq, Eq)]
+pub(crate) enum NvStatus {
+ Ok,
+ AlreadySignalled,
+ BrokenFb,
+ BufferTooSmall,
+ BusyRetry,
+ CallbackNotScheduled,
+ CardNotPresent,
+ CycleDetected,
+ DmaInUse,
+ DmaMemNotLocked,
+ DmaMemNotUnlocked,
+ DualLinkInuse,
+ EccError,
+ FabricManagerNotPresent,
+ FatalError,
+ FeatureNotEnabled,
+ FifoBadAccess,
+ FlcnError,
+ FreqNotSupported,
+ Generic,
+ GpuDmaNotInitialized,
+ GpuInDebugMode,
+ GpuInFullchipReset,
+ GpuIsLost,
+ GpuMemoryOnliningFailure,
+ GpuNotFullPower,
+ GpuUuidNotFound,
+ HotSwitch,
+ I2cError,
+ I2cSpeedTooHigh,
+ IllegalAction,
+ InUse,
+ InflateCompressedDataFailed,
+ InsertDuplicateName,
+ InsufficientPermissions,
+ InsufficientPower,
+ InsufficientResources,
+ InsufficientZbcEntry,
+ InvalidAccessType,
+ InvalidAddress,
+ InvalidArgument,
+ InvalidBase,
+ InvalidChannel,
+ InvalidClass,
+ InvalidClient,
+ InvalidCommand,
+ InvalidData,
+ InvalidDevice,
+ InvalidDmaSpecifier,
+ InvalidEvent,
+ InvalidFlags,
+ InvalidFunction,
+ InvalidHeap,
+ InvalidIndex,
+ InvalidIrqLevel,
+ InvalidLicense,
+ InvalidLimit,
+ InvalidLockState,
+ InvalidMethod,
+ InvalidObject,
+ InvalidObjectBuffer,
+ InvalidObjectHandle,
+ InvalidObjectNew,
+ InvalidObjectOld,
+ InvalidObjectParent,
+ InvalidOffset,
+ InvalidOperation,
+ InvalidOwner,
+ InvalidParamStruct,
+ InvalidParameter,
+ InvalidPath,
+ InvalidPointer,
+ InvalidRead,
+ InvalidRegistryKey,
+ InvalidRequest,
+ InvalidState,
+ InvalidStringLength,
+ InvalidWrite,
+ InvalidXlate,
+ IrqEdgeTriggered,
+ IrqNotFiring,
+ KeyRotationInProgress,
+ LibRmVersionMismatch,
+ MaxSessionLimitReached,
+ MemoryError,
+ MemoryTrainingFailed,
+ MismatchedSlave,
+ MismatchedTarget,
+ MissingTableEntry,
+ ModuleLoadFailed,
+ MoreDataAvailable,
+ MoreProcessingRequired,
+ MultipleMemoryTypes,
+ NoFreeFifos,
+ NoIntrPending,
+ NoMemory,
+ NoSuchDomain,
+ NoValidPath,
+ NotCompatible,
+ NotReady,
+ NotSupported,
+ NvlinkClockError,
+ NvlinkConfigurationError,
+ NvlinkFabricFailure,
+ NvlinkFabricNotReady,
+ NvlinkInitError,
+ NvlinkMinionError,
+ NvlinkTrainingError,
+ ObjectNotFound,
+ ObjectTypeMismatch,
+ OperatingSystem,
+ OtherDeviceFound,
+ OutOfRange,
+ OverlappingUvmCommit,
+ PageTableNotAvail,
+ PidNotFound,
+ PmuNotReady,
+ PrivSecViolation,
+ ProtectionFault,
+ QueueTaskSlotNotAvailable,
+ RcError,
+ ReductionManagerNotAvailable,
+ RejectedVbios,
+ ResetRequired,
+ ResourceLost,
+ ResourceRetirementError,
+ RiscvError,
+ SecureBootFailed,
+ SignalPending,
+ StateInUse,
+ TestOnlyCodeNotEnabled,
+ Timeout,
+ TimeoutRetry,
+ TooManyPrimaries,
+ UvmAddressInUse,
+ Unknown(u32),
+}
+
+impl From<NvStatus> for Result {
+ fn from(status: NvStatus) -> Self {
+ match status {
+ NvStatus::Ok => Ok(()),
+
+ NvStatus::BufferTooSmall | NvStatus::MoreDataAvailable => Err(EMSGSIZE),
+
+ NvStatus::BusyRetry
+ | NvStatus::DmaInUse
+ | NvStatus::DualLinkInuse
+ | NvStatus::GpuInFullchipReset
+ | NvStatus::InUse
+ | NvStatus::KeyRotationInProgress
+ | NvStatus::NotReady
+ | NvStatus::NvlinkFabricNotReady
+ | NvStatus::PmuNotReady
+ | NvStatus::StateInUse
+ | NvStatus::UvmAddressInUse => Err(EBUSY),
+
+ NvStatus::CardNotPresent
+ | NvStatus::FabricManagerNotPresent
+ | NvStatus::InvalidDevice
+ | NvStatus::ReductionManagerNotAvailable => Err(ENODEV),
+
+ NvStatus::FeatureNotEnabled
+ | NvStatus::FreqNotSupported
+ | NvStatus::NotSupported
+ | NvStatus::TestOnlyCodeNotEnabled => Err(ENOTSUPP),
+
+ NvStatus::GpuUuidNotFound
+ | NvStatus::MissingTableEntry
+ | NvStatus::NoSuchDomain
+ | NvStatus::NoValidPath
+ | NvStatus::ObjectNotFound => Err(ENOENT),
+
+ NvStatus::I2cSpeedTooHigh
+ | NvStatus::InvalidAccessType
+ | NvStatus::InvalidArgument
+ | NvStatus::InvalidBase
+ | NvStatus::InvalidChannel
+ | NvStatus::InvalidClass
+ | NvStatus::InvalidClient
+ | NvStatus::InvalidCommand
+ | NvStatus::InvalidData
+ | NvStatus::InvalidDmaSpecifier
+ | NvStatus::InvalidEvent
+ | NvStatus::InvalidFlags
+ | NvStatus::InvalidFunction
+ | NvStatus::InvalidHeap
+ | NvStatus::InvalidIndex
+ | NvStatus::InvalidIrqLevel
+ | NvStatus::InvalidLimit
+ | NvStatus::InvalidLockState
+ | NvStatus::InvalidMethod
+ | NvStatus::InvalidObject
+ | NvStatus::InvalidObjectBuffer
+ | NvStatus::InvalidObjectHandle
+ | NvStatus::InvalidObjectNew
+ | NvStatus::InvalidObjectOld
+ | NvStatus::InvalidObjectParent
+ | NvStatus::InvalidOffset
+ | NvStatus::InvalidOperation
+ | NvStatus::InvalidOwner
+ | NvStatus::InvalidParamStruct
+ | NvStatus::InvalidParameter
+ | NvStatus::InvalidPath
+ | NvStatus::InvalidRegistryKey
+ | NvStatus::InvalidRequest
+ | NvStatus::InvalidState
+ | NvStatus::InvalidStringLength
+ | NvStatus::InvalidXlate
+ | NvStatus::LibRmVersionMismatch
+ | NvStatus::MismatchedSlave
+ | NvStatus::MismatchedTarget
+ | NvStatus::MultipleMemoryTypes
+ | NvStatus::NotCompatible
+ | NvStatus::ObjectTypeMismatch
+ | NvStatus::OverlappingUvmCommit
+ | NvStatus::RejectedVbios => Err(EINVAL),
+
+ NvStatus::IllegalAction => Err(EPERM),
+
+ NvStatus::InsertDuplicateName => Err(EEXIST),
+
+ NvStatus::InsufficientPermissions
+ | NvStatus::InvalidLicense
+ | NvStatus::PrivSecViolation => Err(EACCES),
+
+ NvStatus::InsufficientResources | NvStatus::NoMemory | NvStatus::PageTableNotAvail => {
+ Err(ENOMEM)
+ }
+
+ NvStatus::InsufficientZbcEntry
+ | NvStatus::MaxSessionLimitReached
+ | NvStatus::NoFreeFifos
+ | NvStatus::QueueTaskSlotNotAvailable
+ | NvStatus::TooManyPrimaries => Err(ENOSPC),
+
+ NvStatus::InvalidAddress | NvStatus::InvalidPointer | NvStatus::ProtectionFault => {
+ Err(EFAULT)
+ }
+
+ NvStatus::MoreProcessingRequired | NvStatus::TimeoutRetry => Err(EAGAIN),
+
+ NvStatus::OutOfRange => Err(ERANGE),
+
+ NvStatus::PidNotFound => Err(ESRCH),
+
+ NvStatus::SignalPending => Err(EINTR),
+
+ NvStatus::Timeout => Err(ETIMEDOUT),
+
+ _ => Err(EIO),
+ }
+ }
+}
+
+impl From<u32> for NvStatus {
+ fn from(value: u32) -> Self {
+ match value {
+ bindings::NV_OK => Self::Ok,
+ bindings::NV_ERR_ALREADY_SIGNALLED => Self::AlreadySignalled,
+ bindings::NV_ERR_BROKEN_FB => Self::BrokenFb,
+ bindings::NV_ERR_BUFFER_TOO_SMALL => Self::BufferTooSmall,
+ bindings::NV_ERR_BUSY_RETRY => Self::BusyRetry,
+ bindings::NV_ERR_CALLBACK_NOT_SCHEDULED => Self::CallbackNotScheduled,
+ bindings::NV_ERR_CARD_NOT_PRESENT => Self::CardNotPresent,
+ bindings::NV_ERR_CYCLE_DETECTED => Self::CycleDetected,
+ bindings::NV_ERR_DMA_IN_USE => Self::DmaInUse,
+ bindings::NV_ERR_DMA_MEM_NOT_LOCKED => Self::DmaMemNotLocked,
+ bindings::NV_ERR_DMA_MEM_NOT_UNLOCKED => Self::DmaMemNotUnlocked,
+ bindings::NV_ERR_DUAL_LINK_INUSE => Self::DualLinkInuse,
+ bindings::NV_ERR_ECC_ERROR => Self::EccError,
+ bindings::NV_ERR_FABRIC_MANAGER_NOT_PRESENT => Self::FabricManagerNotPresent,
+ bindings::NV_ERR_FATAL_ERROR => Self::FatalError,
+ bindings::NV_ERR_FEATURE_NOT_ENABLED => Self::FeatureNotEnabled,
+ bindings::NV_ERR_FIFO_BAD_ACCESS => Self::FifoBadAccess,
+ bindings::NV_ERR_FLCN_ERROR => Self::FlcnError,
+ bindings::NV_ERR_FREQ_NOT_SUPPORTED => Self::FreqNotSupported,
+ bindings::NV_ERR_GENERIC => Self::Generic,
+ bindings::NV_ERR_GPU_DMA_NOT_INITIALIZED => Self::GpuDmaNotInitialized,
+ bindings::NV_ERR_GPU_IN_DEBUG_MODE => Self::GpuInDebugMode,
+ bindings::NV_ERR_GPU_IN_FULLCHIP_RESET => Self::GpuInFullchipReset,
+ bindings::NV_ERR_GPU_IS_LOST => Self::GpuIsLost,
+ bindings::NV_ERR_GPU_MEMORY_ONLINING_FAILURE => Self::GpuMemoryOnliningFailure,
+ bindings::NV_ERR_GPU_NOT_FULL_POWER => Self::GpuNotFullPower,
+ bindings::NV_ERR_GPU_UUID_NOT_FOUND => Self::GpuUuidNotFound,
+ bindings::NV_ERR_HOT_SWITCH => Self::HotSwitch,
+ bindings::NV_ERR_I2C_ERROR => Self::I2cError,
+ bindings::NV_ERR_I2C_SPEED_TOO_HIGH => Self::I2cSpeedTooHigh,
+ bindings::NV_ERR_ILLEGAL_ACTION => Self::IllegalAction,
+ bindings::NV_ERR_IN_USE => Self::InUse,
+ bindings::NV_ERR_INFLATE_COMPRESSED_DATA_FAILED => Self::InflateCompressedDataFailed,
+ bindings::NV_ERR_INSERT_DUPLICATE_NAME => Self::InsertDuplicateName,
+ bindings::NV_ERR_INSUFFICIENT_PERMISSIONS => Self::InsufficientPermissions,
+ bindings::NV_ERR_INSUFFICIENT_POWER => Self::InsufficientPower,
+ bindings::NV_ERR_INSUFFICIENT_RESOURCES => Self::InsufficientResources,
+ bindings::NV_ERR_INSUFFICIENT_ZBC_ENTRY => Self::InsufficientZbcEntry,
+ bindings::NV_ERR_INVALID_ACCESS_TYPE => Self::InvalidAccessType,
+ bindings::NV_ERR_INVALID_ADDRESS => Self::InvalidAddress,
+ bindings::NV_ERR_INVALID_ARGUMENT => Self::InvalidArgument,
+ bindings::NV_ERR_INVALID_BASE => Self::InvalidBase,
+ bindings::NV_ERR_INVALID_CHANNEL => Self::InvalidChannel,
+ bindings::NV_ERR_INVALID_CLASS => Self::InvalidClass,
+ bindings::NV_ERR_INVALID_CLIENT => Self::InvalidClient,
+ bindings::NV_ERR_INVALID_COMMAND => Self::InvalidCommand,
+ bindings::NV_ERR_INVALID_DATA => Self::InvalidData,
+ bindings::NV_ERR_INVALID_DEVICE => Self::InvalidDevice,
+ bindings::NV_ERR_INVALID_DMA_SPECIFIER => Self::InvalidDmaSpecifier,
+ bindings::NV_ERR_INVALID_EVENT => Self::InvalidEvent,
+ bindings::NV_ERR_INVALID_FLAGS => Self::InvalidFlags,
+ bindings::NV_ERR_INVALID_FUNCTION => Self::InvalidFunction,
+ bindings::NV_ERR_INVALID_HEAP => Self::InvalidHeap,
+ bindings::NV_ERR_INVALID_INDEX => Self::InvalidIndex,
+ bindings::NV_ERR_INVALID_IRQ_LEVEL => Self::InvalidIrqLevel,
+ bindings::NV_ERR_INVALID_LICENSE => Self::InvalidLicense,
+ bindings::NV_ERR_INVALID_LIMIT => Self::InvalidLimit,
+ bindings::NV_ERR_INVALID_LOCK_STATE => Self::InvalidLockState,
+ bindings::NV_ERR_INVALID_METHOD => Self::InvalidMethod,
+ bindings::NV_ERR_INVALID_OBJECT => Self::InvalidObject,
+ bindings::NV_ERR_INVALID_OBJECT_BUFFER => Self::InvalidObjectBuffer,
+ bindings::NV_ERR_INVALID_OBJECT_HANDLE => Self::InvalidObjectHandle,
+ bindings::NV_ERR_INVALID_OBJECT_NEW => Self::InvalidObjectNew,
+ bindings::NV_ERR_INVALID_OBJECT_OLD => Self::InvalidObjectOld,
+ bindings::NV_ERR_INVALID_OBJECT_PARENT => Self::InvalidObjectParent,
+ bindings::NV_ERR_INVALID_OFFSET => Self::InvalidOffset,
+ bindings::NV_ERR_INVALID_OPERATION => Self::InvalidOperation,
+ bindings::NV_ERR_INVALID_OWNER => Self::InvalidOwner,
+ bindings::NV_ERR_INVALID_PARAM_STRUCT => Self::InvalidParamStruct,
+ bindings::NV_ERR_INVALID_PARAMETER => Self::InvalidParameter,
+ bindings::NV_ERR_INVALID_PATH => Self::InvalidPath,
+ bindings::NV_ERR_INVALID_POINTER => Self::InvalidPointer,
+ bindings::NV_ERR_INVALID_READ => Self::InvalidRead,
+ bindings::NV_ERR_INVALID_REGISTRY_KEY => Self::InvalidRegistryKey,
+ bindings::NV_ERR_INVALID_REQUEST => Self::InvalidRequest,
+ bindings::NV_ERR_INVALID_STATE => Self::InvalidState,
+ bindings::NV_ERR_INVALID_STRING_LENGTH => Self::InvalidStringLength,
+ bindings::NV_ERR_INVALID_WRITE => Self::InvalidWrite,
+ bindings::NV_ERR_INVALID_XLATE => Self::InvalidXlate,
+ bindings::NV_ERR_IRQ_EDGE_TRIGGERED => Self::IrqEdgeTriggered,
+ bindings::NV_ERR_IRQ_NOT_FIRING => Self::IrqNotFiring,
+ bindings::NV_ERR_KEY_ROTATION_IN_PROGRESS => Self::KeyRotationInProgress,
+ bindings::NV_ERR_LIB_RM_VERSION_MISMATCH => Self::LibRmVersionMismatch,
+ bindings::NV_ERR_MAX_SESSION_LIMIT_REACHED => Self::MaxSessionLimitReached,
+ bindings::NV_ERR_MEMORY_ERROR => Self::MemoryError,
+ bindings::NV_ERR_MEMORY_TRAINING_FAILED => Self::MemoryTrainingFailed,
+ bindings::NV_ERR_MISMATCHED_SLAVE => Self::MismatchedSlave,
+ bindings::NV_ERR_MISMATCHED_TARGET => Self::MismatchedTarget,
+ bindings::NV_ERR_MISSING_TABLE_ENTRY => Self::MissingTableEntry,
+ bindings::NV_ERR_MODULE_LOAD_FAILED => Self::ModuleLoadFailed,
+ bindings::NV_ERR_MORE_DATA_AVAILABLE => Self::MoreDataAvailable,
+ bindings::NV_ERR_MORE_PROCESSING_REQUIRED => Self::MoreProcessingRequired,
+ bindings::NV_ERR_MULTIPLE_MEMORY_TYPES => Self::MultipleMemoryTypes,
+ bindings::NV_ERR_NO_FREE_FIFOS => Self::NoFreeFifos,
+ bindings::NV_ERR_NO_INTR_PENDING => Self::NoIntrPending,
+ bindings::NV_ERR_NO_MEMORY => Self::NoMemory,
+ bindings::NV_ERR_NO_SUCH_DOMAIN => Self::NoSuchDomain,
+ bindings::NV_ERR_NO_VALID_PATH => Self::NoValidPath,
+ bindings::NV_ERR_NOT_COMPATIBLE => Self::NotCompatible,
+ bindings::NV_ERR_NOT_READY => Self::NotReady,
+ bindings::NV_ERR_NOT_SUPPORTED => Self::NotSupported,
+ bindings::NV_ERR_NVLINK_CLOCK_ERROR => Self::NvlinkClockError,
+ bindings::NV_ERR_NVLINK_CONFIGURATION_ERROR => Self::NvlinkConfigurationError,
+ bindings::NV_ERR_NVLINK_FABRIC_FAILURE => Self::NvlinkFabricFailure,
+ bindings::NV_ERR_NVLINK_FABRIC_NOT_READY => Self::NvlinkFabricNotReady,
+ bindings::NV_ERR_NVLINK_INIT_ERROR => Self::NvlinkInitError,
+ bindings::NV_ERR_NVLINK_MINION_ERROR => Self::NvlinkMinionError,
+ bindings::NV_ERR_NVLINK_TRAINING_ERROR => Self::NvlinkTrainingError,
+ bindings::NV_ERR_OBJECT_NOT_FOUND => Self::ObjectNotFound,
+ bindings::NV_ERR_OBJECT_TYPE_MISMATCH => Self::ObjectTypeMismatch,
+ bindings::NV_ERR_OPERATING_SYSTEM => Self::OperatingSystem,
+ bindings::NV_ERR_OTHER_DEVICE_FOUND => Self::OtherDeviceFound,
+ bindings::NV_ERR_OUT_OF_RANGE => Self::OutOfRange,
+ bindings::NV_ERR_OVERLAPPING_UVM_COMMIT => Self::OverlappingUvmCommit,
+ bindings::NV_ERR_PAGE_TABLE_NOT_AVAIL => Self::PageTableNotAvail,
+ bindings::NV_ERR_PID_NOT_FOUND => Self::PidNotFound,
+ bindings::NV_ERR_PMU_NOT_READY => Self::PmuNotReady,
+ bindings::NV_ERR_PRIV_SEC_VIOLATION => Self::PrivSecViolation,
+ bindings::NV_ERR_PROTECTION_FAULT => Self::ProtectionFault,
+ bindings::NV_ERR_QUEUE_TASK_SLOT_NOT_AVAILABLE => Self::QueueTaskSlotNotAvailable,
+ bindings::NV_ERR_RC_ERROR => Self::RcError,
+ bindings::NV_ERR_REDUCTION_MANAGER_NOT_AVAILABLE => Self::ReductionManagerNotAvailable,
+ bindings::NV_ERR_REJECTED_VBIOS => Self::RejectedVbios,
+ bindings::NV_ERR_RESET_REQUIRED => Self::ResetRequired,
+ bindings::NV_ERR_RESOURCE_LOST => Self::ResourceLost,
+ bindings::NV_ERR_RESOURCE_RETIREMENT_ERROR => Self::ResourceRetirementError,
+ bindings::NV_ERR_RISCV_ERROR => Self::RiscvError,
+ bindings::NV_ERR_SECURE_BOOT_FAILED => Self::SecureBootFailed,
+ bindings::NV_ERR_SIGNAL_PENDING => Self::SignalPending,
+ bindings::NV_ERR_STATE_IN_USE => Self::StateInUse,
+ bindings::NV_ERR_TEST_ONLY_CODE_NOT_ENABLED => Self::TestOnlyCodeNotEnabled,
+ bindings::NV_ERR_TIMEOUT => Self::Timeout,
+ bindings::NV_ERR_TIMEOUT_RETRY => Self::TimeoutRetry,
+ bindings::NV_ERR_TOO_MANY_PRIMARIES => Self::TooManyPrimaries,
+ bindings::NV_ERR_UVM_ADDRESS_IN_USE => Self::UvmAddressInUse,
+ other => Self::Unknown(other),
+ }
+ }
+}
+
/// Empty type to group methods related to heap parameters for running the GSP firmware.
enum GspFwHeapParams {}

--
2.53.0