To pick the changes in: 2459e56fd8af0b47 ("drm/i915/uapi: implement object placement extension") ebcb40298947bdb0 ("drm/i915/uapi: introduce drm_i915_gem_create_ext") 710217292a61110a ("drm/i915/query: Expose memory regions through the query uAPI") e3bdccafb5bcfab2 ("drm/i915/uapi: convert i915_query and friend to kernel doc") 19d053d477a14506 ("drm/i915/uapi: convert i915_user_extension to kernel doc") 2ef6a01fb636997b ("drm/i915/uapi: fix kernel doc warnings") That picks a new ioctl: $ tools/perf/trace/beauty/drm_ioctl.sh > before $ cp include/uapi/drm/i915_drm.h tools/include/uapi/drm/i915_drm.h $ tools/perf/trace/beauty/drm_ioctl.sh > after $ diff -u before after --- before 2021-07-05 14:25:13.247680316 -0300 +++ after 2021-07-05 14:25:22.454874111 -0300 @@ -166,4 +166,5 @@ [DRM_COMMAND_BASE + 0x39] = "I915_QUERY", [DRM_COMMAND_BASE + 0x3a] = "I915_GEM_VM_CREATE", [DRM_COMMAND_BASE + 0x3b] = "I915_GEM_VM_DESTROY", + [DRM_COMMAND_BASE + 0x3c] = "I915_GEM_CREATE_EXT", }; $ Addressing this perf build warning: Warning: Kernel ABI header at 'tools/include/uapi/drm/i915_drm.h' differs from latest version at 'include/uapi/drm/i915_drm.h' diff -u tools/include/uapi/drm/i915_drm.h include/uapi/drm/i915_drm.h
Unified · Split
| @@ -62,8 +62,8 @@ extern "C" { · 61 unmodified lines | ||
| 62 | 62 | #define I915_ERROR_UEVENT "ERROR" |
| 63 | 63 | #define I915_RESET_UEVENT "RESET" |
| 64 | 64 | |
| 65 | −/* | |
| 66 | − * i915_user_extension: Base class for defining a chain of extensions | |
| 65 | +/** | |
| 66 | + * struct i915_user_extension - Base class for defining a chain of extensions | |
| 67 | 67 | * |
| 68 | 68 | * Many interfaces need to grow over time. In most cases we can simply |
| 69 | 69 | * extend the struct and have userspace pass in more data. Another option, |
| @@ -76,12 +76,58 @@ extern "C" { · 6 unmodified lines | ||
| 76 | 76 | * increasing complexity, and for large parts of that interface to be |
| 77 | 77 | * entirely optional. The downside is more pointer chasing; chasing across |
| 78 | 78 | * the __user boundary with pointers encapsulated inside u64. |
| 79 | + * | |
| 80 | + * Example chaining: | |
| 81 | + * | |
| 82 | + * .. code-block:: C | |
| 83 | + * | |
| 84 | + * struct i915_user_extension ext3 { | |
| 85 | + * .next_extension = 0, // end | |
| 86 | + * .name = ..., | |
| 87 | + * }; | |
| 88 | + * struct i915_user_extension ext2 { | |
| 89 | + * .next_extension = (uintptr_t)&ext3, | |
| 90 | + * .name = ..., | |
| 91 | + * }; | |
| 92 | + * struct i915_user_extension ext1 { | |
| 93 | + * .next_extension = (uintptr_t)&ext2, | |
| 94 | + * .name = ..., | |
| 95 | + * }; | |
| 96 | + * | |
| 97 | + * Typically the struct i915_user_extension would be embedded in some uAPI | |
| 98 | + * struct, and in this case we would feed it the head of the chain(i.e ext1), | |
| 99 | + * which would then apply all of the above extensions. | |
| 100 | + * | |
| 79 | 101 | */ |
| 80 | 102 | struct i915_user_extension { |
| 103 | + /** | |
| 104 | + * @next_extension: | |
| 105 | + * | |
| 106 | + * Pointer to the next struct i915_user_extension, or zero if the end. | |
| 107 | + */ | |
| 81 | 108 | __u64 next_extension; |
| 109 | + /** | |
| 110 | + * @name: Name of the extension. | |
| 111 | + * | |
| 112 | + * Note that the name here is just some integer. | |
| 113 | + * | |
| 114 | + * Also note that the name space for this is not global for the whole | |
| 115 | + * driver, but rather its scope/meaning is limited to the specific piece | |
| 116 | + * of uAPI which has embedded the struct i915_user_extension. | |
| 117 | + */ | |
| 82 | 118 | __u32 name; |
| 83 | − __u32 flags; /* All undefined bits must be zero. */ | |
| 84 | − __u32 rsvd[4]; /* Reserved for future use; must be zero. */ | |
| 119 | + /** | |
| 120 | + * @flags: MBZ | |
| 121 | + * | |
| 122 | + * All undefined bits must be zero. | |
| 123 | + */ | |
| 124 | + __u32 flags; | |
| 125 | + /** | |
| 126 | + * @rsvd: MBZ | |
| 127 | + * | |
| 128 | + * Reserved for future use; must be zero. | |
| 129 | + */ | |
| 130 | + __u32 rsvd[4]; | |
| 85 | 131 | }; |
| 86 | 132 | |
| 87 | 133 | /* |
| @@ -360,6 +406,7 @@ typedef struct _drm_i915_sarea { · 272 unmodified lines | ||
| 360 | 406 | #define DRM_I915_QUERY 0x39 |
| 361 | 407 | #define DRM_I915_GEM_VM_CREATE 0x3a |
| 362 | 408 | #define DRM_I915_GEM_VM_DESTROY 0x3b |
| 409 | +#define DRM_I915_GEM_CREATE_EXT 0x3c | |
| 363 | 410 | /* Must be kept compact -- no holes */ |
| 364 | 411 | |
| 365 | 412 | #define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t) |
| @@ -392,6 +439,7 @@ typedef struct _drm_i915_sarea { · 26 unmodified lines | ||
| 392 | 439 | #define DRM_IOCTL_I915_GEM_ENTERVT DRM_IO(DRM_COMMAND_BASE + DRM_I915_GEM_ENTERVT) |
| 393 | 440 | #define DRM_IOCTL_I915_GEM_LEAVEVT DRM_IO(DRM_COMMAND_BASE + DRM_I915_GEM_LEAVEVT) |
| 394 | 441 | #define DRM_IOCTL_I915_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_CREATE, struct drm_i915_gem_create) |
| 442 | +#define DRM_IOCTL_I915_GEM_CREATE_EXT DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_CREATE_EXT, struct drm_i915_gem_create_ext) | |
| 395 | 443 | #define DRM_IOCTL_I915_GEM_PREAD DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_PREAD, struct drm_i915_gem_pread) |
| 396 | 444 | #define DRM_IOCTL_I915_GEM_PWRITE DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_PWRITE, struct drm_i915_gem_pwrite) |
| 397 | 445 | #define DRM_IOCTL_I915_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MMAP, struct drm_i915_gem_mmap) |
| @@ -1054,12 +1102,12 @@ struct drm_i915_gem_exec_fence { · 656 unmodified lines | ||
| 1054 | 1102 | __u32 flags; |
| 1055 | 1103 | }; |
| 1056 | 1104 | |
| 1057 | −/** | |
| 1105 | +/* | |
| 1058 | 1106 | * See drm_i915_gem_execbuffer_ext_timeline_fences. |
| 1059 | 1107 | */ |
| 1060 | 1108 | #define DRM_I915_GEM_EXECBUFFER_EXT_TIMELINE_FENCES 0 |
| 1061 | 1109 | |
| 1062 | −/** | |
| 1110 | +/* | |
| 1063 | 1111 | * This structure describes an array of drm_syncobj and associated points for |
| 1064 | 1112 | * timeline variants of drm_syncobj. It is invalid to append this structure to |
| 1065 | 1113 | * the execbuf if I915_EXEC_FENCE_ARRAY is set. |
| @@ -1700,7 +1748,7 @@ struct drm_i915_gem_context_param { · 634 unmodified lines | ||
| 1700 | 1748 | __u64 value; |
| 1701 | 1749 | }; |
| 1702 | 1750 | |
| 1703 | −/** | |
| 1751 | +/* | |
| 1704 | 1752 | * Context SSEU programming |
| 1705 | 1753 | * |
| 1706 | 1754 | * It may be necessary for either functional or performance reason to configure |
| @@ -2067,7 +2115,7 @@ struct drm_i915_perf_open_param { · 360 unmodified lines | ||
| 2067 | 2115 | __u64 properties_ptr; |
| 2068 | 2116 | }; |
| 2069 | 2117 | |
| 2070 | −/** | |
| 2118 | +/* | |
| 2071 | 2119 | * Enable data capture for a stream that was either opened in a disabled state |
| 2072 | 2120 | * via I915_PERF_FLAG_DISABLED or was later disabled via |
| 2073 | 2121 | * I915_PERF_IOCTL_DISABLE. |
| @@ -2081,7 +2129,7 @@ struct drm_i915_perf_open_param { · 7 unmodified lines | ||
| 2081 | 2129 | */ |
| 2082 | 2130 | #define I915_PERF_IOCTL_ENABLE _IO('i', 0x0) |
| 2083 | 2131 | |
| 2084 | −/** | |
| 2132 | +/* | |
| 2085 | 2133 | * Disable data capture for a stream. |
| 2086 | 2134 | * |
| 2087 | 2135 | * It is an error to try and read a stream that is disabled. |
| @@ -2090,7 +2138,7 @@ struct drm_i915_perf_open_param { · 2 unmodified lines | ||
| 2090 | 2138 | */ |
| 2091 | 2139 | #define I915_PERF_IOCTL_DISABLE _IO('i', 0x1) |
| 2092 | 2140 | |
| 2093 | −/** | |
| 2141 | +/* | |
| 2094 | 2142 | * Change metrics_set captured by a stream. |
| 2095 | 2143 | * |
| 2096 | 2144 | * If the stream is bound to a specific context, the configuration change |
| @@ -2103,7 +2151,7 @@ struct drm_i915_perf_open_param { · 6 unmodified lines | ||
| 2103 | 2151 | */ |
| 2104 | 2152 | #define I915_PERF_IOCTL_CONFIG _IO('i', 0x2) |
| 2105 | 2153 | |
| 2106 | −/** | |
| 2154 | +/* | |
| 2107 | 2155 | * Common to all i915 perf records |
| 2108 | 2156 | */ |
| 2109 | 2157 | struct drm_i915_perf_record_header { |
| @@ -2151,7 +2199,7 @@ enum drm_i915_perf_record_type { · 41 unmodified lines | ||
| 2151 | 2199 | DRM_I915_PERF_RECORD_MAX /* non-ABI */ |
| 2152 | 2200 | }; |
| 2153 | 2201 | |
| 2154 | −/** | |
| 2202 | +/* | |
| 2155 | 2203 | * Structure to upload perf dynamic configuration into the kernel. |
| 2156 | 2204 | */ |
| 2157 | 2205 | struct drm_i915_perf_oa_config { |
| @@ -2172,53 +2220,95 @@ struct drm_i915_perf_oa_config { · 14 unmodified lines | ||
| 2172 | 2220 | __u64 flex_regs_ptr; |
| 2173 | 2221 | }; |
| 2174 | 2222 | |
| 2223 | +/** | |
| 2224 | + * struct drm_i915_query_item - An individual query for the kernel to process. | |
| 2225 | + * | |
| 2226 | + * The behaviour is determined by the @query_id. Note that exactly what | |
| 2227 | + * @data_ptr is also depends on the specific @query_id. | |
| 2228 | + */ | |
| 2175 | 2229 | struct drm_i915_query_item { |
| 2230 | + /** @query_id: The id for this query */ | |
| 2176 | 2231 | __u64 query_id; |
| 2177 | 2232 | #define DRM_I915_QUERY_TOPOLOGY_INFO 1 |
| 2178 | 2233 | #define DRM_I915_QUERY_ENGINE_INFO 2 |
| 2179 | 2234 | #define DRM_I915_QUERY_PERF_CONFIG 3 |
| 2235 | +#define DRM_I915_QUERY_MEMORY_REGIONS 4 | |
| 2180 | 2236 | /* Must be kept compact -- no holes and well documented */ |
| 2181 | 2237 | |
| 2182 | − /* | |
| 2238 | + /** | |
| 2239 | + * @length: | |
| 2240 | + * | |
| 2183 | 2241 | * When set to zero by userspace, this is filled with the size of the |
| 2184 | − * data to be written at the data_ptr pointer. The kernel sets this | |
| 2242 | + * data to be written at the @data_ptr pointer. The kernel sets this | |
| 2185 | 2243 | * value to a negative value to signal an error on a particular query |
| 2186 | 2244 | * item. |
| 2187 | 2245 | */ |
| 2188 | 2246 | __s32 length; |
| 2189 | 2247 | |
| 2190 | − /* | |
| 2248 | + /** | |
| 2249 | + * @flags: | |
| 2250 | + * | |
| 2191 | 2251 | * When query_id == DRM_I915_QUERY_TOPOLOGY_INFO, must be 0. |
| 2192 | 2252 | * |
| 2193 | 2253 | * When query_id == DRM_I915_QUERY_PERF_CONFIG, must be one of the |
| 2194 | − * following : | |
| 2195 | − * - DRM_I915_QUERY_PERF_CONFIG_LIST | |
| 2196 | − * - DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_UUID | |
| 2197 | − * - DRM_I915_QUERY_PERF_CONFIG_FOR_UUID | |
| 2254 | + * following: | |
| 2255 | + * | |
| 2256 | + * - DRM_I915_QUERY_PERF_CONFIG_LIST | |
| 2257 | + * - DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_UUID | |
| 2258 | + * - DRM_I915_QUERY_PERF_CONFIG_FOR_UUID | |
| 2198 | 2259 | */ |
| 2199 | 2260 | __u32 flags; |
| 2200 | 2261 | #define DRM_I915_QUERY_PERF_CONFIG_LIST 1 |
| 2201 | 2262 | #define DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_UUID 2 |
| 2202 | 2263 | #define DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_ID 3 |
| 2203 | 2264 | |
| 2204 | − /* | |
| 2205 | − * Data will be written at the location pointed by data_ptr when the | |
| 2206 | − * value of length matches the length of the data to be written by the | |
| 2265 | + /** | |
| 2266 | + * @data_ptr: | |
| 2267 | + * | |
| 2268 | + * Data will be written at the location pointed by @data_ptr when the | |
| 2269 | + * value of @length matches the length of the data to be written by the | |
| 2207 | 2270 | * kernel. |
| 2208 | 2271 | */ |
| 2209 | 2272 | __u64 data_ptr; |
| 2210 | 2273 | }; |
| 2211 | 2274 | |
| 2275 | +/** | |
| 2276 | + * struct drm_i915_query - Supply an array of struct drm_i915_query_item for the | |
| 2277 | + * kernel to fill out. | |
| 2278 | + * | |
| 2279 | + * Note that this is generally a two step process for each struct | |
| 2280 | + * drm_i915_query_item in the array: | |
| 2281 | + * | |
| 2282 | + * 1. Call the DRM_IOCTL_I915_QUERY, giving it our array of struct | |
| 2283 | + * drm_i915_query_item, with &drm_i915_query_item.length set to zero. The | |
| 2284 | + * kernel will then fill in the size, in bytes, which tells userspace how | |
| 2285 | + * memory it needs to allocate for the blob(say for an array of properties). | |
| 2286 | + * | |
| 2287 | + * 2. Next we call DRM_IOCTL_I915_QUERY again, this time with the | |
| 2288 | + * &drm_i915_query_item.data_ptr equal to our newly allocated blob. Note that | |
| 2289 | + * the &drm_i915_query_item.length should still be the same as what the | |
| 2290 | + * kernel previously set. At this point the kernel can fill in the blob. | |
| 2291 | + * | |
| 2292 | + * Note that for some query items it can make sense for userspace to just pass | |
| 2293 | + * in a buffer/blob equal to or larger than the required size. In this case only | |
| 2294 | + * a single ioctl call is needed. For some smaller query items this can work | |
| 2295 | + * quite well. | |
| 2296 | + * | |
| 2297 | + */ | |
| 2212 | 2298 | struct drm_i915_query { |
| 2299 | + /** @num_items: The number of elements in the @items_ptr array */ | |
| 2213 | 2300 | __u32 num_items; |
| 2214 | 2301 | |
| 2215 | − /* | |
| 2216 | − * Unused for now. Must be cleared to zero. | |
| 2302 | + /** | |
| 2303 | + * @flags: Unused for now. Must be cleared to zero. | |
| 2217 | 2304 | */ |
| 2218 | 2305 | __u32 flags; |
| 2219 | 2306 | |
| 2220 | − /* | |
| 2221 | − * This points to an array of num_items drm_i915_query_item structures. | |
| 2307 | + /** | |
| 2308 | + * @items_ptr: | |
| 2309 | + * | |
| 2310 | + * Pointer to an array of struct drm_i915_query_item. The number of | |
| 2311 | + * array elements is @num_items. | |
| 2222 | 2312 | */ |
| 2223 | 2313 | __u64 items_ptr; |
| 2224 | 2314 | }; |
| @@ -2292,21 +2382,21 @@ struct drm_i915_query_topology_info { · 67 unmodified lines | ||
| 2292 | 2382 | * Describes one engine and it's capabilities as known to the driver. |
| 2293 | 2383 | */ |
| 2294 | 2384 | struct drm_i915_engine_info { |
| 2295 | − /** Engine class and instance. */ | |
| 2385 | + /** @engine: Engine class and instance. */ | |
| 2296 | 2386 | struct i915_engine_class_instance engine; |
| 2297 | 2387 | |
| 2298 | − /** Reserved field. */ | |
| 2388 | + /** @rsvd0: Reserved field. */ | |
| 2299 | 2389 | __u32 rsvd0; |
| 2300 | 2390 | |
| 2301 | − /** Engine flags. */ | |
| 2391 | + /** @flags: Engine flags. */ | |
| 2302 | 2392 | __u64 flags; |
| 2303 | 2393 | |
| 2304 | − /** Capabilities of this engine. */ | |
| 2394 | + /** @capabilities: Capabilities of this engine. */ | |
| 2305 | 2395 | __u64 capabilities; |
| 2306 | 2396 | #define I915_VIDEO_CLASS_CAPABILITY_HEVC (1 << 0) |
| 2307 | 2397 | #define I915_VIDEO_AND_ENHANCE_CLASS_CAPABILITY_SFC (1 << 1) |
| 2308 | 2398 | |
| 2309 | − /** Reserved fields. */ | |
| 2399 | + /** @rsvd1: Reserved fields. */ | |
| 2310 | 2400 | __u64 rsvd1[4]; |
| 2311 | 2401 | }; |
| 2312 | 2402 | |
| @@ -2317,13 +2407,13 @@ struct drm_i915_engine_info { · 4 unmodified lines | ||
| 2317 | 2407 | * an array of struct drm_i915_engine_info structures. |
| 2318 | 2408 | */ |
| 2319 | 2409 | struct drm_i915_query_engine_info { |
| 2320 | − /** Number of struct drm_i915_engine_info structs following. */ | |
| 2410 | + /** @num_engines: Number of struct drm_i915_engine_info structs following. */ | |
| 2321 | 2411 | __u32 num_engines; |
| 2322 | 2412 | |
| 2323 | − /** MBZ */ | |
| 2413 | + /** @rsvd: MBZ */ | |
| 2324 | 2414 | __u32 rsvd[3]; |
| 2325 | 2415 | |
| 2326 | − /** Marker for drm_i915_engine_info structures. */ | |
| 2416 | + /** @engines: Marker for drm_i915_engine_info structures. */ | |
| 2327 | 2417 | struct drm_i915_engine_info engines[]; |
| 2328 | 2418 | }; |
| 2329 | 2419 | |
| @@ -2377,6 +2467,241 @@ struct drm_i915_query_perf_config { · 47 unmodified lines | ||
| 2377 | 2467 | __u8 data[]; |
| 2378 | 2468 | }; |
| 2379 | 2469 | |
| 2470 | +/** | |
| 2471 | + * enum drm_i915_gem_memory_class - Supported memory classes | |
| 2472 | + */ | |
| 2473 | +enum drm_i915_gem_memory_class { | |
| 2474 | + /** @I915_MEMORY_CLASS_SYSTEM: System memory */ | |
| 2475 | + I915_MEMORY_CLASS_SYSTEM = 0, | |
| 2476 | + /** @I915_MEMORY_CLASS_DEVICE: Device local-memory */ | |
| 2477 | + I915_MEMORY_CLASS_DEVICE, | |
| 2478 | +}; | |
| 2479 | + | |
| 2480 | +/** | |
| 2481 | + * struct drm_i915_gem_memory_class_instance - Identify particular memory region | |
| 2482 | + */ | |
| 2483 | +struct drm_i915_gem_memory_class_instance { | |
| 2484 | + /** @memory_class: See enum drm_i915_gem_memory_class */ | |
| 2485 | + __u16 memory_class; | |
| 2486 | + | |
| 2487 | + /** @memory_instance: Which instance */ | |
| 2488 | + __u16 memory_instance; | |
| 2489 | +}; | |
| 2490 | + | |
| 2491 | +/** | |
| 2492 | + * struct drm_i915_memory_region_info - Describes one region as known to the | |
| 2493 | + * driver. | |
| 2494 | + * | |
| 2495 | + * Note that we reserve some stuff here for potential future work. As an example | |
| 2496 | + * we might want expose the capabilities for a given region, which could include | |
| 2497 | + * things like if the region is CPU mappable/accessible, what are the supported | |
| 2498 | + * mapping types etc. | |
| 2499 | + * | |
| 2500 | + * Note that to extend struct drm_i915_memory_region_info and struct | |
| 2501 | + * drm_i915_query_memory_regions in the future the plan is to do the following: | |
| 2502 | + * | |
| 2503 | + * .. code-block:: C | |
| 2504 | + * | |
| 2505 | + * struct drm_i915_memory_region_info { | |
| 2506 | + * struct drm_i915_gem_memory_class_instance region; | |
| 2507 | + * union { | |
| 2508 | + * __u32 rsvd0; | |
| 2509 | + * __u32 new_thing1; | |
| 2510 | + * }; | |
| 2511 | + * ... | |
| 2512 | + * union { | |
| 2513 | + * __u64 rsvd1[8]; | |
| 2514 | + * struct { | |
| 2515 | + * __u64 new_thing2; | |
| 2516 | + * __u64 new_thing3; | |
| 2517 | + * ... | |
| 2518 | + * }; | |
| 2519 | + * }; | |
| 2520 | + * }; | |
| 2521 | + * | |
| 2522 | + * With this things should remain source compatible between versions for | |
| 2523 | + * userspace, even as we add new fields. | |
| 2524 | + * | |
| 2525 | + * Note this is using both struct drm_i915_query_item and struct drm_i915_query. | |
| 2526 | + * For this new query we are adding the new query id DRM_I915_QUERY_MEMORY_REGIONS | |
| 2527 | + * at &drm_i915_query_item.query_id. | |
| 2528 | + */ | |
| 2529 | +struct drm_i915_memory_region_info { | |
| 2530 | + /** @region: The class:instance pair encoding */ | |
| 2531 | + struct drm_i915_gem_memory_class_instance region; | |
| 2532 | + | |
| 2533 | + /** @rsvd0: MBZ */ | |
| 2534 | + __u32 rsvd0; | |
| 2535 | + | |
| 2536 | + /** @probed_size: Memory probed by the driver (-1 = unknown) */ | |
| 2537 | + __u64 probed_size; | |
| 2538 | + | |
| 2539 | + /** @unallocated_size: Estimate of memory remaining (-1 = unknown) */ | |
| 2540 | + __u64 unallocated_size; | |
| 2541 | + | |
| 2542 | + /** @rsvd1: MBZ */ | |
| 2543 | + __u64 rsvd1[8]; | |
| 2544 | +}; | |
| 2545 | + | |
| 2546 | +/** | |
| 2547 | + * struct drm_i915_query_memory_regions | |
| 2548 | + * | |
| 2549 | + * The region info query enumerates all regions known to the driver by filling | |
| 2550 | + * in an array of struct drm_i915_memory_region_info structures. | |
| 2551 | + * | |
| 2552 | + * Example for getting the list of supported regions: | |
| 2553 | + * | |
| 2554 | + * .. code-block:: C | |
| 2555 | + * | |
| 2556 | + * struct drm_i915_query_memory_regions *info; | |
| 2557 | + * struct drm_i915_query_item item = { | |
| 2558 | + * .query_id = DRM_I915_QUERY_MEMORY_REGIONS; | |
| 2559 | + * }; | |
| 2560 | + * struct drm_i915_query query = { | |
| 2561 | + * .num_items = 1, | |
| 2562 | + * .items_ptr = (uintptr_t)&item, | |
| 2563 | + * }; | |
| 2564 | + * int err, i; | |
| 2565 | + * | |
| 2566 | + * // First query the size of the blob we need, this needs to be large | |
| 2567 | + * // enough to hold our array of regions. The kernel will fill out the | |
| 2568 | + * // item.length for us, which is the number of bytes we need. | |
| 2569 | + * err = ioctl(fd, DRM_IOCTL_I915_QUERY, &query); | |
| 2570 | + * if (err) ... | |
| 2571 | + * | |
| 2572 | + * info = calloc(1, item.length); | |
| 2573 | + * // Now that we allocated the required number of bytes, we call the ioctl | |
| 2574 | + * // again, this time with the data_ptr pointing to our newly allocated | |
| 2575 | + * // blob, which the kernel can then populate with the all the region info. | |
| 2576 | + * item.data_ptr = (uintptr_t)&info, | |
| 2577 | + * | |
| 2578 | + * err = ioctl(fd, DRM_IOCTL_I915_QUERY, &query); | |
| 2579 | + * if (err) ... | |
| 2580 | + * | |
| 2581 | + * // We can now access each region in the array | |
| 2582 | + * for (i = 0; i < info->num_regions; i++) { | |
| 2583 | + * struct drm_i915_memory_region_info mr = info->regions[i]; | |
| 2584 | + * u16 class = mr.region.class; | |
| 2585 | + * u16 instance = mr.region.instance; | |
| 2586 | + * | |
| 2587 | + * .... | |
| 2588 | + * } | |
| 2589 | + * | |
| 2590 | + * free(info); | |
| 2591 | + */ | |
| 2592 | +struct drm_i915_query_memory_regions { | |
| 2593 | + /** @num_regions: Number of supported regions */ | |
| 2594 | + __u32 num_regions; | |
| 2595 | + | |
| 2596 | + /** @rsvd: MBZ */ | |
| 2597 | + __u32 rsvd[3]; | |
| 2598 | + | |
| 2599 | + /** @regions: Info about each supported region */ | |
| 2600 | + struct drm_i915_memory_region_info regions[]; | |
| 2601 | +}; | |
| 2602 | + | |
| 2603 | +/** | |
| 2604 | + * struct drm_i915_gem_create_ext - Existing gem_create behaviour, with added | |
| 2605 | + * extension support using struct i915_user_extension. | |
| 2606 | + * | |
| 2607 | + * Note that in the future we want to have our buffer flags here, at least for | |
| 2608 | + * the stuff that is immutable. Previously we would have two ioctls, one to | |
| 2609 | + * create the object with gem_create, and another to apply various parameters, | |
| 2610 | + * however this creates some ambiguity for the params which are considered | |
| 2611 | + * immutable. Also in general we're phasing out the various SET/GET ioctls. | |
| 2612 | + */ | |
| 2613 | +struct drm_i915_gem_create_ext { | |
| 2614 | + /** | |
| 2615 | + * @size: Requested size for the object. | |
| 2616 | + * | |
| 2617 | + * The (page-aligned) allocated size for the object will be returned. | |
| 2618 | + * | |
| 2619 | + * Note that for some devices we have might have further minimum | |
| 2620 | + * page-size restrictions(larger than 4K), like for device local-memory. | |
| 2621 | + * However in general the final size here should always reflect any | |
| 2622 | + * rounding up, if for example using the I915_GEM_CREATE_EXT_MEMORY_REGIONS | |
| 2623 | + * extension to place the object in device local-memory. | |
| 2624 | + */ | |
| 2625 | + __u64 size; | |
| 2626 | + /** | |
| 2627 | + * @handle: Returned handle for the object. | |
| 2628 | + * | |
| 2629 | + * Object handles are nonzero. | |
| 2630 | + */ | |
| 2631 | + __u32 handle; | |
| 2632 | + /** @flags: MBZ */ | |
| 2633 | + __u32 flags; | |
| 2634 | + /** | |
| 2635 | + * @extensions: The chain of extensions to apply to this object. | |
| 2636 | + * | |
| 2637 | + * This will be useful in the future when we need to support several | |
| 2638 | + * different extensions, and we need to apply more than one when | |
| 2639 | + * creating the object. See struct i915_user_extension. | |
| 2640 | + * | |
| 2641 | + * If we don't supply any extensions then we get the same old gem_create | |
| 2642 | + * behaviour. | |
| 2643 | + * | |
| 2644 | + * For I915_GEM_CREATE_EXT_MEMORY_REGIONS usage see | |
| 2645 | + * struct drm_i915_gem_create_ext_memory_regions. | |
| 2646 | + */ | |
| 2647 | +#define I915_GEM_CREATE_EXT_MEMORY_REGIONS 0 | |
| 2648 | + __u64 extensions; | |
| 2649 | +}; | |
| 2650 | + | |
| 2651 | +/** | |
| 2652 | + * struct drm_i915_gem_create_ext_memory_regions - The | |
| 2653 | + * I915_GEM_CREATE_EXT_MEMORY_REGIONS extension. | |
| 2654 | + * | |
| 2655 | + * Set the object with the desired set of placements/regions in priority | |
| 2656 | + * order. Each entry must be unique and supported by the device. | |
| 2657 | + * | |
| 2658 | + * This is provided as an array of struct drm_i915_gem_memory_class_instance, or | |
| 2659 | + * an equivalent layout of class:instance pair encodings. See struct | |
| 2660 | + * drm_i915_query_memory_regions and DRM_I915_QUERY_MEMORY_REGIONS for how to | |
| 2661 | + * query the supported regions for a device. | |
| 2662 | + * | |
| 2663 | + * As an example, on discrete devices, if we wish to set the placement as | |
| 2664 | + * device local-memory we can do something like: | |
| 2665 | + * | |
| 2666 | + * .. code-block:: C | |
| 2667 | + * | |
| 2668 | + * struct drm_i915_gem_memory_class_instance region_lmem = { | |
| 2669 | + * .memory_class = I915_MEMORY_CLASS_DEVICE, | |
| 2670 | + * .memory_instance = 0, | |
| 2671 | + * }; | |
| 2672 | + * struct drm_i915_gem_create_ext_memory_regions regions = { | |
| 2673 | + * .base = { .name = I915_GEM_CREATE_EXT_MEMORY_REGIONS }, | |
| 2674 | + * .regions = (uintptr_t)®ion_lmem, | |
| 2675 | + * .num_regions = 1, | |
| 2676 | + * }; | |
| 2677 | + * struct drm_i915_gem_create_ext create_ext = { | |
| 2678 | + * .size = 16 * PAGE_SIZE, | |
| 2679 | + * .extensions = (uintptr_t)®ions, | |
| 2680 | + * }; | |
| 2681 | + * | |
| 2682 | + * int err = ioctl(fd, DRM_IOCTL_I915_GEM_CREATE_EXT, &create_ext); | |
| 2683 | + * if (err) ... | |
| 2684 | + * | |
| 2685 | + * At which point we get the object handle in &drm_i915_gem_create_ext.handle, | |
| 2686 | + * along with the final object size in &drm_i915_gem_create_ext.size, which | |
| 2687 | + * should account for any rounding up, if required. | |
| 2688 | + */ | |
| 2689 | +struct drm_i915_gem_create_ext_memory_regions { | |
| 2690 | + /** @base: Extension link. See struct i915_user_extension. */ | |
| 2691 | + struct i915_user_extension base; | |
| 2692 | + | |
| 2693 | + /** @pad: MBZ */ | |
| 2694 | + __u32 pad; | |
| 2695 | + /** @num_regions: Number of elements in the @regions array. */ | |
| 2696 | + __u32 num_regions; | |
| 2697 | + /** | |
| 2698 | + * @regions: The regions/placements array. | |
| 2699 | + * | |
| 2700 | + * An array of struct drm_i915_gem_memory_class_instance. | |
| 2701 | + */ | |
| 2702 | + __u64 regions; | |
| 2703 | +}; | |
| 2704 | + | |
| 2380 | 2705 | #if defined(__cplusplus) |
| 2381 | 2706 | } |
| 2382 | 2707 | #endif |