[RFC 3/5] drm/xe: Disconnect coredump structure from xe_device structure
John.C.Harrison at Intel.com
John.C.Harrison at Intel.com
Sat Nov 9 01:59:32 UTC 2024
From: John Harrison <John.C.Harrison at 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 at 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 = >->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
More information about the Intel-xe
mailing list