Skip to content

Commit 96bfe9f

Browse files
committed
Merge tag 'drm-xe-fixes-2026-03-05' of https://gitlab.freedesktop.org/drm/xe/kernel into drm-fixes
Cross-subsystem Changes: - mm: Fix a hmm_range_fault() livelock / starvation problem (Thomas) Core Changes: - Revert "drm/pagemap: Disable device-to-device migration" (Thomas) Driver Changes: - Do not preempt fence signaling CS instructions (Brost) - Some leak and finalization fixes (Shuicheng, Tomasz, Varun, Zhanjun) - Workaround fix (Roper) Signed-off-by: Dave Airlie <airlied@redhat.com> From: Rodrigo Vivi <rodrigo.vivi@intel.com> Link: https://patch.msgid.link/aamGvvGRBRtX8-6u@intel.com
2 parents 4319899 + 0cfe9c4 commit 96bfe9f

15 files changed

Lines changed: 100 additions & 53 deletions

drivers/gpu/drm/drm_pagemap.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -480,18 +480,8 @@ int drm_pagemap_migrate_to_devmem(struct drm_pagemap_devmem *devmem_allocation,
480480
.start = start,
481481
.end = end,
482482
.pgmap_owner = pagemap->owner,
483-
/*
484-
* FIXME: MIGRATE_VMA_SELECT_DEVICE_PRIVATE intermittently
485-
* causes 'xe_exec_system_allocator --r *race*no*' to trigger aa
486-
* engine reset and a hard hang due to getting stuck on a folio
487-
* lock. This should work and needs to be root-caused. The only
488-
* downside of not selecting MIGRATE_VMA_SELECT_DEVICE_PRIVATE
489-
* is that device-to-device migrations won’t work; instead,
490-
* memory will bounce through system memory. This path should be
491-
* rare and only occur when the madvise attributes of memory are
492-
* changed or atomics are being used.
493-
*/
494-
.flags = MIGRATE_VMA_SELECT_SYSTEM | MIGRATE_VMA_SELECT_DEVICE_COHERENT,
483+
.flags = MIGRATE_VMA_SELECT_SYSTEM | MIGRATE_VMA_SELECT_DEVICE_COHERENT |
484+
MIGRATE_VMA_SELECT_DEVICE_PRIVATE,
495485
};
496486
unsigned long i, npages = npages_in_range(start, end);
497487
unsigned long own_pages = 0, migrated_pages = 0;

drivers/gpu/drm/xe/xe_configfs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,7 @@ static void xe_config_device_release(struct config_item *item)
830830

831831
mutex_destroy(&dev->lock);
832832

833+
kfree(dev->config.ctx_restore_mid_bb[0].cs);
833834
kfree(dev->config.ctx_restore_post_bb[0].cs);
834835
kfree(dev);
835836
}

drivers/gpu/drm/xe/xe_exec_queue.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,16 @@ static struct xe_exec_queue *__xe_exec_queue_alloc(struct xe_device *xe,
266266
return q;
267267
}
268268

269+
static void __xe_exec_queue_fini(struct xe_exec_queue *q)
270+
{
271+
int i;
272+
273+
q->ops->fini(q);
274+
275+
for (i = 0; i < q->width; ++i)
276+
xe_lrc_put(q->lrc[i]);
277+
}
278+
269279
static int __xe_exec_queue_init(struct xe_exec_queue *q, u32 exec_queue_flags)
270280
{
271281
int i, err;
@@ -320,21 +330,10 @@ static int __xe_exec_queue_init(struct xe_exec_queue *q, u32 exec_queue_flags)
320330
return 0;
321331

322332
err_lrc:
323-
for (i = i - 1; i >= 0; --i)
324-
xe_lrc_put(q->lrc[i]);
333+
__xe_exec_queue_fini(q);
325334
return err;
326335
}
327336

328-
static void __xe_exec_queue_fini(struct xe_exec_queue *q)
329-
{
330-
int i;
331-
332-
q->ops->fini(q);
333-
334-
for (i = 0; i < q->width; ++i)
335-
xe_lrc_put(q->lrc[i]);
336-
}
337-
338337
struct xe_exec_queue *xe_exec_queue_create(struct xe_device *xe, struct xe_vm *vm,
339338
u32 logical_mask, u16 width,
340339
struct xe_hw_engine *hwe, u32 flags,

drivers/gpu/drm/xe/xe_gsc_proxy.c

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -435,15 +435,11 @@ static int proxy_channel_alloc(struct xe_gsc *gsc)
435435
return 0;
436436
}
437437

