[Intel-xe] [PATCH 1/3] drm/xe: fix submissions without vm
Matthew Brost
matthew.brost at intel.com
Fri Jul 28 01:22:13 UTC 2023
On Thu, Jul 27, 2023 at 11:59:43AM -0700, Daniele Ceraolo Spurio wrote:
> Kernel engines can submit privileged batches directly in GGTT, so they
> don't always need a vm. The submission front-end already supports
> creating and submitting jobs without a vm, but some parts of the
> back-end assume the vm is always there. Fix this by handling a lack of
> vm in the back-end as well.
>
> Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio at intel.com>
> Cc: Matthew Brost <matthew.brost at intel.com>
One nit below, with that fixed:
Reviewed-by: Matthew Brost <matthew.brost at intel.com>
> ---
> drivers/gpu/drm/xe/xe_guc_submit.c | 2 +-
> drivers/gpu/drm/xe/xe_ring_ops.c | 8 ++++----
> drivers/gpu/drm/xe/xe_sched_job.c | 3 +++
> 3 files changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c
> index 911d4965c27c..c5b265624344 100644
> --- a/drivers/gpu/drm/xe/xe_guc_submit.c
> +++ b/drivers/gpu/drm/xe/xe_guc_submit.c
> @@ -1128,7 +1128,7 @@ static int guc_engine_init(struct xe_engine *e)
> ge->engine = e;
> init_waitqueue_head(&ge->suspend_wait);
>
> - timeout = xe_vm_no_dma_fences(e->vm) ? MAX_SCHEDULE_TIMEOUT : HZ * 5;
> + timeout = e->vm && xe_vm_no_dma_fences(e->vm) ? MAX_SCHEDULE_TIMEOUT : HZ * 5;
> err = drm_sched_init(&ge->sched, &drm_sched_ops, NULL,
> e->lrc[0].ring.size / MAX_JOB_SIZE_BYTES,
> 64, timeout, guc_to_gt(guc)->ordered_wq, NULL,
> diff --git a/drivers/gpu/drm/xe/xe_ring_ops.c b/drivers/gpu/drm/xe/xe_ring_ops.c
> index cc278485908c..8e21c19cb041 100644
> --- a/drivers/gpu/drm/xe/xe_ring_ops.c
> +++ b/drivers/gpu/drm/xe/xe_ring_ops.c
> @@ -212,7 +212,7 @@ static void __emit_job_gen12_copy(struct xe_sched_job *job, struct xe_lrc *lrc,
> u32 ppgtt_flag = get_ppgtt_flag(job);
> struct xe_vm *vm = job->engine->vm;
>
> - if (vm->batch_invalidate_tlb) {
> + if (vm && vm->batch_invalidate_tlb) {
> dw[i++] = preparser_disable(true);
> i = emit_flush_imm_ggtt(xe_lrc_start_seqno_ggtt_addr(lrc),
> seqno, true, dw, i);
> @@ -270,13 +270,13 @@ static void __emit_job_gen12_video(struct xe_sched_job *job, struct xe_lrc *lrc,
> i = emit_aux_table_inv(gt, VE0_AUX_NV, dw, i);
> }
>
> - if (vm->batch_invalidate_tlb)
> + if (vm && vm->batch_invalidate_tlb)
> i = emit_flush_imm_ggtt(xe_lrc_start_seqno_ggtt_addr(lrc),
> seqno, true, dw, i);
>
> dw[i++] = preparser_disable(false);
>
> - if (!vm->batch_invalidate_tlb)
> + if (!vm || !vm->batch_invalidate_tlb)
> i = emit_store_imm_ggtt(xe_lrc_start_seqno_ggtt_addr(lrc),
> seqno, dw, i);
>
> @@ -315,7 +315,7 @@ static void __emit_job_gen12_render_compute(struct xe_sched_job *job,
> mask_flags = PIPE_CONTROL_3D_ENGINE_FLAGS;
>
> /* See __xe_pt_bind_vma() for a discussion on TLB invalidations. */
> - i = emit_pipe_invalidate(mask_flags, vm->batch_invalidate_tlb, dw, i);
> + i = emit_pipe_invalidate(mask_flags, vm && vm->batch_invalidate_tlb, dw, i);
>
> /* hsdes: 1809175790 */
> if (has_aux_ccs(xe))
> diff --git a/drivers/gpu/drm/xe/xe_sched_job.c b/drivers/gpu/drm/xe/xe_sched_job.c
> index f581472cb391..e1af1f2a44c2 100644
> --- a/drivers/gpu/drm/xe/xe_sched_job.c
> +++ b/drivers/gpu/drm/xe/xe_sched_job.c
> @@ -87,6 +87,9 @@ struct xe_sched_job *xe_sched_job_create(struct xe_engine *e,
> int i, j;
> u32 width;
>
> + /* only a kernel context can submit a vm-less job */
> + XE_BUG_ON(!e->vm && !(e->flags & ENGINE_FLAG_KERNEL));
> +
The direction is to drop XE_BUG_ON and replace with XE_WARN_ON [1].
I'd do that in this patch.
Matt
[1] https://patchwork.freedesktop.org/patch/549682/?series=121439&rev=2
> /* Migration and kernel engines have their own locking */
> if (!(e->flags & (ENGINE_FLAG_KERNEL | ENGINE_FLAG_VM |
> ENGINE_FLAG_WA))) {
> --
> 2.41.0
>
More information about the Intel-xe
mailing list