[PATCH] lib/amdgpu: enhance readability of packet creation logic

vitaly.prosyak at amd.com vitaly.prosyak at amd.com
Mon Dec 30 20:01:15 UTC 2024


From: Vitaly Prosyak <vitaly.prosyak at amd.com>

No functional changes.
Added PACKET3_SET_CE_DE_COUNTERS, PACKET3_INCREMENT_CE_COUNTER,
and PACKET3_WAIT_ON_CE_COUNTER for PACKET3 operations specific
to GFX6 through GFX10.

Cc: Jesse Zhang  <jesse.zhang at amd.com>
Cc: Christian Koenig <christian.koenig at amd.com>
Cc: Alexander Deucher <alexander.deucher at amd.com>
Cc: Sunil Khatri <sunil.khatri at amd.com>

Signed-off-by: Vitaly Prosyak <vitaly.prosyak at amd.com>
---
 lib/amdgpu/amd_PM4.h    |  5 +++++
 lib/amdgpu/amd_memory.c | 13 ++++++-------
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/lib/amdgpu/amd_PM4.h b/lib/amdgpu/amd_PM4.h
index dd483baee..5bc3cb783 100644
--- a/lib/amdgpu/amd_PM4.h
+++ b/lib/amdgpu/amd_PM4.h
@@ -216,4 +216,9 @@
 #define mmVM_CONTEXT0_PAGE_TABLE_BASE_ADDR                   0x54f
 
 #define GFX_COMPUTE_NOP  0xffff1000
+
+#define	PACKET3_SET_CE_DE_COUNTERS		0x89
+#define	PACKET3_INCREMENT_CE_COUNTER		0x84
+#define	PACKET3_WAIT_ON_CE_COUNTER		0x86
+
 #endif
diff --git a/lib/amdgpu/amd_memory.c b/lib/amdgpu/amd_memory.c
index 208e20eb8..92ddc9fe2 100644
--- a/lib/amdgpu/amd_memory.c
+++ b/lib/amdgpu/amd_memory.c
@@ -24,7 +24,7 @@
  */
 
 #include "amd_memory.h"
-
+#include "amd_PM4.h"
 /**
  *
  * @param device_handle
@@ -328,20 +328,19 @@ void amdgpu_command_submission_multi_fence_wait_all(amdgpu_device_handle device,
 
 	memset(ib_info, 0, 2 * sizeof(struct amdgpu_cs_ib_info));
 
-	/* IT_SET_CE_DE_COUNTERS */
+	/* IT_SET_CE_DE_COUNTERS valid for gfx 6-10 */
 	ptr = ib_result_ce_cpu;
-	ptr[0] = 0xc0008900;
+	ptr[0] = PACKET3(PACKET3_SET_CE_DE_COUNTERS, 0);
 	ptr[1] = 0;
-	ptr[2] = 0xc0008400;
+	ptr[2] = PACKET3(PACKET3_INCREMENT_CE_COUNTER, 0);
 	ptr[3] = 1;
 	ib_info[0].ib_mc_address = ib_result_ce_mc_address;
 	ib_info[0].size = 4;
 	ib_info[0].flags = AMDGPU_IB_FLAG_CE;
 
-	/* IT_WAIT_ON_CE_COUNTER */
 	ptr = ib_result_cpu;
-	ptr[0] = 0xc0008600;
-	ptr[1] = 0x00000001;
+	ptr[0] = PACKET3(PACKET3_WAIT_ON_CE_COUNTER, 0);
+	ptr[1] = 1;//Conditional Surface Sync for wrapping CE buffers.
 	ib_info[1].ib_mc_address = ib_result_mc_address;
 	ib_info[1].size = 2;
 
-- 
2.34.1



More information about the igt-dev mailing list