Skip to contentSkip to conversation

drm/amdgpu: release gtt bo after each move test

PATCH In review Nirmoy Das 4 participants 13 messages Oct 12, 2021 – Oct 21, 2021 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

Nirmoy Das

author
#0 lore raw

PATCH 1/1 drm/amdgpu: release gtt bo after each move test

When gart size is < gtt size this test will fail with -ENOMEM as we are not freeing gtt bo after each move test. This is generally not an issue when gart size >= gtt size.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_test.c +1 -1
index 909d830b513e..0cf2a560d673 100644
@@ -212,7 +212,6 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
 
 		DRM_INFO("Tested GTT->VRAM and VRAM->GTT copy for GTT offset 0x%llx\n",
 			 gart_addr - adev->gmc.gart_start);
-		continue;
 
 out_lclean_unpin:
 		amdgpu_bo_unpin(gtt_obj[i]);
@@ -220,6 +219,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
 		amdgpu_bo_unreserve(gtt_obj[i]);
 out_lclean_unref:
 		amdgpu_bo_unref(&gtt_obj[i]);
+		continue;
 out_lclean:
 		for (--i; i >= 0; --i) {
 			amdgpu_bo_unpin(gtt_obj[i]);
Signature · 1 line
2.32.0

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 8 lines · zhang

Hi . Nirmoy

If you let continue to unpin. this will  allways test a same va for gtt

I think we should  rafresh calculate  the value n

Right, I guess then the test should only run till gart size.

Regards,

Nirmoy

Quoted 32 lines · Nirmoy Das
Quoted 30 lines

When gart size is < gtt size this test will fail with -ENOMEM as we are not freeing gtt bo after each move test. This is generally not an issue when gart size >= gtt size.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_test.c +1 -1
index 909d830b513e..0cf2a560d673 100644
@@ -212,7 +212,6 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
 
  		DRM_INFO("Tested GTT->VRAM and VRAM->GTT copy for GTT offset 0x%llx\n",
  			 gart_addr - adev->gmc.gart_start);
-		continue;
 
  out_lclean_unpin:
  		amdgpu_bo_unpin(gtt_obj[i]);
@@ -220,6 +219,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
  		amdgpu_bo_unreserve(gtt_obj[i]);
  out_lclean_unref:
  		amdgpu_bo_unref(&gtt_obj[i]);
+		continue;
  out_lclean:
  		for (--i; i >= 0; --i) {
  			amdgpu_bo_unpin(gtt_obj[i]);
#3 lore raw
Quoted 7 lines · Nirmoy
Quoted 4 lines · zhang

Hi . Nirmoy

Quoted 7 lines
Quoted 4 lines

If you let continue to unpin. this will  allways test a same va for gtt

I think we should  rafresh calculate the value n

Right, I guess then the test should only run till gart size.

Actually the test size calculation was fine, it is just that we wouldn't release BO after a successful test as the cleanup code is inside the test for loop.

Regards,

Nirmoy

Quoted 37 lines

Regards,

Nirmoy

Quoted 32 lines · Nirmoy Das
Quoted 30 lines

When gart size is < gtt size this test will fail with -ENOMEM as we are not freeing gtt bo after each move test. This is generally not an issue when gart size >= gtt size.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_test.c +1 -1
index 909d830b513e..0cf2a560d673 100644
@@ -212,7 +212,6 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
 
  		DRM_INFO("Tested GTT->VRAM and VRAM->GTT copy for GTT offset 0x%llx\n",
  			 gart_addr - adev->gmc.gart_start);
-		continue;
 
  out_lclean_unpin:
  		amdgpu_bo_unpin(gtt_obj[i]);
@@ -220,6 +219,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
  		amdgpu_bo_unreserve(gtt_obj[i]);
  out_lclean_unref:
  		amdgpu_bo_unref(&gtt_obj[i]);
+		continue;
  out_lclean:
  		for (--i; i >= 0; --i) {
  			amdgpu_bo_unpin(gtt_obj[i]);
author
#4 lore raw

PATCH 1/1 drm/amdgpu: release gtt bo after each move test

In reply to Nirmoy Das

When gart size is < gtt size this test will fail with -ENOMEM as we are not freeing gtt bo after each move test. This is generally not an issue when gart size >= gtt size.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_test.c +1 -1
index 909d830b513e..0cf2a560d673 100644
@@ -212,7 +212,6 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
 
 		DRM_INFO("Tested GTT->VRAM and VRAM->GTT copy for GTT offset 0x%llx\n",
 			 gart_addr - adev->gmc.gart_start);
-		continue;
 
 out_lclean_unpin:
 		amdgpu_bo_unpin(gtt_obj[i]);
@@ -220,6 +219,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
 		amdgpu_bo_unreserve(gtt_obj[i]);
 out_lclean_unref:
 		amdgpu_bo_unref(&gtt_obj[i]);
+		continue;
 out_lclean:
 		for (--i; i >= 0; --i) {
 			amdgpu_bo_unpin(gtt_obj[i]);
Signature · 1 line
2.32.0
#5 lore raw

Please ignore this!

Quoted 30 lines · Nirmoy Das

When gart size is < gtt size this test will fail with -ENOMEM as we are not freeing gtt bo after each move test. This is generally not an issue when gart size >= gtt size.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_test.c +1 -1
index 909d830b513e..0cf2a560d673 100644
@@ -212,7 +212,6 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
 
  		DRM_INFO("Tested GTT->VRAM and VRAM->GTT copy for GTT offset 0x%llx\n",
  			 gart_addr - adev->gmc.gart_start);
-		continue;
 
  out_lclean_unpin:
  		amdgpu_bo_unpin(gtt_obj[i]);
@@ -220,6 +219,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
  		amdgpu_bo_unreserve(gtt_obj[i]);
  out_lclean_unref:
  		amdgpu_bo_unref(&gtt_obj[i]);
+		continue;
  out_lclean:
  		for (--i; i >= 0; --i) {
  			amdgpu_bo_unpin(gtt_obj[i]);
author
#6 lore raw

PATCH 1/1 drm/amdgpu: fix BO leak after successful move test

In reply to Nirmoy Das

GTT BO cleanup code is with in the test for loop and we would skip cleaning up GTT BO on success.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | 25 ++++++++++++------------
 1 file changed, 12 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_test.c +12 -13
index 909d830b513e..5fe7ff680c29 100644
@@ -35,6 +35,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
 	struct amdgpu_bo *vram_obj = NULL;
 	struct amdgpu_bo **gtt_obj = NULL;
 	struct amdgpu_bo_param bp;
+	struct dma_fence *fence = NULL;
 	uint64_t gart_addr, vram_addr;
 	unsigned n, size;
 	int i, r;
@@ -82,7 +83,6 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
 		void *gtt_map, *vram_map;
 		void **gart_start, **gart_end;
 		void **vram_start, **vram_end;
-		struct dma_fence *fence = NULL;
 
 		bp.domain = AMDGPU_GEM_DOMAIN_GTT;
 		r = amdgpu_bo_create(adev, &bp, gtt_obj + i);
@@ -212,24 +212,23 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
 
 		DRM_INFO("Tested GTT->VRAM and VRAM->GTT copy for GTT offset 0x%llx\n",
 			 gart_addr - adev->gmc.gart_start);
-		continue;
+	}
 
+	--i;
 out_lclean_unpin:
-		amdgpu_bo_unpin(gtt_obj[i]);
+	amdgpu_bo_unpin(gtt_obj[i]);
 out_lclean_unres:
-		amdgpu_bo_unreserve(gtt_obj[i]);
+	amdgpu_bo_unreserve(gtt_obj[i]);
 out_lclean_unref:
-		amdgpu_bo_unref(&gtt_obj[i]);
+	amdgpu_bo_unref(&gtt_obj[i]);
 out_lclean:
-		for (--i; i >= 0; --i) {
-			amdgpu_bo_unpin(gtt_obj[i]);
-			amdgpu_bo_unreserve(gtt_obj[i]);
-			amdgpu_bo_unref(&gtt_obj[i]);
-		}
-		if (fence)
-			dma_fence_put(fence);
-		break;
+	for (--i; i >= 0; --i) {
+		amdgpu_bo_unpin(gtt_obj[i]);
+		amdgpu_bo_unreserve(gtt_obj[i]);
+		amdgpu_bo_unref(&gtt_obj[i]);
 	}
+	if (fence)
+		dma_fence_put(fence);
 
 	amdgpu_bo_unpin(vram_obj);
 out_unres:
Signature · 1 line
2.32.0
#7 lore raw

Re: [PATCH 1/1] drm/amdgpu: fix BO leak after successful move test

ping.

Quoted 65 lines · Nirmoy Das

GTT BO cleanup code is with in the test for loop and we would skip cleaning up GTT BO on success.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | 25 ++++++++++++------------
  1 file changed, 12 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_test.c +12 -13
index 909d830b513e..5fe7ff680c29 100644
@@ -35,6 +35,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
  	struct amdgpu_bo *vram_obj = NULL;
  	struct amdgpu_bo **gtt_obj = NULL;
  	struct amdgpu_bo_param bp;
+	struct dma_fence *fence = NULL;
  	uint64_t gart_addr, vram_addr;
  	unsigned n, size;
  	int i, r;
@@ -82,7 +83,6 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
  		void *gtt_map, *vram_map;
  		void **gart_start, **gart_end;
  		void **vram_start, **vram_end;
-		struct dma_fence *fence = NULL;
 
  		bp.domain = AMDGPU_GEM_DOMAIN_GTT;
  		r = amdgpu_bo_create(adev, &bp, gtt_obj + i);
@@ -212,24 +212,23 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
 
  		DRM_INFO("Tested GTT->VRAM and VRAM->GTT copy for GTT offset 0x%llx\n",
  			 gart_addr - adev->gmc.gart_start);
-		continue;
+	}
 
+	--i;
  out_lclean_unpin:
-		amdgpu_bo_unpin(gtt_obj[i]);
+	amdgpu_bo_unpin(gtt_obj[i]);
  out_lclean_unres:
-		amdgpu_bo_unreserve(gtt_obj[i]);
+	amdgpu_bo_unreserve(gtt_obj[i]);
  out_lclean_unref:
-		amdgpu_bo_unref(&gtt_obj[i]);
+	amdgpu_bo_unref(&gtt_obj[i]);
  out_lclean:
-		for (--i; i >= 0; --i) {
-			amdgpu_bo_unpin(gtt_obj[i]);
-			amdgpu_bo_unreserve(gtt_obj[i]);
-			amdgpu_bo_unref(&gtt_obj[i]);
-		}
-		if (fence)
-			dma_fence_put(fence);
-		break;
+	for (--i; i >= 0; --i) {
+		amdgpu_bo_unpin(gtt_obj[i]);
+		amdgpu_bo_unreserve(gtt_obj[i]);
+		amdgpu_bo_unref(&gtt_obj[i]);
  	}
+	if (fence)
+		dma_fence_put(fence);
 
  	amdgpu_bo_unpin(vram_obj);
  out_unres:
#8 lore raw

Re: [PATCH 1/1] drm/amdgpu: fix BO leak after successful move test

In reply to Nirmoy Das

Am 13.10.21 um 17:09 schrieb Nirmoy Das:

Quoted 46 lines

GTT BO cleanup code is with in the test for loop and we would skip cleaning up GTT BO on success.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | 25 ++++++++++++------------
  1 file changed, 12 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_test.c +6 -5
index 909d830b513e..5fe7ff680c29 100644
@@ -35,6 +35,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
  	struct amdgpu_bo *vram_obj = NULL;
  	struct amdgpu_bo **gtt_obj = NULL;
  	struct amdgpu_bo_param bp;
+	struct dma_fence *fence = NULL;
  	uint64_t gart_addr, vram_addr;
  	unsigned n, size;
  	int i, r;
@@ -82,7 +83,6 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
  		void *gtt_map, *vram_map;
  		void **gart_start, **gart_end;
  		void **vram_start, **vram_end;
-		struct dma_fence *fence = NULL;
 
  		bp.domain = AMDGPU_GEM_DOMAIN_GTT;
  		r = amdgpu_bo_create(adev, &bp, gtt_obj + i);
@@ -212,24 +212,23 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
 
  		DRM_INFO("Tested GTT->VRAM and VRAM->GTT copy for GTT offset 0x%llx\n",
  			 gart_addr - adev->gmc.gart_start);
-		continue;
+	}
 
+	--i;
  out_lclean_unpin:
-		amdgpu_bo_unpin(gtt_obj[i]);
+	amdgpu_bo_unpin(gtt_obj[i]);
  out_lclean_unres:
-		amdgpu_bo_unreserve(gtt_obj[i]);
+	amdgpu_bo_unreserve(gtt_obj[i]);
  out_lclean_unref:
-		amdgpu_bo_unref(&gtt_obj[i]);
+	amdgpu_bo_unref(&gtt_obj[i]);

drivers/gpu/drm/amd/amdgpu/amdgpu_test.c static void amdgpu_do_test_moves(struct amdgpu_device *adev) · line 225

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_test.c +1 -8
  out_lclean:
-		for (--i; i >= 0; --i) {
-			amdgpu_bo_unpin(gtt_obj[i]);
-			amdgpu_bo_unreserve(gtt_obj[i]);
-			amdgpu_bo_unref(&gtt_obj[i]);
-		}
-		if (fence)
-			dma_fence_put(fence);
-		break;
+	for (--i; i >= 0; --i) {

The usual idiom for cleanups like that is "while (i--)..." because that also works with an unsigned i.

Apart from that looks good to me.

Christian.

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_test.c +5 -0
+		amdgpu_bo_unpin(gtt_obj[i]);
+		amdgpu_bo_unreserve(gtt_obj[i]);
+		amdgpu_bo_unref(&gtt_obj[i]);
  	}
+	if (fence)
+		dma_fence_put(fence);
 
  	amdgpu_bo_unpin(vram_obj);
  out_unres:
#9 lore raw

Re: [PATCH 1/1] drm/amdgpu: fix BO leak after successful move test

Am 20.10.21 um 13:50 schrieb Christian König:

Quoted 62 lines

Am 13.10.21 um 17:09 schrieb Nirmoy Das:

Quoted 48 lines

GTT BO cleanup code is with in the test for loop and we would skip cleaning up GTT BO on success.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | 25 ++++++++++++------------

  1 file changed, 12 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_test.c +1 -0
index 909d830b513e..5fe7ff680c29 100644
@@ -35,6 +35,7 @@ static void amdgpu_do_test_moves(struct 
 amdgpu_device *adev)
       struct amdgpu_bo *vram_obj = NULL;
       struct amdgpu_bo **gtt_obj = NULL;
       struct amdgpu_bo_param bp;
+    struct dma_fence *fence = NULL;
       uint64_t gart_addr, vram_addr;
       unsigned n, size;

      int i, r;

drivers/gpu/drm/amd/amdgpu/amdgpu_test.c +1 -2
@@ -82,7 +83,6 @@ static void amdgpu_do_test_moves(struct 
 amdgpu_device *adev)
           void *gtt_map, *vram_map;
           void **gart_start, **gart_end;
           void **vram_start, **vram_end;
-        struct dma_fence *fence = NULL;
             bp.domain = AMDGPU_GEM_DOMAIN_GTT;
           r = amdgpu_bo_create(adev, &bp, gtt_obj + i);
@@ -212,24 +212,23 @@ static void amdgpu_do_test_moves(struct 
 amdgpu_device *adev)
             DRM_INFO("Tested GTT->VRAM and VRAM->GTT copy for GTT offset 0x%llx\n",
                gart_addr - adev->gmc.gart_start);
-        continue;
+    }
   +    --i;

  out_lclean_unpin:
-        amdgpu_bo_unpin(gtt_obj[i]);
+    amdgpu_bo_unpin(gtt_obj[i]);
  out_lclean_unres:
-        amdgpu_bo_unreserve(gtt_obj[i]);
+    amdgpu_bo_unreserve(gtt_obj[i]);
  out_lclean_unref:
-        amdgpu_bo_unref(&gtt_obj[i]);
+    amdgpu_bo_unref(&gtt_obj[i]);
  out_lclean:
-        for (--i; i >= 0; --i) {

Quoted 8 lines

-            amdgpu_bo_unpin(gtt_obj[i]);
-            amdgpu_bo_unreserve(gtt_obj[i]);
-            amdgpu_bo_unref(&gtt_obj[i]);
-        }
-        if (fence)
-            dma_fence_put(fence);
-        break;
+    for (--i; i >= 0; --i) {

The usual idiom for cleanups like that is "while (i--)..." because that also works with an unsigned i.

Quoted 1 line

Apart from that looks good to me.

But I'm not sure that we would want to keep the in kernel tests around anyway.

We now have my amdgpu_stress tool to test memory bandwidth and mesa has an option for that for a long time as well.

Christian.

Quoted 12 lines

Christian.

Quoted 8 lines

+        amdgpu_bo_unpin(gtt_obj[i]);
+        amdgpu_bo_unreserve(gtt_obj[i]);
+        amdgpu_bo_unref(&gtt_obj[i]);
      }
+    if (fence)
+        dma_fence_put(fence);
        amdgpu_bo_unpin(vram_obj);
  out_unres:

#10 lore raw

Re: [PATCH 1/1] drm/amdgpu: fix BO leak after successful move test

Quoted 64 lines · Christian König

Am 20.10.21 um 13:50 schrieb Christian König:

Quoted 63 lines

Am 13.10.21 um 17:09 schrieb Nirmoy Das:

Quoted 49 lines

GTT BO cleanup code is with in the test for loop and we would skip cleaning up GTT BO on success.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | 25
++++++++++++------------

  1 file changed, 12 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_test.c +1 -0
index 909d830b513e..5fe7ff680c29 100644
@@ -35,6 +35,7 @@ static void amdgpu_do_test_moves(struct 
 amdgpu_device *adev)
       struct amdgpu_bo *vram_obj = NULL;
       struct amdgpu_bo **gtt_obj = NULL;
       struct amdgpu_bo_param bp;
+    struct dma_fence *fence = NULL;
       uint64_t gart_addr, vram_addr;
       unsigned n, size;

      int i, r;

drivers/gpu/drm/amd/amdgpu/amdgpu_test.c +1 -2
@@ -82,7 +83,6 @@ static void amdgpu_do_test_moves(struct 
 amdgpu_device *adev)
           void *gtt_map, *vram_map;
           void **gart_start, **gart_end;
           void **vram_start, **vram_end;
-        struct dma_fence *fence = NULL;
             bp.domain = AMDGPU_GEM_DOMAIN_GTT;
           r = amdgpu_bo_create(adev, &bp, gtt_obj + i);
@@ -212,24 +212,23 @@ static void amdgpu_do_test_moves(struct 
 amdgpu_device *adev)
             DRM_INFO("Tested GTT->VRAM and VRAM->GTT copy for GTT offset 0x%llx\n",
                gart_addr - adev->gmc.gart_start);
-        continue;
+    }
   +    --i;

  out_lclean_unpin:
