gpu: nova-core: add fwctl driver for firmware control interface
Subsystems (8)
v3 cover gpu: nova-core: add fwctl driver for firmware control interface
Add a fwctl endpoint to nova-core for the GSP GMC API commands used to manage vGPU types on a physical GPU.
The request path is:
userspace
|
| FWCTL_RPC (FWCTL_RPC_CONFIGURATION)
v
nova-core command allowlist
|
| typed GMC request
v
GSP command queue -> GSP-RM
Userspace supplies the native GMC command ID and command-specific payload. nova-core constructs the transport headers and permits only the seven vGPU management commands for adding, querying, assigning and deassigning vGPU types. Other commands and scopes are rejected.
The request starts with an eight-byte header containing command_id and a zero reserved field, followed by the command-specific payload. The response echoes this header and appends the firmware response payload.
This series is based on:
[PATCH v5 00/35] Introduce NVIDIA vGPU manager [1]
Userspace tools:
https://github.com/alokk-nvidia/vgpu-tools/tree/m1-nvkv/fwctl
Changes since v2 [2]:
- Define CommandToGsp request types for the seven permitted commands and submit them through send_gmc_command().
- Add the missing management command variants to GmcCommandId instead of exporting numeric constants through the vGPU firmware module.
- Read successful response payloads through MessageFromGsp into an owned buffer before the receive-queue slot is consumed.
- Preserve firmware-error handling: return EIO when GSP rejects a command, while propagating transport errors.
- Use pin-init self-reference support to borrow the GPU-owned command queue. Unregister fwctl and drain callbacks before dropping GPU resources.
- Add the new userspace header to Nova's MAINTAINERS entry.
The userspace request/response format, seven-command allowlist, configuration scope restriction and response-capacity limit are unchanged. GMC, MCTP and NVDM transport headers remain inside nova-core.
The complete integration tree, including the prerequisites and the companion VFIO series, is available at:
https://github.com/alokk-nvidia/nova-core/tree/nova-vgpu-wip-20261124
Previous postings:
v2 posting: [2]
v1 posting: [3]
[1]
https://lore.kernel.org/nova-gpu/[email protected]/
[2]
https://lore.kernel.org/nova-gpu/[email protected]/
[3]
https://lore.kernel.org/rust-for-linux/[email protected]/
Zhi Wang (1):
gpu: nova-core: add fwctl driver for firmware control interface
MAINTAINERS | 1 + drivers/gpu/nova-core/Kconfig | 2 + drivers/gpu/nova-core/driver.rs | 23 +++++ drivers/gpu/nova-core/fwctl.rs | 160 +++++++++++++++++++++++++++++ drivers/gpu/nova-core/gsp/fw.rs | 5 + drivers/gpu/nova-core/nova_core.rs | 2 + include/uapi/fwctl/fwctl.h | 1 + include/uapi/fwctl/nova-core.h | 34 ++++++ rust/kernel/fwctl.rs | 2 + rust/uapi/uapi_helper.h | 2 + 10 files changed, 232 insertions(+) create mode 100644 drivers/gpu/nova-core/fwctl.rs create mode 100644 include/uapi/fwctl/nova-core.h
base-commit: 7c4cb57138562f96b53683e29c8fddef73d57294
Signature · 1 line
2.53.0
PATCH v3 1/1 gpu: nova-core: add fwctl driver for firmware control interface
From: Zhi Wang <[email protected]>
Add a fwctl driver that provides an interface for userspace to issue GMC API commands to the GSP. Userspace supplies the command ID and payload while the transport headers remain internal to the kernel.
Allow the seven vGPU management commands in the configuration scope. Reject all other commands and scopes.
zhiw: Adapt to the GPU-owned command queue and its GMC transaction API. Use the existing vGPU firmware module for command constants and register fwctl after GPU and auxiliary-device initialization.
--- MAINTAINERS | 1 + drivers/gpu/nova-core/Kconfig | 2 + drivers/gpu/nova-core/driver.rs | 23 +++++ drivers/gpu/nova-core/fwctl.rs | 160 +++++++++++++++++++++++++++++ drivers/gpu/nova-core/gsp/fw.rs | 5 + drivers/gpu/nova-core/nova_core.rs | 2 + include/uapi/fwctl/fwctl.h | 1 + include/uapi/fwctl/nova-core.h | 34 ++++++ rust/kernel/fwctl.rs | 2 + rust/uapi/uapi_helper.h | 2 + 10 files changed, 232 insertions(+) create mode 100644 drivers/gpu/nova-core/fwctl.rs create mode 100644 include/uapi/fwctl/nova-core.h
MAINTAINERS +1 -0
@@ -8583,6 +8583,7 @@ C: irc://irc.oftc.net/nouveau T: git https://gitlab.freedesktop.org/drm/rust/kernel.git drm-rust-next F: Documentation/gpu/nova/ F: drivers/gpu/nova-core/ +F: include/uapi/fwctl/nova-core.h DRM DRIVER FOR NVIDIA GPUS [RUST] M: Danilo Krummrich <[email protected]>
drivers/gpu/nova-core/Kconfig +2 -0
@@ -4,8 +4,10 @@ config NOVA_CORE depends on PCI depends on RUST depends on !CPU_BIG_ENDIAN + depends on FWCTL=y select AUXILIARY_BUS select GPU_BUDDY + select RUST_FWCTL_ABSTRACTIONS select RUST_FW_LOADER_ABSTRACTIONS default n help
drivers/gpu/nova-core/driver.rs +23 -0
@@ -6,6 +6,7 @@ Bound, Core, // }, + fwctl, io::resource, pci, pci::{
@@ -24,6 +25,10 @@use crate ::{ api::NovaCoreApi , + fwctl::{ +NovaCoreFwCtl , +NovaCoreFwCtlData ,// + }, gpu::Gpu ,// };
@@ -35,6 +40,9 @@ pub(crate) struct NovaCore<'bound> {#[allow(clippy::type_complexity)] #[uses('gpu: invariant)] _reg: auxiliary::Registration<'gpu, ForLt!(NovaCoreApi<'_>)>, +/// Unregisters fwctl and drains its callbacks before GPU resources are dropped. +#[uses('gpu: invariant)] + _fwctl: fwctl::Registration<'gpu, NovaCoreFwCtl>,#[pin] #[uses('bar1)] pub(crate) gpu: Gpu<'bar>,
@@ -151,6 +159,21 @@ fn probe<'bound>( NovaCoreApi::new(pdev, gpu), )? }, + + _fwctl: { + let fwctl_dev = fwctl::Device::<NovaCoreFwCtl>::new(pdev.as_ref())?; + +// SAFETY: The device is newly allocated, unregistered, and parented to `pdev`. +// The self-referential borrow keeps `gpu` alive until fwctl is unregistered +// and its callbacks are drained. `NovaCore` is dropped before `pdev` unbinds. +unsafe { + fwctl::Registration ::new ( + pdev.as_ref (), + &fwctl_dev, +NovaCoreFwCtlData ::new (gpu.get_ref ().cmdq ()), + )? + } + }, }) } }
drivers/gpu/nova-core/fwctl.rs new file +160 -0
160 lines not on this page · raw message
drivers/gpu/nova-core/gsp/fw.rs +5 -0
@@ -720,6 +720,11 @@ pub(crate) enum GmcCommandId with TryFrom<Bounded<u32, 24>> { ExecGenericBootloader = bindings::GMCAPI_COMMANDS_GMCAPI_CMD_EXEC_GENERIC_BOOTLOADER, ExecHsBinary = bindings::GMCAPI_COMMANDS_GMCAPI_CMD_EXEC_HS_BINARY, GspSuspend = bindings::GMCAPI_COMMANDS_GMCAPI_CMD_GSP_SUSPEND, + AddVgpuType = bindings::GMCAPI_COMMANDS_GMCAPI_CMD_ADD_VGPU_TYPE, + QuerySupportedVgpuTypes = bindings::GMCAPI_COMMANDS_GMCAPI_CMD_QUERY_SUPPORTED_VGPU_TYPES, + QueryCreatableVgpuTypes = bindings::GMCAPI_COMMANDS_GMCAPI_CMD_QUERY_CREATABLE_VGPU_TYPES, + AssignVgpuType = bindings::GMCAPI_COMMANDS_GMCAPI_CMD_ASSIGN_VGPU_TYPE, + DeassignVgpuType = bindings::GMCAPI_COMMANDS_GMCAPI_CMD_DEASSIGN_VGPU_TYPE, QueryVgpuProperties = bindings::GMCAPI_COMMANDS_GMCAPI_CMD_QUERY_VGPU_PROPERTIES, QueryAssignedVfVgpuType = bindings::GMCAPI_COMMANDS_GMCAPI_CMD_QUERY_ASSIGNED_VF_VGPU_TYPE, BootloadGspVgpuPluginTask =
drivers/gpu/nova-core/nova_core.rs +2 -0
@@ -17,6 +17,7 @@mod fb;mod firmware;mod fsp; +mod fwctl;mod gpu;mod gsp;mod irq;
@@ -98,6 +99,7 @@ fn init(module: &'static kernel::ThisModule) -> impl PinInit<Self, Error> { description: "Nova Core GPU driver", license: "GPL v2", firmware: [], + imports_ns: ["FWCTL"], params: { gsp_keep_logs: bool { default: false,
include/uapi/fwctl/fwctl.h +1 -0
@@ -46,6 +46,7 @@ enum fwctl_device_type {FWCTL_DEVICE_TYPE_CXL =2 ,FWCTL_DEVICE_TYPE_BNXT =3 ,FWCTL_DEVICE_TYPE_PDS =4 , + FWCTL_DEVICE_TYPE_NOVA_CORE = 8, };/**
include/uapi/fwctl/nova-core.h new file +34 -0
@@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* +* Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES +* +* NVIDIA nova-core fwctl interface. All fwctl traffic uses the GMC API +* transport. User-space supplies a command_id and optional payload; the +* kernel constructs the GMC transport headers, validates the command_id +* against the permitted set for the requested scope, and returns only the +* response payload. +* +* The device_type for this file is FWCTL_DEVICE_TYPE_NOVA_CORE. +*/ +#ifndef _UAPI_FWCTL_NOVA_CORE_H +#define _UAPI_FWCTL_NOVA_CORE_H + +#include <linux/types.h> + +/** +* struct fwctl_rpc_nova_core - ioctl(FWCTL_RPC) in/out buffer format +* @command_id: GMC API command identifier (from GMCAPI_COMMANDS). +* @reserved: Must be zero. +* +* The request buffer passed to FWCTL_RPC begins with this header, +* followed by the command-specific payload bytes (if any). +* +* The response buffer returned by FWCTL_RPC begins with this same +* header (echoing the command_id), followed by the response payload. +*/ +struct fwctl_rpc_nova_core { +__u32 command_id; +__u32 reserved; +}; + +#endif
rust/kernel/fwctl.rs +2 -0
@@ -44,6 +44,8 @@ pub enum DeviceType { Pds = bindings::fwctl_device_type_FWCTL_DEVICE_TYPE_PDS,/// Broadcom NetXtreme (bnxt) device. Bnxt = bindings::fwctl_device_type_FWCTL_DEVICE_TYPE_BNXT, +/// NVIDIA nova-core GPU device. + NovaCore = bindings::fwctl_device_type_FWCTL_DEVICE_TYPE_NOVA_CORE, }/// Scope of access for an RPC request.
rust/uapi/uapi_helper.h +2 -0
@@ -11,6 +11,8 @@#include <uapi/drm/drm.h> #include <uapi/drm/nova_drm.h> #include <uapi/drm/panthor_drm.h> +#include <uapi/fwctl/fwctl.h> +#include <uapi/fwctl/nova-core.h> #include <uapi/linux/android/binder.h> #include <uapi/linux/android/binder_netlink.h> #include <uapi/linux/ioctl.h>
Signature · 1 line
2.53.0