[PATCH 5/7] drm/xe: Cleanup unwind of gt initialization
Lucas De Marchi
lucas.demarchi at intel.com
Fri Jan 31 22:31:38 UTC 2025
Move the xe_gt_remove() to be handled by xe_gt.c itself so the caller,
xe_device_probe() doesn't have to unwind the gt loop. It's also more in
line with the xe_device_probe() style.
Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
---
drivers/gpu/drm/xe/xe_device.c | 21 ++-----------------
drivers/gpu/drm/xe/xe_gt.c | 37 ++++++++++++++++------------------
drivers/gpu/drm/xe/xe_gt.h | 1 -
3 files changed, 19 insertions(+), 40 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
index e519f435b1606..bea626f6b4cbf 100644
--- a/drivers/gpu/drm/xe/xe_device.c
+++ b/drivers/gpu/drm/xe/xe_device.c
@@ -743,7 +743,6 @@ int xe_device_probe(struct xe_device *xe)
struct xe_tile *tile;
struct xe_gt *gt;
int err;
- u8 last_gt;
u8 id;
xe_pat_init_early(xe);
@@ -851,18 +850,16 @@ int xe_device_probe(struct xe_device *xe)
return err;
for_each_gt(gt, xe, id) {
- last_gt = id;
-
err = xe_gt_init(gt);
if (err)
- goto err_fini_gt;
+ return err;
}
xe_heci_gsc_init(xe);
err = xe_oa_init(xe);
if (err)
- goto err_fini_gt;
+ return err;
err = xe_display_init(xe);
if (err)
@@ -895,14 +892,6 @@ int xe_device_probe(struct xe_device *xe)
err_fini_oa:
xe_oa_fini(xe);
-err_fini_gt:
- for_each_gt(gt, xe, id) {
- if (id < last_gt)
- xe_gt_remove(gt);
- else
- break;
- }
-
return err;
}
@@ -916,9 +905,6 @@ static void xe_device_remove_display(struct xe_device *xe)
void xe_device_remove(struct xe_device *xe)
{
- struct xe_gt *gt;
- u8 id;
-
xe_oa_unregister(xe);
xe_device_remove_display(xe);
@@ -926,9 +912,6 @@ void xe_device_remove(struct xe_device *xe)
xe_oa_fini(xe);
xe_heci_gsc_fini(xe);
-
- for_each_gt(gt, xe, id)
- xe_gt_remove(gt);
}
void xe_device_shutdown(struct xe_device *xe)
diff --git a/drivers/gpu/drm/xe/xe_gt.c b/drivers/gpu/drm/xe/xe_gt.c
index 01a4a852b8f43..48f6fd8c14b65 100644
--- a/drivers/gpu/drm/xe/xe_gt.c
+++ b/drivers/gpu/drm/xe/xe_gt.c
@@ -140,26 +140,6 @@ static void xe_gt_disable_host_l2_vram(struct xe_gt *gt)
xe_force_wake_put(gt_to_fw(gt), fw_ref);
}
-/**
- * xe_gt_remove() - Clean up the GT structures before driver removal
- * @gt: the GT object
- *
- * This function should only act on objects/structures that must be cleaned
- * before the driver removal callback is complete and therefore can't be
- * deferred to a drmm action.
- */
-void xe_gt_remove(struct xe_gt *gt)
-{
- int i;
-
- xe_uc_remove(>->uc);
-
- for (i = 0; i < XE_ENGINE_CLASS_MAX; ++i)
- xe_hw_fence_irq_finish(>->fence_irq[i]);
-
- xe_gt_disable_host_l2_vram(gt);
-}
-
static void gt_reset_worker(struct work_struct *w);
static int emit_nop_job(struct xe_gt *gt, struct xe_exec_queue *q)
@@ -582,6 +562,19 @@ int xe_gt_init_hwconfig(struct xe_gt *gt)
return err;
}
+static void xe_gt_remove(void *arg)
+{
+ struct xe_gt *gt = arg;
+ int i;
+
+ xe_uc_remove(>->uc);
+
+ for (i = 0; i < XE_ENGINE_CLASS_MAX; ++i)
+ xe_hw_fence_irq_finish(>->fence_irq[i]);
+
+ xe_gt_disable_host_l2_vram(gt);
+}
+
int xe_gt_init(struct xe_gt *gt)
{
int err;
@@ -594,6 +587,10 @@ int xe_gt_init(struct xe_gt *gt)
xe_hw_fence_irq_init(>->fence_irq[i]);
}
+ err = devm_add_action_or_reset(gt_to_xe(gt)->drm.dev, xe_gt_remove, gt);
+ if (err)
+ return err;
+
err = xe_gt_pagefault_init(gt);
if (err)
return err;
diff --git a/drivers/gpu/drm/xe/xe_gt.h b/drivers/gpu/drm/xe/xe_gt.h
index e504cc33ade4f..187fa6490eafc 100644
--- a/drivers/gpu/drm/xe/xe_gt.h
+++ b/drivers/gpu/drm/xe/xe_gt.h
@@ -54,7 +54,6 @@ int xe_gt_resume(struct xe_gt *gt);
void xe_gt_reset_async(struct xe_gt *gt);
void xe_gt_sanitize(struct xe_gt *gt);
int xe_gt_sanitize_freq(struct xe_gt *gt);
-void xe_gt_remove(struct xe_gt *gt);
/**
* xe_gt_wait_for_reset - wait for gt's async reset to finalize.
--
2.48.0
More information about the Intel-xe
mailing list