-        amdgpu_bo_unpin(gtt_obj[i]);
+    amdgpu_bo_unpin(gtt_obj[i]);
  out_lclean_unres:
-        amdgpu_bo_unreserve(gtt_obj[i]);
+    amdgpu_bo_unreserve(gtt_obj[i]);
  out_lclean_unref:
-        amdgpu_bo_unref(&gtt_obj[i]);
+    amdgpu_bo_unref(&gtt_obj[i]);
  out_lclean:
-        for (--i; i >= 0; --i) {

Quoted 8 lines

-            amdgpu_bo_unpin(gtt_obj[i]);
-            amdgpu_bo_unreserve(gtt_obj[i]);
-            amdgpu_bo_unref(&gtt_obj[i]);
-        }
-        if (fence)
-            dma_fence_put(fence);
-        break;
+    for (--i; i >= 0; --i) {

The usual idiom for cleanups like that is "while (i--)..." because that also works with an unsigned i.

Quoted 5 lines
Quoted 1 line

Apart from that looks good to me.

But I'm not sure that we would want to keep the in kernel tests around anyway.

We now have my amdgpu_stress tool to test memory bandwidth and mesa has an option for that for a long time as well.

Shall I then remove amdgpu_test.c ?

Nirmoy

Quoted 16 lines

Christian.

Quoted 12 lines

Christian.

Quoted 8 lines

+        amdgpu_bo_unpin(gtt_obj[i]);
+        amdgpu_bo_unreserve(gtt_obj[i]);
+        amdgpu_bo_unref(&gtt_obj[i]);
      }
