Skip to content

Commit 19c0222

Browse files
brianweltyThomas Hellström
authored andcommitted
drm/xe: Fix modifying exec_queue priority in xe_migrate_init
After exec_queue has been created, we cannot simply modify q->priority. This needs to be done by the backend via q->ops. However in this case, it would be more efficient to simply pass a flag when creating the exec_queue and set the desired priority upfront during queue creation. To that end: new flag EXEC_QUEUE_FLAG_HIGH_PRIORITY is introduced. The priority field is moved to be with other scheduling properties and is now exec_queue.sched_props.priority. This is no longer set to initial value by the backend, but is now set within __xe_exec_queue_create(). Fixes: b4eeced ("drm/xe: Fix potential deadlock handling page faults") Signed-off-by: Brian Welty <brian.welty@intel.com> Signed-off-by: Matthew Brost <matthew.brost@intel.com> Reviewed-by: Matthew Brost <matthew.brost@intel.com> (cherry picked from commit a8004af) Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
1 parent fef257e commit 19c0222

4 files changed

Lines changed: 14 additions & 9 deletions

File tree

drivers/gpu/drm/xe/xe_exec_queue.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ static struct xe_exec_queue *__xe_exec_queue_create(struct xe_device *xe,
6767
q->sched_props.timeslice_us = hwe->eclass->sched_props.timeslice_us;
6868
q->sched_props.preempt_timeout_us =
6969
hwe->eclass->sched_props.preempt_timeout_us;
70+
if (q->flags & EXEC_QUEUE_FLAG_KERNEL &&
71+
q->flags & EXEC_QUEUE_FLAG_HIGH_PRIORITY)
72+
q->sched_props.priority = XE_EXEC_QUEUE_PRIORITY_KERNEL;
73+
else
74+
q->sched_props.priority = XE_EXEC_QUEUE_PRIORITY_NORMAL;
7075

7176
if (xe_exec_queue_is_parallel(q)) {
7277
q->parallel.composite_fence_ctx = dma_fence_context_alloc(1);

drivers/gpu/drm/xe/xe_exec_queue_types.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ struct xe_exec_queue {
5252
struct xe_vm *vm;
5353
/** @class: class of this exec queue */
5454
enum xe_engine_class class;
55-
/** @priority: priority of this exec queue */
56-
enum xe_exec_queue_priority priority;
5755
/**
5856
* @logical_mask: logical mask of where job submitted to exec queue can run
5957
*/
@@ -84,6 +82,8 @@ struct xe_exec_queue {
8482
#define EXEC_QUEUE_FLAG_VM BIT(4)
8583
/* child of VM queue for multi-tile VM jobs */
8684
#define EXEC_QUEUE_FLAG_BIND_ENGINE_CHILD BIT(5)
85+
/* kernel exec_queue only, set priority to highest level */
86+
#define EXEC_QUEUE_FLAG_HIGH_PRIORITY BIT(6)
8787

8888
/**
8989
* @flags: flags for this exec queue, should statically setup aside from ban
@@ -142,6 +142,8 @@ struct xe_exec_queue {
142142
u32 timeslice_us;
143143
/** @preempt_timeout_us: preemption timeout in micro-seconds */
144144
u32 preempt_timeout_us;
145+
/** @priority: priority of this exec queue */
146+
enum xe_exec_queue_priority priority;
145147
} sched_props;
146148

147149
/** @compute: compute exec queue state */

drivers/gpu/drm/xe/xe_guc_submit.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ static void init_policies(struct xe_guc *guc, struct xe_exec_queue *q)
421421
{
422422
struct exec_queue_policy policy;
423423
struct xe_device *xe = guc_to_xe(guc);
424-
enum xe_exec_queue_priority prio = q->priority;
424+
enum xe_exec_queue_priority prio = q->sched_props.priority;
425425
u32 timeslice_us = q->sched_props.timeslice_us;
426426
u32 preempt_timeout_us = q->sched_props.preempt_timeout_us;
427427

@@ -1231,7 +1231,6 @@ static int guc_exec_queue_init(struct xe_exec_queue *q)
12311231
err = xe_sched_entity_init(&ge->entity, sched);
12321232
if (err)
12331233
goto err_sched;
1234-
q->priority = XE_EXEC_QUEUE_PRIORITY_NORMAL;
12351234

12361235
if (xe_exec_queue_is_lr(q))
12371236
INIT_WORK(&q->guc->lr_tdr, xe_guc_exec_queue_lr_cleanup);
@@ -1301,14 +1300,14 @@ static int guc_exec_queue_set_priority(struct xe_exec_queue *q,
13011300
{
13021301
struct xe_sched_msg *msg;
13031302

1304-
if (q->priority == priority || exec_queue_killed_or_banned(q))
1303+
if (q->sched_props.priority == priority || exec_queue_killed_or_banned(q))
13051304
return 0;
13061305

13071306
msg = kmalloc(sizeof(*msg), GFP_KERNEL);
13081307
if (!msg)
13091308
return -ENOMEM;
13101309

1311-
q->priority = priority;
1310+
q->sched_props.priority = priority;
13121311
guc_exec_queue_add_msg(q, msg, SET_SCHED_PROPS);
13131312

13141313
return 0;

drivers/gpu/drm/xe/xe_migrate.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,8 @@ struct xe_migrate *xe_migrate_init(struct xe_tile *tile)
344344

345345
m->q = xe_exec_queue_create(xe, vm, logical_mask, 1, hwe,
346346
EXEC_QUEUE_FLAG_KERNEL |
347-
EXEC_QUEUE_FLAG_PERMANENT);
347+
EXEC_QUEUE_FLAG_PERMANENT |
348+
EXEC_QUEUE_FLAG_HIGH_PRIORITY);
348349
} else {
349350
m->q = xe_exec_queue_create_class(xe, primary_gt, vm,
350351
XE_ENGINE_CLASS_COPY,
@@ -355,8 +356,6 @@ struct xe_migrate *xe_migrate_init(struct xe_tile *tile)
355356
xe_vm_close_and_put(vm);
356357
return ERR_CAST(m->q);
357358
}
358-
if (xe->info.has_usm)
359-
m->q->priority = XE_EXEC_QUEUE_PRIORITY_KERNEL;
360359

361360
mutex_init(&m->job_mutex);
362361

0 commit comments

Comments
 (0)