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

authored by

Tomasz Lis and committed by
Michal Wajdeczko
393e5fea 223b2f51

+13 -13
+11 -12
drivers/gpu/drm/xe/xe_exec_queue.c
··· 270 270 return q; 271 271 } 272 272 273 + static void __xe_exec_queue_fini(struct xe_exec_queue *q) 274 + { 275 + int i; 276 + 277 + q->ops->fini(q); 278 + 279 + for (i = 0; i < q->width; ++i) 280 + xe_lrc_put(q->lrc[i]); 281 + } 282 + 273 283 static int __xe_exec_queue_init(struct xe_exec_queue *q, u32 exec_queue_flags) 274 284 { 275 285 int i, err; ··· 334 324 return 0; 335 325 336 326 err_lrc: 337 - for (i = i - 1; i >= 0; --i) 338 - xe_lrc_put(q->lrc[i]); 327 + __xe_exec_queue_fini(q); 339 328 return err; 340 - } 341 - 342 - static void __xe_exec_queue_fini(struct xe_exec_queue *q) 343 - { 344 - int i; 345 - 346 - q->ops->fini(q); 347 - 348 - for (i = 0; i < q->width; ++i) 349 - xe_lrc_put(q->lrc[i]); 350 329 } 351 330 352 331 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 /**