+    if (fence)
+        dma_fence_put(fence);
        amdgpu_bo_unpin(vram_obj);
  out_unres:

#11 lore raw

Re: [PATCH 1/1] drm/amdgpu: fix BO leak after successful move test

Am 20.10.21 um 14:55 schrieb Das, Nirmoy:

Quoted 66 lines · Christian König
Quoted 64 lines

Am 20.10.21 um 13:50 schrieb Christian König:

Quoted 63 lines

Am 13.10.21 um 17:09 schrieb Nirmoy Das:

Quoted 49 lines

GTT BO cleanup code is with in the test for loop and we would skip cleaning up GTT BO on success.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | 25
++++++++++++------------

  1 file changed, 12 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_test.c +1 -0
index 909d830b513e..5fe7ff680c29 100644
@@ -35,6 +35,7 @@ static void amdgpu_do_test_moves(struct 
 amdgpu_device *adev)
       struct amdgpu_bo *vram_obj = NULL;
       struct amdgpu_bo **gtt_obj = NULL;
       struct amdgpu_bo_param bp;
+    struct dma_fence *fence = NULL;
       uint64_t gart_addr, vram_addr;
       unsigned n, size;

      int i, r;

drivers/gpu/drm/amd/amdgpu/amdgpu_test.c +1 -2
@@ -82,7 +83,6 @@ static void amdgpu_do_test_moves(struct 
 amdgpu_device *adev)
           void *gtt_map, *vram_map;
           void **gart_start, **gart_end;
           void **vram_start, **vram_end;
