Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 3c1fa4aa60b1 ("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 393e5fea6f7d7054abc2c3d97a4cfe8306cd6079)
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

authored by

Tomasz Lis and committed by
Rodrigo Vivi
99f9b534 e377182f

+13 -13
+11 -12
drivers/gpu/drm/xe/xe_exec_queue.c
··· 266 266 return q; 267 267 } 268 268 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 + 269 279 static int __xe_exec_queue_init(struct xe_exec_queue *q, u32 exec_queue_flags) 270 280 { 271 281 int i, err; ··· 330 320 return 0; 331 321 332 322 err_lrc: 333 - for (i = i - 1; i >= 0; --i) 334 - xe_lrc_put(q->lrc[i]); 323 + __xe_exec_queue_fini(q); 335 324 return err; 336 - } 337 - 338 - static void __xe_exec_queue_fini(struct xe_exec_queue *q) 339 - { 340 - int i; 341 - 342 - q->ops->fini(q); 343 - 344 - for (i = 0; i < q->width; ++i) 345 - xe_lrc_put(q->lrc[i]); 346 325 } 347 326 348 327 struct xe_exec_queue *xe_exec_queue_create(struct xe_device *xe, struct xe_vm *vm,
+2 -1
drivers/gpu/drm/xe/xe_lrc.h
··· 75 75 */ 76 76 static inline void xe_lrc_put(struct xe_lrc *lrc) 77 77 { 78 - kref_put(&lrc->refcount, xe_lrc_destroy); 78 + if (lrc) 79 + kref_put(&lrc->refcount, xe_lrc_destroy); 79 80 } 80 81 81 82 /**