VRAM is no longer usable after the device is wedged. Reject new VRAM
allocations with -ENOSPC so TTM can try another placement, such as TT.

An allocation racing with the wedge may still complete. The wedged fault
path prevents new VRAM CPU mappings, and device teardown releases the
resource.

Cc: Matthew Brost <[email protected]>
Cc: Thomas Hellström <[email protected]>
Cc: Himal Prasad Ghimiray <[email protected]>
Cc: Rodrigo Vivi <[email protected]>
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Arvind Yadav <[email protected]>
---
 drivers/gpu/drm/xe/xe_ttm_vram_mgr.c | 4 ++++
 1 file changed, 4 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..d0b266672010 100644
--- a/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c
+++ b/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c
@@ -54,6 +54,7 @@ static int xe_ttm_vram_mgr_new(struct ttm_resource_manager 
*man,
                               const struct ttm_place *place,
                               struct ttm_resource **res)
 {
+       struct xe_device *xe = ttm_to_xe_device(tbo->bdev);
        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;
@@ -61,6 +62,9 @@ static int xe_ttm_vram_mgr_new(struct ttm_resource_manager 
*man,
        unsigned long lpfn;
        int err;
 
+       if (xe_device_wedged(xe))
+               return -ENOSPC;
+
        lpfn = place->lpfn;
        if (!lpfn || lpfn > man->size >> PAGE_SHIFT)
                lpfn = man->size >> PAGE_SHIFT;
-- 
2.43.0

Reply via email to