]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/xe: Save off position in ring in which a job was programmed
authorMatthew Brost <matthew.brost@intel.com>
Wed, 8 Oct 2025 21:45:00 +0000 (14:45 -0700)
committerMatthew Brost <matthew.brost@intel.com>
Thu, 9 Oct 2025 10:22:16 +0000 (03:22 -0700)
VF post-migration recovery needs to modify the ring with updated GGTT
addresses for pending jobs. Save off position in ring in which a job was
programmed to facilitate.

v4:
 - s/VF resume/VF post-migration recovery (Tomasz)

Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Tomasz Lis <tomasz.lis@intel.com>
Link: https://lore.kernel.org/r/20251008214532.3442967-3-matthew.brost@intel.com
drivers/gpu/drm/xe/xe_ring_ops.c
drivers/gpu/drm/xe/xe_sched_job_types.h

index d71837773d6c63ef56a5744f2c5d7dea0638eaef..ac0c6dcffe156bbadc99c8a6a9dcb58f4d319df4 100644 (file)
@@ -245,12 +245,14 @@ static int emit_copy_timestamp(struct xe_lrc *lrc, u32 *dw, int i)
 
 /* for engines that don't require any special HW handling (no EUs, no aux inval, etc) */
 static void __emit_job_gen12_simple(struct xe_sched_job *job, struct xe_lrc *lrc,
-                                   u64 batch_addr, u32 seqno)
+                                   u64 batch_addr, u32 *head, u32 seqno)
 {
        u32 dw[MAX_JOB_SIZE_DW], i = 0;
        u32 ppgtt_flag = get_ppgtt_flag(job);
        struct xe_gt *gt = job->q->gt;
 
+       *head = lrc->ring.tail;
+
        i = emit_copy_timestamp(lrc, dw, i);
 
        if (job->ring_ops_flush_tlb) {
@@ -296,7 +298,7 @@ static bool has_aux_ccs(struct xe_device *xe)
 }
 
 static void __emit_job_gen12_video(struct xe_sched_job *job, struct xe_lrc *lrc,
-                                  u64 batch_addr, u32 seqno)
+                                  u64 batch_addr, u32 *head, u32 seqno)
 {
        u32 dw[MAX_JOB_SIZE_DW], i = 0;
        u32 ppgtt_flag = get_ppgtt_flag(job);
@@ -304,6 +306,8 @@ static void __emit_job_gen12_video(struct xe_sched_job *job, struct xe_lrc *lrc,
        struct xe_device *xe = gt_to_xe(gt);
        bool decode = job->q->class == XE_ENGINE_CLASS_VIDEO_DECODE;
 
+       *head = lrc->ring.tail;
+
        i = emit_copy_timestamp(lrc, dw, i);
 
        dw[i++] = preparser_disable(true);
@@ -346,7 +350,8 @@ static void __emit_job_gen12_video(struct xe_sched_job *job, struct xe_lrc *lrc,
 
 static void __emit_job_gen12_render_compute(struct xe_sched_job *job,
                                            struct xe_lrc *lrc,
-                                           u64 batch_addr, u32 seqno)
+                                           u64 batch_addr, u32 *head,
+                                           u32 seqno)
 {
        u32 dw[MAX_JOB_SIZE_DW], i = 0;
        u32 ppgtt_flag = get_ppgtt_flag(job);
@@ -355,6 +360,8 @@ static void __emit_job_gen12_render_compute(struct xe_sched_job *job,
        bool lacks_render = !(gt->info.engine_mask & XE_HW_ENGINE_RCS_MASK);
        u32 mask_flags = 0;
 
+       *head = lrc->ring.tail;
+
        i = emit_copy_timestamp(lrc, dw, i);
 
        dw[i++] = preparser_disable(true);
@@ -396,11 +403,14 @@ static void __emit_job_gen12_render_compute(struct xe_sched_job *job,
 }
 
 static void emit_migration_job_gen12(struct xe_sched_job *job,
-                                    struct xe_lrc *lrc, u32 seqno)
+                                    struct xe_lrc *lrc, u32 *head,
+                                    u32 seqno)
 {
        u32 saddr = xe_lrc_start_seqno_ggtt_addr(lrc);
        u32 dw[MAX_JOB_SIZE_DW], i = 0;
 
+       *head = lrc->ring.tail;
+
        i = emit_copy_timestamp(lrc, dw, i);
 
        i = emit_store_imm_ggtt(saddr, seqno, dw, i);
@@ -434,6 +444,7 @@ static void emit_job_gen12_gsc(struct xe_sched_job *job)
 
        __emit_job_gen12_simple(job, job->q->lrc[0],
                                job->ptrs[0].batch_addr,
+                               &job->ptrs[0].head,
                                xe_sched_job_lrc_seqno(job));
 }
 
@@ -443,6 +454,7 @@ static void emit_job_gen12_copy(struct xe_sched_job *job)
 
        if (xe_sched_job_is_migration(job->q)) {
                emit_migration_job_gen12(job, job->q->lrc[0],
+                                        &job->ptrs[0].head,
                                         xe_sched_job_lrc_seqno(job));
                return;
        }
@@ -450,6 +462,7 @@ static void emit_job_gen12_copy(struct xe_sched_job *job)
        for (i = 0; i < job->q->width; ++i)
                __emit_job_gen12_simple(job, job->q->lrc[i],
                                        job->ptrs[i].batch_addr,
+                                       &job->ptrs[i].head,
                                        xe_sched_job_lrc_seqno(job));
 }
 
@@ -461,6 +474,7 @@ static void emit_job_gen12_video(struct xe_sched_job *job)
        for (i = 0; i < job->q->width; ++i)
                __emit_job_gen12_video(job, job->q->lrc[i],
                                       job->ptrs[i].batch_addr,
+                                      &job->ptrs[i].head,
                                       xe_sched_job_lrc_seqno(job));
 }
 
@@ -471,6 +485,7 @@ static void emit_job_gen12_render_compute(struct xe_sched_job *job)
        for (i = 0; i < job->q->width; ++i)
                __emit_job_gen12_render_compute(job, job->q->lrc[i],
                                                job->ptrs[i].batch_addr,
+                                               &job->ptrs[i].head,
                                                xe_sched_job_lrc_seqno(job));
 }
 
index dbf260dded8dff52835a2e7227e4bbeee930022b..7ce58765a34ab6f4c72bb2ad0d381fec59289e44 100644 (file)
@@ -24,6 +24,11 @@ struct xe_job_ptrs {
        struct dma_fence_chain *chain_fence;
        /** @batch_addr: Batch buffer address. */
        u64 batch_addr;
+       /**
+        * @head: The tail pointer of the LRC (so head pointer of job) when the
+        * job was submitted
+        */
+       u32 head;
 };
 
 /**