From: "Jesse.zhang@amd.com" <jesse.zhang@amd.com>
To: <igt-dev@lists.freedesktop.org>
Cc: Vitaly Prosyak <vitaly.prosyak@amd.com>,
Alex Deucher <alexander.deucher@amd.com>,
Christian Koenig <christian.koenig@amd.com>,
Kamil Konieczny <kamil.konieczny@linux.intel.com>,
"Jesse.zhang@amd.com" <jesse.zhang@amd.com>,
Jesse Zhang <Jesse.Zhang@amd.com>
Subject: [PATCH i-g-t 1/4] lib/amdgpu: add gpu reset check
Date: Thu, 7 Nov 2024 10:05:07 +0800 [thread overview]
Message-ID: <20241107020510.350132-1-jesse.zhang@amd.com> (raw)
GPU reset types include full adapter reset, soft reset,
queue reset and pipeline reset. It is possible to check
whether a specific reset is supported via the sysfs interface
and run special cases for testing.
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
---
lib/amdgpu/amd_ip_blocks.c | 57 ++++++++++++++++++++++++++++++++++++++
lib/amdgpu/amd_ip_blocks.h | 8 ++++++
2 files changed, 65 insertions(+)
diff --git a/lib/amdgpu/amd_ip_blocks.c b/lib/amdgpu/amd_ip_blocks.c
index df603618b..40db28d8d 100644
--- a/lib/amdgpu/amd_ip_blocks.c
+++ b/lib/amdgpu/amd_ip_blocks.c
@@ -995,3 +995,60 @@ asic_rings_readness(amdgpu_device_handle device_handle, uint32_t mask,
arr[i++] = is_rings_available(device_handle, mask, ip);
}
+/**
+ * is_reset_enable:
+ * @ip_type: such as gfx, compute and dma.
+ * @reset_type: includes full adapter reset, soft reset, queue reset, and pipeline reset
+ *
+ * Check if reset supports certain reset types.
+ */
+
+bool
+is_reset_enable(enum amd_ip_block_type ip_type, uint32_t reset_type)
+{
+ char cmd[256];
+ FILE *fp, *fp2;
+ char buffer[100];
+ bool enable = false;
+ char reset_mask[100];
+
+ if(ip_type == AMD_IP_GFX)
+ snprintf(reset_mask, sizeof(reset_mask) - 1, "gfx_reset_mask");
+ else if (ip_type == AMD_IP_COMPUTE)
+ snprintf(reset_mask, sizeof(reset_mask) - 1, "compute_reset_mask");
+ else if (ip_type == AMD_IP_DMA)
+ snprintf(reset_mask, sizeof(reset_mask) - 1, "sdma_reset_mask");
+ else if (ip_type == AMD_IP_VCN_JPEG)
+ snprintf(reset_mask, sizeof(reset_mask) - 1, "jpeg_reset_mask");
+ else if (ip_type == AMD_IP_VPE)
+ snprintf(reset_mask, sizeof(reset_mask) - 1, "vpe_reset_mask");
+ else
+ snprintf(reset_mask, sizeof(reset_mask) - 1, "vcn_reset_mask");
+
+ snprintf(cmd, sizeof(cmd) - 1, "sudo cat /sys/kernel/debug/dri/0/name |grep -oP '(?<=dev=)[0-9:.]+'");
+ fp = popen(cmd, "r");
+ if (fp == NULL)
+ return false;
+
+ if (fgets(buffer, 13, fp) != NULL) {
+ snprintf(cmd,sizeof(cmd) - 1,"sudo cat /sys/bus/pci/devices/%s/%s | grep -oP '%s'",
+ buffer,reset_mask,
+ reset_type & AMDGPU_RESET_TYPE_FULL ? "full":
+ reset_type & AMDGPU_RESET_TYPE_SOFT_RESET ? "soft":
+ reset_type & AMDGPU_RESET_TYPE_PER_QUEUE ? "queue": "pipe");
+
+ fp2 = popen(cmd, "r");
+ if (fp2 == NULL) {
+ pclose(fp);
+ return false;
+ }
+
+ if (fgets(buffer, 13, fp2) != NULL) {
+ enable = true;
+ }
+ pclose(fp2);
+ }
+ pclose(fp);
+
+ return enable;
+}
diff --git a/lib/amdgpu/amd_ip_blocks.h b/lib/amdgpu/amd_ip_blocks.h
index 109d36602..337ef3c25 100644
--- a/lib/amdgpu/amd_ip_blocks.h
+++ b/lib/amdgpu/amd_ip_blocks.h
@@ -14,6 +14,12 @@
#define MAX_CARDS_SUPPORTED 4
+/* reset mask */
+#define AMDGPU_RESET_TYPE_FULL (1 << 0) /* full adapter reset, mode1/mode2/BACO/etc. */
+#define AMDGPU_RESET_TYPE_SOFT_RESET (1 << 1) /* IP level soft reset */
+#define AMDGPU_RESET_TYPE_PER_QUEUE (1 << 2) /* per queue */
+#define AMDGPU_RESET_TYPE_PER_PIPE (1 << 3) /* per pipe */
+
enum amd_ip_block_type {
AMD_IP_GFX = 0,
AMD_IP_COMPUTE,
@@ -212,4 +218,6 @@ amdgpu_open_devices(bool open_render_node, int max_cards_supported, int drm_amdg
void
asic_rings_readness(amdgpu_device_handle device_handle, uint32_t mask, bool arr[AMD_IP_MAX]);
+bool
+is_reset_enable(enum amd_ip_block_type ip_type, uint32_t reset_type);
#endif
--
2.25.1
next reply other threads:[~2024-11-07 2:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-07 2:05 Jesse.zhang@amd.com [this message]
2024-11-07 2:05 ` [PATCH i-g-t 2/4] tests/amd_queue_reset: modify the asic filter Jesse.zhang@amd.com
2024-11-07 2:05 ` [PATCH i-g-t 3/4] tests/amd_deadlock: add the filter for amd deadlock Jesse.zhang@amd.com
2024-11-07 2:05 ` [PATCH i-g-t 4/4] tests/amd_dispatch: add the filter for amd dispatch Jesse.zhang@amd.com
2024-11-11 0:44 ` vitaly prosyak
2024-11-07 2:54 ` ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/4] lib/amdgpu: add gpu reset check Patchwork
2024-11-07 3:02 ` ✓ CI.xeBAT: " Patchwork
2024-11-07 3:56 ` ✗ Fi.CI.IGT: failure " Patchwork
2024-11-08 9:08 ` ✗ CI.xeFULL: " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241107020510.350132-1-jesse.zhang@amd.com \
--to=jesse.zhang@amd.com \
--cc=alexander.deucher@amd.com \
--cc=christian.koenig@amd.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=kamil.konieczny@linux.intel.com \
--cc=vitaly.prosyak@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox