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>,
"Jesse.zhang@amd.com" <jesse.zhang@amd.com>
Subject: [PATCH 1/2 V2 i-g-t] lib/amdgpu: Enhanced SDMA negative test interface
Date: Wed, 28 Aug 2024 17:45:49 +0800 [thread overview]
Message-ID: <20240828094549.150449-1-jesse.zhang@amd.com> (raw)
To enhance the reset function, several invalid sdma writes are added.
1. Assembling invalid operation code.
2. Writing invalid memory address.
3. Writing illegal register.
4. Sending invalid packet length.
Signed-off-by: Jesse Zhang <jesse.zhang@amd.com>
---
lib/amdgpu/amd_deadlock_helpers.h | 5 ---
lib/amdgpu/amd_ip_blocks.c | 51 +++++++++++++++++++++++++++++++
lib/amdgpu/amd_ip_blocks.h | 5 ++-
3 files changed, 55 insertions(+), 6 deletions(-)
diff --git a/lib/amdgpu/amd_deadlock_helpers.h b/lib/amdgpu/amd_deadlock_helpers.h
index e36227950..165ffb98d 100644
--- a/lib/amdgpu/amd_deadlock_helpers.h
+++ b/lib/amdgpu/amd_deadlock_helpers.h
@@ -24,11 +24,6 @@
#ifndef __AMD_DEADLOCK_HELPERS_H__
#define __AMD_DEADLOCK_HELPERS_H__
-enum hang_type {
- DMA_CORRUPTED_HEADER_HANG,
- DMA_SLOW_LINEARCOPY_HANG
-};
-
void
amdgpu_wait_memory_helper(amdgpu_device_handle device_handle, unsigned int ip_type);
diff --git a/lib/amdgpu/amd_ip_blocks.c b/lib/amdgpu/amd_ip_blocks.c
index 175c84cf9..a486347ac 100644
--- a/lib/amdgpu/amd_ip_blocks.c
+++ b/lib/amdgpu/amd_ip_blocks.c
@@ -57,6 +57,56 @@ sdma_ring_write_linear(const struct amdgpu_ip_funcs *func,
return 0;
}
+static int
+sdma_ring_bad_write_linear(const struct amdgpu_ip_funcs *func,
+ const struct amdgpu_ring_context *ring_context,
+ uint32_t *pm4_dw, unsigned int cmd_error)
+{
+ uint32_t i, j, stream_length;
+ uint32_t opcode;
+
+ i = 0;
+ j = 0;
+
+ if (cmd_error == CMD_STREAM_EXEC_INVALID_PACKET_LENGTH)
+ stream_length = ring_context->write_length / 16;
+ else
+ stream_length = ring_context->write_length;
+
+ if (cmd_error == CMD_STREAM_EXEC_INVALID_OPCODE)
+ opcode = 0xf2;
+ else
+ opcode = SDMA_OPCODE_WRITE;
+
+ if (func->family_id == AMDGPU_FAMILY_SI)
+ ring_context->pm4[i++] = SDMA_PACKET_SI(opcode, 0, 0, 0,
+ ring_context->write_length);
+ else
+ ring_context->pm4[i++] = SDMA_PACKET(opcode,
+ SDMA_WRITE_SUB_OPCODE_LINEAR,
+ ring_context->secure ? SDMA_ATOMIC_TMZ(1) : 0);
+ if (cmd_error == CMD_STREAM_TRANS_BAD_MEM_ADDRESS) {
+ ring_context->pm4[i++] = lower_32_bits(0xdeadbee0);
+ ring_context->pm4[i++] = upper_32_bits(0xdeadbee0);
+ }else if (cmd_error == CMD_STREAM_TRANS_BAD_REG_ADDRESS) {
+ ring_context->pm4[i++] = lower_32_bits(mmVM_CONTEXT0_PAGE_TABLE_BASE_ADDR);
+ ring_context->pm4[i++] = upper_32_bits(mmVM_CONTEXT0_PAGE_TABLE_BASE_ADDR);
+ } else {
+ ring_context->pm4[i++] = lower_32_bits(ring_context->bo_mc);
+ ring_context->pm4[i++] = upper_32_bits(ring_context->bo_mc);
+ }
+ if (func->family_id >= AMDGPU_FAMILY_AI)
+ ring_context->pm4[i++] = ring_context->write_length - 1;
+ else
+ ring_context->pm4[i++] = ring_context->write_length;
+
+ while (j++ < stream_length)
+ ring_context->pm4[i++] = func->deadbeaf;
+ *pm4_dw = i;
+
+ return 0;
+}
+
static int
sdma_ring_atomic(const struct amdgpu_ip_funcs *func,
const struct amdgpu_ring_context *ring_context,
@@ -429,6 +479,7 @@ static struct amdgpu_ip_funcs sdma_v3_x_ip_funcs = {
.deadbeaf = 0xdeadbeaf,
.pattern = 0xaaaaaaaa,
.write_linear = sdma_ring_write_linear,
+ .bad_write_linear = sdma_ring_bad_write_linear,
.write_linear_atomic = sdma_ring_atomic,
.const_fill = sdma_ring_const_fill,
.copy_linear = sdma_ring_copy_linear,
diff --git a/lib/amdgpu/amd_ip_blocks.h b/lib/amdgpu/amd_ip_blocks.h
index 86b82c40c..3e729f4c0 100644
--- a/lib/amdgpu/amd_ip_blocks.h
+++ b/lib/amdgpu/amd_ip_blocks.h
@@ -42,7 +42,10 @@ enum cmd_error_type {
BACKEND_SE_GC_SHADER_INVALID_SHADER,
BACKEND_SE_GC_SHADER_INVALID_PROGRAM_ADDR, /* COMPUTE_PGM */
BACKEND_SE_GC_SHADER_INVALID_PROGRAM_SETTING, /* COMPUTE_PGM_RSRC */
- BACKEND_SE_GC_SHADER_INVALID_USER_DATA /* COMPUTE_USER_DATA */
+ BACKEND_SE_GC_SHADER_INVALID_USER_DATA, /* COMPUTE_USER_DATA */
+
+ DMA_CORRUPTED_HEADER_HANG,
+ DMA_SLOW_LINEARCOPY_HANG
};
#define _MAX_NUM_ASIC_ID_EXCLUDE_FILTER 3
--
2.25.1
reply other threads:[~2024-08-28 9:45 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20240828094549.150449-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=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