Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/ttm: Add an allocation flag to propagate -ENOSPC on OOM

Some graphics APIs differentiate between out-of-graphics-memory and
out-of-host-memory (system memory). Add a device init flag to have -ENOSPC
propagated from the resource managers instead of being converted to
-ENOMEM, to aid driver stacks in determining what error code to return or
whether corrective action can be taken at the driver level.

Co-developed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Tvrtko Ursulin <tursulin@ursulin.net>
Link: https://lore.kernel.org/r/20251020115411.36818-7-tvrtko.ursulin@igalia.com

authored by

Tvrtko Ursulin and committed by
Tvrtko Ursulin
402b3a86 ccbadd9e

+10 -1
+3 -1
drivers/gpu/drm/ttm/ttm_bo.c
··· 32 32 #define pr_fmt(fmt) "[TTM] " fmt 33 33 34 34 #include <drm/drm_print.h> 35 + #include <drm/ttm/ttm_allocation.h> 35 36 #include <drm/ttm/ttm_bo.h> 36 37 #include <drm/ttm/ttm_placement.h> 37 38 #include <drm/ttm/ttm_tt.h> ··· 879 878 880 879 /* For backward compatibility with userspace */ 881 880 if (ret == -ENOSPC) 882 - return -ENOMEM; 881 + return bo->bdev->alloc_flags & TTM_ALLOCATION_PROPAGATE_ENOSPC ? 882 + ret : -ENOMEM; 883 883 884 884 /* 885 885 * We might need to add a TTM.
+1
drivers/gpu/drm/ttm/ttm_device.c
··· 227 227 return -ENOMEM; 228 228 } 229 229 230 + bdev->alloc_flags = alloc_flags; 230 231 bdev->funcs = funcs; 231 232 232 233 ttm_sys_man_init(bdev);
+1
include/drm/ttm/ttm_allocation.h
··· 7 7 #define TTM_ALLOCATION_POOL_BENEFICIAL_ORDER(n) ((n) & 0xff) /* Max order which caller can benefit from */ 8 8 #define TTM_ALLOCATION_POOL_USE_DMA_ALLOC BIT(8) /* Use coherent DMA allocations. */ 9 9 #define TTM_ALLOCATION_POOL_USE_DMA32 BIT(9) /* Use GFP_DMA32 allocations. */ 10 + #define TTM_ALLOCATION_PROPAGATE_ENOSPC BIT(10) /* Do not convert ENOSPC from resource managers to ENOMEM. */ 10 11 11 12 #endif
+5
include/drm/ttm/ttm_device.h
··· 221 221 struct list_head device_list; 222 222 223 223 /** 224 + * @alloc_flags: TTM_ALLOCATION_ flags. 225 + */ 226 + unsigned int alloc_flags; 227 + 228 + /** 224 229 * @funcs: Function table for the device. 225 230 * Constant after bo device init 226 231 */