Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Lucas De Marchi <lucas.demarchi@intel.com>
To: <intel-xe@lists.freedesktop.org>
Cc: Matt Roper <matthew.d.roper@intel.com>,
	Rodrigo Vivi <rodrigo.vivi@intel.com>,
	Francois Dugast <francois.dugast@intel.com>,
	Maarten Lankhorst <dev@lankhorst.se>,
	Lucas De Marchi <lucas.demarchi@intel.com>
Subject: [PATCH 7/7] drm/xe: Move oa fini to xe_oa
Date: Fri, 31 Jan 2025 14:31:40 -0800	[thread overview]
Message-ID: <20250131223140.4144292-8-lucas.demarchi@intel.com> (raw)
In-Reply-To: <20250131223140.4144292-1-lucas.demarchi@intel.com>

Like done with other functions, cleanup the error handling in
xe_device_probe() by moving the OA fini to be handled by xe_oa.

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 drivers/gpu/drm/xe/xe_device.c |  7 +----
 drivers/gpu/drm/xe/xe_oa.c     | 48 +++++++++++++++++-----------------
 drivers/gpu/drm/xe/xe_oa.h     |  1 -
 3 files changed, 25 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
index bea626f6b4cbf..aa6632cc22305 100644
--- a/drivers/gpu/drm/xe/xe_device.c
+++ b/drivers/gpu/drm/xe/xe_device.c
@@ -863,7 +863,7 @@ int xe_device_probe(struct xe_device *xe)
 
 	err = xe_display_init(xe);
 	if (err)
-		goto err_fini_oa;
+		return err;
 
 	err = drm_dev_register(&xe->drm, 0);
 	if (err)
@@ -889,9 +889,6 @@ int xe_device_probe(struct xe_device *xe)
 err_fini_display:
 	xe_display_driver_remove(xe);
 
-err_fini_oa:
-	xe_oa_fini(xe);
-
 	return err;
 }
 
@@ -909,8 +906,6 @@ void xe_device_remove(struct xe_device *xe)
 
 	xe_device_remove_display(xe);
 
-	xe_oa_fini(xe);
-
 	xe_heci_gsc_fini(xe);
 }
 
diff --git a/drivers/gpu/drm/xe/xe_oa.c b/drivers/gpu/drm/xe/xe_oa.c
index fa873f3d0a9d1..2c640185bdeca 100644
--- a/drivers/gpu/drm/xe/xe_oa.c
+++ b/drivers/gpu/drm/xe/xe_oa.c
@@ -2641,6 +2641,27 @@ static void xe_oa_init_supported_formats(struct xe_oa *oa)
 	}
 }
 
+static int destroy_config(int id, void *p, void *data)
+{
+	xe_oa_config_put(p);
+
+	return 0;
+}
+
+static void xe_oa_fini(void *arg)
+{
+	struct xe_device *xe = arg;
+	struct xe_oa *oa = &xe->oa;
+
+	if (!oa->xe)
+		return;
+
+	idr_for_each(&oa->metrics_idr, destroy_config, oa);
+	idr_destroy(&oa->metrics_idr);
+
+	oa->xe = NULL;
+}
+
 /**
  * xe_oa_init - OA initialization during device probe
  * @xe: @xe_device
@@ -2672,31 +2693,10 @@ int xe_oa_init(struct xe_device *xe)
 	}
 
 	xe_oa_init_supported_formats(oa);
-	return 0;
-exit:
-	oa->xe = NULL;
-	return ret;
-}
 
-static int destroy_config(int id, void *p, void *data)
-{
-	xe_oa_config_put(p);
-	return 0;
-}
-
-/**
- * xe_oa_fini - OA de-initialization during device remove
- * @xe: @xe_device
- */
-void xe_oa_fini(struct xe_device *xe)
-{
-	struct xe_oa *oa = &xe->oa;
-
-	if (!oa->xe)
-		return;
-
-	idr_for_each(&oa->metrics_idr, destroy_config, oa);
-	idr_destroy(&oa->metrics_idr);
+	return devm_add_action_or_reset(xe->drm.dev, xe_oa_fini, xe);
 
+exit:
 	oa->xe = NULL;
+	return ret;
 }
diff --git a/drivers/gpu/drm/xe/xe_oa.h b/drivers/gpu/drm/xe/xe_oa.h
index 87a38820c317d..eb36ce250c615 100644
--- a/drivers/gpu/drm/xe/xe_oa.h
+++ b/drivers/gpu/drm/xe/xe_oa.h
@@ -15,7 +15,6 @@ struct xe_gt;
 struct xe_hw_engine;
 
 int xe_oa_init(struct xe_device *xe);
-void xe_oa_fini(struct xe_device *xe);
 void xe_oa_register(struct xe_device *xe);
 void xe_oa_unregister(struct xe_device *xe);
 int xe_oa_stream_open_ioctl(struct drm_device *dev, u64 data, struct drm_file *file);
-- 
2.48.0


  parent reply	other threads:[~2025-01-31 22:32 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-31 22:31 [PATCH 0/7] Cleanup error handling on probe Lucas De Marchi
2025-01-31 22:31 ` [PATCH 1/7] drm/xe: Fix xe_display_fini() calls Lucas De Marchi
2025-02-03 20:32   ` Rodrigo Vivi
2025-01-31 22:31 ` [PATCH 2/7] drm/xe: Fix error handling in xe_irq_install() Lucas De Marchi
2025-02-03 20:36   ` Rodrigo Vivi
2025-01-31 22:31 ` [PATCH 3/7] drm/xe: Fix xe_tile_init_noalloc() error propagation Lucas De Marchi
2025-02-03 14:21   ` Francois Dugast
2025-01-31 22:31 ` [PATCH 4/7] drm/xe: Stop ignoring errors from xe_ttm_stolen_mgr_init() Lucas De Marchi
2025-02-03 14:10   ` Francois Dugast
2025-01-31 22:31 ` [PATCH 5/7] drm/xe: Cleanup unwind of gt initialization Lucas De Marchi
2025-02-01  6:24   ` Raag Jadav
2025-02-01 15:55     ` Lucas De Marchi
2025-02-02  8:09       ` Raag Jadav
2025-01-31 22:31 ` [PATCH 6/7] drm/xe: Cleanup extra calls to xe_hw_fence_irq_finish() Lucas De Marchi
2025-02-03 21:46   ` Rodrigo Vivi
2025-01-31 22:31 ` Lucas De Marchi [this message]
2025-01-31 22:37 ` ✓ CI.Patch_applied: success for Cleanup error handling on probe Patchwork
2025-01-31 22:37 ` ✓ CI.checkpatch: " Patchwork
2025-01-31 22:38 ` ✓ CI.KUnit: " Patchwork
2025-01-31 22:55 ` ✓ CI.Build: " Patchwork
2025-01-31 22:57 ` ✓ CI.Hooks: " Patchwork
2025-01-31 22:59 ` ✓ CI.checksparse: " Patchwork
2025-01-31 23:32 ` ✗ Xe.CI.BAT: failure " Patchwork
2025-02-01  8:05 ` ✗ Xe.CI.Full: " Patchwork
2025-02-03 18:39 ` [PATCH 0/7] " Lucas De Marchi
2025-02-04  8:58 ` Tvrtko Ursulin
2025-02-04 14:50   ` Lucas De Marchi
2025-02-04 18:10     ` Tvrtko Ursulin
2025-02-04 22:42       ` Rodrigo Vivi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250131223140.4144292-8-lucas.demarchi@intel.com \
    --to=lucas.demarchi@intel.com \
    --cc=dev@lankhorst.se \
    --cc=francois.dugast@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.d.roper@intel.com \
    --cc=rodrigo.vivi@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox