diff options
| author | Arthur Hanson Rasmusson <arthur@vgpu.io> | 2026-10-01 22:22:21 -0400 |
|---|---|---|
| committer | Arthur Hanson Rasmusson <arthur@vgpu.io> | 2026-10-01 22:22:21 -0400 |
| commit | bf63a7dfef0b31c233d21d8f49f81dc40702e9c7 (patch) | |
| tree | 09c4e1178b2335549ddd7692774001c96d6dd28b /kernel/gsp_phys_gpu.h | |
| parent | bc4a3de674c1a93030186fc627e05e9a3c81b519 (diff) | |
| download | open-iov-bf63a7dfef0b31c233d21d8f49f81dc40702e9c7.tar.gz open-iov-bf63a7dfef0b31c233d21d8f49f81dc40702e9c7.zip | |
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.
Diffstat (limited to 'kernel/gsp_phys_gpu.h')
| -rw-r--r-- | kernel/gsp_phys_gpu.h | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/kernel/gsp_phys_gpu.h b/kernel/gsp_phys_gpu.h index 36532a5..c8beb1d 100644 --- a/kernel/gsp_phys_gpu.h +++ b/kernel/gsp_phys_gpu.h @@ -13,10 +13,17 @@ void gsp_phys_gpu_release(void); void __iomem *gsp_phys_gpu_bar0(void); /* - * Backend session state (P0 skeleton; one physical GPU, one live claim). - * OFF until a start claims the device; READY is the only state in which live - * RPC forwarding is legal. The refcount and owner flag decide who releases: - * the load-time module-owned claim is joined, never released, by a stop(). + * Read by the backend session to enforce the mdev-owned start gate; the + * gsp_phys_gpu module parameter itself is owned by main.c. + */ +bool gsp_phys_gpu_enabled(void); + +/* + * Backend session state (P0 skeleton + P1 lifecycle; one physical GPU, one + * live claim). OFF until a start claims the device; READY is the only state + * in which live RPC forwarding is legal. The refcount and owner flag decide + * who releases: the load-time module-owned claim is joined, never released, + * by a stop(); an mdev-owned claim is released by the last stop(). */ enum gsp_phys_backend_state { GSP_PHYS_BACKEND_OFF = 0, @@ -28,15 +35,30 @@ enum gsp_phys_backend_state { /* * Refcounted session start/stop around gsp_phys_gpu_claim()/_release(); safe - * (and idempotent) in any state. The generation counter is bumped when the - * session leaves READY; a forward that captured the previous value re-checks - * it under gsp_phys_rm_lock and refuses, so a stop cannot race an in-flight - * forward. The lock itself stays private to gsp_phys_gpu.c; the state and - * generation accessors are lock-free reads for use from the RPC path. + * (and idempotent) in any state. gsp_phys_backend_start() never blocks on the + * claim/boot: an mdev-owned start schedules a work item and returns, and a + * failed claim leaves the session OFF (fail-open: the caller keeps using the + * emulation path). The generation counter is bumped when the session leaves + * READY; a forward that captured the previous value re-checks it under + * gsp_phys_rm_lock and refuses, so a stop cannot race an in-flight forward. + * The lock itself stays private to gsp_phys_gpu.c; the state and generation + * accessors are lock-free reads for use from the RPC path. + * + * Module exit uses the two-phase form so the ยง1.4 ordering can be kept: + * begin_stop() gates the session (STOPPING + generation bump) before the + * caller drains the emulation threads, then end_stop() runs the release. */ int gsp_phys_backend_start(void); void gsp_phys_backend_stop(void); +void gsp_phys_backend_begin_stop(void); +void gsp_phys_backend_end_stop(void); int gsp_phys_backend_state(void); u32 gsp_phys_backend_generation(void); +/* + * True when the gsp_phys_mdev_owned module parameter is set (default 0: + * load-time module-owned claim/boot, today's behavior). + */ +bool gsp_phys_mdev_owned_enabled(void); + #endif /* GSP_PHYS_GPU_H */ |
