Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/ttm: add new api ttm_device_prepare_hibernation()

This new api is used for hibernation to move GTT BOs to shmem after
VRAM eviction. shmem will be flushed to swap disk later to reduce
the system memory usage for hibernation.

Signed-off-by: Samuel Zhang <guoqing.zhang@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Link: https://lore.kernel.org/r/20250710062313.3226149-2-guoqing.zhang@amd.com
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>

authored by

Samuel Zhang and committed by
Mario Limonciello
40b6a946 bead8800

+23
+22
drivers/gpu/drm/ttm/ttm_device.c
··· 125 125 return ret; 126 126 } 127 127 128 + /** 129 + * ttm_device_prepare_hibernation - move GTT BOs to shmem for hibernation. 130 + * 131 + * @bdev: A pointer to a struct ttm_device to prepare hibernation for. 132 + * 133 + * Return: 0 on success, negative number on failure. 134 + */ 135 + int ttm_device_prepare_hibernation(struct ttm_device *bdev) 136 + { 137 + struct ttm_operation_ctx ctx = { 138 + .interruptible = false, 139 + .no_wait_gpu = false, 140 + }; 141 + int ret; 142 + 143 + do { 144 + ret = ttm_device_swapout(bdev, &ctx, GFP_KERNEL); 145 + } while (ret > 0); 146 + return ret; 147 + } 148 + EXPORT_SYMBOL(ttm_device_prepare_hibernation); 149 + 128 150 /* 129 151 * A buffer object shrink method that tries to swap out the first 130 152 * buffer object on the global::swap_lru list.
+1
include/drm/ttm/ttm_device.h
··· 272 272 int ttm_global_swapout(struct ttm_operation_ctx *ctx, gfp_t gfp_flags); 273 273 int ttm_device_swapout(struct ttm_device *bdev, struct ttm_operation_ctx *ctx, 274 274 gfp_t gfp_flags); 275 + int ttm_device_prepare_hibernation(struct ttm_device *bdev); 275 276 276 277 static inline struct ttm_resource_manager * 277 278 ttm_manager_type(struct ttm_device *bdev, int mem_type)