drm/xe: move the kernel lrc from hwe to execlist port
authorIlia Levi <ilia.levi@intel.com>
Mon, 26 Aug 2024 10:06:55 +0000 (13:06 +0300)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Wed, 28 Aug 2024 18:50:13 +0000 (14:50 -0400)
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 <ilia.levi@intel.com>
Reviewed-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240826100655.1719060-1-ilia.levi@intel.com
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
drivers/gpu/drm/xe/xe_execlist.c
drivers/gpu/drm/xe/xe_execlist_types.h
drivers/gpu/drm/xe/xe_hw_engine.c
drivers/gpu/drm/xe/xe_hw_engine_types.h

index 7502e3486eafa7d5f5f0e024f752f8e26a06a3b8..6a59165b95690802ef8bcf66b0ea949e9ee03884 100644 (file)
@@ -123,8 +123,8 @@ static void __xe_execlist_port_idle(struct xe_execlist_port *port)
        if (!port->running_exl)
                return;
 
-       xe_lrc_write_ring(port->hwe->kernel_lrc, noop, sizeof(noop));
-       __start_lrc(port->hwe, port->hwe->kernel_lrc, 0);
+       xe_lrc_write_ring(port->lrc, noop, sizeof(noop));
+       __start_lrc(port->hwe, port->lrc, 0);
        port->running_exl = NULL;
 }
 
@@ -254,14 +254,22 @@ struct xe_execlist_port *xe_execlist_port_create(struct xe_device *xe,
 {
        struct drm_device *drm = &xe->drm;
        struct xe_execlist_port *port;
-       int i;
+       int i, err;
 
        port = drmm_kzalloc(drm, sizeof(*port), GFP_KERNEL);
-       if (!port)
-               return ERR_PTR(-ENOMEM);
+       if (!port) {
+               err = -ENOMEM;
+               goto err;
+       }
 
        port->hwe = hwe;
 
+       port->lrc = xe_lrc_create(hwe, NULL, SZ_16K);
+       if (IS_ERR(port->lrc)) {
+               err = PTR_ERR(port->lrc);
+               goto err;
+       }
+
        spin_lock_init(&port->lock);
        for (i = 0; i < ARRAY_SIZE(port->active); i++)
                INIT_LIST_HEAD(&port->active[i]);
@@ -277,6 +285,9 @@ struct xe_execlist_port *xe_execlist_port_create(struct xe_device *xe,
        add_timer(&port->irq_fail);
 
        return port;
+
+err:
+       return ERR_PTR(err);
 }
 
 void xe_execlist_port_destroy(struct xe_execlist_port *port)
@@ -287,6 +298,8 @@ void xe_execlist_port_destroy(struct xe_execlist_port *port)
        spin_lock_irq(&gt_to_xe(port->hwe->gt)->irq.lock);
        port->hwe->irq_handler = NULL;
        spin_unlock_irq(&gt_to_xe(port->hwe->gt)->irq.lock);
+
+       xe_lrc_put(port->lrc);
 }
 
 static struct dma_fence *
index f94bbf4c53e43fa5e637b2945fa6da6080ed8b16..415140936f11da49ed988606c81fba0a3e471de9 100644 (file)
@@ -27,6 +27,8 @@ struct xe_execlist_port {
        struct xe_execlist_exec_queue *running_exl;
 
        struct timer_list irq_fail;
+
+       struct xe_lrc *lrc;
 };
 
 struct xe_execlist_exec_queue {
index 18980238a2ea1b937e2a38abc965fd48061d41a9..a094bc71a5631370701b9e548d4c3594287b1e2d 100644 (file)
@@ -273,7 +273,6 @@ static void hw_engine_fini(void *arg)
 
        if (hwe->exl_port)
                xe_execlist_port_destroy(hwe->exl_port);
-       xe_lrc_put(hwe->kernel_lrc);
 
        hwe->gt = NULL;
 }
@@ -558,21 +557,13 @@ static int hw_engine_init(struct xe_gt *gt, struct xe_hw_engine *hwe,
                goto err_name;
        }
 
-       hwe->kernel_lrc = xe_lrc_create(hwe, NULL, SZ_16K);
-       if (IS_ERR(hwe->kernel_lrc)) {
-               err = PTR_ERR(hwe->kernel_lrc);
-               goto err_hwsp;
-       }
-
        if (!xe_device_uc_enabled(xe)) {
                hwe->exl_port = xe_execlist_port_create(xe, hwe);
                if (IS_ERR(hwe->exl_port)) {
                        err = PTR_ERR(hwe->exl_port);
-                       goto err_kernel_lrc;
+                       goto err_hwsp;
                }
-       }
-
-       if (xe_device_uc_enabled(xe)) {
+       } else {
                /* GSCCS has a special interrupt for reset */
                if (hwe->class == XE_ENGINE_CLASS_OTHER)
                        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,
 
        return devm_add_action_or_reset(xe->drm.dev, hw_engine_fini, hwe);
 
-err_kernel_lrc:
-       xe_lrc_put(hwe->kernel_lrc);
 err_hwsp:
        xe_bo_unpin_map_no_vm(hwe->hwsp);
 err_name:
index 39f24012d0f4693c826f16f4ec52f9c28d62350a..8be6d420ece40bead73f2bdadbc94f5da4e83316 100644 (file)
@@ -136,8 +136,6 @@ struct xe_hw_engine {
        enum xe_force_wake_domains domain;
        /** @hwsp: hardware status page buffer object */
        struct xe_bo *hwsp;
-       /** @kernel_lrc: Kernel LRC (should be replaced /w an xe_engine) */
-       struct xe_lrc *kernel_lrc;
        /** @exl_port: execlists port */
        struct xe_execlist_port *exl_port;
        /** @fence_irq: fence IRQ to run when a hw engine IRQ is received */