Skip to content

Commit 4d33ed6

Browse files
committed
Merge tag 'drm-xe-fixes-2025-07-17' of https://gitlab.freedesktop.org/drm/xe/kernel into drm-fixes
Driver Changes: - SR-IOV fixes for GT reset and TLB invalidation - Fix memory copy direction during migration - Fix alignment check on migration - Fix MOCS and page fault init order to correctly account for topology Signed-off-by: Dave Airlie <[email protected]> From: Lucas De Marchi <[email protected]> Link: https://lore.kernel.org/r/6jworkgupwstm4v7aohbuzod3dyz4u7pyfhshr5ifgf2xisgj3@cm5em5yupjiu
2 parents 4399e3d + 5c244ee commit 4d33ed6

File tree

6 files changed

+72
-20
lines changed

6 files changed

+72
-20
lines changed

drivers/gpu/drm/xe/xe_gt.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,8 @@ int xe_gt_init_early(struct xe_gt *gt)
417417
if (err)
418418
return err;
419419

420+
xe_mocs_init_early(gt);
421+
420422
return 0;
421423
}
422424

@@ -630,17 +632,15 @@ int xe_gt_init(struct xe_gt *gt)
630632
if (err)
631633
return err;
632634

633-
err = xe_gt_pagefault_init(gt);
635+
err = xe_gt_sysfs_init(gt);
634636
if (err)
635637
return err;
636638

637-
xe_mocs_init_early(gt);
638-
639-
err = xe_gt_sysfs_init(gt);
639+
err = gt_fw_domain_init(gt);
640640
if (err)
641641
return err;
642642

643-
err = gt_fw_domain_init(gt);
643+
err = xe_gt_pagefault_init(gt);
644644
if (err)
645645
return err;
646646

@@ -839,6 +839,9 @@ static int gt_reset(struct xe_gt *gt)
839839
goto err_out;
840840
}
841841

842+
if (IS_SRIOV_PF(gt_to_xe(gt)))
843+
xe_gt_sriov_pf_stop_prepare(gt);
844+
842845
xe_uc_gucrc_disable(&gt->uc);
843846
xe_uc_stop_prepare(&gt->uc);
844847
xe_gt_pagefault_reset(gt);

drivers/gpu/drm/xe/xe_gt_sriov_pf.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,25 @@ void xe_gt_sriov_pf_sanitize_hw(struct xe_gt *gt, unsigned int vfid)
172172
pf_clear_vf_scratch_regs(gt, vfid);
173173
}
174174

