xref: /linux/include/uapi/drm/nova_drm.h (revision e727d1c382a0cb2e10fd7aabef9217d1a37c80c7)
1 /* SPDX-License-Identifier: MIT */
2 
3 #ifndef __NOVA_DRM_H__
4 #define __NOVA_DRM_H__
5 
6 #include "drm.h"
7 
8 /* DISCLAIMER: Do not use, this is not a stable uAPI.
9  *
10  * This uAPI serves only testing purposes as long as this driver is still in
11  * development. It is required to implement and test infrastructure which is
12  * upstreamed in the context of this driver. See also [1].
13  *
14  * [1] https://lore.kernel.org/dri-devel/Zfsj0_tb-0-tNrJy@cassiopeiae/T/#u
15  */
16 
17 #if defined(__cplusplus)
18 extern "C" {
19 #endif
20 
21 /*
22  * NOVA_GETPARAM_VRAM_BAR_SIZE
23  *
24  * Query the VRAM BAR size in bytes.
25  */
26 #define NOVA_GETPARAM_VRAM_BAR_SIZE	0x1
27 
28 /**
29  * enum drm_nova_architecture - GPU architecture identifier
30  */
31 enum drm_nova_architecture {
32 	NOVA_DRM_ARCHITECTURE_TURING		= 0x16,
33 	NOVA_DRM_ARCHITECTURE_AMPERE		= 0x17,
34 	NOVA_DRM_ARCHITECTURE_HOPPER		= 0x18,
35 	NOVA_DRM_ARCHITECTURE_ADA		= 0x19,
36 	NOVA_DRM_ARCHITECTURE_BLACKWELL_GB10X	= 0x1a,
37 	NOVA_DRM_ARCHITECTURE_BLACKWELL_GB20X	= 0x1b,
38 };
39 
40 /**
41  * enum drm_nova_chipid - opaque GPU chip identifier
42  *
43  * These values identify the chip a GPU is based on. They are otherwise
44  * opaque: userspace must not assume the values carry any particular meaning
45  * or encoding, only that they may be compared against this enum.
46  */
47 enum drm_nova_chipid {
48 	/* Turing */
49 	NOVA_DRM_CHIPID_TU102			= 0x162,
50 	NOVA_DRM_CHIPID_TU104			= 0x164,
51 	NOVA_DRM_CHIPID_TU106			= 0x166,
52 	NOVA_DRM_CHIPID_TU117			= 0x167,
53 	NOVA_DRM_CHIPID_TU116			= 0x168,
54 	/* Ampere */
55 	NOVA_DRM_CHIPID_GA100			= 0x170,
56 	NOVA_DRM_CHIPID_GA102			= 0x172,
57 	NOVA_DRM_CHIPID_GA103			= 0x173,
58 	NOVA_DRM_CHIPID_GA104			= 0x174,
59 	NOVA_DRM_CHIPID_GA106			= 0x176,
60 	NOVA_DRM_CHIPID_GA107			= 0x177,
61 	/* Hopper */
62 	NOVA_DRM_CHIPID_GH100			= 0x180,
63 	/* Ada */
64 	NOVA_DRM_CHIPID_AD102			= 0x192,
65 	NOVA_DRM_CHIPID_AD103			= 0x193,
66 	NOVA_DRM_CHIPID_AD104			= 0x194,
67 	NOVA_DRM_CHIPID_AD106			= 0x196,
68 	NOVA_DRM_CHIPID_AD107			= 0x197,
69 	/* Blackwell GB10x */
70 	NOVA_DRM_CHIPID_GB100			= 0x1a0,
71 	NOVA_DRM_CHIPID_GB102			= 0x1a2,
72 	/* Blackwell GB20x */
73 	NOVA_DRM_CHIPID_GB202			= 0x1b2,
74 	NOVA_DRM_CHIPID_GB203			= 0x1b3,
75 	NOVA_DRM_CHIPID_GB205			= 0x1b5,
76 	NOVA_DRM_CHIPID_GB206			= 0x1b6,
77 	NOVA_DRM_CHIPID_GB207			= 0x1b7,
78 };
79 
80 /**
81  * struct drm_nova_getparam - query GPU and driver metadata
82  */
83 struct drm_nova_getparam {
84 	/**
85 	 * @param: The identifier of the parameter to query.
86 	 */
87 	__u64 param;
88 
89 	/**
90 	 * @value: The value for the specified parameter.
91 	 */
92 	__u64 value;
93 };
94 
95 /**
96  * struct drm_nova_gem_create - create a new DRM GEM object
97  */
98 struct drm_nova_gem_create {
99 	/**
100 	 * @handle: The handle of the new DRM GEM object.
101 	 */
102 	__u32 handle;
103 
104 	/**
105 	 * @pad: 32 bit padding, should be 0.
106 	 */
107 	__u32 pad;
108 
109 	/**
110 	 * @size: The size of the new DRM GEM object.
111 	 */
112 	__u64 size;
113 };
114 
115 /**
116  * struct drm_nova_gem_info - query DRM GEM object metadata
117  */
118 struct drm_nova_gem_info {
119 	/**
120 	 * @handle: The handle of the DRM GEM object to query.
121 	 */
122 	__u32 handle;
123 
124 	/**
125 	 * @pad: 32 bit padding, should be 0.
126 	 */
127 	__u32 pad;
128 
129 	/**
130 	 * @size: The size of the DRM GEM obejct.
131 	 */
132 	__u64 size;
133 };
134 
135 /**
136  * struct drm_nova_info - query device information
137  */
138 struct drm_nova_info {
139 	/**
140 	 * @id: The identifier of the information to query.
141 	 */
142 	__u32 id;
143 
144 	/**
145 	 * @size: The amount of space allocated by userspace at @data. The kernel
146 	 * will return the number of bytes it wrote, or the size of the queried
147 	 * information structure if @data is NULL.
148 	 */
149 	__u32 size;
150 
151 	/**
152 	 * @data: Pointer to the userspace buffer into which the queried
153 	 * information will be written. May be NULL, in which case nothing is
154 	 * written and @size is set to the size of the information structure so
155 	 * userspace can allocate a suitably sized buffer.
156 	 */
157 	__u64 data;
158 };
159 
160 /**
161  * DRM_NOVA_INFO_GPU
162  *
163  * Query GPU information. The result is returned in a
164  * &struct drm_nova_info_gpu.
165  */
166 #define DRM_NOVA_INFO_GPU		0x00
167 
168 /**
169  * struct drm_nova_info_gpu - GPU information
170  */
171 struct drm_nova_info_gpu {
172 	/**
173 	 * @architecture: GPU architecture identifier.
174 	 *
175 	 * See &enum drm_nova_architecture for currently known architectures.
176 	 */
177 	__u32 architecture;
178 
179 	/**
180 	 * @chipid: Opaque GPU chip identifier.
181 	 *
182 	 * See &enum drm_nova_chipid for currently known chips.
183 	 */
184 	__u32 chipid;
185 
186 	/**
187 	 * @vram_size: Amount of usable FB, excluding GSP carveouts and protected
188 	 * regions.
189 	 */
190 	__u64 vram_size;
191 
192 	/**
193 	 * @gpu_name: NUL-terminated full GPU name.
194 	 */
195 	__u8 gpu_name[64];
196 
197 	/**
198 	 * @gpu_short_name: NUL-terminated short GPU name.
199 	 */
200 	__u8 gpu_short_name[64];
201 
202 	/**
203 	 * @gpu_gid: 16-byte SHA-1 GPU identifier supplied by GSP-RM.
204 	 */
205 	__u8 gpu_gid[16];
206 };
207 
208 #define DRM_NOVA_GETPARAM		0x00
209 #define DRM_NOVA_GEM_CREATE		0x01
210 #define DRM_NOVA_GEM_INFO		0x02
211 #define DRM_NOVA_INFO			0x03
212 
213 /* Note: this is an enum so that it can be resolved by Rust bindgen. */
214 enum {
215 	DRM_IOCTL_NOVA_GETPARAM		= DRM_IOWR(DRM_COMMAND_BASE + DRM_NOVA_GETPARAM,
216 						   struct drm_nova_getparam),
217 	DRM_IOCTL_NOVA_GEM_CREATE	= DRM_IOWR(DRM_COMMAND_BASE + DRM_NOVA_GEM_CREATE,
218 						   struct drm_nova_gem_create),
219 	DRM_IOCTL_NOVA_GEM_INFO		= DRM_IOWR(DRM_COMMAND_BASE + DRM_NOVA_GEM_INFO,
220 						   struct drm_nova_gem_info),
221 	DRM_IOCTL_NOVA_INFO		= DRM_IOWR(DRM_COMMAND_BASE + DRM_NOVA_INFO,
222 						   struct drm_nova_info),
223 };
224 
225 #if defined(__cplusplus)
226 }
227 #endif
228 
229 #endif /* __NOVA_DRM_H__ */
230