All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/7] drm/amdgpu/benchmark: use dev_info rather than DRM macros for logging
@ 2022-02-18 22:25 Alex Deucher
  2022-02-18 22:25 ` [PATCH 2/7] drm/amdgpu: plumb error handling though amdgpu_benchmark() Alex Deucher
                   ` (6 more replies)
  0 siblings, 7 replies; 12+ messages in thread
From: Alex Deucher @ 2022-02-18 22:25 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alex Deucher

So we can tell which output goes to which device when multiple GPUs
are present.  Also while we are here, convert DRM_ERROR to dev_info.
The error cases are not critical.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
index 313517f7cf10..b38783278a99 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
@@ -56,13 +56,15 @@ static int amdgpu_benchmark_do_move(struct amdgpu_device *adev, unsigned size,
 }
 
 
-static void amdgpu_benchmark_log_results(int n, unsigned size,
+static void amdgpu_benchmark_log_results(struct amdgpu_device *adev,
+					 int n, unsigned size,
 					 unsigned int time,
 					 unsigned sdomain, unsigned ddomain,
 					 char *kind)
 {
 	unsigned int throughput = (n * (size >> 10)) / time;
-	DRM_INFO("amdgpu: %s %u bo moves of %u kB from"
+
+	dev_info(adev->dev, "amdgpu: %s %u bo moves of %u kB from"
 		 " %d to %d in %u ms, throughput: %u Mb/s or %u MB/s\n",
 		 kind, n, size >> 10, sdomain, ddomain, time,
 		 throughput * 8, throughput);
@@ -131,14 +133,14 @@ static void amdgpu_benchmark_move(struct amdgpu_device *adev, unsigned size,
 		if (time < 0)
 			goto out_cleanup;
 		if (time > 0)
-			amdgpu_benchmark_log_results(n, size, time,
+			amdgpu_benchmark_log_results(adev, n, size, time,
 						     sdomain, ddomain, "dma");
 	}
 
 out_cleanup:
 	/* Check error value now. The value can be overwritten when clean up.*/
 	if (r) {
-		DRM_ERROR("Error while benchmarking BO move.\n");
+		dev_info(adev->dev, "Error while benchmarking BO move.\n");
 	}
 
 	if (sobj) {
@@ -239,6 +241,6 @@ void amdgpu_benchmark(struct amdgpu_device *adev, int test_number)
 		break;
 
 	default:
-		DRM_ERROR("Unknown benchmark\n");
+		dev_info(adev->dev, "Unknown benchmark\n");
 	}
 }
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/7] drm/amdgpu: plumb error handling though amdgpu_benchmark()
  2022-02-18 22:25 [PATCH 1/7] drm/amdgpu/benchmark: use dev_info rather than DRM macros for logging Alex Deucher
@ 2022-02-18 22:25 ` Alex Deucher
  2022-02-18 22:25 ` [PATCH 3/7] drm/amdgpu: print the selected benchmark test in the log Alex Deucher
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Alex Deucher @ 2022-02-18 22:25 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alex Deucher

So we can tell when this function fails.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h           |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c | 100 +++++++++++-------
 2 files changed, 64 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 566303c9942f..66d556fc17ef 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -586,7 +586,7 @@ void amdgpu_device_wb_free(struct amdgpu_device *adev, u32 wb);
 /*
  * Benchmarking
  */
-void amdgpu_benchmark(struct amdgpu_device *adev, int test_number);
+int amdgpu_benchmark(struct amdgpu_device *adev, int test_number);
 
 
 /*
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
index b38783278a99..7709f48e25a1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
@@ -70,15 +70,14 @@ static void amdgpu_benchmark_log_results(struct amdgpu_device *adev,
 		 throughput * 8, throughput);
 }
 
-static void amdgpu_benchmark_move(struct amdgpu_device *adev, unsigned size,
-				  unsigned sdomain, unsigned ddomain)
+static int amdgpu_benchmark_move(struct amdgpu_device *adev, unsigned size,
+				 unsigned sdomain, unsigned ddomain)
 {
 	struct amdgpu_bo *dobj = NULL;
 	struct amdgpu_bo *sobj = NULL;
 	struct amdgpu_bo_param bp;
 	uint64_t saddr, daddr;
 	int r, n;
-	int time;
 
 	memset(&bp, 0, sizeof(bp));
 	bp.size = size;
@@ -129,19 +128,18 @@ static void amdgpu_benchmark_move(struct amdgpu_device *adev, unsigned size,
 	daddr = amdgpu_bo_gpu_offset(dobj);
 
 	if (adev->mman.buffer_funcs) {
-		time = amdgpu_benchmark_do_move(adev, size, saddr, daddr, n);
-		if (time < 0)
+		r = amdgpu_benchmark_do_move(adev, size, saddr, daddr, n);
+		if (r < 0)
 			goto out_cleanup;
-		if (time > 0)
-			amdgpu_benchmark_log_results(adev, n, size, time,
+		if (r > 0)
+			amdgpu_benchmark_log_results(adev, n, size, r,
 						     sdomain, ddomain, "dma");
 	}
 
 out_cleanup:
 	/* Check error value now. The value can be overwritten when clean up.*/
-	if (r) {
+	if (r < 0)
 		dev_info(adev->dev, "Error while benchmarking BO move.\n");
-	}
 
 	if (sobj) {
 		r = amdgpu_bo_reserve(sobj, true);
@@ -159,11 +157,12 @@ static void amdgpu_benchmark_move(struct amdgpu_device *adev, unsigned size,
 		}
 		amdgpu_bo_unref(&dobj);
 	}
+	return r;
 }
 
-void amdgpu_benchmark(struct amdgpu_device *adev, int test_number)
+int amdgpu_benchmark(struct amdgpu_device *adev, int test_number)
 {
-	int i;
+	int i, r;
 	static const int common_modes[AMDGPU_BENCHMARK_COMMON_MODES_N] = {
 		640 * 480 * 4,
 		720 * 480 * 4,
@@ -187,60 +186,87 @@ void amdgpu_benchmark(struct amdgpu_device *adev, int test_number)
 	switch (test_number) {
 	case 1:
 		/* simple test, VRAM to GTT and GTT to VRAM */
-		amdgpu_benchmark_move(adev, 1024*1024, AMDGPU_GEM_DOMAIN_GTT,
-				      AMDGPU_GEM_DOMAIN_VRAM);
-		amdgpu_benchmark_move(adev, 1024*1024, AMDGPU_GEM_DOMAIN_VRAM,
-				      AMDGPU_GEM_DOMAIN_GTT);
+		r = amdgpu_benchmark_move(adev, 1024*1024, AMDGPU_GEM_DOMAIN_GTT,
+					  AMDGPU_GEM_DOMAIN_VRAM);
+		if (r)
+			return r;
+		r = amdgpu_benchmark_move(adev, 1024*1024, AMDGPU_GEM_DOMAIN_VRAM,
+					  AMDGPU_GEM_DOMAIN_GTT);
+		if (r)
+			return r;
 		break;
 	case 2:
 		/* simple test, VRAM to VRAM */
 		amdgpu_benchmark_move(adev, 1024*1024, AMDGPU_GEM_DOMAIN_VRAM,
 				      AMDGPU_GEM_DOMAIN_VRAM);
+		if (r)
+			return r;
 		break;
 	case 3:
 		/* GTT to VRAM, buffer size sweep, powers of 2 */
-		for (i = 1; i <= 16384; i <<= 1)
-			amdgpu_benchmark_move(adev, i * AMDGPU_GPU_PAGE_SIZE,
-					      AMDGPU_GEM_DOMAIN_GTT,
-					      AMDGPU_GEM_DOMAIN_VRAM);
+		for (i = 1; i <= 16384; i <<= 1) {
+			r = amdgpu_benchmark_move(adev, i * AMDGPU_GPU_PAGE_SIZE,
+						  AMDGPU_GEM_DOMAIN_GTT,
+						  AMDGPU_GEM_DOMAIN_VRAM);
+			if (r)
+				return r;
+		}
 		break;
 	case 4:
 		/* VRAM to GTT, buffer size sweep, powers of 2 */
-		for (i = 1; i <= 16384; i <<= 1)
-			amdgpu_benchmark_move(adev, i * AMDGPU_GPU_PAGE_SIZE,
-					      AMDGPU_GEM_DOMAIN_VRAM,
-					      AMDGPU_GEM_DOMAIN_GTT);
+		for (i = 1; i <= 16384; i <<= 1) {
+			r = amdgpu_benchmark_move(adev, i * AMDGPU_GPU_PAGE_SIZE,
+						  AMDGPU_GEM_DOMAIN_VRAM,
+						  AMDGPU_GEM_DOMAIN_GTT);
+			if (r)
+				return r;
+		}
 		break;
 	case 5:
 		/* VRAM to VRAM, buffer size sweep, powers of 2 */
-		for (i = 1; i <= 16384; i <<= 1)
-			amdgpu_benchmark_move(adev, i * AMDGPU_GPU_PAGE_SIZE,
-					      AMDGPU_GEM_DOMAIN_VRAM,
-					      AMDGPU_GEM_DOMAIN_VRAM);
+		for (i = 1; i <= 16384; i <<= 1) {
+			r = amdgpu_benchmark_move(adev, i * AMDGPU_GPU_PAGE_SIZE,
+						  AMDGPU_GEM_DOMAIN_VRAM,
+						  AMDGPU_GEM_DOMAIN_VRAM);
+			if (r)
+				return r;
+		}
 		break;
 	case 6:
 		/* GTT to VRAM, buffer size sweep, common modes */
-		for (i = 0; i < AMDGPU_BENCHMARK_COMMON_MODES_N; i++)
-			amdgpu_benchmark_move(adev, common_modes[i],
-					      AMDGPU_GEM_DOMAIN_GTT,
-					      AMDGPU_GEM_DOMAIN_VRAM);
+		for (i = 0; i < AMDGPU_BENCHMARK_COMMON_MODES_N; i++) {
+			r = amdgpu_benchmark_move(adev, common_modes[i],
+						  AMDGPU_GEM_DOMAIN_GTT,
+						  AMDGPU_GEM_DOMAIN_VRAM);
+			if (r)
+				return r;
+		}
 		break;
 	case 7:
 		/* VRAM to GTT, buffer size sweep, common modes */
-		for (i = 0; i < AMDGPU_BENCHMARK_COMMON_MODES_N; i++)
-			amdgpu_benchmark_move(adev, common_modes[i],
-					      AMDGPU_GEM_DOMAIN_VRAM,
-					      AMDGPU_GEM_DOMAIN_GTT);
+		for (i = 0; i < AMDGPU_BENCHMARK_COMMON_MODES_N; i++) {
+			r = amdgpu_benchmark_move(adev, common_modes[i],
+						  AMDGPU_GEM_DOMAIN_VRAM,
+						  AMDGPU_GEM_DOMAIN_GTT);
+			if (r)
+				return r;
+		}
 		break;
 	case 8:
 		/* VRAM to VRAM, buffer size sweep, common modes */
-		for (i = 0; i < AMDGPU_BENCHMARK_COMMON_MODES_N; i++)
-			amdgpu_benchmark_move(adev, common_modes[i],
+		for (i = 0; i < AMDGPU_BENCHMARK_COMMON_MODES_N; i++) {
+			r = amdgpu_benchmark_move(adev, common_modes[i],
 					      AMDGPU_GEM_DOMAIN_VRAM,
 					      AMDGPU_GEM_DOMAIN_VRAM);
+			if (r)
+				return r;
+		}
 		break;
 
 	default:
 		dev_info(adev->dev, "Unknown benchmark\n");
+		r = -EINVAL;
+		break;
 	}
+	return r;
 }
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/7] drm/amdgpu: print the selected benchmark test in the log
  2022-02-18 22:25 [PATCH 1/7] drm/amdgpu/benchmark: use dev_info rather than DRM macros for logging Alex Deucher
  2022-02-18 22:25 ` [PATCH 2/7] drm/amdgpu: plumb error handling though amdgpu_benchmark() Alex Deucher
@ 2022-02-18 22:25 ` Alex Deucher
  2022-02-18 22:26 ` [PATCH 4/7] drm/amdgpu: add a benchmark mutex Alex Deucher
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Alex Deucher @ 2022-02-18 22:25 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alex Deucher

So you can tell which benchmark was run.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
index 7709f48e25a1..62422c395789 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
@@ -185,6 +185,7 @@ int amdgpu_benchmark(struct amdgpu_device *adev, int test_number)
 
 	switch (test_number) {
 	case 1:
+		dev_info(adev->dev, "benchmark test: %d\n", test_number);
 		/* simple test, VRAM to GTT and GTT to VRAM */
 		r = amdgpu_benchmark_move(adev, 1024*1024, AMDGPU_GEM_DOMAIN_GTT,
 					  AMDGPU_GEM_DOMAIN_VRAM);
@@ -196,6 +197,7 @@ int amdgpu_benchmark(struct amdgpu_device *adev, int test_number)
 			return r;
 		break;
 	case 2:
+		dev_info(adev->dev, "benchmark test: %d\n", test_number);
 		/* simple test, VRAM to VRAM */
 		amdgpu_benchmark_move(adev, 1024*1024, AMDGPU_GEM_DOMAIN_VRAM,
 				      AMDGPU_GEM_DOMAIN_VRAM);
@@ -203,6 +205,7 @@ int amdgpu_benchmark(struct amdgpu_device *adev, int test_number)
 			return r;
 		break;
 	case 3:
+		dev_info(adev->dev, "benchmark test: %d\n", test_number);
 		/* GTT to VRAM, buffer size sweep, powers of 2 */
 		for (i = 1; i <= 16384; i <<= 1) {
 			r = amdgpu_benchmark_move(adev, i * AMDGPU_GPU_PAGE_SIZE,
@@ -213,6 +216,7 @@ int amdgpu_benchmark(struct amdgpu_device *adev, int test_number)
 		}
 		break;
 	case 4:
+		dev_info(adev->dev, "benchmark test: %d\n", test_number);
 		/* VRAM to GTT, buffer size sweep, powers of 2 */
 		for (i = 1; i <= 16384; i <<= 1) {
 			r = amdgpu_benchmark_move(adev, i * AMDGPU_GPU_PAGE_SIZE,
@@ -223,6 +227,7 @@ int amdgpu_benchmark(struct amdgpu_device *adev, int test_number)
 		}
 		break;
 	case 5:
+		dev_info(adev->dev, "benchmark test: %d\n", test_number);
 		/* VRAM to VRAM, buffer size sweep, powers of 2 */
 		for (i = 1; i <= 16384; i <<= 1) {
 			r = amdgpu_benchmark_move(adev, i * AMDGPU_GPU_PAGE_SIZE,
@@ -233,6 +238,7 @@ int amdgpu_benchmark(struct amdgpu_device *adev, int test_number)
 		}
 		break;
 	case 6:
+		dev_info(adev->dev, "benchmark test: %d\n", test_number);
 		/* GTT to VRAM, buffer size sweep, common modes */
 		for (i = 0; i < AMDGPU_BENCHMARK_COMMON_MODES_N; i++) {
 			r = amdgpu_benchmark_move(adev, common_modes[i],
@@ -243,6 +249,7 @@ int amdgpu_benchmark(struct amdgpu_device *adev, int test_number)
 		}
 		break;
 	case 7:
+		dev_info(adev->dev, "benchmark test: %d\n", test_number);
 		/* VRAM to GTT, buffer size sweep, common modes */
 		for (i = 0; i < AMDGPU_BENCHMARK_COMMON_MODES_N; i++) {
 			r = amdgpu_benchmark_move(adev, common_modes[i],
@@ -253,6 +260,7 @@ int amdgpu_benchmark(struct amdgpu_device *adev, int test_number)
 		}
 		break;
 	case 8:
+		dev_info(adev->dev, "benchmark test: %d\n", test_number);
 		/* VRAM to VRAM, buffer size sweep, common modes */
 		for (i = 0; i < AMDGPU_BENCHMARK_COMMON_MODES_N; i++) {
 			r = amdgpu_benchmark_move(adev, common_modes[i],
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 4/7] drm/amdgpu: add a benchmark mutex
  2022-02-18 22:25 [PATCH 1/7] drm/amdgpu/benchmark: use dev_info rather than DRM macros for logging Alex Deucher
  2022-02-18 22:25 ` [PATCH 2/7] drm/amdgpu: plumb error handling though amdgpu_benchmark() Alex Deucher
  2022-02-18 22:25 ` [PATCH 3/7] drm/amdgpu: print the selected benchmark test in the log Alex Deucher
@ 2022-02-18 22:26 ` Alex Deucher
  2022-02-18 22:26 ` [PATCH 5/7] drm/amdgpu: expose benchmarks via debugfs Alex Deucher
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Alex Deucher @ 2022-02-18 22:26 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alex Deucher

To avoid multiple runs in parallel to avoid mixing results.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h           |  2 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c | 23 +++++++++++--------
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c    |  1 +
 3 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 66d556fc17ef..c736c30e0a0a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1100,6 +1100,8 @@ struct amdgpu_device {
 	struct list_head                ras_list;
 
 	struct ip_discovery_top         *ip_top;
+
+	struct mutex			benchmark_mutex;
 };
 
 static inline struct amdgpu_device *drm_to_adev(struct drm_device *ddev)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
index 62422c395789..8e4997983124 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
@@ -183,6 +183,7 @@ int amdgpu_benchmark(struct amdgpu_device *adev, int test_number)
 		1920 * 1200 * 4
 	};
 
+	mutex_lock(&adev->benchmark_mutex);
 	switch (test_number) {
 	case 1:
 		dev_info(adev->dev, "benchmark test: %d\n", test_number);
@@ -190,11 +191,11 @@ int amdgpu_benchmark(struct amdgpu_device *adev, int test_number)
 		r = amdgpu_benchmark_move(adev, 1024*1024, AMDGPU_GEM_DOMAIN_GTT,
 					  AMDGPU_GEM_DOMAIN_VRAM);
 		if (r)
-			return r;
+			goto done;
 		r = amdgpu_benchmark_move(adev, 1024*1024, AMDGPU_GEM_DOMAIN_VRAM,
 					  AMDGPU_GEM_DOMAIN_GTT);
 		if (r)
-			return r;
+			goto done;
 		break;
 	case 2:
 		dev_info(adev->dev, "benchmark test: %d\n", test_number);
@@ -202,7 +203,7 @@ int amdgpu_benchmark(struct amdgpu_device *adev, int test_number)
 		amdgpu_benchmark_move(adev, 1024*1024, AMDGPU_GEM_DOMAIN_VRAM,
 				      AMDGPU_GEM_DOMAIN_VRAM);
 		if (r)
-			return r;
+			goto done;
 		break;
 	case 3:
 		dev_info(adev->dev, "benchmark test: %d\n", test_number);
@@ -212,7 +213,7 @@ int amdgpu_benchmark(struct amdgpu_device *adev, int test_number)
 						  AMDGPU_GEM_DOMAIN_GTT,
 						  AMDGPU_GEM_DOMAIN_VRAM);
 			if (r)
-				return r;
+				goto done;
 		}
 		break;
 	case 4:
@@ -223,7 +224,7 @@ int amdgpu_benchmark(struct amdgpu_device *adev, int test_number)
 						  AMDGPU_GEM_DOMAIN_VRAM,
 						  AMDGPU_GEM_DOMAIN_GTT);
 			if (r)
-				return r;
+				goto done;
 		}
 		break;
 	case 5:
@@ -234,7 +235,7 @@ int amdgpu_benchmark(struct amdgpu_device *adev, int test_number)
 						  AMDGPU_GEM_DOMAIN_VRAM,
 						  AMDGPU_GEM_DOMAIN_VRAM);
 			if (r)
-				return r;
+				goto done;
 		}
 		break;
 	case 6:
@@ -245,7 +246,7 @@ int amdgpu_benchmark(struct amdgpu_device *adev, int test_number)
 						  AMDGPU_GEM_DOMAIN_GTT,
 						  AMDGPU_GEM_DOMAIN_VRAM);
 			if (r)
-				return r;
+				goto done;
 		}
 		break;
 	case 7:
@@ -256,7 +257,7 @@ int amdgpu_benchmark(struct amdgpu_device *adev, int test_number)
 						  AMDGPU_GEM_DOMAIN_VRAM,
 						  AMDGPU_GEM_DOMAIN_GTT);
 			if (r)
-				return r;
+				goto done;
 		}
 		break;
 	case 8:
@@ -267,7 +268,7 @@ int amdgpu_benchmark(struct amdgpu_device *adev, int test_number)
 					      AMDGPU_GEM_DOMAIN_VRAM,
 					      AMDGPU_GEM_DOMAIN_VRAM);
 			if (r)
-				return r;
+				goto done;
 		}
 		break;
 
@@ -276,5 +277,9 @@ int amdgpu_benchmark(struct amdgpu_device *adev, int test_number)
 		r = -EINVAL;
 		break;
 	}
+
+done:
+	mutex_unlock(&adev->benchmark_mutex);
+
 	return r;
 }
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 31834d2d4d55..63b4876e13c1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -3550,6 +3550,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 	mutex_init(&adev->psp.mutex);
 	mutex_init(&adev->notifier_lock);
 	mutex_init(&adev->pm.stable_pstate_ctx_lock);
+	mutex_init(&adev->benchmark_mutex);
 
 	amdgpu_device_init_apu_flags(adev);
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 5/7] drm/amdgpu: expose benchmarks via debugfs
  2022-02-18 22:25 [PATCH 1/7] drm/amdgpu/benchmark: use dev_info rather than DRM macros for logging Alex Deucher
                   ` (2 preceding siblings ...)
  2022-02-18 22:26 ` [PATCH 4/7] drm/amdgpu: add a benchmark mutex Alex Deucher
@ 2022-02-18 22:26 ` Alex Deucher
  2022-02-18 22:26 ` [PATCH 6/7] drm/amdgpu: drop benchmark module parameter Alex Deucher
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Alex Deucher @ 2022-02-18 22:26 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alex Deucher

They provide a nice smoke test of transfer performance
using SDMA.  Allow the user to run these at runtime
rather than only at init time.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 23 +++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
index db8a8710333e..c7190d02897e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
@@ -1362,6 +1362,25 @@ static int amdgpu_debugfs_evict_gtt(void *data, u64 *val)
 	return 0;
 }
 
+static int amdgpu_debugfs_benchmark(void *data, u64 val)
+{
+	struct amdgpu_device *adev = (struct amdgpu_device *)data;
+	struct drm_device *dev = adev_to_drm(adev);
+	int r;
+
+	r = pm_runtime_get_sync(dev->dev);
+	if (r < 0) {
+		pm_runtime_put_autosuspend(dev->dev);
+		return r;
+	}
+
+	r = amdgpu_benchmark(adev, val);
+
+	pm_runtime_mark_last_busy(dev->dev);
+	pm_runtime_put_autosuspend(dev->dev);
+
+	return r;
+}
 
 static int amdgpu_debugfs_vm_info_show(struct seq_file *m, void *unused)
 {
@@ -1398,6 +1417,8 @@ DEFINE_DEBUGFS_ATTRIBUTE(amdgpu_evict_vram_fops, amdgpu_debugfs_evict_vram,
 			 NULL, "%lld\n");
 DEFINE_DEBUGFS_ATTRIBUTE(amdgpu_evict_gtt_fops, amdgpu_debugfs_evict_gtt,
 			 NULL, "%lld\n");
+DEFINE_DEBUGFS_ATTRIBUTE(amdgpu_benchmark_fops, NULL, amdgpu_debugfs_benchmark,
+			 "%lld\n");
 
 static void amdgpu_ib_preempt_fences_swap(struct amdgpu_ring *ring,
 					  struct dma_fence **fences)
@@ -1683,6 +1704,8 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)
 			    &amdgpu_debugfs_test_ib_fops);
 	debugfs_create_file("amdgpu_vm_info", 0444, root, adev,
 			    &amdgpu_debugfs_vm_info_fops);
+	debugfs_create_file("amdgpu_benchmark", 0222, root, adev,
+			    &amdgpu_benchmark_fops);
 
 	adev->debugfs_vbios_blob.data = adev->bios;
 	adev->debugfs_vbios_blob.size = adev->bios_size;
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 6/7] drm/amdgpu: drop benchmark module parameter
  2022-02-18 22:25 [PATCH 1/7] drm/amdgpu/benchmark: use dev_info rather than DRM macros for logging Alex Deucher
                   ` (3 preceding siblings ...)
  2022-02-18 22:26 ` [PATCH 5/7] drm/amdgpu: expose benchmarks via debugfs Alex Deucher
@ 2022-02-18 22:26 ` Alex Deucher
  2022-02-18 22:26 ` [PATCH 7/7] drm/amdgpu: drop testing " Alex Deucher
  2022-02-21 10:59 ` [PATCH 1/7] drm/amdgpu/benchmark: use dev_info rather than DRM macros for logging Christian König
  6 siblings, 0 replies; 12+ messages in thread
From: Alex Deucher @ 2022-02-18 22:26 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alex Deucher

Now that we expose the benchmarks via debugfs, there is no
longer a need for the module parameter.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        | 1 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 ------
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    | 8 --------
 3 files changed, 15 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index c736c30e0a0a..d6cf2e343a43 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -155,7 +155,6 @@ extern int amdgpu_vis_vram_limit;
 extern int amdgpu_gart_size;
 extern int amdgpu_gtt_size;
 extern int amdgpu_moverate;
-extern int amdgpu_benchmarking;
 extern int amdgpu_testing;
 extern int amdgpu_audio;
 extern int amdgpu_disp_priority;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 63b4876e13c1..02863e2ea3c4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -3811,12 +3811,6 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 		else
 			DRM_INFO("amdgpu: acceleration disabled, skipping move tests\n");
 	}
-	if (amdgpu_benchmarking) {
-		if (adev->accel_working)
-			amdgpu_benchmark(adev, amdgpu_benchmarking);
-		else
-			DRM_INFO("amdgpu: acceleration disabled, skipping benchmarks\n");
-	}
 
 	/*
 	 * Register gpu instance before amdgpu_device_enable_mgpu_fan_boost.
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index a0b5cf9a41cc..a76d78a6dc54 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -110,7 +110,6 @@ int amdgpu_vis_vram_limit;
 int amdgpu_gart_size = -1; /* auto */
 int amdgpu_gtt_size = -1; /* auto */
 int amdgpu_moverate = -1; /* auto */
-int amdgpu_benchmarking;
 int amdgpu_testing;
 int amdgpu_audio = -1;
 int amdgpu_disp_priority;
@@ -231,13 +230,6 @@ module_param_named(gttsize, amdgpu_gtt_size, int, 0600);
 MODULE_PARM_DESC(moverate, "Maximum buffer migration rate in MB/s. (32, 64, etc., -1=auto, 0=1=disabled)");
 module_param_named(moverate, amdgpu_moverate, int, 0600);
 
-/**
- * DOC: benchmark (int)
- * Run benchmarks. The default is 0 (Skip benchmarks).
- */
-MODULE_PARM_DESC(benchmark, "Run benchmark");
-module_param_named(benchmark, amdgpu_benchmarking, int, 0444);
-
 /**
  * DOC: test (int)
  * Test BO GTT->VRAM and VRAM->GTT GPU copies. The default is 0 (Skip test, only set 1 to run test).
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 7/7] drm/amdgpu: drop testing module parameter
  2022-02-18 22:25 [PATCH 1/7] drm/amdgpu/benchmark: use dev_info rather than DRM macros for logging Alex Deucher
                   ` (4 preceding siblings ...)
  2022-02-18 22:26 ` [PATCH 6/7] drm/amdgpu: drop benchmark module parameter Alex Deucher
@ 2022-02-18 22:26 ` Alex Deucher
  2022-02-21 17:44   ` Michel Dänzer
  2022-02-21 10:59 ` [PATCH 1/7] drm/amdgpu/benchmark: use dev_info rather than DRM macros for logging Christian König
  6 siblings, 1 reply; 12+ messages in thread
From: Alex Deucher @ 2022-02-18 22:26 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alex Deucher

This was always duplicate functionality with the benchmark tests.
Drop it.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/Makefile        |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        |   7 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |   7 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |   8 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_test.c   | 250 ---------------------
 5 files changed, 1 insertion(+), 273 deletions(-)
 delete mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_test.c

diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile b/drivers/gpu/drm/amd/amdgpu/Makefile
index 7fedbb725e17..5dfe08cb045e 100644
--- a/drivers/gpu/drm/amd/amdgpu/Makefile
+++ b/drivers/gpu/drm/amd/amdgpu/Makefile
@@ -46,7 +46,7 @@ amdgpu-y += amdgpu_device.o amdgpu_kms.o \
 	atom.o amdgpu_fence.o amdgpu_ttm.o amdgpu_object.o amdgpu_gart.o \
 	amdgpu_encoders.o amdgpu_display.o amdgpu_i2c.o \
 	amdgpu_gem.o amdgpu_ring.o \
-	amdgpu_cs.o amdgpu_bios.o amdgpu_benchmark.o amdgpu_test.o \
+	amdgpu_cs.o amdgpu_bios.o amdgpu_benchmark.o \
 	atombios_dp.o amdgpu_afmt.o amdgpu_trace_points.o \
 	atombios_encoders.o amdgpu_sa.o atombios_i2c.o \
 	amdgpu_dma_buf.o amdgpu_vm.o amdgpu_ib.o amdgpu_pll.o \
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index d6cf2e343a43..a117b40f03a0 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -155,7 +155,6 @@ extern int amdgpu_vis_vram_limit;
 extern int amdgpu_gart_size;
 extern int amdgpu_gtt_size;
 extern int amdgpu_moverate;
-extern int amdgpu_testing;
 extern int amdgpu_audio;
 extern int amdgpu_disp_priority;
 extern int amdgpu_hw_i2c;
@@ -587,12 +586,6 @@ void amdgpu_device_wb_free(struct amdgpu_device *adev, u32 wb);
  */
 int amdgpu_benchmark(struct amdgpu_device *adev, int test_number);
 
-
-/*
- * Testing
- */
-void amdgpu_test_moves(struct amdgpu_device *adev);
-
 /*
  * ASIC specific register table accessible by UMD
  */
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 02863e2ea3c4..ae420a5c6407 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -3805,13 +3805,6 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 	} else
 		adev->ucode_sysfs_en = true;
 
