Skip to contentSkip to conversation

drm/amdgpu: fix contiguous handling for IB parsing

PATCH In review Christian König 3 participants 5 messages Jul 24, 2024 – Jul 25, 2024

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

PATCH 1/1 drm/amdgpu: fix contiguous handling for IB parsing

Otherwise we won't get correct access to the IB.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +7 -8
index ec888fc6ead8..41055224930f 100644
@@ -1763,7 +1763,7 @@ int amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser,
 	struct ttm_operation_ctx ctx = { false, false };
 	struct amdgpu_vm *vm = &fpriv->vm;
 	struct amdgpu_bo_va_mapping *mapping;
-	int r;
+	int i, r;
 
 	addr /= AMDGPU_GPU_PAGE_SIZE;
 
@@ -1778,13 +1778,12 @@ int amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser,
 	if (dma_resv_locking_ctx((*bo)->tbo.base.resv) != &parser->exec.ticket)
 		return -EINVAL;
 
-	if (!((*bo)->flags & AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS)) {
-		(*bo)->flags |= AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS;
-		amdgpu_bo_placement_from_domain(*bo, (*bo)->allowed_domains);
-		r = ttm_bo_validate(&(*bo)->tbo, &(*bo)->placement, &ctx);
-		if (r)
-			return r;
-	}
+	amdgpu_bo_placement_from_domain(*bo, (*bo)->allowed_domains);
+	for (i = 0; i < (*bo)->placement.num_placement; i++)
+		(*bo)->placements[i].flags |= TTM_PL_FLAG_CONTIGUOUS;
+	r = ttm_bo_validate(&(*bo)->tbo, &(*bo)->placement, &ctx);
+	if (r)
+		return r;
 
 	return amdgpu_ttm_alloc_gart(&(*bo)->tbo);
 }
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Christian König

Otherwise we won't get correct access to the IB.

Fixes e362b7c8f8c7 ("drm/amdgpu: Modify the contiguous flags behaviour")
Quoted 40 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +7 -9
index ec888fc6ead8..41055224930f 100644
@@ -1763,7 +1763,7 @@ int amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser,
        struct ttm_operation_ctx ctx = { false, false };
        struct amdgpu_vm *vm = &fpriv->vm;
        struct amdgpu_bo_va_mapping *mapping;
-       int r;
+       int i, r;
 
        addr /= AMDGPU_GPU_PAGE_SIZE;
 
@@ -1778,13 +1778,12 @@ int amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser,
        if (dma_resv_locking_ctx((*bo)->tbo.base.resv) != &parser->exec.ticket)
                return -EINVAL;
 
-       if (!((*bo)->flags & AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS)) {
-               (*bo)->flags |= AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS;
-               amdgpu_bo_placement_from_domain(*bo, (*bo)->allowed_domains);
-               r = ttm_bo_validate(&(*bo)->tbo, &(*bo)->placement, &ctx);
-               if (r)
-                       return r;
-       }
+       amdgpu_bo_placement_from_domain(*bo, (*bo)->allowed_domains);
+       for (i = 0; i < (*bo)->placement.num_placement; i++)
+               (*bo)->placements[i].flags |= TTM_PL_FLAG_CONTIGUOUS;
+       r = ttm_bo_validate(&(*bo)->tbo, &(*bo)->placement, &ctx);
+       if (r)
+               return r;
 
        return amdgpu_ttm_alloc_gart(&(*bo)->tbo);
 }
--

2.34.1

maintainer
#2 lore raw
Quoted 4 lines · Alex Deucher
Quoted 1 line · Christian König
Quoted 8 lines
Quoted 3 lines

Otherwise we won't get correct access to the IB.

Fixes e362b7c8f8c7 ("drm/amdgpu: Modify the contiguous flags behaviour")

NAK (just capitialising to avoid it getting committed)

This doesn't fix it, I think you also need
AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS set as well.

Dave.