438-
static void xe_gsc_proxy_remove(void *arg)
438+
static void xe_gsc_proxy_stop(struct xe_gsc *gsc)
439439
{
440-
struct xe_gsc *gsc = arg;
441440
struct xe_gt *gt = gsc_to_gt(gsc);
442441
struct xe_device *xe = gt_to_xe(gt);
443442

444-
if (!gsc->proxy.component_added)
445-
return;
446-
447443
/* disable HECI2 IRQs */
448444
scoped_guard(xe_pm_runtime, xe) {
449445
CLASS(xe_force_wake, fw_ref)(gt_to_fw(gt), XE_FW_GSC);
@@ -455,6 +451,30 @@ static void xe_gsc_proxy_remove(void *arg)
455451
}
456452

457453
xe_gsc_wait_for_worker_completion(gsc);
454+
gsc->proxy.started = false;
455+
}
456+
457+
static void xe_gsc_proxy_remove(void *arg)
458+
{
459+
struct xe_gsc *gsc = arg;
460+
struct xe_gt *gt = gsc_to_gt(gsc);
461+
struct xe_device *xe = gt_to_xe(gt);
462+
463+
if (!gsc->proxy.component_added)
464+
return;
465+
466+
/*
467+
* GSC proxy start is an async process that can be ongoing during
468+
* Xe module load/unload. Using devm managed action to register
469+
* xe_gsc_proxy_stop could cause issues if Xe module unload has
470+
* already started when the action is registered, potentially leading
471+
* to the cleanup being called at the wrong time. Therefore, instead
472+
* of registering a separate devm action to undo what is done in
473+
* proxy start, we call it from here, but only if the start has
474+
* completed successfully (tracked with the 'started' flag).
475+
*/
476+
if (gsc->proxy.started)
477+
xe_gsc_proxy_stop(gsc);
458478

459479
component_del(xe->drm.dev, &xe_gsc_proxy_component_ops);
460480
gsc->proxy.component_added = false;
@@ -510,6 +530,7 @@ int xe_gsc_proxy_init(struct xe_gsc *gsc)
510530
*/
511531
int xe_gsc_proxy_start(struct xe_gsc *gsc)
512532
{
533+
struct xe_gt *gt = gsc_to_gt(gsc);
513534
int err;
514535

515536
/* enable the proxy interrupt in the GSC shim layer */
@@ -521,12 +542,18 @@ int xe_gsc_proxy_start(struct xe_gsc *gsc)
521542
*/
522543
err = xe_gsc_proxy_request_handler(gsc);
523544
if (err)
524-
return err;
545+
goto err_irq_disable;
525546

526547
if (!xe_gsc_proxy_init_done(gsc)) {
527-
xe_gt_err(gsc_to_gt(gsc), "GSC FW reports proxy init not completed\n");
528-
return -EIO;
548+
xe_gt_err(gt, "GSC FW reports proxy init not completed\n");
549+
err = -EIO;
550+
goto err_irq_disable;
529551
}
530552

553+
gsc->proxy.started = true;
531554
return 0;
555+
556+
err_irq_disable:
557+
gsc_proxy_irq_toggle(gsc, false);
558+
return err;
532559
}

drivers/gpu/drm/xe/xe_gsc_types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ struct xe_gsc {
5858
struct mutex mutex;
5959
/** @proxy.component_added: whether the component has been added */
6060
bool component_added;
61+
/** @proxy.started: whether the proxy has been started */
62+
bool started;
6163
/** @proxy.bo: object to store message to and from the GSC */
6264
struct xe_bo *bo;
6365
/** @proxy.to_gsc: map of the memory used to send messages to the GSC */

drivers/gpu/drm/xe/xe_lrc.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ static inline struct xe_lrc *xe_lrc_get(struct xe_lrc *lrc)
7575
*/
7676
static inline void xe_lrc_put(struct xe_lrc *lrc)
7777
{
78-
kref_put(&lrc->refcount, xe_lrc_destroy);
78+
if (lrc)
79+
kref_put(&lrc->refcount, xe_lrc_destroy);
7980
}
8081

8182
/**

drivers/gpu/drm/xe/xe_reg_sr.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,12 @@ int xe_reg_sr_add(struct xe_reg_sr *sr,
9898
*pentry = *e;
9999
ret = xa_err(xa_store(&sr->xa, idx, pentry, GFP_KERNEL));
100100
if (ret)
101-
goto fail;
101+
goto fail_free;
102102

103103
return 0;
104104

105+
fail_free:
106+
kfree(pentry);
105107
fail:
106108
xe_gt_err(gt,
107109
"discarding save-restore reg %04lx (clear: %08x, set: %08x, masked: %s, mcr: %s): ret=%d\n",

drivers/gpu/drm/xe/xe_ring_ops.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,9 @@ static void __emit_job_gen12_simple(struct xe_sched_job *job, struct xe_lrc *lrc
280280

281281
i = emit_bb_start(batch_addr, ppgtt_flag, dw, i);
282282

283+
/* Don't preempt fence signaling */
284+
dw[i++] = MI_ARB_ON_OFF | MI_ARB_DISABLE;
285+
283286
if (job->user_fence.used) {
284287
i = emit_flush_dw(dw, i);
285288
i = emit_store_imm_ppgtt_posted(job->user_fence.addr,
@@ -345,6 +348,9 @@ static void __emit_job_gen12_video(struct xe_sched_job *job, struct xe_lrc *lrc,
345348

346349
i = emit_bb_start(batch_addr, ppgtt_flag, dw, i);
347350

351+
/* Don't preempt fence signaling */
352+
dw[i++] = MI_ARB_ON_OFF | MI_ARB_DISABLE;
353+
348354
if (job->user_fence.used) {
349355
i = emit_flush_dw(dw, i);
350356
i = emit_store_imm_ppgtt_posted(job->user_fence.addr,
@@ -397,6 +403,9 @@ static void __emit_job_gen12_render_compute(struct xe_sched_job *job,
397403

398404
i = emit_bb_start(batch_addr, ppgtt_flag, dw, i);
399405

406+
/* Don't preempt fence signaling */
407+
dw[i++] = MI_ARB_ON_OFF | MI_ARB_DISABLE;
408+
400409
i = emit_render_cache_flush(job, dw, i);
401410

402411
if (job->user_fence.used)

drivers/gpu/drm/xe/xe_vm_madvise.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ int xe_vm_madvise_ioctl(struct drm_device *dev, void *data, struct drm_file *fil
453453
madvise_range.num_vmas,
454454
args->atomic.val)) {
455455
err = -EINVAL;
456-
goto madv_fini;
456+
goto free_vmas;
457457
}
458458
}
459459

@@ -490,6 +490,7 @@ int xe_vm_madvise_ioctl(struct drm_device *dev, void *data, struct drm_file *fil
490490
err_fini:
491491
if (madvise_range.has_bo_vmas)
492492
drm_exec_fini(&exec);
493+
free_vmas:
493494
kfree(madvise_range.vmas);
494495
madvise_range.vmas = NULL;
495496
madv_fini:

drivers/gpu/drm/xe/xe_wa.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,13 @@ static const struct xe_rtp_entry_sr gt_was[] = {
241241

242242
{ XE_RTP_NAME("16025250150"),
243243
XE_RTP_RULES(GRAPHICS_VERSION(2001)),
244-
XE_RTP_ACTIONS(SET(LSN_VC_REG2,
245-
LSN_LNI_WGT(1) |
246-
LSN_LNE_WGT(1) |
247-
LSN_DIM_X_WGT(1) |
248-
LSN_DIM_Y_WGT(1) |
249-
LSN_DIM_Z_WGT(1)))
244+
XE_RTP_ACTIONS(FIELD_SET(LSN_VC_REG2,
245+
LSN_LNI_WGT_MASK | LSN_LNE_WGT_MASK |
246+
LSN_DIM_X_WGT_MASK | LSN_DIM_Y_WGT_MASK |
247+
LSN_DIM_Z_WGT_MASK,
248+
LSN_LNI_WGT(1) | LSN_LNE_WGT(1) |
249+
LSN_DIM_X_WGT(1) | LSN_DIM_Y_WGT(1) |
250+
LSN_DIM_Z_WGT(1)))
250251
},
251252

252253
/* Xe2_HPM */

0 commit comments

Comments
 (0)