Skip to content

Commit aeb4ae6

Browse files
illevirodrigovivi
authored andcommitted
drm/xe: move the kernel lrc from hwe to execlist port
The kernel lrc is used solely by the execlist infra. Move it to the execlist port struct and initialize it only when execlists are used. v2: Rebase, improve error handling readability (Jonathan) Signed-off-by: Ilia Levi <[email protected]> Reviewed-by: Jonathan Cavitt <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Rodrigo Vivi <[email protected]>
1 parent 3adcf97 commit aeb4ae6

File tree

4 files changed

+22
-20
lines changed

4 files changed

+22
-20
lines changed

drivers/gpu/drm/xe/xe_execlist.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ static void __xe_execlist_port_idle(struct xe_execlist_port *port)
123123
if (!port->running_exl)
124124
return;
125125

126-
xe_lrc_write_ring(port->hwe->kernel_lrc, noop, sizeof(noop));
127-
__start_lrc(port->hwe, port->hwe->kernel_lrc, 0);
126+
xe_lrc_write_ring(port->lrc, noop, sizeof(noop));
127+
__start_lrc(port->hwe, port->lrc, 0);
128128
port->running_exl = NULL;
129129
}
130130

@@ -254,14 +254,22 @@ struct xe_execlist_port *xe_execlist_port_create(struct xe_device *xe,
254254
{
255255
struct drm_device *drm = &xe->drm;
256256
struct xe_execlist_port *port;
257-
int i;
257+
int i, err;
258258

259259
port = drmm_kzalloc(drm, sizeof(*port), GFP_KERNEL);
260-
if (!port)
261-
return ERR_PTR(-ENOMEM);
260+
if (!port) {
261+
err = -ENOMEM;
262+
goto err;
263+
}
262264

263265
port->hwe = hwe;
264266

267+
port->lrc = xe_lrc_create(hwe, NULL, SZ_16K);
268+
if (IS_ERR(port->lrc)) {
269+
err = PTR_ERR(port->lrc);
270+
goto err;
271+
}
272+
265273
spin_lock_init(&port->lock);
266274
for (i = 0; i < ARRAY_SIZE(port->active); i++)
267275
INIT_LIST_HEAD(&port->active[i]);
@@ -277,6 +285,9 @@ struct xe_execlist_port *xe_execlist_port_create(struct xe_device *xe,
277285
add_timer(&port->irq_fail);
278286

279287
return port;
288+
289+
err:
290+
return ERR_PTR(err);
280291
}
281292

282293
void xe_execlist_port_destroy(struct xe_execlist_port *port)
@@ -287,6 +298,8 @@ void xe_execlist_port_destroy(struct xe_execlist_port *port)
287298
spin_lock_irq(&gt_to_xe(port->hwe->gt)->irq.lock);
288299
port->hwe->irq_handler = NULL;
289300
spin_unlock_irq(&gt_to_xe(port->hwe->gt)->irq.lock);
301+
302+
xe_lrc_put(port->lrc);
290303
}
291304

292305
static struct dma_fence *

drivers/gpu/drm/xe/xe_execlist_types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ struct xe_execlist_port {
2727
struct xe_execlist_exec_queue *running_exl;
2828

2929
struct timer_list irq_fail;
30+
31+
struct xe_lrc *lrc;
3032
};
3133

3234
struct xe_execlist_exec_queue {

drivers/gpu/drm/xe/xe_hw_engine.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ static void hw_engine_fini(void *arg)
273273

274274
if (hwe->exl_port)
275275
xe_execlist_port_destroy(hwe->exl_port);
276-
xe_lrc_put(hwe->kernel_lrc);
277276

278277
hwe->gt = NULL;
279278
}
@@ -558,21 +557,13 @@ static int hw_engine_init(struct xe_gt *gt, struct xe_hw_engine *hwe,
558557
goto err_name;
559558
}
560559

561-
hwe->kernel_lrc = xe_lrc_create(hwe, NULL, SZ_16K);
562-
if (IS_ERR(hwe->kernel_lrc)) {
563-
err = PTR_ERR(hwe->kernel_lrc);
564-
goto err_hwsp;
565-
}
566-
567560
if (!xe_device_uc_enabled(xe)) {
568561
hwe->exl_port = xe_execlist_port_create(xe, hwe);
569562
if (IS_ERR(hwe->exl_port)) {
570563
err = PTR_ERR(hwe->exl_port);
571-
goto err_kernel_lrc;
564+
goto err_hwsp;
572565
}
573-
}
574-
575-
if (xe_device_uc_enabled(xe)) {
566+
} else {
576567
/* GSCCS has a special interrupt for reset */
577568
if (hwe->class == XE_ENGINE_CLASS_OTHER)
578569
hwe->irq_handler = xe_gsc_hwe_irq_handler;
@@ -587,8 +578,6 @@ static int hw_engine_init(struct xe_gt *gt, struct xe_hw_engine *hwe,
587578

588579
return devm_add_action_or_reset(xe->drm.dev, hw_engine_fini, hwe);
589580

590-
err_kernel_lrc:
591-
xe_lrc_put(hwe->kernel_lrc);
592581
err_hwsp:
593582
xe_bo_unpin_map_no_vm(hwe->hwsp);
594583
err_name:

drivers/gpu/drm/xe/xe_hw_engine_types.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,6 @@ struct xe_hw_engine {
136136
enum xe_force_wake_domains domain;
137137
/** @hwsp: hardware status page buffer object */
138138
struct xe_bo *hwsp;
139-
/** @kernel_lrc: Kernel LRC (should be replaced /w an xe_engine) */
140-
struct xe_lrc *kernel_lrc;
141139
/** @exl_port: execlists port */
142140
struct xe_execlist_port *exl_port;
143141
/** @fence_irq: fence IRQ to run when a hw engine IRQ is received */

0 commit comments

Comments
 (0)