drm/amdgpu: fix vram reservation issue
authorYiPeng Chai <YiPeng.Chai@amd.com>
Tue, 12 Aug 2025 01:17:58 +0000 (09:17 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 12 Aug 2025 20:07:45 +0000 (16:07 -0400)
The vram block allocation flag must be cleared
before making vram reservation, otherwise reserving
addresses within the currently freed memory range
will always fail.

Fixes: c9cad937c0c5 ("drm/amdgpu: add drm buddy support to amdgpu")
Signed-off-by: YiPeng Chai <YiPeng.Chai@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit d38eaf27de1b8584f42d6fb3f717b7ec44b3a7a1)

drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c

index 07c936e90d8e40080d956afa73de00e3d8cbdb7d..78f9e86ccc099057cdcea3c1b2f4b54a4dc93b10 100644 (file)
@@ -648,9 +648,8 @@ static void amdgpu_vram_mgr_del(struct ttm_resource_manager *man,
        list_for_each_entry(block, &vres->blocks, link)
                vis_usage += amdgpu_vram_mgr_vis_size(adev, block);
 
-       amdgpu_vram_mgr_do_reserve(man);
-
        drm_buddy_free_list(mm, &vres->blocks, vres->flags);
+       amdgpu_vram_mgr_do_reserve(man);
        mutex_unlock(&mgr->lock);
 
        atomic64_sub(vis_usage, &mgr->vis_usage);