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

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 <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>

authored by

Ilia Levi and committed by
Rodrigo Vivi
aeb4ae66 3adcf970

+22 -20
+18 -5
drivers/gpu/drm/xe/xe_execlist.c
··· 123 123 if (!port->running_exl) 124 124 return; 125 125 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); 128 128 port->running_exl = NULL; 129 129 } 130 130 ··· 254 254 { 255 255 struct drm_device *drm = &xe->drm; 256 256 struct xe_execlist_port *port; 257 - int i; 257 + int i, err; 258 258 259 259 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 + } 262 264 263 265 port->hwe = hwe; 266 + 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 + } 264 272 265 273 spin_lock_init(&port->lock); 266 274 for (i = 0; i < ARRAY_SIZE(port->active); i++) ··· 285 277 add_timer(&port->irq_fail); 286 278 287 279 return port; 280 + 281 + err: 282 + return ERR_PTR(err); 288 283 } 289 284 290 285 void xe_execlist_port_destroy(struct xe_execlist_port *port) ··· 298 287 spin_lock_irq(&gt_to_xe(port->hwe->gt)->irq.lock); 299 288 port->hwe->irq_handler = NULL; 300 289 spin_unlock_irq(&gt_to_xe(port->hwe->gt)->irq.lock); 290 + 291 + xe_lrc_put(port->lrc); 301 292 } 302 293 303 294 static struct dma_fence *
+2
drivers/gpu/drm/xe/xe_execlist_types.h
··· 27 27 struct xe_execlist_exec_queue *running_exl; 28 28 29 29 struct timer_list irq_fail; 30 + 31 + struct xe_lrc *lrc; 30 32 }; 31 33 32 34 struct xe_execlist_exec_queue {
+2 -13
drivers/gpu/drm/xe/xe_hw_engine.c
··· 273 273 274 274 if (hwe->exl_port) 275 275 xe_execlist_port_destroy(hwe->exl_port); 276 - xe_lrc_put(hwe->kernel_lrc); 277 276 278 277 hwe->gt = NULL; 279 278 } ··· 557 558 goto err_name; 558 559 } 559 560 560 - hwe->kernel_lrc = xe_lrc_create(hwe, NULL, SZ_16K); 561 - if (IS_ERR(hwe->kernel_lrc)) { 562 - err = PTR_ERR(hwe->kernel_lrc); 563 - goto err_hwsp; 564 - } 565 - 566 561 if (!xe_device_uc_enabled(xe)) { 567 562 hwe->exl_port = xe_execlist_port_create(xe, hwe); 568 563 if (IS_ERR(hwe->exl_port)) { 569 564 err = PTR_ERR(hwe->exl_port); 570 - goto err_kernel_lrc; 565 + goto err_hwsp; 571 566 } 572 - } 573 - 574 - if (xe_device_uc_enabled(xe)) { 567 + } else { 575 568 /* GSCCS has a special interrupt for reset */ 576 569 if (hwe->class == XE_ENGINE_CLASS_OTHER) 577 570 hwe->irq_handler = xe_gsc_hwe_irq_handler; ··· 578 587 579 588 return devm_add_action_or_reset(xe->drm.dev, hw_engine_fini, hwe); 580 589 581 - err_kernel_lrc: 582 - xe_lrc_put(hwe->kernel_lrc); 583 590 err_hwsp: 584 591 xe_bo_unpin_map_no_vm(hwe->hwsp); 585 592 err_name:
-2
drivers/gpu/drm/xe/xe_hw_engine_types.h
··· 136 136 enum xe_force_wake_domains domain; 137 137 /** @hwsp: hardware status page buffer object */ 138 138 struct xe_bo *hwsp; 139 - /** @kernel_lrc: Kernel LRC (should be replaced /w an xe_engine) */ 140 - struct xe_lrc *kernel_lrc; 141 139 /** @exl_port: execlists port */ 142 140 struct xe_execlist_port *exl_port; 143 141 /** @fence_irq: fence IRQ to run when a hw engine IRQ is received */