#ifndef GSP_PHYS_GPU_H #define GSP_PHYS_GPU_H #include /* * Physical GPU ownership (real-GSP execution backend, bring-up rung 1). * Claim is disabled unless the gsp_phys_gpu module parameter is set. */ bool gsp_phys_gpu_claimed(void); int gsp_phys_gpu_claim(void); void gsp_phys_gpu_release(void); void __iomem *gsp_phys_gpu_bar0(void); u32 gsp_phys_gpu_fw_crc32(void); /* * 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, GSP_PHYS_BACKEND_CLAIMING, GSP_PHYS_BACKEND_BOOTING, GSP_PHYS_BACKEND_READY, GSP_PHYS_BACKEND_STOPPING, }; /* * Refcounted session start/stop around gsp_phys_gpu_claim()/_release(); safe * (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); /* * True when the gsp_phys_static_live module parameter is set (default 0: * the guest GET_GSP_STATIC_INFO reply is the emulated model unchanged). When * set, the handler overlays the live GPU name/short-name/VBIOS identity from * the backend snapshot, failing open to the emulated reply on any miss. */ bool gsp_phys_static_live_enabled(void); /* * True when the gsp_phys_ctrl_forward module parameter is set (default 0: * guest GSP_RM_CONTROL replies are the emulated answers unchanged). When set, * a whitelist of side-effect-free control queries is forwarded to the live * backend with the snapshot's adopted internal handles, falling back to the * emulated per-command handler on any miss. */ bool gsp_phys_ctrl_forward_enabled(void); /* * True when the gsp_phys_work_forward module parameter is set (default 0: the * guest's CE pushes stay software-emulated exactly as before). When set, the * sema service shadows each decoded CE push as one copy on the debugfs ladder's * real channel using only module-owned ladder buffers; the software release * remains authoritative and is applied unchanged either way. */ bool gsp_phys_work_forward_enabled(void); #endif /* GSP_PHYS_GPU_H */