Skip to contentSkip to conversation

drm/amdgpu: flush gpu tlb after a gart allocation

PATCH In review Nirmoy Das 2 participants 3 messages May 28, 2021

Subsystems (2)
lore
Share & tools
lore

Nirmoy Das

author
#0 lore raw

PATCH 1/1 drm/amdgpu: flush gpu tlb after a gart allocation

Flush gpu tlb in amdgpu_ttm_alloc_gart(). Also
don't flush gpu tlb after recovering each BO.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 2 --
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c  | 5 ++++-
 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -2
index 5562b5c90c03..68d41063e120 100644
@@ -329,8 +329,6 @@ int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
 
 	mb();
 	amdgpu_asic_flush_hdp(adev, NULL);
-	for (i = 0; i < adev->num_vmhubs; i++)
-		amdgpu_gmc_flush_gpu_tlb(adev, 0, i, 0);
 	return 0;
 }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +4 -1
index c0aef327292a..e68b5dab84a4 100644
@@ -977,7 +977,7 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo)
 	struct ttm_placement placement;
 	struct ttm_place placements;
 	uint64_t addr, flags;
-	int r;
+	int r, i;
 
 	if (bo->mem.start != AMDGPU_BO_INVALID_OFFSET)
 		return 0;
@@ -1014,6 +1014,9 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo)
 			return r;
 		}
 
+		for (i = 0; i < adev->num_vmhubs; i++)
+			amdgpu_gmc_flush_gpu_tlb(adev, 0, i, 0);
+
 		ttm_resource_free(bo, &bo->mem);
 		bo->mem = tmp;
 	}
Signature · 6 lines
2.31.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
maintainer
#1 lore raw

Am 28.05.21 um 14:54 schrieb Nirmoy Das:

Quoted 14 lines

Flush gpu tlb in amdgpu_ttm_alloc_gart(). Also
don't flush gpu tlb after recovering each BO.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 2 --
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c  | 5 ++++-
  2 files changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -0
index 5562b5c90c03..68d41063e120 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset, · line 331

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -0
@@ -329,8 +329,6 @@ int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
 
  	mb();
  	amdgpu_asic_flush_hdp(adev, NULL);

The memory barrier and HDP flush can be moved as well.

Quoted 19 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -2
-	for (i = 0; i < adev->num_vmhubs; i++)
-		amdgpu_gmc_flush_gpu_tlb(adev, 0, i, 0);
  	return 0;
  }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -1
index c0aef327292a..e68b5dab84a4 100644
@@ -977,7 +977,7 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo)
  	struct ttm_placement placement;
  	struct ttm_place placements;
  	uint64_t addr, flags;
-	int r;
+	int r, i;
 
  	if (bo->mem.start != AMDGPU_BO_INVALID_OFFSET)
  		return 0;

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo) · line 1019

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3 -0
@@ -1014,6 +1014,9 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo)
  			return r;
  		}
 
+		for (i = 0; i < adev->num_vmhubs; i++)
+			amdgpu_gmc_flush_gpu_tlb(adev, 0, i, 0);
+

Probably best to make that a function in amdgpu_gart.c to keep the GART functionality properly abstracted.

This can then be called from both amdgpu_gtt_mgr_recover() after dropping the lock and here.

Regards,
Christian.

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo) · line 1022

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
  		ttm_resource_free(bo, &bo->mem);
  		bo->mem = tmp;
  	}

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#2 lore raw
Quoted 50 lines · Christian König

Am 28.05.21 um 14:54 schrieb Nirmoy Das:

Quoted 14 lines

Flush gpu tlb in amdgpu_ttm_alloc_gart(). Also
don't flush gpu tlb after recovering each BO.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 2 -- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c  | 5 ++++-

  2 files changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -0
index 5562b5c90c03..68d41063e120 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_bind(struct amdgpu_device *adev, · line 331

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -0
@@ -329,8 +329,6 @@ int amdgpu_gart_bind(struct amdgpu_device *adev, 
 uint64_t offset,
         mb();
       amdgpu_asic_flush_hdp(adev, NULL);

The memory barrier and HDP flush can be moved as well.

Quoted 18 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -2
-    for (i = 0; i < adev->num_vmhubs; i++)
-        amdgpu_gmc_flush_gpu_tlb(adev, 0, i, 0);
       return 0;
   }

  diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index c0aef327292a..e68b5dab84a4 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -1
@@ -977,7 +977,7 @@ int amdgpu_ttm_alloc_gart(struct 
 ttm_buffer_object *bo)
       struct ttm_placement placement;
       struct ttm_place placements;
       uint64_t addr, flags;
-    int r;
+    int r, i;
         if (bo->mem.start != AMDGPU_BO_INVALID_OFFSET)
           return 0;

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c int amdgpu_ttm_alloc_gart(struct · line 1019

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2 -0
@@ -1014,6 +1014,9 @@ int amdgpu_ttm_alloc_gart(struct 
 ttm_buffer_object *bo)
               return r;
           }
   +        for (i = 0; i < adev->num_vmhubs; i++)
+            amdgpu_gmc_flush_gpu_tlb(adev, 0, i, 0);
+

Probably best to make that a function in amdgpu_gart.c to keep the GART functionality properly abstracted.

Quoted 1 line

This can then be called from both amdgpu_gtt_mgr_recover() after dropping the lock and here.

Thanks, Christian! I will resend.

Nirmoy

Quoted 8 lines

Regards,
Christian.

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
           ttm_resource_free(bo, &bo->mem);
           bo->mem = tmp;

      }

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx