From c1b1906f86ee34bae4a80d0ed4176b64d82e8dec Mon Sep 17 00:00:00 2001 From: Tejas Upadhyay Date: Thu, 3 Sep 2026 21:45:54 +0530 Subject: [PATCH] drm/xe: Link VRAM resource allocation with gpu buddy Setup to link allocation resource structure inside gpu buddy. This functionality is critical for supporting the memory page offline feature on CRI, where identified faulty pages must be traced back to their originating buffer for safe removal. v3(MattB): store memory resource(res) instead of tbo V2(MattB): Clear block->private in xe_ttm_vram_mgr_del as well Reviewed-by: Andi Shyti Reviewed-by: Himal Prasad Ghimiray Reviewed-by: Matthew Brost Signed-off-by: Tejas Upadhyay Signed-off-by: Matthew Brost Link: https://patch.msgid.link/20260903161553.528932-18-tejas.upadhyay@intel.com --- drivers/gpu/drm/xe/xe_ttm_vram_mgr.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c b/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c index 05911904c1f9..0f9cf1c3a576 100644 --- a/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c +++ b/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c @@ -57,6 +57,7 @@ static int xe_ttm_vram_mgr_new(struct ttm_resource_manager *man, struct xe_ttm_vram_mgr *mgr = to_xe_ttm_vram_mgr(man); struct xe_ttm_vram_mgr_resource *vres; struct gpu_buddy *mm = &mgr->mm; + struct gpu_buddy_block *block; u64 size, min_page_size; unsigned long lpfn; int err; @@ -141,6 +142,8 @@ static int xe_ttm_vram_mgr_new(struct ttm_resource_manager *man, } mgr->visible_avail -= vres->used_visible_size; + list_for_each_entry(block, &vres->blocks, link) + block->private = &vres->base; mutex_unlock(&mgr->lock); if (!(vres->base.placement & TTM_PL_FLAG_CONTIGUOUS) && @@ -179,8 +182,11 @@ static void xe_ttm_vram_mgr_del(struct ttm_resource_manager *man, to_xe_ttm_vram_mgr_resource(res); struct xe_ttm_vram_mgr *mgr = to_xe_ttm_vram_mgr(man); struct gpu_buddy *mm = &mgr->mm; + struct gpu_buddy_block *block; mutex_lock(&mgr->lock); + list_for_each_entry(block, &vres->blocks, link) + block->private = NULL; gpu_buddy_free_list(mm, &vres->blocks, 0); mgr->visible_avail += vres->used_visible_size; mutex_unlock(&mgr->lock);