-	if ((amdgpu_testing & 1)) {
-		if (adev->accel_working)
-			amdgpu_test_moves(adev);
-		else
-			DRM_INFO("amdgpu: acceleration disabled, skipping move tests\n");
-	}
-
 	/*
 	 * Register gpu instance before amdgpu_device_enable_mgpu_fan_boost.
 	 * Otherwise the mgpu fan boost feature will be skipped due to the
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index a76d78a6dc54..a0990f2e5562 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -110,7 +110,6 @@ int amdgpu_vis_vram_limit;
 int amdgpu_gart_size = -1; /* auto */
 int amdgpu_gtt_size = -1; /* auto */
 int amdgpu_moverate = -1; /* auto */
-int amdgpu_testing;
 int amdgpu_audio = -1;
 int amdgpu_disp_priority;
 int amdgpu_hw_i2c;
@@ -230,13 +229,6 @@ module_param_named(gttsize, amdgpu_gtt_size, int, 0600);
 MODULE_PARM_DESC(moverate, "Maximum buffer migration rate in MB/s. (32, 64, etc., -1=auto, 0=1=disabled)");
 module_param_named(moverate, amdgpu_moverate, int, 0600);
 
-/**
- * DOC: test (int)
- * Test BO GTT->VRAM and VRAM->GTT GPU copies. The default is 0 (Skip test, only set 1 to run test).
- */
-MODULE_PARM_DESC(test, "Run tests");
-module_param_named(test, amdgpu_testing, int, 0444);
-
 /**
  * DOC: audio (int)
  * Set HDMI/DPAudio. Only affects non-DC display handling. The default is -1 (Enabled), set 0 to disabled it.
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c
deleted file mode 100644
index 909d830b513e..000000000000
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c
+++ /dev/null
@@ -1,250 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0 OR MIT
-/*
- * Copyright 2009 VMware, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: Michel Dänzer
- */
-
-#include <drm/amdgpu_drm.h>
-#include "amdgpu.h"
-#include "amdgpu_uvd.h"
-#include "amdgpu_vce.h"
-
-/* Test BO GTT->VRAM and VRAM->GTT GPU copies across the whole GTT aperture */
-static void amdgpu_do_test_moves(struct amdgpu_device *adev)
-{
-	struct amdgpu_ring *ring = adev->mman.buffer_funcs_ring;
-	struct amdgpu_bo *vram_obj = NULL;
-	struct amdgpu_bo **gtt_obj = NULL;
-	struct amdgpu_bo_param bp;
-	uint64_t gart_addr, vram_addr;
-	unsigned n, size;
-	int i, r;
-
-	size = 1024 * 1024;
-
-	/* Number of tests =
-	 * (Total GTT - gart_pin_size - (2 transfer windows for buffer moves)) / test size
-	 */
-	n = adev->gmc.gart_size - atomic64_read(&adev->gart_pin_size);
-	n -= AMDGPU_GTT_MAX_TRANSFER_SIZE * AMDGPU_GTT_NUM_TRANSFER_WINDOWS *
-		AMDGPU_GPU_PAGE_SIZE;
-	n /= size;
-
-	gtt_obj = kcalloc(n, sizeof(*gtt_obj), GFP_KERNEL);
-	if (!gtt_obj) {
-		DRM_ERROR("Failed to allocate %d pointers\n", n);
-		r = 1;
-		goto out_cleanup;
-	}
-	memset(&bp, 0, sizeof(bp));
-	bp.size = size;
-	bp.byte_align = PAGE_SIZE;
-	bp.domain = AMDGPU_GEM_DOMAIN_VRAM;
-	bp.flags = 0;
-	bp.type = ttm_bo_type_kernel;
-	bp.resv = NULL;
-	bp.bo_ptr_size = sizeof(struct amdgpu_bo);
-
-	r = amdgpu_bo_create(adev, &bp, &vram_obj);
-	if (r) {
-		DRM_ERROR("Failed to create VRAM object\n");
-		goto out_cleanup;
-	}
-	r = amdgpu_bo_reserve(vram_obj, false);
-	if (unlikely(r != 0))
-		goto out_unref;
-	r = amdgpu_bo_pin(vram_obj, AMDGPU_GEM_DOMAIN_VRAM);
-	if (r) {
-		DRM_ERROR("Failed to pin VRAM object\n");
-		goto out_unres;
-	}
-	vram_addr = amdgpu_bo_gpu_offset(vram_obj);
-	for (i = 0; i < n; i++) {
-		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);
-		if (r) {
-			DRM_ERROR("Failed to create GTT object %d\n", i);
-			goto out_lclean;
-		}
-
-		r = amdgpu_bo_reserve(gtt_obj[i], false);
-		if (unlikely(r != 0))
-			goto out_lclean_unref;
-		r = amdgpu_bo_pin(gtt_obj[i], AMDGPU_GEM_DOMAIN_GTT);
-		if (r) {
-			DRM_ERROR("Failed to pin GTT object %d\n", i);
-			goto out_lclean_unres;
-		}
-		r = amdgpu_ttm_alloc_gart(&gtt_obj[i]->tbo);
-		if (r) {
-			DRM_ERROR("%p bind failed\n", gtt_obj[i]);
-			goto out_lclean_unpin;
-		}
-		gart_addr = amdgpu_bo_gpu_offset(gtt_obj[i]);
-
-		r = amdgpu_bo_kmap(gtt_obj[i], &gtt_map);
-		if (r) {
-			DRM_ERROR("Failed to map GTT object %d\n", i);
-			goto out_lclean_unpin;
-		}
-
-		for (gart_start = gtt_map, gart_end = gtt_map + size;
-		     gart_start < gart_end;
-		     gart_start++)
-			*gart_start = gart_start;
-
-		amdgpu_bo_kunmap(gtt_obj[i]);
-
-		r = amdgpu_copy_buffer(ring, gart_addr, vram_addr,
-				       size, NULL, &fence, false, false, false);
-
-		if (r) {
-			DRM_ERROR("Failed GTT->VRAM copy %d\n", i);
-			goto out_lclean_unpin;
-		}
-
-		r = dma_fence_wait(fence, false);
-		if (r) {
-			DRM_ERROR("Failed to wait for GTT->VRAM fence %d\n", i);
-			goto out_lclean_unpin;
-		}
-
-		dma_fence_put(fence);
-		fence = NULL;
-
-		r = amdgpu_bo_kmap(vram_obj, &vram_map);
-		if (r) {
-			DRM_ERROR("Failed to map VRAM object after copy %d\n", i);
-			goto out_lclean_unpin;
-		}
-
-		for (gart_start = gtt_map, gart_end = gtt_map + size,
-		     vram_start = vram_map, vram_end = vram_map + size;
-		     vram_start < vram_end;
-		     gart_start++, vram_start++) {
-			if (*vram_start != gart_start) {
-				DRM_ERROR("Incorrect GTT->VRAM copy %d: Got 0x%p, "
-					  "expected 0x%p (GTT/VRAM offset "
-					  "0x%16llx/0x%16llx)\n",
-					  i, *vram_start, gart_start,
-					  (unsigned long long)
-					  (gart_addr - adev->gmc.gart_start +
-					   (void *)gart_start - gtt_map),
-					  (unsigned long long)
-					  (vram_addr - adev->gmc.vram_start +
-					   (void *)gart_start - gtt_map));
-				amdgpu_bo_kunmap(vram_obj);
-				goto out_lclean_unpin;
-			}
-			*vram_start = vram_start;
-		}
-
-		amdgpu_bo_kunmap(vram_obj);
-
-		r = amdgpu_copy_buffer(ring, vram_addr, gart_addr,
-				       size, NULL, &fence, false, false, false);
-
-		if (r) {
-			DRM_ERROR("Failed VRAM->GTT copy %d\n", i);
-			goto out_lclean_unpin;
-		}
-
-		r = dma_fence_wait(fence, false);
-		if (r) {
-			DRM_ERROR("Failed to wait for VRAM->GTT fence %d\n", i);
-			goto out_lclean_unpin;
-		}
-
-		dma_fence_put(fence);
-		fence = NULL;
-
-		r = amdgpu_bo_kmap(gtt_obj[i], &gtt_map);
-		if (r) {
-			DRM_ERROR("Failed to map GTT object after copy %d\n", i);
-			goto out_lclean_unpin;
-		}
-
-		for (gart_start = gtt_map, gart_end = gtt_map + size,
-		     vram_start = vram_map, vram_end = vram_map + size;
-		     gart_start < gart_end;
-		     gart_start++, vram_start++) {
-			if (*gart_start != vram_start) {
-				DRM_ERROR("Incorrect VRAM->GTT copy %d: Got 0x%p, "
-					  "expected 0x%p (VRAM/GTT offset "
-					  "0x%16llx/0x%16llx)\n",
-					  i, *gart_start, vram_start,
-					  (unsigned long long)
-					  (vram_addr - adev->gmc.vram_start +
-					   (void *)vram_start - vram_map),
-					  (unsigned long long)
-					  (gart_addr - adev->gmc.gart_start +
-					   (void *)vram_start - vram_map));
-				amdgpu_bo_kunmap(gtt_obj[i]);
-				goto out_lclean_unpin;
-			}
-		}
-
-		amdgpu_bo_kunmap(gtt_obj[i]);
-
-		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]);
-out_lclean_unres:
-		amdgpu_bo_unreserve(gtt_obj[i]);
-out_lclean_unref:
-		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;
-	}
-
-	amdgpu_bo_unpin(vram_obj);
-out_unres:
-	amdgpu_bo_unreserve(vram_obj);
-out_unref:
-	amdgpu_bo_unref(&vram_obj);
-out_cleanup:
-	kfree(gtt_obj);
-	if (r) {
-		pr_warn("Error while testing BO move\n");
-	}
-}
-
-void amdgpu_test_moves(struct amdgpu_device *adev)
-{
-	if (adev->mman.buffer_funcs)
-		amdgpu_do_test_moves(adev);
-}
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/7] drm/amdgpu/benchmark: use dev_info rather than DRM macros for logging
  2022-02-18 22:25 [PATCH 1/7] drm/amdgpu/benchmark: use dev_info rather than DRM macros for logging Alex Deucher
                   ` (5 preceding siblings ...)
  2022-02-18 22:26 ` [PATCH 7/7] drm/amdgpu: drop testing " Alex Deucher