-        struct dma_fence *fence = NULL;
             bp.domain = AMDGPU_GEM_DOMAIN_GTT;
           r = amdgpu_bo_create(adev, &bp, gtt_obj + i);
@@ -212,24 +212,23 @@ static void amdgpu_do_test_moves(struct 
 amdgpu_device *adev)
             DRM_INFO("Tested GTT->VRAM and VRAM->GTT copy for GTT offset 0x%llx\n",
                gart_addr - adev->gmc.gart_start);
-        continue;
+    }
   +    --i;

  out_lclean_unpin:
-        amdgpu_bo_unpin(gtt_obj[i]);
+    amdgpu_bo_unpin(gtt_obj[i]);
  out_lclean_unres:
-        amdgpu_bo_unreserve(gtt_obj[i]);
+    amdgpu_bo_unreserve(gtt_obj[i]);
  out_lclean_unref:
-        amdgpu_bo_unref(&gtt_obj[i]);
+    amdgpu_bo_unref(&gtt_obj[i]);
  out_lclean:
-        for (--i; i >= 0; --i) {

Quoted 8 lines

-            amdgpu_bo_unpin(gtt_obj[i]);
-            amdgpu_bo_unreserve(gtt_obj[i]);
-            amdgpu_bo_unref(&gtt_obj[i]);
-        }
-        if (fence)
-            dma_fence_put(fence);
-        break;
+    for (--i; i >= 0; --i) {

The usual idiom for cleanups like that is "while (i--)..." because that also works with an unsigned i.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Apart from that looks good to me.

But I'm not sure that we would want to keep the in kernel tests around anyway.

We now have my amdgpu_stress tool to test memory bandwidth and mesa has an option for that for a long time as well.

Shall I then remove amdgpu_test.c ?

Please double check if the amdgpu_stress utility gives you the same functionality, if yes we should probably remove this test here.

Thanks,
Christian.

Quoted 21 lines

Nirmoy

Quoted 16 lines

Christian.

Quoted 12 lines

Christian.

Quoted 8 lines

+        amdgpu_bo_unpin(gtt_obj[i]);
+        amdgpu_bo_unreserve(gtt_obj[i]);
+        amdgpu_bo_unref(&gtt_obj[i]);
      }
