Skip to contentSkip to conversation

drm/amdgpu: fix number of fence calculations

PATCH In review Christian König 2 participants 2 messages Jun 20, 2023 – Jun 21, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: fix number of fence calculations

Since adding gang submit we need to take the gang size into account while reserving fences.

Fixes 4624459c84d7 ("drm/amdgpu: add gang submit frontend v6")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +6 -5
index d9503882ea97..b34f9f8d33d2 100644
@@ -136,9 +136,6 @@ static int amdgpu_cs_p1_user_fence(struct amdgpu_cs_parser *p,
 	bo = amdgpu_bo_ref(gem_to_amdgpu_bo(gobj));
 	p->uf_entry.priority = 0;
 	p->uf_entry.tv.bo = &bo->tbo;
-	/* One for TTM and two for the CS job */
-	p->uf_entry.tv.num_shared = 3;
-
 	drm_gem_object_put(gobj);
 
 	size = amdgpu_bo_size(bo);
@@ -912,15 +909,19 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
 
 	mutex_lock(&p->bo_list->bo_list_mutex);
 
-	/* One for TTM and one for the CS job */
+	/* One for TTM and one for each CS job */
 	amdgpu_bo_list_for_each_entry(e, p->bo_list)
-		e->tv.num_shared = 2;
+		e->tv.num_shared = 1 + p->gang_size;
+	p->uf_entry.tv.num_shared = 1 + p->gang_size;
 
 	amdgpu_bo_list_get_list(p->bo_list, &p->validated);
 
 	INIT_LIST_HEAD(&duplicates);
 	amdgpu_vm_get_pd_bo(&fpriv->vm, &p->validated, &p->vm_pd);
 
+	/* Two for VM updates, one for TTM and one for each CS job */
+	p->vm_pd.tv.num_shared = 3 + p->gang_size;
+
 	if (p->uf_entry.tv.bo && !ttm_to_amdgpu_bo(p->uf_entry.tv.bo)->parent)
 		list_add(&p->uf_entry.tv.head, &p->validated);
 
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Christian König

Since adding gang submit we need to take the gang size into account while reserving fences.

Fixes 4624459c84d7 ("drm/amdgpu: add gang submit frontend v6")
Quoted 43 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +6 -6
index d9503882ea97..b34f9f8d33d2 100644
@@ -136,9 +136,6 @@ static int amdgpu_cs_p1_user_fence(struct amdgpu_cs_parser *p,
        bo = amdgpu_bo_ref(gem_to_amdgpu_bo(gobj));
        p->uf_entry.priority = 0;
        p->uf_entry.tv.bo = &bo->tbo;
-       /* One for TTM and two for the CS job */
-       p->uf_entry.tv.num_shared = 3;
-
        drm_gem_object_put(gobj);
 
        size = amdgpu_bo_size(bo);
@@ -912,15 +909,19 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
 
        mutex_lock(&p->bo_list->bo_list_mutex);
 
-       /* One for TTM and one for the CS job */
+       /* One for TTM and one for each CS job */
        amdgpu_bo_list_for_each_entry(e, p->bo_list)
-               e->tv.num_shared = 2;
+               e->tv.num_shared = 1 + p->gang_size;
+       p->uf_entry.tv.num_shared = 1 + p->gang_size;
 
        amdgpu_bo_list_get_list(p->bo_list, &p->validated);
 
        INIT_LIST_HEAD(&duplicates);
        amdgpu_vm_get_pd_bo(&fpriv->vm, &p->validated, &p->vm_pd);
 
+       /* Two for VM updates, one for TTM and one for each CS job */
+       p->vm_pd.tv.num_shared = 3 + p->gang_size;
+
        if (p->uf_entry.tv.bo && !ttm_to_amdgpu_bo(p->uf_entry.tv.bo)->parent)
                list_add(&p->uf_entry.tv.head, &p->validated);
 
--

2.34.1