[PATCH V14 3/9] drm/xe: Link LRC BO and its execution Queue
Tejas Upadhyay <[email protected]> Thu, 30 Jul 2026 15:41:25 +0530
| Newsgroups | org.freedesktop.lists.intel-xe |
|---|---|
| Message-ID | <[email protected]> |
To establish a link between an LRC BO (Logical Ring Context Buffer Object) and its corresponding execution Queue in the drm/xe driver, you need to store a back-pointer to the queue within the BO's private data structure. This allows the driver to identify and take corrective action on the specific queue if the LRC BO encounters an error (e.g., memory corruption or eviction issues). V3(Sashiko): - Placeholder of 8 byte for non-lrc bo is acceptable - Assign bo-q is safe just use READ_ONCE/WRITE_ONCE V2(MattB): - Handle multiqueue Signed-off-by: Tejas Upadhyay <[email protected]> --- drivers/gpu/drm/xe/xe_bo_types.h | 3 +++ drivers/gpu/drm/xe/xe_exec_queue.c | 6 ++++++ drivers/gpu/drm/xe/xe_lrc.c | 1 + 3 files changed, 10 insertions(+) diff --git a/drivers/gpu/drm/xe/xe_bo_types.h b/drivers/gpu/drm/xe/xe_bo_types.h index e45f24301050..a9c48e440669 100644 --- a/drivers/gpu/drm/xe/xe_bo_types.h +++ b/drivers/gpu/drm/xe/xe_bo_types.h @@ -20,6 +20,7 @@ struct xe_device; struct xe_mem_pool_node; struct xe_vm; +struct xe_exec_queue; #define XE_BO_MAX_PLACEMENTS 3 @@ -42,6 +43,8 @@ struct xe_bo { u32 flags; /** @vm: VM this BO is attached to, for extobj this will be NULL */ struct xe_vm *vm; + /** @q: Queue this BO is attached to, mostly for LRC BO, NULL otherwise */ + struct xe_exec_queue *q; /** @tile: Tile this BO is attached to (kernel BO only) */ struct xe_tile *tile; /** @placements: valid placements for this BO */ diff --git a/drivers/gpu/drm/xe/xe_exec_queue.c b/drivers/gpu/drm/xe/xe_exec_queue.c index 38972b6e6d37..ab81a512fb41 100644 --- a/drivers/gpu/drm/xe/xe_exec_queue.c +++ b/drivers/gpu/drm/xe/xe_exec_queue.c @@ -390,6 +390,12 @@ static int __xe_exec_queue_init(struct xe_exec_queue *q, u32 exec_queue_flags) goto err_lrc; } + /* + * The queue ref counts the LRCs, thus it safe for the LRC BO to hold a + * pointer to queue without reference. The reader holds dma_resv ( + * xe_bo_lock) which serializes with xe_lrc_finish(). + */ + WRITE_ONCE(lrc->bo->q, xe_exec_queue_multi_queue_primary(q)); xe_exec_queue_set_lrc(q, lrc, i); if (__lrc) diff --git a/drivers/gpu/drm/xe/xe_lrc.c b/drivers/gpu/drm/xe/xe_lrc.c index 3e7c995085d0..ee77106b06bc 100644 --- a/drivers/gpu/drm/xe/xe_lrc.c +++ b/drivers/gpu/drm/xe/xe_lrc.c @@ -1066,6 +1066,7 @@ static void xe_lrc_set_ppgtt(struct xe_lrc *lrc, struct xe_vm *vm) static void xe_lrc_finish(struct xe_lrc *lrc) { xe_hw_fence_ctx_finish(&lrc->fence_ctx); + WRITE_ONCE(lrc->bo->q, NULL); xe_bo_unpin_map_no_vm(lrc->bo); xe_bo_unpin_map_no_vm(lrc->seqno_bo); } -- 2.52.0