Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: John.C.Harrison@Intel.com
To: Intel-Xe@Lists.FreeDesktop.Org
Cc: John Harrison <John.C.Harrison@Intel.com>
Subject: [RFC 3/5] drm/xe: Disconnect coredump structure from xe_device structure
Date: Fri,  8 Nov 2024 17:59:32 -0800	[thread overview]
Message-ID: <20241109015934.2203462-4-John.C.Harrison@Intel.com> (raw)
In-Reply-To: <20241109015934.2203462-1-John.C.Harrison@Intel.com>

From: John Harrison <John.C.Harrison@Intel.com>

The devcoredump code is currently assuming that there is only ever one
coredump object and it lives inside an xe_device object. This will not
be the case shortly. So break that assumption and add a direct link
from the coredump back to the xe instead.

Signed-off-by: John Harrison <John.C.Harrison@Intel.com>
---
 drivers/gpu/drm/xe/xe_devcoredump.c       | 25 ++++++++++-------------
 drivers/gpu/drm/xe/xe_devcoredump_types.h |  2 ++
 2 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_devcoredump.c b/drivers/gpu/drm/xe/xe_devcoredump.c
index f0fcc898b3ae..53dc79506094 100644
--- a/drivers/gpu/drm/xe/xe_devcoredump.c
+++ b/drivers/gpu/drm/xe/xe_devcoredump.c
@@ -69,11 +69,6 @@
 /* 1 hour timeout */
 #define XE_COREDUMP_TIMEOUT_JIFFIES (60 * 60 * HZ)
 