@ 2022-02-21 10:59 ` Christian König
  6 siblings, 0 replies; 12+ messages in thread
From: Christian König @ 2022-02-21 10:59 UTC (permalink / raw)
  To: Alex Deucher, amd-gfx

Am 18.02.22 um 23:25 schrieb Alex Deucher:
> So we can tell which output goes to which device when multiple GPUs
> are present.  Also while we are here, convert DRM_ERROR to dev_info.
> The error cases are not critical.
>
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

Reviewed-by: Christian König <christian.koenig@amd.com> for the entire 
series.

As a follow up we should probably replace the create, reserve, pin, 
alloc_gart dance in amdgpu_benchmark_move() with a call to 
amdgpu_bo_create_kernel() and amdgpu_bo_free_kernel().

And using ktime() instead of jiffies would protect us against wrap 
arounds in amdgpu_benchmark_do_move().

Regards,
Christian.

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c | 12 +++++++-----
>   1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
> index 313517f7cf10..b38783278a99 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
> @@ -56,13 +56,15 @@ static int amdgpu_benchmark_do_move(struct amdgpu_device *adev, unsigned size,
>   }
>   
>   
> -static void amdgpu_benchmark_log_results(int n, unsigned size,
> +static void amdgpu_benchmark_log_results(struct amdgpu_device *adev,
> +					 int n, unsigned size,
>   					 unsigned int time,
>   					 unsigned sdomain, unsigned ddomain,
>   					 char *kind)
>   {
>   	unsigned int throughput = (n * (size >> 10)) / time;
> -	DRM_INFO("amdgpu: %s %u bo moves of %u kB from"
> +
> +	dev_info(adev->dev, "amdgpu: %s %u bo moves of %u kB from"
>   		 " %d to %d in %u ms, throughput: %u Mb/s or %u MB/s\n",
>   		 kind, n, size >> 10, sdomain, ddomain, time,
>   		 throughput * 8, throughput);
> @@ -131,14 +133,14 @@ static void amdgpu_benchmark_move(struct amdgpu_device *adev, unsigned size,
>   		if (time < 0)
>   			goto out_cleanup;
>   		if (time > 0)
> -			amdgpu_benchmark_log_results(n, size, time,
> +			amdgpu_benchmark_log_results(adev, n, size, time,
>   						     sdomain, ddomain, "dma");
>   	}
>   
>   out_cleanup:
>   	/* Check error value now. The value can be overwritten when clean up.*/
>   	if (r) {
> -		DRM_ERROR("Error while benchmarking BO move.\n");
> +		dev_info(adev->dev, "Error while benchmarking BO move.\n");
>   	}
>   
>   	if (sobj) {
> @@ -239,6 +241,6 @@ void amdgpu_benchmark(struct amdgpu_device *adev, int test_number)
>   		break;
>   
>   	default:
> -		DRM_ERROR("Unknown benchmark\n");
> +		dev_info(adev->dev, "Unknown benchmark\n");
>   	}
>   }


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 7/7] drm/amdgpu: drop testing module parameter
  2022-02-18 22:26 ` [PATCH 7/7] drm/amdgpu: drop testing " Alex Deucher