+    if (fence)
+        dma_fence_put(fence);
        amdgpu_bo_unpin(vram_obj);
  out_unres:

#12 lore raw

Re: [PATCH 1/1] drm/amdgpu: fix BO leak after successful move test

In reply to Christian König
Quoted 64 lines · Christian König

Am 20.10.21 um 13:50 schrieb Christian König:

Quoted 63 lines

Am 13.10.21 um 17:09 schrieb Nirmoy Das:

Quoted 49 lines

GTT BO cleanup code is with in the test for loop and we would skip cleaning up GTT BO on success.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | 25
++++++++++++------------

  1 file changed, 12 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_test.c +1 -0
index 909d830b513e..5fe7ff680c29 100644
@@ -35,6 +35,7 @@ static void amdgpu_do_test_moves(struct 
 amdgpu_device *adev)
       struct amdgpu_bo *vram_obj = NULL;
       struct amdgpu_bo **gtt_obj = NULL;
       struct amdgpu_bo_param bp;
+    struct dma_fence *fence = NULL;
       uint64_t gart_addr, vram_addr;
       unsigned n, size;

      int i, r;

drivers/gpu/drm/amd/amdgpu/amdgpu_test.c +1 -2
@@ -82,7 +83,6 @@ static void amdgpu_do_test_moves(struct 
 amdgpu_device *adev)
           void *gtt_map, *vram_map;
           void **gart_start, **gart_end;
           void **vram_start, **vram_end;
