Skip to content

Commit d72312d

Browse files
tomaszliThomas Hellström
authored andcommitted
drm/xe: Protect against unset LRC when pausing submissions
While pausing submissions, it is possible to encouner an exec queue which is during creation, and therefore doesn't have a valid xe_lrc struct reference. Protect agains such situation, by checking for NULL before access. Reviewed-by: Matthew Brost <matthew.brost@intel.com> Fixes: c25c101 ("drm/xe/vf: Replay GuC submission state on pause / unpause") Signed-off-by: Tomasz Lis <tomasz.lis@intel.com> Signed-off-by: Matthew Brost <matthew.brost@intel.com> Link: https://patch.msgid.link/20251124222853.1900800-1-tomasz.lis@intel.com (cherry picked from commit 07cf4b8) Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
1 parent 3d98a71 commit d72312d

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

drivers/gpu/drm/xe/xe_guc_submit.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2112,6 +2112,18 @@ static void guc_exec_queue_revert_pending_state_change(struct xe_guc *guc,
21122112
q->guc->resume_time = 0;
21132113
}
21142114

2115+
static void lrc_parallel_clear(struct xe_lrc *lrc)
2116+
{
2117+
struct xe_device *xe = gt_to_xe(lrc->gt);
2118+
struct iosys_map map = xe_lrc_parallel_map(lrc);
2119+
int i;
2120+
2121+
for (i = 0; i < WQ_SIZE / sizeof(u32); ++i)
2122+
parallel_write(xe, map, wq[i],
2123+
FIELD_PREP(WQ_TYPE_MASK, WQ_TYPE_NOOP) |
2124+
FIELD_PREP(WQ_LEN_MASK, 0));
2125+
}
2126+
21152127
/*
21162128
* This function is quite complex but only real way to ensure no state is lost
21172129
* during VF resume flows. The function scans the queue state, make adjustments
@@ -2135,19 +2147,17 @@ static void guc_exec_queue_pause(struct xe_guc *guc, struct xe_exec_queue *q)
21352147
guc_exec_queue_revert_pending_state_change(guc, q);
21362148

21372149
if (xe_exec_queue_is_parallel(q)) {
2138-
struct xe_device *xe = guc_to_xe(guc);
2139-
struct iosys_map map = xe_lrc_parallel_map(q->lrc[0]);
2150+
/* Pairs with WRITE_ONCE in __xe_exec_queue_init */
2151+
struct xe_lrc *lrc = READ_ONCE(q->lrc[0]);
21402152

21412153
/*
21422154
* NOP existing WQ commands that may contain stale GGTT
21432155
* addresses. These will be replayed upon unpause. The hardware
21442156
* seems to get confused if the WQ head/tail pointers are
21452157
* adjusted.
21462158
*/
2147-
for (i = 0; i < WQ_SIZE / sizeof(u32); ++i)
2148-
parallel_write(xe, map, wq[i],
2149-
FIELD_PREP(WQ_TYPE_MASK, WQ_TYPE_NOOP) |
2150-
FIELD_PREP(WQ_LEN_MASK, 0));
2159+
if (lrc)
2160+
lrc_parallel_clear(lrc);
21512161
}
21522162

21532163
job = xe_sched_first_pending_job(sched);

0 commit comments

Comments
 (0)