175+
static void pf_cancel_restart(struct xe_gt *gt)
176+
{
177+
xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt)));
178+
179+
if (cancel_work_sync(&gt->sriov.pf.workers.restart))
180+
xe_gt_sriov_dbg_verbose(gt, "pending restart canceled!\n");
181+
}
182+
183+
/**
184+
* xe_gt_sriov_pf_stop_prepare() - Prepare to stop SR-IOV support.
185+
* @gt: the &xe_gt
186+
*
187+
* This function can only be called on the PF.
188+
*/
189+
void xe_gt_sriov_pf_stop_prepare(struct xe_gt *gt)
190+
{
191+
pf_cancel_restart(gt);
192+
}
193+
175194
static void pf_restart(struct xe_gt *gt)
176195
{
177196
struct xe_device *xe = gt_to_xe(gt);

drivers/gpu/drm/xe/xe_gt_sriov_pf.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ int xe_gt_sriov_pf_init_early(struct xe_gt *gt);
1313
int xe_gt_sriov_pf_init(struct xe_gt *gt);
1414
void xe_gt_sriov_pf_init_hw(struct xe_gt *gt);
1515
void xe_gt_sriov_pf_sanitize_hw(struct xe_gt *gt, unsigned int vfid);
16+
void xe_gt_sriov_pf_stop_prepare(struct xe_gt *gt);
1617
void xe_gt_sriov_pf_restart(struct xe_gt *gt);
1718
#else
1819
static inline int xe_gt_sriov_pf_init_early(struct xe_gt *gt)
@@ -29,6 +30,10 @@ static inline void xe_gt_sriov_pf_init_hw(struct xe_gt *gt)
2930
{
3031
}
3132

33+
static inline void xe_gt_sriov_pf_stop_prepare(struct xe_gt *gt)
34+
{
35+
}
36+
3237
static inline void xe_gt_sriov_pf_restart(struct xe_gt *gt)
3338
{
3439
}

drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2364,6 +2364,21 @@ int xe_gt_sriov_pf_config_restore(struct xe_gt *gt, unsigned int vfid,
23642364
return err;
23652365
}
23662366

2367+
static int pf_push_self_config(struct xe_gt *gt)
2368+
{
2369+
int err;
2370+
2371+
err = pf_push_full_vf_config(gt, PFID);
2372+
if (err) {
2373+
xe_gt_sriov_err(gt, "Failed to push self configuration (%pe)\n",
2374+
ERR_PTR(err));
2375+
return err;
2376+
}
2377+
2378+
xe_gt_sriov_dbg_verbose(gt, "self configuration completed\n");
2379+
return 0;
2380+
}
2381+
23672382
static void fini_config(void *arg)
23682383
{
23692384
struct xe_gt *gt = arg;
@@ -2387,9 +2402,17 @@ static void fini_config(void *arg)
23872402
int xe_gt_sriov_pf_config_init(struct xe_gt *gt)
23882403
{
23892404
struct xe_device *xe = gt_to_xe(gt);
2405+
int err;
23902406

23912407
xe_gt_assert(gt, IS_SRIOV_PF(xe));
23922408

2409+
mutex_lock(xe_gt_sriov_pf_master_mutex(gt));
2410+
err = pf_push_self_config(gt);
2411+
mutex_unlock(xe_gt_sriov_pf_master_mutex(gt));
2412+
2413+
if (err)
2414+
return err;
2415+
23932416
return devm_add_action_or_reset(xe->drm.dev, fini_config, gt);
23942417
}
23952418

@@ -2407,6 +2430,10 @@ void xe_gt_sriov_pf_config_restart(struct xe_gt *gt)
24072430
unsigned int n, total_vfs = xe_sriov_pf_get_totalvfs(gt_to_xe(gt));
24082431
unsigned int fail = 0, skip = 0;
24092432

2433+
mutex_lock(xe_gt_sriov_pf_master_mutex(gt));
2434+
pf_push_self_config(gt);
2435+
mutex_unlock(xe_gt_sriov_pf_master_mutex(gt));
2436+
24102437
for (n = 1; n <= total_vfs; n++) {
24112438
if (xe_gt_sriov_pf_config_is_empty(gt, n))
24122439
skip++;

drivers/gpu/drm/xe/xe_migrate.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,8 +1817,8 @@ int xe_migrate_access_memory(struct xe_migrate *m, struct xe_bo *bo,
18171817
xe_bo_assert_held(bo);
18181818

18191819
/* Use bounce buffer for small access and unaligned access */
1820-
if (len & XE_CACHELINE_MASK ||
1821-
((uintptr_t)buf | offset) & XE_CACHELINE_MASK) {
1820+
if (!IS_ALIGNED(len, XE_CACHELINE_BYTES) ||
1821+
!IS_ALIGNED((unsigned long)buf + offset, XE_CACHELINE_BYTES)) {
18221822
int buf_offset = 0;
18231823

18241824
/*
@@ -1848,7 +1848,7 @@ int xe_migrate_access_memory(struct xe_migrate *m, struct xe_bo *bo,
18481848
err = xe_migrate_access_memory(m, bo,
18491849
offset & ~XE_CACHELINE_MASK,
18501850
(void *)ptr,
1851-
sizeof(bounce), 0);
1851+
sizeof(bounce), write);
18521852
if (err)
18531853
return err;
18541854
} else {

drivers/gpu/drm/xe/xe_ring_ops.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,14 @@ static int emit_bb_start(u64 batch_addr, u32 ppgtt_flag, u32 *dw, int i)
110110
return i;
111111
}
112112

113-
static int emit_flush_invalidate(u32 *dw, int i)
113+
static int emit_flush_invalidate(u32 addr, u32 val, u32 *dw, int i)
114114
{
115115
dw[i++] = MI_FLUSH_DW | MI_INVALIDATE_TLB | MI_FLUSH_DW_OP_STOREDW |
116-
MI_FLUSH_IMM_DW | MI_FLUSH_DW_STORE_INDEX;
117-
dw[i++] = LRC_PPHWSP_FLUSH_INVAL_SCRATCH_ADDR;
118-
dw[i++] = 0;
116+
MI_FLUSH_IMM_DW;
117+
118+
dw[i++] = addr | MI_FLUSH_DW_USE_GTT;
119119
dw[i++] = 0;
120+
dw[i++] = val;
120121

121122
return i;
122123
}
@@ -397,23 +398,20 @@ static void __emit_job_gen12_render_compute(struct xe_sched_job *job,
397398
static void emit_migration_job_gen12(struct xe_sched_job *job,
398399
struct xe_lrc *lrc, u32 seqno)
399400
{
401+
u32 saddr = xe_lrc_start_seqno_ggtt_addr(lrc);
400402
u32 dw[MAX_JOB_SIZE_DW], i = 0;
401403

402404
i = emit_copy_timestamp(lrc, dw, i);
403405

404-
i = emit_store_imm_ggtt(xe_lrc_start_seqno_ggtt_addr(lrc),
405-
seqno, dw, i);
406+
i = emit_store_imm_ggtt(saddr, seqno, dw, i);
406407

407408
dw[i++] = MI_ARB_ON_OFF | MI_ARB_DISABLE; /* Enabled again below */
408409

409410
i = emit_bb_start(job->ptrs[0].batch_addr, BIT(8), dw, i);
410411

411-
if (!IS_SRIOV_VF(gt_to_xe(job->q->gt))) {
412-
/* XXX: Do we need this? Leaving for now. */
413-
dw[i++] = preparser_disable(true);
414-
i = emit_flush_invalidate(dw, i);
415-
dw[i++] = preparser_disable(false);
416-
}
412+
dw[i++] = preparser_disable(true);
413+
i = emit_flush_invalidate(saddr, seqno, dw, i);
414+
dw[i++] = preparser_disable(false);
417415

418416
i = emit_bb_start(job->ptrs[1].batch_addr, BIT(8), dw, i);
419417

0 commit comments

Comments
 (0)