radv/amdgpu: skip adding per VM BOs for sparse during CS BO list build
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Tue, 20 Jun 2023 10:52:26 +0000 (12:52 +0200)
committerMarge Bot <emma+marge@anholt.net>
Tue, 27 Jun 2023 13:13:03 +0000 (13:13 +0000)
This should be similar but it will help for re-introducing
OP_MAP/ON_UNMAP instead of OP_REPLACE.

Cc: mesa-stable
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23741>

src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c
src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c

index 8c26c9f..72771ab 100644 (file)
@@ -136,21 +136,6 @@ 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) {
index 6a697da..fd4f545 100644 (file)
@@ -787,6 +787,20 @@ 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;