From 00abc931bc13414816682fdcaf72d2b5262d6cd0 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Fri, 18 Aug 2023 16:20:32 +0200 Subject: [PATCH] Revert "radv/amdgpu: skip adding per VM BOs for sparse during CS BO list build" This reverts commit 51caece74cd54e99a5f89521e8feacd894781ca2. Cc: mesa-stable Signed-off-by: Samuel Pitoiset Part-of: (cherry picked from commit e3fae0173005801ba39d50de3944bc6113e2a624) --- .pick_status.json | 2 +- src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c | 15 +++++++++++++++ src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c | 14 -------------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 09a1d618663..be7a5435a71 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -5264,7 +5264,7 @@ "description": "Revert \"radv/amdgpu: skip adding per VM BOs for sparse during CS BO list build\"", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c index 72771ab4075..8c26c9fbcf1 100644 --- a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c +++ b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c @@ -136,6 +136,21 @@ radv_amdgpu_winsys_bo_virtual_bind(struct radeon_winsys *_ws, struct radeon_wins return VK_ERROR_OUT_OF_DEVICE_MEMORY; } + /* Do not add the BO to the virtual BO list if it's already in the global list to avoid dangling + * BO references because it might have been destroyed without being previously unbound. Resetting + * it to NULL clears the old BO ranges if present. + * + * This is going to be clarified in the Vulkan spec: + * https://gitlab.khronos.org/vulkan/vulkan/-/issues/3125 + * + * The issue still exists for non-global BO but it will be addressed later, once we are 100% it's + * RADV fault (mostly because the solution looks more complicated). + */ + if (bo && bo->base.use_global_list) { + bo = NULL; + bo_offset = 0; + } + /* We have at most 2 new ranges (1 by the bind, and another one by splitting a range that * contains the newly bound range). */ if (parent->range_capacity - parent->range_count < 2) { diff --git a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c index ba50e7823b2..ecd39618cea 100644 --- a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c +++ b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c @@ -827,20 +827,6 @@ radv_amdgpu_add_cs_to_bo_list(struct radv_amdgpu_cs *cs, struct drm_amdgpu_bo_li for (unsigned k = 0; k < virtual_bo->bo_count; ++k) { struct radv_amdgpu_winsys_bo *bo = virtual_bo->bos[k]; bool found = false; - - /* Do not add the BO to the virtual BO list if it's already in the global list to avoid - * dangling BO references because it might have been destroyed without being previously - * unbound. Resetting it to NULL clears the old BO ranges if present. - * - * This is going to be clarified in the Vulkan spec: - * https://gitlab.khronos.org/vulkan/vulkan/-/issues/3125 - * - * The issue still exists for non-global BO but it will be addressed later, once we are - * 100% it's RADV fault (mostly because the solution looks more complicated). - */ - if (bo->base.use_global_list) - continue; - for (unsigned m = 0; m < num_handles; ++m) { if (handles[m].bo_handle == bo->bo_handle) { found = true;