Quoted 41 lines
Quoted 41 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +7 -9
index ec888fc6ead8..41055224930f 100644
@@ -1763,7 +1763,7 @@ int amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser,
        struct ttm_operation_ctx ctx = { false, false };
        struct amdgpu_vm *vm = &fpriv->vm;
        struct amdgpu_bo_va_mapping *mapping;
-       int r;
+       int i, r;
 
        addr /= AMDGPU_GPU_PAGE_SIZE;
 
@@ -1778,13 +1778,12 @@ int amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser,
        if (dma_resv_locking_ctx((*bo)->tbo.base.resv) != &parser->exec.ticket)
                return -EINVAL;
 
-       if (!((*bo)->flags & AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS)) {
-               (*bo)->flags |= AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS;
-               amdgpu_bo_placement_from_domain(*bo, (*bo)->allowed_domains);
-               r = ttm_bo_validate(&(*bo)->tbo, &(*bo)->placement, &ctx);
-               if (r)
-                       return r;
-       }
+       amdgpu_bo_placement_from_domain(*bo, (*bo)->allowed_domains);
+       for (i = 0; i < (*bo)->placement.num_placement; i++)
+               (*bo)->placements[i].flags |= TTM_PL_FLAG_CONTIGUOUS;
+       r = ttm_bo_validate(&(*bo)->tbo, &(*bo)->placement, &ctx);
+       if (r)
+               return r;
 
        return amdgpu_ttm_alloc_gart(&(*bo)->tbo);
 }
--

2.34.1

maintainer
#3 lore raw
Quoted 13 lines · Dave Airlie
Quoted 11 lines · Alex Deucher
Quoted 4 lines · Christian König

Otherwise we won't get correct access to the IB.

Fixes e362b7c8f8c7 ("drm/amdgpu: Modify the contiguous flags behaviour")
Quoted 7 lines
Quoted 1 line

NAK (just capitialising to avoid it getting committed)

This doesn't fix it, I think you also need
AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS set as well.

It does work once you set both flags on the bo (*bo)->flags |= AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS;

need to be added as well.

Dave.

maintainer
#4 lore raw
In reply to Alex Deucher
Quoted 4 lines · Alex Deucher
Quoted 1 line · Christian König
Quoted 8 lines
Quoted 3 lines

Otherwise we won't get correct access to the IB.

Fixes e362b7c8f8c7 ("drm/amdgpu: Modify the contiguous flags behaviour")

Please also add

since this is apparently needed for fixes to get into 6.10

Dave.

Quoted 41 lines
Quoted 41 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +7 -9
index ec888fc6ead8..41055224930f 100644
@@ -1763,7 +1763,7 @@ int amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser,
        struct ttm_operation_ctx ctx = { false, false };
        struct amdgpu_vm *vm = &fpriv->vm;
        struct amdgpu_bo_va_mapping *mapping;
-       int r;
+       int i, r;
 
        addr /= AMDGPU_GPU_PAGE_SIZE;
 
@@ -1778,13 +1778,12 @@ int amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser,
        if (dma_resv_locking_ctx((*bo)->tbo.base.resv) != &parser->exec.ticket)
                return -EINVAL;
 
-       if (!((*bo)->flags & AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS)) {
-               (*bo)->flags |= AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS;
-               amdgpu_bo_placement_from_domain(*bo, (*bo)->allowed_domains);
-               r = ttm_bo_validate(&(*bo)->tbo, &(*bo)->placement, &ctx);
-               if (r)
-                       return r;
-       }
+       amdgpu_bo_placement_from_domain(*bo, (*bo)->allowed_domains);
+       for (i = 0; i < (*bo)->placement.num_placement; i++)
+               (*bo)->placements[i].flags |= TTM_PL_FLAG_CONTIGUOUS;
+       r = ttm_bo_validate(&(*bo)->tbo, &(*bo)->placement, &ctx);
+       if (r)
+               return r;
 
        return amdgpu_ttm_alloc_gart(&(*bo)->tbo);
 }
--

2.34.1