summaryrefslogtreecommitdiffstats
path: root/kernel/main.c
diff options
context:
space:
mode:
authorArthur Hanson Rasmusson <arthur@vgpu.io>2026-09-30 23:10:52 -0400
committerArthur Hanson Rasmusson <arthur@vgpu.io>2026-09-30 23:10:52 -0400
commit7a882f4f4e8bccd37598ac0449f91f4b3e0ee162 (patch)
tree86f43024b57d3b88ffc4ee5e2f67f2ec3ba9f007 /kernel/main.c
parent756fdfd6b2090b731b34846b1b23b726bb3978ec (diff)
downloadopen-iov-7a882f4f4e8bccd37598ac0449f91f4b3e0ee162.tar.gz
open-iov-7a882f4f4e8bccd37598ac0449f91f4b3e0ee162.zip
gsp-phys: claim the physical GPU and stage real GSP firmware (backend rungs 1-2)
Rung 1 (ownership): a default-off gsp_phys_gpu module param; on claim the distribution driver is released from 10de:1ed3, our pci_driver binds it, BAR0/1/3 are mapped and the falcon state is sampled; release unbinds ours and rebinds the distribution driver. Verified live: claim reads BOOT0=0x164000a1 with the falcon halted and mailboxes clear; rmmod rebinds nvidia and nvidia-smi stays healthy. Rung 2 (firmware): while the device is owned, gsp_phys_fw (default nvidia/570.211.01/gsp_tu10x.bin) is fetched with request_firmware, checked as ELF64 RISC-V, and its sections are logged (.fwimage, .fwversion, .fwsignature_tu10x). The image is held for the boot rung. The claim is default-off; the emulation path is unchanged.
Diffstat (limited to 'kernel/main.c')
-rw-r--r--kernel/main.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/kernel/main.c b/kernel/main.c
index fa88d19..f86dc98 100644
--- a/kernel/main.c
+++ b/kernel/main.c
@@ -31,6 +31,7 @@
#include "ioctl.h"
#include "nv-vgpu-vfio-interface.h"
+#include "gsp_phys_gpu.h"
#define NV_VERSION_STRING "550.163.01"
@@ -155,6 +156,8 @@ static rm_vgpu_vfio_ops_t g_rm_vgpu_vfio_ops;
/* mdev parent structure for our physical device */
static struct mdev_parent *g_mdev_parent = NULL;
+static bool gsp_phys_gpu_param;
+
/* VFIO ops implementation */
static NV_STATUS nv_vgpu_vfio_probe(struct pci_dev *pdev, NvU32 vgpu_type_id, NvU32 *vgpu_id);
static void nv_vgpu_vfio_remove(struct pci_dev *pdev);
@@ -1443,6 +1446,13 @@ static int __init nv_vgpu_init(void)
}
pr_info("gsp-resman-vfio: VFIO ops set\n");
+ if (gsp_phys_gpu_param) {
+ ret = gsp_phys_gpu_claim();
+ if (ret)
+ pr_warn("gsp-resman-vfio: physical GPU claim failed: %d\n",
+ ret);
+ }
+
pr_info("NVIDIA vGPU VFIO driver loaded (version %s)\n", NVIDIA_VGPU_VFIO_VERSION);
/* Start the emulated-GPU progress service: it discovers the guest's
* GPU-VA -> guest-PA map and applies copy-engine semaphore releases so
@@ -1478,6 +1488,8 @@ static void __exit nv_vgpu_exit(void)
pr_info("gsp-resman-vfio: nv_vgpu_exit: clearing VFIO ops to break circular dependency\n");
g_vgpu_vfio_ops = NULL;
+ gsp_phys_gpu_release();
+
if (nv_vgpu_driver.device_count > 0) {
struct nv_vgpu_device *vgpu;
mutex_lock(&nv_vgpu_driver.lock);
@@ -2428,6 +2440,15 @@ module_param_cb(chan_dump, &nv_vgpu_chan_dump_ops, NULL, 0200);
MODULE_PARM_DESC(chan_dump, "Dump the sema service channel table (any value)");
/*
+ * Physical GPU ownership for the real-GSP execution backend (bring-up rung
+ * 1: claim). Default off. On claim the distribution driver is unbound from
+ * the physical GPU, this module's pci_driver binds it and the BARs are
+ * mapped. Only set when no VM holds an mdev; release happens on unload.
+ */
+module_param_named(gsp_phys_gpu, gsp_phys_gpu_param, bool, 0644);
+MODULE_PARM_DESC(gsp_phys_gpu, "Claim the physical GPU for the real-GSP backend (default 0)");
+
+/*
* GR ring discovery: pin the compute channels' rings/USERDs, which follow the
* CE rings in the channel video-memory allocation. Default on; set 0 to leave
* GR channels untranslated when debugging push-execution side effects.