summaryrefslogtreecommitdiffstats
path: root/kernel/gsp_phys_gpu.h
blob: 36532a5ff51d3dc76b1c3346bae5b784df0a3948 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef GSP_PHYS_GPU_H
#define GSP_PHYS_GPU_H

#include <linux/types.h>

/*
 * 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);

/*
 * 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().
 */
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. 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.
 */
int gsp_phys_backend_start(void);
void gsp_phys_backend_stop(void);
int gsp_phys_backend_state(void);
u32 gsp_phys_backend_generation(void);

#endif /* GSP_PHYS_GPU_H */