Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/xe: Save off position in ring in which a job was programmed

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

+24 -4
+19 -4
drivers/gpu/drm/xe/xe_ring_ops.c
··· 245 245 246 246 /* for engines that don't require any special HW handling (no EUs, no aux inval, etc) */ 247 247 static void __emit_job_gen12_simple(struct xe_sched_job *job, struct xe_lrc *lrc, 248 - u64 batch_addr, u32 seqno) 248 + u64 batch_addr, u32 *head, u32 seqno) 249 249 { 250 250 u32 dw[MAX_JOB_SIZE_DW], i = 0; 251 251 u32 ppgtt_flag = get_ppgtt_flag(job); 252 252 struct xe_gt *gt = job->q->gt; 253 + 254 + *head = lrc->ring.tail; 253 255 254 256 i = emit_copy_timestamp(lrc, dw, i); 255 257 ··· 298 296 } 299 297 300 298 static void __emit_job_gen12_video(struct xe_sched_job *job, struct xe_lrc *lrc, 301 - u64 batch_addr, u32 seqno) 299 + u64 batch_addr, u32 *head, u32 seqno) 302 300 { 303 301 u32 dw[MAX_JOB_SIZE_DW], i = 0; 304 302 u32 ppgtt_flag = get_ppgtt_flag(job); 305 303 struct xe_gt *gt = job->q->gt; 306 304 struct xe_device *xe = gt_to_xe(gt); 307 305 bool decode = job->q->class == XE_ENGINE_CLASS_VIDEO_DECODE; 306 + 307 + *head = lrc->ring.tail; 308 308 309 309 i = emit_copy_timestamp(lrc, dw, i); 310 310 ··· 350 346 351 347 static void __emit_job_gen12_render_compute(struct xe_sched_job *job, 352 348 struct xe_lrc *lrc, 353 - u64 batch_addr, u32 seqno) 349 + u64 batch_addr, u32 *head, 350 + u32 seqno) 354 351 { 355 352 u32 dw[MAX_JOB_SIZE_DW], i = 0; 356 353 u32 ppgtt_flag = get_ppgtt_flag(job); ··· 359 354 struct xe_device *xe = gt_to_xe(gt); 360 355 bool lacks_render = !(gt->info.engine_mask & XE_HW_ENGINE_RCS_MASK); 361 356 u32 mask_flags = 0; 357 + 358 + *head = lrc->ring.tail; 362 359 363 360 i = emit_copy_timestamp(lrc, dw, i); 364 361 ··· 403 396 } 404 397 405 398 static void emit_migration_job_gen12(struct xe_sched_job *job, 406 - struct xe_lrc *lrc, u32 seqno) 399 + struct xe_lrc *lrc, u32 *head, 400 + u32 seqno) 407 401 { 408 402 u32 saddr = xe_lrc_start_seqno_ggtt_addr(lrc); 409 403 u32 dw[MAX_JOB_SIZE_DW], i = 0; 404 + 405 + *head = lrc->ring.tail; 410 406 411 407 i = emit_copy_timestamp(lrc, dw, i); 412 408 ··· 444 434 445 435 __emit_job_gen12_simple(job, job->q->lrc[0], 446 436 job->ptrs[0].batch_addr, 437 + &job->ptrs[0].head, 447 438 xe_sched_job_lrc_seqno(job)); 448 439 } 449 440 ··· 454 443 455 444 if (xe_sched_job_is_migration(job->q)) { 456 445 emit_migration_job_gen12(job, job->q->lrc[0], 446 + &job->ptrs[0].head, 457 447 xe_sched_job_lrc_seqno(job)); 458 448 return; 459 449 } ··· 462 450 for (i = 0; i < job->q->width; ++i) 463 451 __emit_job_gen12_simple(job, job->q->lrc[i], 464 452 job->ptrs[i].batch_addr, 453 + &job->ptrs[i].head, 465 454 xe_sched_job_lrc_seqno(job)); 466 455 } 467 456 ··· 474 461 for (i = 0; i < job->q->width; ++i) 475 462 __emit_job_gen12_video(job, job->q->lrc[i], 476 463 job->ptrs[i].batch_addr, 464 + &job->ptrs[i].head, 477 465 xe_sched_job_lrc_seqno(job)); 478 466 } 479 467 ··· 485 471 for (i = 0; i < job->q->width; ++i) 486 472 __emit_job_gen12_render_compute(job, job->q->lrc[i], 487 473 job->ptrs[i].batch_addr, 474 + &job->ptrs[i].head, 488 475 xe_sched_job_lrc_seqno(job)); 489 476 } 490 477
+5
drivers/gpu/drm/xe/xe_sched_job_types.h
··· 24 24 struct dma_fence_chain *chain_fence; 25 25 /** @batch_addr: Batch buffer address. */ 26 26 u64 batch_addr; 27 + /** 28 + * @head: The tail pointer of the LRC (so head pointer of job) when the 29 + * job was submitted 30 + */ 31 + u32 head; 27 32 }; 28 33 29 34 /**