]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amdgpu: use TTM_NUM_MOVE_FENCES when reserving fences
authorPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Tue, 3 Feb 2026 10:22:11 +0000 (11:22 +0100)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 30 Mar 2026 19:16:33 +0000 (15:16 -0400)
Use TTM_NUM_MOVE_FENCES as an upperbound of how many fences
ttm might need to deal with moves/evictions.

Signed-off-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Acked-by: Felix Kuehling <felix.kuehling@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
drivers/gpu/drm/amd/amdkfd/kfd_svm.c
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_wb.c

index c048217615c1f9fdd436ba69ea83f7a30d1f4f79..b24d5d21be5f2441c31ae44a8c0febbda8c97e12 100644 (file)
@@ -908,9 +908,8 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
                        goto out_free_user_pages;
 
                amdgpu_bo_list_for_each_entry(e, p->bo_list) {
-                       /* One fence for TTM and one for each CS job */
                        r = drm_exec_prepare_obj(&p->exec, &e->bo->tbo.base,
-                                                1 + p->gang_size);
+                                                TTM_NUM_MOVE_FENCES + p->gang_size);
                        drm_exec_retry_on_contention(&p->exec);
                        if (unlikely(r))
                                goto out_free_user_pages;
@@ -920,7 +919,7 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
 
                if (p->uf_bo) {
                        r = drm_exec_prepare_obj(&p->exec, &p->uf_bo->tbo.base,
-                                                1 + p->gang_size);
+                                                TTM_NUM_MOVE_FENCES + p->gang_size);
                        drm_exec_retry_on_contention(&p->exec);
                        if (unlikely(r))
                                goto out_free_user_pages;
index 5cef8cd141485337b92618dcee3bbf0cdd06faaf..e54295b56282affc42b4bef7706069cd573851b5 100644 (file)
@@ -328,11 +328,9 @@ static int amdgpu_vkms_prepare_fb(struct drm_plane *plane,
                return r;
        }
 
-       r = dma_resv_reserve_fences(rbo->tbo.base.resv, 1);
-       if (r) {
-               dev_err(adev->dev, "allocating fence slot failed (%d)\n", r);
+       r = dma_resv_reserve_fences(rbo->tbo.base.resv, TTM_NUM_MOVE_FENCES);
+       if (r)
                goto error_unlock;
-       }
 
        if (plane->type != DRM_PLANE_TYPE_CURSOR)
                domain = amdgpu_display_supported_domains(adev, rbo->flags);
index 37fdcaf7192f14be5e5297c06e73ca05ba825c2c..b120fdb0ef77b564c825376da518865d333fbdae 100644 (file)
@@ -628,9 +628,8 @@ svm_range_vram_node_new(struct kfd_node *node, struct svm_range *prange,
                }
        }
 
-       r = dma_resv_reserve_fences(bo->tbo.base.resv, 1);
+       r = dma_resv_reserve_fences(bo->tbo.base.resv, TTM_NUM_MOVE_FENCES);
        if (r) {
-               pr_debug("failed %d to reserve bo\n", r);
                amdgpu_bo_unreserve(bo);
                goto reserve_bo_failed;
        }
index 3ba71e2d259ce283787e0a6ee1a99a6bc88e1213..81e43534ec599336cd8a317d91cd7843e0110039 100644 (file)
@@ -954,11 +954,9 @@ static int amdgpu_dm_plane_helper_prepare_fb(struct drm_plane *plane,
                return r;
        }
 
-       r = dma_resv_reserve_fences(rbo->tbo.base.resv, 1);
-       if (r) {
-               drm_err(adev_to_drm(adev), "reserving fence slot failed (%d)\n", r);
+       r = dma_resv_reserve_fences(rbo->tbo.base.resv, TTM_NUM_MOVE_FENCES);
+       if (r)
                goto error_unlock;
-       }
 
        if (plane->type != DRM_PLANE_TYPE_CURSOR)
                domain = amdgpu_display_supported_domains(adev, rbo->flags);
index d9527c05fc878ef6916782ff9fde847813938461..110f0173eee676953f1d0e4965443c4086055a4e 100644 (file)
@@ -106,11 +106,9 @@ static int amdgpu_dm_wb_prepare_job(struct drm_writeback_connector *wb_connector
                return r;
        }
 
-       r = dma_resv_reserve_fences(rbo->tbo.base.resv, 1);
-       if (r) {
-               drm_err(adev_to_drm(adev), "reserving fence slot failed (%d)\n", r);
+       r = dma_resv_reserve_fences(rbo->tbo.base.resv, TTM_NUM_MOVE_FENCES);
+       if (r)
                goto error_unlock;
-       }
 
        domain = amdgpu_display_supported_domains(adev, rbo->flags);