Skip to content

Commit b55caa6

Browse files
committed
Merge tag 'drm-xe-fixes-2025-09-18' of https://gitlab.freedesktop.org/drm/xe/kernel into drm-fixes
- Release kobject for the failure path (Shuicheng) - SRIOV PF: Drop rounddown_pow_of_two fair (Michal) - Remove type casting on hwmon (Mallesh) - Defer free of NVM auxiliary container to device release (Nitin) - Fix a NULL vs IS_ERR (Dan) - Add cleanup action in xe_device_sysfs_init (Zongyao) - Fix error handling if PXP fails to start (Daniele) - Set GuC RCS/CCS yield policy (Daniele) Signed-off-by: Dave Airlie <airlied@redhat.com> From: Rodrigo Vivi <rodrigo.vivi@intel.com> Link: https://lore.kernel.org/r/aMwL7vxFP1L94IML@intel.com
2 parents f5a9c2b + 26caeae commit b55caa6

17 files changed

+208
-73
lines changed

drivers/gpu/drm/xe/abi/guc_actions_abi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ enum xe_guc_action {
117117
XE_GUC_ACTION_ENTER_S_STATE = 0x501,
118118
XE_GUC_ACTION_EXIT_S_STATE = 0x502,
119119
XE_GUC_ACTION_GLOBAL_SCHED_POLICY_CHANGE = 0x506,
120+
XE_GUC_ACTION_UPDATE_SCHEDULING_POLICIES_KLV = 0x509,
120121
XE_GUC_ACTION_SCHED_CONTEXT = 0x1000,
121122
XE_GUC_ACTION_SCHED_CONTEXT_MODE_SET = 0x1001,
122123
XE_GUC_ACTION_SCHED_CONTEXT_MODE_DONE = 0x1002,

drivers/gpu/drm/xe/abi/guc_klvs_abi.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* | 0 | 31:16 | **KEY** - KLV key identifier |
1818
* | | | - `GuC Self Config KLVs`_ |
1919
* | | | - `GuC Opt In Feature KLVs`_ |
20+
* | | | - `GuC Scheduling Policies KLVs`_ |
2021
* | | | - `GuC VGT Policy KLVs`_ |
2122
* | | | - `GuC VF Configuration KLVs`_ |
2223
* | | | |
@@ -152,6 +153,30 @@ enum {
152153
#define GUC_KLV_OPT_IN_FEATURE_DYNAMIC_INHIBIT_CONTEXT_SWITCH_KEY 0x4003
153154
#define GUC_KLV_OPT_IN_FEATURE_DYNAMIC_INHIBIT_CONTEXT_SWITCH_LEN 0u
154155

156+
/**
157+
* DOC: GuC Scheduling Policies KLVs
158+
*
159+
* `GuC KLV`_ keys available for use with UPDATE_SCHEDULING_POLICIES_KLV.
160+
*
161+
* _`GUC_KLV_SCHEDULING_POLICIES_RENDER_COMPUTE_YIELD` : 0x1001
162+
* Some platforms do not allow concurrent execution of RCS and CCS
163+
* workloads from different address spaces. By default, the GuC prioritizes
164+
* RCS submissions over CCS ones, which can lead to CCS workloads being
165+
* significantly (or completely) starved of execution time. This KLV allows
166+
* the driver to specify a quantum (in ms) and a ratio (percentage value
167+
* between 0 and 100), and the GuC will prioritize the CCS for that
168+
* percentage of each quantum. For example, specifying 100ms and 30% will
169+
* make the GuC prioritize the CCS for 30ms of every 100ms.
170+
* Note that this does not necessarly mean that RCS and CCS engines will
171+
* only be active for their percentage of the quantum, as the restriction
172+
* only kicks in if both classes are fully busy with non-compatible address
173+
* spaces; i.e., if one engine is idle or running the same address space,
174+
* a pending job on the other engine will still be submitted to the HW no
175+
* matter what the ratio is
176+
*/
177+
#define GUC_KLV_SCHEDULING_POLICIES_RENDER_COMPUTE_YIELD_KEY 0x1001
178+
#define GUC_KLV_SCHEDULING_POLICIES_RENDER_COMPUTE_YIELD_LEN 2u
179+
155180
/**
156181
* DOC: GuC VGT Policy KLVs
157182
*

drivers/gpu/drm/xe/xe_device_sysfs.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,12 +311,16 @@ int xe_device_sysfs_init(struct xe_device *xe)
311311
if (xe->info.platform == XE_BATTLEMAGE) {
312312
ret = sysfs_create_files(&dev->kobj, auto_link_downgrade_attrs);
313313
if (ret)
314-
return ret;
314+
goto cleanup;
315315

316316
ret = late_bind_create_files(dev);
317317
if (ret)
318-
return ret;
318+
goto cleanup;
319319
}
320320

321321
return devm_add_action_or_reset(dev, xe_device_sysfs_fini, xe);
322+
323+
cleanup:
324+
xe_device_sysfs_fini(xe);
325+
return ret;
322326
}

drivers/gpu/drm/xe/xe_exec_queue.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,16 @@ static int __xe_exec_queue_init(struct xe_exec_queue *q)
151151
return err;
152152
}
153153

154+
static void __xe_exec_queue_fini(struct xe_exec_queue *q)
155+
{
156+
int i;
157+
158+
q->ops->fini(q);
159+
160+
for (i = 0; i < q->width; ++i)
161+
xe_lrc_put(q->lrc[i]);
162+
}
163+
154164
struct xe_exec_queue *xe_exec_queue_create(struct xe_device *xe, struct xe_vm *vm,
155165
u32 logical_mask, u16 width,
156166
struct xe_hw_engine *hwe, u32 flags,
@@ -181,11 +191,13 @@ struct xe_exec_queue *xe_exec_queue_create(struct xe_device *xe, struct xe_vm *v
181191
if (xe_exec_queue_uses_pxp(q)) {
182192
err = xe_pxp_exec_queue_add(xe->pxp, q);
183193
if (err)
184-
goto err_post_alloc;
194+
goto err_post_init;
185195
}
186196

187197
return q;
188198

199+
err_post_init:
200+
__xe_exec_queue_fini(q);
189201
err_post_alloc:
190202
__xe_exec_queue_free(q);
191203
return ERR_PTR(err);
@@ -283,13 +295,11 @@ void xe_exec_queue_destroy(struct kref *ref)
283295
xe_exec_queue_put(eq);
284296
}
285297

286-
q->ops->fini(q);
298+
q->ops->destroy(q);
287299
}
288300

289301
void xe_exec_queue_fini(struct xe_exec_queue *q)
290302
{
291-
int i;
292-
293303
/*
294304
* Before releasing our ref to lrc and xef, accumulate our run ticks
295305
* and wakeup any waiters.
@@ -298,9 +308,7 @@ void xe_exec_queue_fini(struct xe_exec_queue *q)
298308
if (q->xef && atomic_dec_and_test(&q->xef->exec_queue.pending_removal))
299309
wake_up_var(&q->xef->exec_queue.pending_removal);
300310

301-
for (i = 0; i < q->width; ++i)
302-
xe_lrc_put(q->lrc[i]);
303-
311+
__xe_exec_queue_fini(q);
304312
__xe_exec_queue_free(q);
305313
}
306314

drivers/gpu/drm/xe/xe_exec_queue_types.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,14 @@ struct xe_exec_queue_ops {
166166
int (*init)(struct xe_exec_queue *q);
167167
/** @kill: Kill inflight submissions for backend */
168168
void (*kill)(struct xe_exec_queue *q);
169-
/** @fini: Fini exec queue for submission backend */
169+
/** @fini: Undoes the init() for submission backend */
170170
void (*fini)(struct xe_exec_queue *q);
171+
/**
172+
* @destroy: Destroy exec queue for submission backend. The backend
173+
* function must call xe_exec_queue_fini() (which will in turn call the
174+
* fini() backend function) to ensure the queue is properly cleaned up.
175+
*/
176+
void (*destroy)(struct xe_exec_queue *q);
171177
/** @set_priority: Set priority for exec queue */
172178
int (*set_priority)(struct xe_exec_queue *q,
173179
enum xe_exec_queue_priority priority);

drivers/gpu/drm/xe/xe_execlist.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,20 @@ static int execlist_exec_queue_init(struct xe_exec_queue *q)
385385
return err;
386386
}
387387

388-
static void execlist_exec_queue_fini_async(struct work_struct *w)
388+
static void execlist_exec_queue_fini(struct xe_exec_queue *q)
389+
{
390+
struct xe_execlist_exec_queue *exl = q->execlist;
391+
392+
drm_sched_entity_fini(&exl->entity);
393+
drm_sched_fini(&exl->sched);
394+
395+
kfree(exl);
396+
}
397+
398+
static void execlist_exec_queue_destroy_async(struct work_struct *w)
389399
{
390400
struct xe_execlist_exec_queue *ee =
391-
container_of(w, struct xe_execlist_exec_queue, fini_async);
401+
container_of(w, struct xe_execlist_exec_queue, destroy_async);
392402
struct xe_exec_queue *q = ee->q;
393403
struct xe_execlist_exec_queue *exl = q->execlist;
394404
struct xe_device *xe = gt_to_xe(q->gt);
@@ -401,10 +411,6 @@ static void execlist_exec_queue_fini_async(struct work_struct *w)
401411
list_del(&exl->active_link);
402412
spin_unlock_irqrestore(&exl->port->lock, flags);
403413

404-
drm_sched_entity_fini(&exl->entity);
405-
drm_sched_fini(&exl->sched);
406-
kfree(exl);
407-
408414
xe_exec_queue_fini(q);
409415
}
410416

@@ -413,10 +419,10 @@ static void execlist_exec_queue_kill(struct xe_exec_queue *q)
413419
/* NIY */
414420
}
415421

