From bf63a7dfef0b31c233d21d8f49f81dc40702e9c7 Mon Sep 17 00:00:00 2001 From: Arthur Hanson Rasmusson Date: Thu, 1 Oct 2026 22:22:21 -0400 Subject: gsp-phys: mdev-owned backend lifecycle (P1) Add the gsp_phys_mdev_owned ownership selector (default 0: unchanged load-time module-owned claim/boot). With 1, module load claims nothing; the first mdev create starts a refcounted backend session whose claim+boot runs asynchronously from a work item, so mdev create and init_work never block. The last mdev remove releases after the emulation thread is stopped. Failures are fail-open: the backend stays OFF and the mdev keeps serving the emulation path. nv_vgpu_exit now gates the session STOPPING under the session lock, drains the emulation threads via mdev_unregister_driver(), and only then releases the claim; the module-owned path keeps its previous release position. A start while STOPPING is refused and a concurrent second stopper cannot release twice. No forwarding is added. --- kernel/include/nvidia-vgpu-vfio.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'kernel/include/nvidia-vgpu-vfio.h') diff --git a/kernel/include/nvidia-vgpu-vfio.h b/kernel/include/nvidia-vgpu-vfio.h index 961bba2..aed3dc5 100644 --- a/kernel/include/nvidia-vgpu-vfio.h +++ b/kernel/include/nvidia-vgpu-vfio.h @@ -135,6 +135,12 @@ struct nv_vgpu_device { /* VFIO device registration state */ bool vfio_dev_registered; + + /* True when this mdev holds a reference on the physical backend + * session (gsp_phys_backend_start() succeeded in init_work); the + * matching gsp_phys_backend_stop() runs in cleanup_work after the + * emulation thread is stopped. */ + bool phys_backend_ref; }; typedef struct nv_vgpu_device nv_vgpu_device; -- cgit v1.2.3