Skip to content

Commit 99f9b53

Browse files
tomaszlirodrigovivi
authored andcommitted
drm/xe/queue: Call fini on exec queue creation fail
Every call to queue init should have a corresponding fini call. Skipping this would mean skipping removal of the queue from GuC list (which is part of guc_id allocation). A damaged queue stored in exec_queue_lookup list would lead to invalid memory reference, sooner or later. Call fini to free guc_id. This must be done before any internal LRCs are freed. Since the finalization with this extra call became very similar to __xe_exec_queue_fini(), reuse that. To make this reuse possible, alter xe_lrc_put() so it can survive NULL parameters, like other similar functions. v2: Reuse _xe_exec_queue_fini(). Make xe_lrc_put() aware of NULLs. Fixes: 3c1fa4a ("drm/xe: Move queue init before LRC creation") Signed-off-by: Tomasz Lis <tomasz.lis@intel.com> Reviewed-by: Matthew Brost <matthew.brost@intel.com> (v1) Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com> Link: https://patch.msgid.link/20260226212701.2937065-2-tomasz.lis@intel.com (cherry picked from commit 393e5fe) Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
1 parent e377182 commit 99f9b53

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

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_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
/**

0 commit comments

Comments
 (0)