416-
static void execlist_exec_queue_fini(struct xe_exec_queue *q)
422+
static void execlist_exec_queue_destroy(struct xe_exec_queue *q)
417423
{
418-
INIT_WORK(&q->execlist->fini_async, execlist_exec_queue_fini_async);
419-
queue_work(system_unbound_wq, &q->execlist->fini_async);
424+
INIT_WORK(&q->execlist->destroy_async, execlist_exec_queue_destroy_async);
425+
queue_work(system_unbound_wq, &q->execlist->destroy_async);
420426
}
421427

422428
static int execlist_exec_queue_set_priority(struct xe_exec_queue *q,
@@ -467,6 +473,7 @@ static const struct xe_exec_queue_ops execlist_exec_queue_ops = {
467473
.init = execlist_exec_queue_init,
468474
.kill = execlist_exec_queue_kill,
469475
.fini = execlist_exec_queue_fini,
476+
.destroy = execlist_exec_queue_destroy,
470477
.set_priority = execlist_exec_queue_set_priority,
471478
.set_timeslice = execlist_exec_queue_set_timeslice,
472479
.set_preempt_timeout = execlist_exec_queue_set_preempt_timeout,

drivers/gpu/drm/xe/xe_execlist_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ struct xe_execlist_exec_queue {
4242

4343
bool has_run;
4444

45-
struct work_struct fini_async;
45+
struct work_struct destroy_async;
4646

4747
enum xe_exec_queue_priority active_priority;
4848
struct list_head active_link;

drivers/gpu/drm/xe/xe_gt.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include "xe_gt_topology.h"
4242
#include "xe_guc_exec_queue_types.h"
4343
#include "xe_guc_pc.h"
44+
#include "xe_guc_submit.h"
4445
#include "xe_hw_fence.h"
4546
#include "xe_hw_engine_class_sysfs.h"
4647
#include "xe_irq.h"
@@ -97,7 +98,7 @@ void xe_gt_sanitize(struct xe_gt *gt)
9798
* FIXME: if xe_uc_sanitize is called here, on TGL driver will not
9899
* reload
99100
*/
100-
gt->uc.guc.submission_state.enabled = false;
101+
xe_guc_submit_disable(&gt->uc.guc);
101102
}
102103

103104
static void xe_gt_enable_host_l2_vram(struct xe_gt *gt)

drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1632,7 +1632,6 @@ static u64 pf_estimate_fair_lmem(struct xe_gt *gt, unsigned int num_vfs)
16321632
u64 fair;
16331633

16341634
fair = div_u64(available, num_vfs);
1635-
fair = rounddown_pow_of_two(fair); /* XXX: ttm_vram_mgr & drm_buddy limitation */
16361635
fair = ALIGN_DOWN(fair, alignment);
16371636
#ifdef MAX_FAIR_LMEM
16381637
fair = min_t(u64, MAX_FAIR_LMEM, fair);

drivers/gpu/drm/xe/xe_guc.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -880,9 +880,7 @@ int xe_guc_post_load_init(struct xe_guc *guc)
880880
return ret;
881881
}
882882

883-
guc->submission_state.enabled = true;
884-
885-
return 0;
883+
return xe_guc_submit_enable(guc);
886884
}
887885

888886
int xe_guc_reset(struct xe_guc *guc)
@@ -1579,7 +1577,7 @@ void xe_guc_sanitize(struct xe_guc *guc)
15791577
{
15801578
xe_uc_fw_sanitize(&guc->fw);
15811579
xe_guc_ct_disable(&guc->ct);
1582-
guc->submission_state.enabled = false;
1580+
xe_guc_submit_disable(guc);
15831581
}
15841582

15851583
int xe_guc_reset_prepare(struct xe_guc *guc)

0 commit comments

Comments
 (0)