-        struct dma_fence *fence = NULL;
             bp.domain = AMDGPU_GEM_DOMAIN_GTT;
           r = amdgpu_bo_create(adev, &bp, gtt_obj + i);
@@ -212,24 +212,23 @@ static void amdgpu_do_test_moves(struct 
 amdgpu_device *adev)
             DRM_INFO("Tested GTT->VRAM and VRAM->GTT copy for GTT offset 0x%llx\n",
                gart_addr - adev->gmc.gart_start);
-        continue;
+    }
   +    --i;

  out_lclean_unpin:
-        amdgpu_bo_unpin(gtt_obj[i]);
+    amdgpu_bo_unpin(gtt_obj[i]);
  out_lclean_unres:
-        amdgpu_bo_unreserve(gtt_obj[i]);
+    amdgpu_bo_unreserve(gtt_obj[i]);
  out_lclean_unref:
-        amdgpu_bo_unref(&gtt_obj[i]);
+    amdgpu_bo_unref(&gtt_obj[i]);
  out_lclean:
-        for (--i; i >= 0; --i) {

Quoted 8 lines

-            amdgpu_bo_unpin(gtt_obj[i]);
-            amdgpu_bo_unreserve(gtt_obj[i]);
-            amdgpu_bo_unref(&gtt_obj[i]);
-        }
-        if (fence)
-            dma_fence_put(fence);
-        break;
+    for (--i; i >= 0; --i) {

The usual idiom for cleanups like that is "while (i--)..." because that also works with an unsigned i.

Quoted 8 lines
Quoted 1 line

Apart from that looks good to me.

But I'm not sure that we would want to keep the in kernel tests around anyway.

We now have my amdgpu_stress tool to test memory bandwidth and mesa has an option for that for a long time as well.

Christian.

  I found a  testsuit about "bo eviction Test"  for amdgpu . in libdrm  tests.

But I couldn't found  amdgpu_stress tool to test memory bandwid anywhere

Quoted 12 lines
Quoted 12 lines

Christian.

Quoted 8 lines

+        amdgpu_bo_unpin(gtt_obj[i]);
+        amdgpu_bo_unreserve(gtt_obj[i]);
+        amdgpu_bo_unref(&gtt_obj[i]);
      }