@ 2022-02-21 17:44   ` Michel Dänzer
  2022-02-21 21:35     ` Alex Deucher
  0 siblings, 1 reply; 12+ messages in thread
From: Michel Dänzer @ 2022-02-21 17:44 UTC (permalink / raw)
  To: Alex Deucher; +Cc: amd-gfx

On 2022-02-18 23:26, Alex Deucher wrote:
> This was always duplicate functionality with the benchmark tests.

Not really. The purpose of amdgpu_do_test_moves is testing that copies between GTT & VRAM work across the whole GTT aperture (when I originally wrote radeon_do_test_moves, they didn't on the PowerBook I was using at the time).


-- 
Earthling Michel Dänzer            |                  https://redhat.com
Libre software enthusiast          |         Mesa and Xwayland developer

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 7/7] drm/amdgpu: drop testing module parameter
  2022-02-21 17:44   ` Michel Dänzer
@ 2022-02-21 21:35     ` Alex Deucher
  2022-02-22  9:07       ` Michel Dänzer
  0 siblings, 1 reply; 12+ messages in thread
From: Alex Deucher @ 2022-02-21 21:35 UTC (permalink / raw)
  To: Michel Dänzer; +Cc: Alex Deucher, amd-gfx list

On Mon, Feb 21, 2022 at 12:44 PM Michel Dänzer
<michel.daenzer@mailbox.org> wrote:
>
> On 2022-02-18 23:26, Alex Deucher wrote:
> > This was always duplicate functionality with the benchmark tests.
>
> Not really. The purpose of amdgpu_do_test_moves is testing that copies between GTT & VRAM work across the whole GTT aperture (when I originally wrote radeon_do_test_moves, they didn't on the PowerBook I was using at the time).
>

Fair enough.  I'll drop it for now.  Might be useful to convert to
debugfs at some point as well.

Alex

>
> --
> Earthling Michel Dänzer            |                  https://redhat.com
> Libre software enthusiast          |         Mesa and Xwayland developer

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 7/7] drm/amdgpu: drop testing module parameter
  2022-02-21 21:35     ` Alex Deucher
@ 2022-02-22  9:07       ` Michel Dänzer
  2022-02-22 11:39         ` Christian König
  0 siblings, 1 reply; 12+ messages in thread
From: Michel Dänzer @ 2022-02-22  9:07 UTC (permalink / raw)
  To: Alex Deucher; +Cc: Alex Deucher, amd-gfx list

On 2022-02-21 22:35, Alex Deucher wrote:
> On Mon, Feb 21, 2022 at 12:44 PM Michel Dänzer
> <michel.daenzer@mailbox.org> wrote:
>>
>> On 2022-02-18 23:26, Alex Deucher wrote:
>>> This was always duplicate functionality with the benchmark tests.
>>
>> Not really. The purpose of amdgpu_do_test_moves is testing that copies between GTT & VRAM work across the whole GTT aperture (when I originally wrote radeon_do_test_moves, they didn't on the PowerBook I was using at the time).
>>
> 
> Fair enough.  I'll drop it for now.  Might be useful to convert to
> debugfs at some point as well.

To be clear, I'm not saying this needs to stay — maybe it's not useful anymore. I'm just pointing out that it's not redundant with the benchmarks.


-- 
Earthling Michel Dänzer            |                  https://redhat.com
Libre software enthusiast          |         Mesa and Xwayland developer

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 7/7] drm/amdgpu: drop testing module parameter
  2022-02-22  9:07       ` Michel Dänzer
@ 2022-02-22 11:39         ` Christian König
  0 siblings, 0 replies; 12+ messages in thread
From: Christian König @ 2022-02-22 11:39 UTC (permalink / raw)
  To: Michel Dänzer, Alex Deucher; +Cc: Alex Deucher, amd-gfx list



Am 22.02.22 um 10:07 schrieb Michel Dänzer:
> On 2022-02-21 22:35, Alex Deucher wrote:
>> On Mon, Feb 21, 2022 at 12:44 PM Michel Dänzer
>> <michel.daenzer@mailbox.org> wrote:
>>> On 2022-02-18 23:26, Alex Deucher wrote:
>>>> This was always duplicate functionality with the benchmark tests.
>>> Not really. The purpose of amdgpu_do_test_moves is testing that copies between GTT & VRAM work across the whole GTT aperture (when I originally wrote radeon_do_test_moves, they didn't on the PowerBook I was using at the time).
>>>
>> Fair enough.  I'll drop it for now.  Might be useful to convert to
>> debugfs at some point as well.
> To be clear, I'm not saying this needs to stay — maybe it's not useful anymore. I'm just pointing out that it's not redundant with the benchmarks.

Yeah, the test doesn't necessary work that well any more since we now 
have the GART table much smaller than the GTT size.

I think it's still the best to just remove that.

Regards,
Christian.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-02-22 11:39 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-18 22:25 [PATCH 1/7] drm/amdgpu/benchmark: use dev_info rather than DRM macros for logging Alex Deucher
2022-02-18 22:25 ` [PATCH 2/7] drm/amdgpu: plumb error handling though amdgpu_benchmark() Alex Deucher
2022-02-18 22:25 ` [PATCH 3/7] drm/amdgpu: print the selected benchmark test in the log Alex Deucher
2022-02-18 22:26 ` [PATCH 4/7] drm/amdgpu: add a benchmark mutex Alex Deucher
2022-02-18 22:26 ` [PATCH 5/7] drm/amdgpu: expose benchmarks via debugfs Alex Deucher
2022-02-18 22:26 ` [PATCH 6/7] drm/amdgpu: drop benchmark module parameter Alex Deucher
2022-02-18 22:26 ` [PATCH 7/7] drm/amdgpu: drop testing " Alex Deucher
2022-02-21 17:44   ` Michel Dänzer
2022-02-21 21:35     ` Alex Deucher
2022-02-22  9:07       ` Michel Dänzer
2022-02-22 11:39         ` Christian König
2022-02-21 10:59 ` [PATCH 1/7] drm/amdgpu/benchmark: use dev_info rather than DRM macros for logging Christian König

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.