-static struct xe_device *coredump_to_xe(const struct xe_devcoredump *coredump)
-{
-	return container_of(coredump, struct xe_device, devcoredump);
-}
-
 static struct xe_guc *exec_queue_to_guc(struct xe_exec_queue *q)
 {
 	return &q->gt->uc.guc;
@@ -82,14 +77,13 @@ static struct xe_guc *exec_queue_to_guc(struct xe_exec_queue *q)
 static ssize_t __xe_devcoredump_read(char *buffer, size_t count,
 				     struct xe_devcoredump *coredump)
 {
-	struct xe_device *xe;
+	struct xe_device *xe = coredump->xe;
 	struct xe_devcoredump_snapshot *ss;
 	struct drm_printer p;
 	struct drm_print_iterator iter;
 	struct timespec64 ts;
 	int i;
 
-	xe = coredump_to_xe(coredump);
 	ss = &coredump->snapshot;
 
 	iter.data = buffer;
@@ -221,7 +215,7 @@ static void xe_devcoredump_free(void *data)
 	struct xe_devcoredump *coredump = data;
 
 	/* Our device is gone. Nothing to do... */
-	if (!data || !coredump_to_xe(coredump))
+	if (!data)
 		return;
 
 	cancel_work_sync(&coredump->snapshot.work);
@@ -233,8 +227,10 @@ static void xe_devcoredump_free(void *data)
 	memset(&coredump->snapshot, 0, sizeof(coredump->snapshot));
 	coredump->captured = false;
 	coredump->job = NULL;
-	drm_info(&coredump_to_xe(coredump)->drm,
-		 "Xe device coredump has been deleted.\n");
+
+	/* Only report to user when freeing the sysfs accessible dump */
+	if (coredump == &coredump->xe->devcoredump)
+		drm_info(&coredump->xe->drm, "Xe device coredump has been deleted.\n");
 }
 
 static void devcoredump_snapshot_job(struct xe_devcoredump *coredump,
@@ -298,7 +294,7 @@ static void devcoredump_snapshot_gt(struct xe_devcoredump *coredump, struct xe_g
 	xe_force_wake_put(gt_to_fw(gt), fw_ref);
 }
 
-static void devcoredump_snapshot_xe(struct xe_devcoredump *coredump, struct xe_device *xe)
+static void devcoredump_snapshot_xe(struct xe_devcoredump *coredump)
 {
 	struct xe_devcoredump_snapshot *ss = &coredump->snapshot;
 
@@ -309,7 +305,7 @@ static void devcoredump_snapshot_xe(struct xe_devcoredump *coredump, struct xe_d
 	struct xe_gt *gt;
 	int i;
 
-	for_each_gt(gt, xe, i) {
+	for_each_gt(gt, coredump->xe, i) {
 		struct xe_gt_snapshot *ss_gt;
 		struct xe_guc *guc = &gt->uc.guc;
 		unsigned int fw_ref;
@@ -340,7 +336,7 @@ static void devcoredump_snapshot_for_thing(struct xe_devcoredump *coredump,
 	struct xe_device *xe;
 	bool cookie;
 
-	xe = coredump_to_xe(coredump);
+	xe = coredump->xe;
 
 	xe_assert(xe, !coredump->captured);
 	coredump->captured = true;
@@ -358,7 +354,7 @@ static void devcoredump_snapshot_for_thing(struct xe_devcoredump *coredump,
 	else if (gt)
 		devcoredump_snapshot_gt(coredump, gt);
 	else
-		devcoredump_snapshot_xe(coredump, xe);
+		devcoredump_snapshot_xe(coredump);
 
 	queue_work(system_unbound_wq, &ss->work);
 
@@ -378,6 +374,7 @@ static void devcoredump_for_thing(struct xe_device *_xe, struct xe_gt *gt, struc
 		return;
 	}
 
+	coredump->xe = xe;
 	devcoredump_snapshot_for_thing(coredump, gt, job);
 
 	drm_info(&xe->drm, "Xe device coredump has been created\n");
diff --git a/drivers/gpu/drm/xe/xe_devcoredump_types.h b/drivers/gpu/drm/xe/xe_devcoredump_types.h
index 3703ddea1252..cf0233c268d1 100644
--- a/drivers/gpu/drm/xe/xe_devcoredump_types.h
+++ b/drivers/gpu/drm/xe/xe_devcoredump_types.h
@@ -76,6 +76,8 @@ struct xe_devcoredump_snapshot {
  * for reading the information.
  */
 struct xe_devcoredump {
+	/** @xe: Related Xe device */
+	struct xe_device *xe;
 	/** @captured: The snapshot of the first hang has already been taken. */
 	bool captured;
 	/** @snapshot: Snapshot is captured at time of the first crash */
-- 
2.47.0


  parent reply	other threads:[~2024-11-09  1:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-09  1:59 [RFC 0/5] drm/xe: Support capture and dump of devcoredump for general debug John.C.Harrison
2024-11-09  1:59 ` [RFC 1/5] drm/xe/devcoredump: Support coredumps without jobs John.C.Harrison
2024-11-09  1:59 ` [RFC 2/5] drm/xe: Trigger a devcoredump capture on a GT reset John.C.Harrison
2024-11-09  1:59 ` John.C.Harrison [this message]
2024-11-09  1:59 ` [RFC 4/5] drm/xe: Make coredump printing to in-memory cache optional John.C.Harrison
2024-11-09  1:59 ` [RFC 5/5] drm/xe: Support devcoredump capture from dead CT handler John.C.Harrison
2024-11-09  2:05 ` ✓ CI.Patch_applied: success for drm/xe: Support capture and dump of devcoredump for general debug Patchwork
2024-11-09  2:05 ` ✗ CI.checkpatch: warning " Patchwork
2024-11-09  2:06 ` ✓ CI.KUnit: success " Patchwork
2024-11-09  2:18 ` ✓ CI.Build: " Patchwork
2024-11-09  2:20 ` ✓ CI.Hooks: " Patchwork
2024-11-09  2:22 ` ✓ CI.checksparse: " Patchwork
2024-11-09  2:39 ` ✓ CI.BAT: " Patchwork
2024-11-10  3:58 ` ✗ CI.FULL: failure " Patchwork

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=20241109015934.2203462-4-John.C.Harrison@Intel.com \
    --to=john.c.harrison@intel.com \
    --cc=Intel-Xe@Lists.FreeDesktop.Org \
    /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