+    if (fence)
+        dma_fence_put(fence);
        amdgpu_bo_unpin(vram_obj);
  out_unres:

maintainer
#13 lore raw

Re: [PATCH 1/1] drm/amdgpu: fix BO leak after successful move test

Am 21.10.21 um 04:07 schrieb zhang:

Quoted 70 lines · Christian König
Quoted 68 lines

Am 20.10.21 um 13:50 schrieb Christian König:

Quoted 63 lines

Am 13.10.21 um 17:09 schrieb Nirmoy Das:

Quoted 49 lines

GTT BO cleanup code is with in the test for loop and we would skip cleaning up GTT BO on success.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | 25
++++++++++++------------

  1 file changed, 12 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_test.c +1 -0
index 909d830b513e..5fe7ff680c29 100644
@@ -35,6 +35,7 @@ static void amdgpu_do_test_moves(struct 
 amdgpu_device *adev)
       struct amdgpu_bo *vram_obj = NULL;
       struct amdgpu_bo **gtt_obj = NULL;
       struct amdgpu_bo_param bp;
+    struct dma_fence *fence = NULL;
       uint64_t gart_addr, vram_addr;
       unsigned n, size;

      int i, r;

drivers/gpu/drm/amd/amdgpu/amdgpu_test.c +1 -2
@@ -82,7 +83,6 @@ static void amdgpu_do_test_moves(struct 
 amdgpu_device *adev)
           void *gtt_map, *vram_map;
           void **gart_start, **gart_end;
           void **vram_start, **vram_end;
