Skip to contentSkip to conversation

tests/amdgpu: add stable pstate test

PATCH In review Jesse Zhang 3 participants 3 messages Sep 25, 2023 – Sep 26, 2023 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/amdgpu: add stable pstate test

In order to verify gfx power and clock, add pstate test.

v2:
- restricted build for pstate tests due to build failure

       for drmlib <= 2.4.109 (Vitaly)

- Optimize some code (Luben)

---
 include/drm-uapi/amdgpu_drm.h |  9 +++++
 tests/amdgpu/amd_pstate.c     | 69 +++++++++++++++++++++++++++++++++++
 tests/amdgpu/meson.build      |  6 +++
 3 files changed, 84 insertions(+)
 create mode 100644 tests/amdgpu/amd_pstate.c
include/drm-uapi/amdgpu_drm.h +9 -0
index 0cbd1540a..6240ae5ea 100644
@@ -206,6 +206,8 @@ union drm_amdgpu_bo_list {
 #define AMDGPU_CTX_OP_FREE_CTX	2
 #define AMDGPU_CTX_OP_QUERY_STATE	3
 #define AMDGPU_CTX_OP_QUERY_STATE2	4
+#define AMDGPU_CTX_OP_GET_STABLE_PSTATE	5
+#define AMDGPU_CTX_OP_SET_STABLE_PSTATE	6
 
 /* GPU reset status */
 #define AMDGPU_CTX_NO_RESET		0
@@ -237,6 +239,13 @@ union drm_amdgpu_bo_list {
 */
 #define AMDGPU_CTX_PRIORITY_HIGH        512
 #define AMDGPU_CTX_PRIORITY_VERY_HIGH   1023
+/* select a stable profiling pstate for perfmon tools */
+#define AMDGPU_CTX_STABLE_PSTATE_FLAGS_MASK  0xf
+#define AMDGPU_CTX_STABLE_PSTATE_NONE  0
+#define AMDGPU_CTX_STABLE_PSTATE_STANDARD  1
+#define AMDGPU_CTX_STABLE_PSTATE_MIN_SCLK  2
+#define AMDGPU_CTX_STABLE_PSTATE_MIN_MCLK  3
+#define AMDGPU_CTX_STABLE_PSTATE_PEAK  4
 
 struct drm_amdgpu_ctx_in {
 	/** AMDGPU_CTX_OP_* */
tests/amdgpu/amd_pstate.c new file +59 -0

59 lines not on this page · raw message

+ igt_subtest("amdgpu_pstate")
+ amdgpu_stable_pstate_test(device);
+
+ igt_fixture {
+ amdgpu_device_deinitialize(device);
+ drm_close_driver(fd);
+ }
+}
+

tests/amdgpu/meson.build +6 -0
index ebf52bf38..4a522386d 100644
@@ -42,6 +42,12 @@ if libdrm_amdgpu.found()
 	else
 		warning('libdrm <= 2.4.97 found, amd_syncobj test not applicable')
 	endif
+
+	if libdrm_amdgpu.version().version_compare('> 2.4.109')
+		amdgpu_progs +=[ 'amd_pstate', ]
+	else
+		warning('libdrm <= 2.4.109 found, amd_pstate test not applicable')
+	endif
 	amdgpu_deps += libdrm_amdgpu
 endif
 
Signature · 1 line
2.25.1
#1 lore raw

[igt-dev] ✗ Fi.CI.BUILD: failure for tests/amdgpu: add stable pstate test (rev2)

== Series Details ==

== Series Details ==

Series: tests/amdgpu: add stable pstate test (rev2)
URL : https://patchwork.freedesktop.org/series/124092/
State : failure

== Summary ==

Applying: tests/amdgpu: add stable pstate test
Patch failed at 0001 tests/amdgpu: add stable pstate test When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".

Reviewed-by on v1 1/1
#2 lore raw
In reply to Jesse Zhang

The patch looks good to me.

However there is kind of issue there:

https://patchwork.freedesktop.org/series/124092/

I am not sure , did you use 'git fetch' and then 'git pull --rebase' just before  the patch was locally created and then sent to igt-dev?

After the fix , please, use:

Thanks, Vitaly

Quoted 135 lines · Jesse Zhang

In order to verify gfx power and clock, add pstate test.

v2:
- restricted build for pstate tests due to build failure

       for drmlib <= 2.4.109 (Vitaly)

- Optimize some code (Luben)

---
 include/drm-uapi/amdgpu_drm.h |  9 +++++
 tests/amdgpu/amd_pstate.c     | 69 +++++++++++++++++++++++++++++++++++
 tests/amdgpu/meson.build      |  6 +++
 3 files changed, 84 insertions(+)
 create mode 100644 tests/amdgpu/amd_pstate.c
include/drm-uapi/amdgpu_drm.h +9 -0
index 0cbd1540a..6240ae5ea 100644
@@ -206,6 +206,8 @@ union drm_amdgpu_bo_list {
 #define AMDGPU_CTX_OP_FREE_CTX	2
 #define AMDGPU_CTX_OP_QUERY_STATE	3
 #define AMDGPU_CTX_OP_QUERY_STATE2	4
+#define AMDGPU_CTX_OP_GET_STABLE_PSTATE	5
+#define AMDGPU_CTX_OP_SET_STABLE_PSTATE	6
 
 /* GPU reset status */
 #define AMDGPU_CTX_NO_RESET		0
@@ -237,6 +239,13 @@ union drm_amdgpu_bo_list {
 */
 #define AMDGPU_CTX_PRIORITY_HIGH        512
 #define AMDGPU_CTX_PRIORITY_VERY_HIGH   1023
+/* select a stable profiling pstate for perfmon tools */
+#define AMDGPU_CTX_STABLE_PSTATE_FLAGS_MASK  0xf
+#define AMDGPU_CTX_STABLE_PSTATE_NONE  0
+#define AMDGPU_CTX_STABLE_PSTATE_STANDARD  1
+#define AMDGPU_CTX_STABLE_PSTATE_MIN_SCLK  2
+#define AMDGPU_CTX_STABLE_PSTATE_MIN_MCLK  3
+#define AMDGPU_CTX_STABLE_PSTATE_PEAK  4
 
 struct drm_amdgpu_ctx_in {
 	/** AMDGPU_CTX_OP_* */
tests/amdgpu/amd_pstate.c new file +68 -0
new file mode 100644
index 000000000..40fdc32cc
@@ -0,0 +1,69 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright 2014 Advanced Micro Devices, Inc.
+ * Copyright 2022 Advanced Micro Devices, Inc.
+ * Copyright 2023 Advanced Micro Devices, Inc.
+ */
+#include <amdgpu.h>
+#include <amdgpu_drm.h>
+#include "drmtest.h"
+#include "igt.h"
+
+static void
+amdgpu_stable_pstate_test(amdgpu_device_handle device_handle)
+{
+	int r;
+	amdgpu_context_handle context_handle;
+	uint32_t current_pstate, new_pstate;
+
+	r = amdgpu_cs_ctx_create(device_handle, &context_handle);
+	igt_assert_eq(r, 0);
+
+	r = amdgpu_cs_ctx_stable_pstate(context_handle,
+					AMDGPU_CTX_OP_GET_STABLE_PSTATE,
+					0, &current_pstate);
+	igt_assert_eq(r, 0);
+	igt_assert_eq(new_pstate, AMDGPU_CTX_STABLE_PSTATE_NONE);
+	r = amdgpu_cs_ctx_stable_pstate(context_handle,
+					AMDGPU_CTX_OP_SET_STABLE_PSTATE,
+					AMDGPU_CTX_STABLE_PSTATE_PEAK, NULL);
+	igt_assert_eq(r, 0);
+
+	r = amdgpu_cs_ctx_stable_pstate(context_handle,
+					AMDGPU_CTX_OP_GET_STABLE_PSTATE,
+					0, &new_pstate);
+	igt_assert_eq(r, 0);
+	igt_assert_eq(new_pstate, AMDGPU_CTX_STABLE_PSTATE_PEAK);
+
+	r = amdgpu_cs_ctx_free(context_handle);
+	igt_assert_eq(r, 0);
+
+}
+
+igt_main
+{
+	amdgpu_device_handle device;
+	int fd = -1;
+
+	igt_fixture {
+		uint32_t major, minor;
+		int err;
+
+		fd = drm_open_driver(DRIVER_AMDGPU);
+
+		err = amdgpu_device_initialize(fd, &major, &minor, &device);
+		igt_require(err == 0);
+
+		igt_info("Initialized amdgpu, driver version %d.%d\n",
+			 major, minor);
+	}
 
+	igt_subtest("amdgpu_pstate")
+	amdgpu_stable_pstate_test(device);
+
+	igt_fixture {
+		amdgpu_device_deinitialize(device);
+		drm_close_driver(fd);
+	}
+}
+
tests/amdgpu/meson.build +6 -0
index ebf52bf38..4a522386d 100644
@@ -42,6 +42,12 @@ if libdrm_amdgpu.found()
 	else
 		warning('libdrm <= 2.4.97 found, amd_syncobj test not applicable')
 	endif
+
+	if libdrm_amdgpu.version().version_compare('> 2.4.109')
+		amdgpu_progs +=[ 'amd_pstate', ]
+	else
+		warning('libdrm <= 2.4.109 found, amd_pstate test not applicable')
+	endif
 	amdgpu_deps += libdrm_amdgpu
 endif