When the amount of VRAM in use exceeds the free system memory, evicting VRAM at suspend may invoke the OOM killer, and under heavy memory pressure the system may hang [1].
Patch 3 avoids invoking the OOM killer by having the user BO eviction use __GFP_RETRY_MAYFAIL, so that suspend is aborted with -ENOMEM instead. That makes eviction failures more likely, which exposes two pre-existing issues in the failure paths, fixed by patches 1 and 2: Patch 1 undoes the eviction of pinned BOs if suspend fails partway. Otherwise the device continues operating with stale backups, which a later resume restores over the live VRAM contents. This was reported by Sashiko on v1 of patch 2. Patch 2 converts -ENOMEM from the eviction at runtime suspend to -EAGAIN, since runtime PM otherwise treats the error as fatal and stops runtime-suspending the device. The patches are ordered so that no intermediate state makes the failure paths more likely to be hit before they are fixed. Patch 2 depends on patch 1, since retrying runtime suspend would otherwise restore stale pinned BO backups. v2: - Patches 2 and 3 were previously posted separately. Combined them into a series. - Patch 1: New patch. Undo pinned BO eviction on suspend failure, a prerequisite for patch 2. Reported by Sashiko. - Patch 2: Reworded the commit message for the new patch order. - Patch 3: Rebased. Testing: - W=1 build and checkpatch are clean. [1] https://gitlab.freedesktop.org/drm/xe/kernel/-/work_items/9615 AI tool use: an AI coding assistant was used for review and for drafting parts of the implementation and commit messages. Thomas Hellström (3): drm/xe: Undo pinned BO eviction on suspend failure drm/xe: Don't fail runtime suspend permanently on VRAM eviction -ENOMEM drm/ttm, drm/xe: Don't invoke the OOM killer when evicting VRAM at suspend drivers/gpu/drm/ttm/ttm_resource.c | 37 +++++++++++++++++++------ drivers/gpu/drm/xe/xe_bo.c | 26 ++++++++++++++++++ drivers/gpu/drm/xe/xe_bo.h | 1 + drivers/gpu/drm/xe/xe_bo_evict.c | 44 ++++++++++++++++++++++++++---- drivers/gpu/drm/xe/xe_bo_evict.h | 1 + drivers/gpu/drm/xe/xe_device.c | 5 +++- drivers/gpu/drm/xe/xe_pm.c | 15 ++++++++-- include/drm/ttm/ttm_resource.h | 5 ++++ 8 files changed, 118 insertions(+), 16 deletions(-) -- 2.56.1
