[igt-dev] [PATCH] tests/amdgpu: add amdgpu reset test
Kamil Konieczny
kamil.konieczny at linux.intel.com
Fri Sep 22 09:37:13 UTC 2023
Hi Jesse,
please improve subject,
[PATCH] tests/amdgpu: add amdgpu reset test
-------------------^
There is missing test which you change, better write:
[PATCH] tests/amd_deadlock: add reset subtest
Please write description of your patch here, for example
what or how will you test.
> Signed-off-by: Jesse Zhang <Jesse.Zhang at amd.com>
> Signed-off-by: Tim Huang <tim.huang at amd.com>
> ---
> tests/amdgpu/amd_deadlock.c | 40 +++++++++++++++++++++++++++++++++++++
> 1 file changed, 40 insertions(+)
>
> diff --git a/tests/amdgpu/amd_deadlock.c b/tests/amdgpu/amd_deadlock.c
> index d805b8d18..1b9254d06 100644
> --- a/tests/amdgpu/amd_deadlock.c
> +++ b/tests/amdgpu/amd_deadlock.c
> @@ -27,6 +27,9 @@
> #include "lib/amdgpu/amd_command_submission.h"
> #include "lib/amdgpu/amd_dispatch.h"
> #include "lib/amdgpu/amd_deadlock_helpers.h"
> +#include <sys/stat.h>
> +#include <fcntl.h>
> +#include <sys/sysmacros.h>
Add system include as first, before igt lib ones. Also sort them
alphabetically, here fcntl before sys/s... ones.
>
> static void
> amdgpu_dispatch_hang_slow_gfx(amdgpu_device_handle device_handle)
> @@ -70,6 +73,41 @@ amdgpu_gfx_illegal_mem_access(amdgpu_device_handle device_handle)
> bad_access_helper(device_handle, 0, AMDGPU_HW_IP_GFX);
> }
>
> +static void
> +amdgpu_gpu_reset_test(amdgpu_device_handle device_handle, int drm_amdgpu)
> +{
> + int r;
> + char debugfs_path[256], tmp[10];
> + int fd;
> + struct stat sbuf;
> + amdgpu_context_handle context_handle;
> + uint32_t hang_state, hangs;
> +
> + r = amdgpu_cs_ctx_create(device_handle, &context_handle);
> + igt_assert_eq(r, 0);
> +
> + r = fstat(drm_amdgpu, &sbuf);
> + igt_assert_eq(r, 0);
> +
> + sprintf(debugfs_path, "/sys/kernel/debug/dri/%d/amdgpu_gpu_recover", minor(sbuf.st_rdev));
> + fd = open(debugfs_path, O_RDONLY);
> + igt_assert_fd(fd);
> +
> + r = read(fd, tmp, sizeof(tmp)/sizeof(char));
> + igt_assert_lt(0,r);
> +
> + r = amdgpu_cs_query_reset_state(context_handle, &hang_state, &hangs);
> + igt_assert_eq(r, 0);
> + igt_assert_eq(hang_state, AMDGPU_CTX_UNKNOWN_RESET);
> +
> + close(fd);
> + r = amdgpu_cs_ctx_free(context_handle);
> + igt_assert_eq(r, 0);
> +
> + amdgpu_gfx_dispatch_test(device_handle, AMDGPU_HW_IP_GFX);
> + amdgpu_gfx_dispatch_test(device_handle, AMDGPU_HW_IP_COMPUTE);
> +}
> +
> igt_main
> {
> amdgpu_device_handle device;
> @@ -116,6 +154,8 @@ igt_main
> igt_subtest("dispatch_hang_slow_gfx")
> amdgpu_dispatch_hang_slow_gfx(device);
>
> + igt_subtest("amdgpu-reset-test")
---------------- ^^^^^^
Your test have already "amd" in test name amd_deadlock, so no
need for repeating amdgpu but it is your decision, you may keep
it if you want.
Regards,
Kamil
> + amdgpu_gpu_reset_test(device,fd);
> igt_fixture {
> amdgpu_device_deinitialize(device);
> drm_close_driver(fd);
> --
> 2.25.1
>
More information about the igt-dev
mailing list