1/* SPDX-License-Identifier: MIT */
2/*
3 * Copyright �� 2023 Intel Corporation
4 */
5
6#ifndef _XE_DEVCOREDUMP_TYPES_H_
7#define _XE_DEVCOREDUMP_TYPES_H_
8
9#include <linux/ktime.h>
10#include <linux/mutex.h>
11
12#include "xe_hw_engine_types.h"
13
14struct xe_device;
15struct xe_gt;
16
17/**
18 * struct xe_devcoredump_snapshot - Crash snapshot
19 *
20 * This struct contains all the useful information quickly captured at the time
21 * of the crash. So, any subsequent reads of the coredump points to a data that
22 * shows the state of the GPU of when the issue has happened.
23 */
24struct xe_devcoredump_snapshot {
25	/** @snapshot_time:  Time of this capture. */
26	ktime_t snapshot_time;
27	/** @boot_time:  Relative boot time so the uptime can be calculated. */
28	ktime_t boot_time;
29
30	/** @gt: Affected GT, used by forcewake for delayed capture */
31	struct xe_gt *gt;
32	/** @work: Workqueue for deferred capture outside of signaling context */
33	struct work_struct work;
34
35	/* GuC snapshots */
36	/** @ct: GuC CT snapshot */
37	struct xe_guc_ct_snapshot *ct;
38	/** @ge: Guc Engine snapshot */
39	struct xe_guc_submit_exec_queue_snapshot *ge;
40
41	/** @hwe: HW Engine snapshot array */
42	struct xe_hw_engine_snapshot *hwe[XE_NUM_HW_ENGINES];
43	/** @job: Snapshot of job state */
44	struct xe_sched_job_snapshot *job;
45	/** @vm: Snapshot of VM state */
46	struct xe_vm_snapshot *vm;
47};
48
49/**
50 * struct xe_devcoredump - Xe devcoredump main structure
51 *
52 * This struct represents the live and active dev_coredump node.
53 * It is created/populated at the time of a crash/error. Then it
54 * is read later when user access the device coredump data file
55 * for reading the information.
56 */
57struct xe_devcoredump {
58	/** @captured: The snapshot of the first hang has already been taken. */
59	bool captured;
60	/** @snapshot: Snapshot is captured at time of the first crash */
61	struct xe_devcoredump_snapshot snapshot;
62};
63
64#endif
65