-        struct dma_fence *fence = NULL;
             bp.domain = AMDGPU_GEM_DOMAIN_GTT;
           r = amdgpu_bo_create(adev, &bp, gtt_obj + i);
@@ -212,24 +212,23 @@ static void amdgpu_do_test_moves(struct 
 amdgpu_device *adev)
             DRM_INFO("Tested GTT->VRAM and VRAM->GTT copy for GTT offset 0x%llx\n",
                gart_addr - adev->gmc.gart_start);
-        continue;
+    }
   +    --i;

  out_lclean_unpin:
-        amdgpu_bo_unpin(gtt_obj[i]);
+    amdgpu_bo_unpin(gtt_obj[i]);
  out_lclean_unres:
-        amdgpu_bo_unreserve(gtt_obj[i]);
+    amdgpu_bo_unreserve(gtt_obj[i]);
  out_lclean_unref:
-        amdgpu_bo_unref(&gtt_obj[i]);
+    amdgpu_bo_unref(&gtt_obj[i]);
  out_lclean:
-        for (--i; i >= 0; --i) {

Quoted 8 lines

-            amdgpu_bo_unpin(gtt_obj[i]);
-            amdgpu_bo_unreserve(gtt_obj[i]);
-            amdgpu_bo_unref(&gtt_obj[i]);
-        }
-        if (fence)
-            dma_fence_put(fence);
-        break;
+    for (--i; i >= 0; --i) {

The usual idiom for cleanups like that is "while (i--)..." because that also works with an unsigned i.

Quoted 1 line

Apart from that looks good to me.

But I'm not sure that we would want to keep the in kernel tests around anyway.

Quoted 7 lines
Quoted 4 lines

We now have my amdgpu_stress tool to test memory bandwidth and mesa has an option for that for a long time as well.

Christian.

  I found a  testsuit about "bo eviction Test"  for amdgpu . in libdrm  tests.

But I couldn't found  amdgpu_stress tool to test memory bandwid anywhere

That was merged just yesterday. See upstream libdrm.

Christian.

Quoted 14 lines
Quoted 13 lines
Quoted 13 lines

Christian.

Quoted 8 lines

+        amdgpu_bo_unpin(gtt_obj[i]);
+        amdgpu_bo_unreserve(gtt_obj[i]);
+        amdgpu_bo_unref(&gtt_obj[i]);
      }
+    if (fence)
+        dma_fence_put(fence);
        amdgpu_bo_unpin(vram_obj);
  out_unres: