]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
drm/xe: Convert stolen memory over to ttm_range_manager
authorSanjay Yadav <sanjay.kumar.yadav@intel.com>
Wed, 22 Apr 2026 12:55:03 +0000 (18:25 +0530)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Fri, 8 May 2026 14:39:59 +0000 (10:39 -0400)
commit1c76fa517214cbdca458076b4dcb4a3e0b87347f
tree4e33912572f335ebd1a8e7788404136f31f40c73
parentc53ed3e99920df6a90553c89a1c053aa0776841e
drm/xe: Convert stolen memory over to ttm_range_manager

Stolen memory requires physically contiguous allocations for display
scanout and compressed framebuffers. The stolen memory manager was
sharing the gpu_buddy allocator backend with the VRAM manager, but
buddy manages non-contiguous power-of-two blocks making it a poor fit.
Stolen memory also has fundamentally different allocation patterns:

- Allocation sizes are not power-of-two. Since buddy rounds up to the
  next power-of-two block size, a ~17MB request can fail even with
  ~22MB free, because the free space is fragmented across non-fitting
  power-of-two blocks.
- Hardware restrictions prevent using the first 4K page of stolen for
  certain allocations (e.g., FBC). The display code sets fpfn=1 to
  enforce this, but when fpfn != 0, gpu_buddy enables
  GPU_BUDDY_RANGE_ALLOCATION mode which disables the try_harder
  coalescing path, further reducing allocation success.

This combination caused FBC compressed framebuffer (CFB) allocation
failures on platforms like NVL/PTL. In case of NVL where stolen memory
is ~56MB and the initial plane framebuffer consumes ~34MB at probe time,
leaving ~22MB for subsequent allocations.

Use ttm_range_man_init_nocheck() to set up a drm_mm-backed TTM resource
manager for stolen memory. This reuses the TTM core's ttm_range_manager
callbacks, avoiding duplicate implementations.

Tested on NVL with a 4K DP display: stolen_mm shows a single ~22MB
contiguous free hole after initial plane framebuffer allocation, and
FBC successfully allocates its CFB from that region. The corresponding
IGT was previously skipped and now passes.

v2:
- Clarify that stolen memory requires contiguous allocations (Matt B)
- Properly handle xe_ttm_resource_visible() for stolen instead of
  unconditionally returning true (Matt A)

v3:
- Rebase
- Fix xe_display_bo_fbdev_prefer_stolen() to compare in pages, since
  ttm_range_manager stores stolen->size in pages not bytes (Matt A)

v4:
- Add kernel-doc for struct xe_ttm_stolen_mgr (Matt B)

Closes: https://gitlab.freedesktop.org/drm/xe/kernel/-/work_items/7631
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Suggested-by: Matthew Auld <matthew.auld@intel.com>
Assisted-by: GitHub Copilot:claude-sonnet-4.6
Signed-off-by: Sanjay Yadav <sanjay.kumar.yadav@intel.com>
Acked-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Acked-by: Vinod Govindapillai <vinod.govindapillai@intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Link: https://patch.msgid.link/20260422125502.3088222-2-sanjay.kumar.yadav@intel.com
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
drivers/gpu/drm/xe/display/xe_display_bo.c
drivers/gpu/drm/xe/xe_bo.c
drivers/gpu/drm/xe/xe_device_types.h
drivers/gpu/drm/xe/xe_res_cursor.h
drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c
drivers/gpu/drm/xe/xe_ttm_stolen_mgr.h
drivers/gpu/drm/xe/xe_ttm_vram_mgr.c