diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c index 8f93e09e51bb..d30a8411d2a3 100644 --- a/drivers/gpu/drm/xe/xe_bo.c +++ b/drivers/gpu/drm/xe/xe_bo.c @@ -104,13 +104,16 @@ static bool resource_is_vram(struct ttm_resource *res) bool xe_bo_is_vram(struct xe_bo *bo) { - return resource_is_vram(bo->ttm.resource) || - resource_is_stolen_vram(xe_bo_device(bo), bo->ttm.resource); + struct ttm_resource *res = bo->ttm.resource; + + return res && (resource_is_vram(res) || resource_is_stolen_vram(xe_bo_device(bo), res)); } bool xe_bo_is_stolen(struct xe_bo *bo) { - return bo->ttm.resource->mem_type == XE_PL_STOLEN; + struct ttm_resource *res = bo->ttm.resource; + + return res && res->mem_type == XE_PL_STOLEN; } /** @@ -929,9 +932,6 @@ int xe_ttm_bo_purge(struct ttm_buffer_object *ttm_bo, struct ttm_operation_ctx * xe_bo_assert_held(bo); - if (!ttm_bo->ttm) - return 0; - if (!xe_bo_madv_is_dontneed(bo)) return 0;