]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/xe: Save CTX_TIMESTAMP mmio value instead of LRC value
authorUmesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Fri, 9 May 2025 16:12:01 +0000 (09:12 -0700)
committerUmesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Mon, 12 May 2025 21:33:23 +0000 (14:33 -0700)
For determining actual job execution time, save the current value of the
CTX_TIMESTAMP register rather than the value saved in LRC since the
current register value is the closest to the start time of the job.

v2: Define MI_STORE_REGISTER_MEM to fix compile error
v3: Place MI_STORE_REGISTER_MEM sorted by MI_INSTR (Lucas)

Fixes: 65921374c48f ("drm/xe: Emit ctx timestamp copy in ring ops")
Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Link: https://lore.kernel.org/r/20250509161159.2173069-6-umesh.nerlige.ramappa@intel.com
drivers/gpu/drm/xe/instructions/xe_mi_commands.h
drivers/gpu/drm/xe/xe_lrc.c
drivers/gpu/drm/xe/xe_ring_ops.c

index eba582058d550854ce425563cffd8f3b53a9bac6..e3f5e8bb3ebcd9a622078818dc9ab43f026898b8 100644 (file)
 #define   MI_LRI_FORCE_POSTED          REG_BIT(12)
 #define   MI_LRI_LEN(x)                        (((x) & 0xff) + 1)
 
+#define MI_STORE_REGISTER_MEM          (__MI_INSTR(0x24) | XE_INSTR_NUM_DW(4))
+#define   MI_SRM_USE_GGTT              REG_BIT(22)
+#define   MI_SRM_ADD_CS_OFFSET         REG_BIT(19)
+
 #define MI_FLUSH_DW                    __MI_INSTR(0x26)
 #define   MI_FLUSH_DW_PROTECTED_MEM_EN REG_BIT(22)
 #define   MI_FLUSH_DW_STORE_INDEX      REG_BIT(21)
index 855c8acaf3f1e74d2c2fcbab75710384e9c344df..015b00a73c0b76ac0cb16238c78269a074a86285 100644 (file)
@@ -687,7 +687,7 @@ static inline u32 __xe_lrc_start_seqno_offset(struct xe_lrc *lrc)
 
 static u32 __xe_lrc_ctx_job_timestamp_offset(struct xe_lrc *lrc)
 {
-       /* The start seqno is stored in the driver-defined portion of PPHWSP */
+       /* This is stored in the driver-defined portion of PPHWSP */
        return xe_lrc_pphwsp_offset(lrc) + LRC_CTX_JOB_TIMESTAMP_OFFSET;
 }
 
index a7582b097ae678a00008d2be3d18ad4aca036311..bc1689db4cd7165d4a6c52db84af5c693c8a8001 100644 (file)
@@ -234,13 +234,10 @@ static u32 get_ppgtt_flag(struct xe_sched_job *job)
 
 static int emit_copy_timestamp(struct xe_lrc *lrc, u32 *dw, int i)
 {
-       dw[i++] = MI_COPY_MEM_MEM | MI_COPY_MEM_MEM_SRC_GGTT |
-               MI_COPY_MEM_MEM_DST_GGTT;
+       dw[i++] = MI_STORE_REGISTER_MEM | MI_SRM_USE_GGTT | MI_SRM_ADD_CS_OFFSET;
+       dw[i++] = RING_CTX_TIMESTAMP(0).addr;
        dw[i++] = xe_lrc_ctx_job_timestamp_ggtt_addr(lrc);
        dw[i++] = 0;
-       dw[i++] = xe_lrc_ctx_timestamp_ggtt_addr(lrc);
-       dw[i++] = 0;
-       dw[i++] = MI_NOOP;
 
        return i;
 }