Hi Dave and Sima, Here goes our late, final drm-xe-next PR towards 7.1. We just purgeable BO uAPI in today, hence the late pull. In the big things we have: - Add support for purgeable buffer objects Thanks, Matt UAPI Changes: - Add support for purgeable buffer objects (Arvind, Himal) Driver Changes: - Remove useless comment (Maarten) - Issue GGTT invalidation under lock in ggtt_node_remove (Brost, Fixes) - Fix mismatched include guards in header files (Shuicheng)
Showing the changes to include/uapi (1 of 22 files). Show all
Unified · Split
| @@ -432,6 +432,7 @@ struct drm_xe_query_config { · 431 unmodified lines | ||
| 432 | 432 | #define DRM_XE_QUERY_CONFIG_FLAG_HAS_CPU_ADDR_MIRROR (1 << 2) |
| 433 | 433 | #define DRM_XE_QUERY_CONFIG_FLAG_HAS_NO_COMPRESSION_HINT (1 << 3) |
| 434 | 434 | #define DRM_XE_QUERY_CONFIG_FLAG_HAS_DISABLE_STATE_CACHE_PERF_FIX (1 << 4) |
| 435 | + #define DRM_XE_QUERY_CONFIG_FLAG_HAS_PURGING_SUPPORT (1 << 5) | |
| 435 | 436 | #define DRM_XE_QUERY_CONFIG_MIN_ALIGNMENT 2 |
| 436 | 437 | #define DRM_XE_QUERY_CONFIG_VA_BITS 3 |
| 437 | 438 | #define DRM_XE_QUERY_CONFIG_MAX_EXEC_QUEUE_PRIORITY 4 |
| @@ -2171,6 +2172,7 @@ struct drm_xe_query_eu_stall { · 1733 unmodified lines | ||
| 2171 | 2172 | * - DRM_XE_MEM_RANGE_ATTR_PREFERRED_LOC: Set preferred memory location. |
| 2172 | 2173 | * - DRM_XE_MEM_RANGE_ATTR_ATOMIC: Set atomic access policy. |
| 2173 | 2174 | * - DRM_XE_MEM_RANGE_ATTR_PAT: Set page attribute table index. |
| 2175 | + * - DRM_XE_VMA_ATTR_PURGEABLE_STATE: Set purgeable state for BOs. | |
| 2174 | 2176 | * |
| 2175 | 2177 | * Example: |
| 2176 | 2178 | * |
| @@ -2203,6 +2205,7 @@ struct drm_xe_madvise { · 26 unmodified lines | ||
| 2203 | 2205 | #define DRM_XE_MEM_RANGE_ATTR_PREFERRED_LOC 0 |
| 2204 | 2206 | #define DRM_XE_MEM_RANGE_ATTR_ATOMIC 1 |
| 2205 | 2207 | #define DRM_XE_MEM_RANGE_ATTR_PAT 2 |
| 2208 | +#define DRM_XE_VMA_ATTR_PURGEABLE_STATE 3 | |
| 2206 | 2209 | /** @type: type of attribute */ |
| 2207 | 2210 | __u32 type; |
| 2208 | 2211 | |
| @@ -2293,6 +2296,72 @@ struct drm_xe_madvise { · 84 unmodified lines | ||
| 2293 | 2296 | /** @pat_index.reserved: Reserved */ |
| 2294 | 2297 | __u64 reserved; |
| 2295 | 2298 | } pat_index; |
| 2299 | + | |
| 2300 | + /** | |
| 2301 | + * @purge_state_val: Purgeable state configuration | |
| 2302 | + * | |
| 2303 | + * Used when @type == DRM_XE_VMA_ATTR_PURGEABLE_STATE. | |
| 2304 | + * | |
| 2305 | + * Configures the purgeable state of buffer objects in the specified | |
| 2306 | + * virtual address range. This allows applications to hint to the kernel | |
| 2307 | + * about bo's usage patterns for better memory management. | |
| 2308 | + * | |
| 2309 | + * By default all VMAs are in WILLNEED state. | |
| 2310 | + * | |
| 2311 | + * Supported values for @purge_state_val.val: | |
| 2312 | + * - DRM_XE_VMA_PURGEABLE_STATE_WILLNEED (0): Marks BO as needed. | |
| 2313 | + * If the BO was previously purged, the kernel sets the __u32 at | |
| 2314 | + * @retained_ptr to 0 (backing store lost) so the application knows | |
| 2315 | + * it must recreate the BO. | |
| 2316 | + * | |
| 2317 | + * - DRM_XE_VMA_PURGEABLE_STATE_DONTNEED (1): Marks BO as not currently | |
| 2318 | + * needed. Kernel may purge it under memory pressure to reclaim memory. | |
| 2319 | + * Only applies to non-shared BOs. The kernel sets the __u32 at | |
| 2320 | + * @retained_ptr to 1 if the backing store still exists (not yet purged), | |
| 2321 | + * or 0 if it was already purged. | |
| 2322 | + * | |
| 2323 | + * Important: Once marked as DONTNEED, touching the BO's memory | |
| 2324 | + * is undefined behavior. It may succeed temporarily (before the | |
| 2325 | + * kernel purges the backing store) but will suddenly fail once | |
| 2326 | + * the BO transitions to PURGED state. | |
| 2327 | + * | |
| 2328 | + * To transition back: use WILLNEED and check @retained_ptr — | |
| 2329 | + * if 0, backing store was lost and the BO must be recreated. | |
| 2330 | + * | |
| 2331 | + * The following operations are blocked in DONTNEED state to | |
| 2332 | + * prevent the BO from being re-mapped after madvise: | |
| 2333 | + * - New mmap() calls: Fail with -EBUSY | |
| 2334 | + * - VM_BIND operations: Fail with -EBUSY | |
| 2335 | + * - New dma-buf exports: Fail with -EBUSY | |
| 2336 | + * - CPU page faults (existing mmap): Fail with SIGBUS | |
| 2337 | + * - GPU page faults (fault-mode VMs): Fail with -EACCES | |
| 2338 | + */ | |
| 2339 | + struct { | |
| 2340 | +#define DRM_XE_VMA_PURGEABLE_STATE_WILLNEED 0 | |
| 2341 | +#define DRM_XE_VMA_PURGEABLE_STATE_DONTNEED 1 | |
| 2342 | + /** @purge_state_val.val: value for DRM_XE_VMA_ATTR_PURGEABLE_STATE */ | |
| 2343 | + __u32 val; | |
| 2344 | + | |
| 2345 | + /** @purge_state_val.pad: MBZ */ | |
| 2346 | + __u32 pad; | |
| 2347 | + /** | |
| 2348 | + * @purge_state_val.retained_ptr: Pointer to a __u32 output | |
| 2349 | + * field for backing store status. | |
| 2350 | + * | |
| 2351 | + * Userspace must initialize the __u32 value at this address | |
| 2352 | + * to 0 before the ioctl. Kernel writes a __u32 after the | |
| 2353 | + * operation: | |
| 2354 | + * - 1 if backing store exists (not purged) | |
| 2355 | + * - 0 if backing store was purged | |
| 2356 | + * | |
| 2357 | + * If userspace fails to initialize to 0, ioctl returns -EINVAL. | |
| 2358 | + * This ensures a safe default (0 = assume purged) if kernel | |
| 2359 | + * cannot write the result. | |
| 2360 | + * | |
| 2361 | + * Similar to i915's drm_i915_gem_madvise.retained field. | |
| 2362 | + */ | |
| 2363 | + __u64 retained_ptr; | |
| 2364 | + } purge_state_val; | |
| 2296 | 2365 | }; |
| 2297 | 2366 | |
| 2298 | 2367 | /** @reserved: Reserved */ |