1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2023 Intel Corporation
4  */
5 
6 #ifndef _XE_GUC_SUBMIT_TYPES_H_
7 #define _XE_GUC_SUBMIT_TYPES_H_
8 
9 #include "xe_hw_engine_types.h"
10 
11 /* Work item for submitting workloads into work queue of GuC. */
12 #define WQ_STATUS_ACTIVE		1
13 #define WQ_STATUS_SUSPENDED		2
14 #define WQ_STATUS_CMD_ERROR		3
15 #define WQ_STATUS_ENGINE_ID_NOT_USED	4
16 #define WQ_STATUS_SUSPENDED_FROM_RESET	5
17 #define WQ_TYPE_NOOP			0x4
18 #define WQ_TYPE_MULTI_LRC		0x5
19 #define WQ_TYPE_MASK			GENMASK(7, 0)
20 #define WQ_LEN_MASK			GENMASK(26, 16)
21 
22 #define WQ_GUC_ID_MASK			GENMASK(15, 0)
23 #define WQ_RING_TAIL_MASK		GENMASK(28, 18)
24 
25 #define PARALLEL_SCRATCH_SIZE	2048
26 #define WQ_SIZE			(PARALLEL_SCRATCH_SIZE / 2)
27 #define WQ_OFFSET		(PARALLEL_SCRATCH_SIZE - WQ_SIZE)
28 #define CACHELINE_BYTES		64
29 
30 struct guc_sched_wq_desc {
31 	u32 head;
32 	u32 tail;
33 	u32 error_offset;
34 	u32 wq_status;
35 	u32 reserved[28];
36 } __packed;
37 
38 struct sync_semaphore {
39 	u32 semaphore;
40 	u8 unused[CACHELINE_BYTES - sizeof(u32)];
41 };
42 
43 /**
44  * struct guc_submit_parallel_scratch - A scratch shared mapped buffer.
45  */
46 struct guc_submit_parallel_scratch {
47 	/** @wq_desc: Guc scheduler workqueue descriptor */
48 	struct guc_sched_wq_desc wq_desc;
49 
50 	/** @go: Go Semaphore */
51 	struct sync_semaphore go;
52 	/** @join: Joined semaphore for the relevant hw engine instances */
53 	struct sync_semaphore join[XE_HW_ENGINE_MAX_INSTANCE];
54 
55 	/** @unused: Unused/Reserved memory space */
56 	u8 unused[WQ_OFFSET - sizeof(struct guc_sched_wq_desc) -
57 		  sizeof(struct sync_semaphore) *
58 		  (XE_HW_ENGINE_MAX_INSTANCE + 1)];
59 
60 	/** @wq: Workqueue info */
61 	u32 wq[WQ_SIZE / sizeof(u32)];
62 };
63 
64 struct lrc_snapshot {
65 	u32 context_desc;
66 	u32 head;
67 	struct {
68 		u32 internal;
69 		u32 memory;
70 	} tail;
71 	u32 start_seqno;
72 	u32 seqno;
73 };
74 
75 struct pending_list_snapshot {
76 	u32 seqno;
77 	bool fence;
78 	bool finished;
79 };
80 
81 /**
82  * struct xe_guc_submit_exec_queue_snapshot - Snapshot for devcoredump
83  */
84 struct xe_guc_submit_exec_queue_snapshot {
85 	/** @name: name of this exec queue */
86 	char name[MAX_FENCE_NAME_LEN];
87 	/** @class: class of this exec queue */
88 	enum xe_engine_class class;
89 	/**
90 	 * @logical_mask: logical mask of where job submitted to exec queue can run
91 	 */
92 	u32 logical_mask;
93 	/** @width: width (number BB submitted per exec) of this exec queue */
94 	u16 width;
95 	/** @refcount: ref count of this exec queue */
96 	u32 refcount;
97 	/**
98 	 * @sched_timeout: the time after which a job is removed from the
99 	 * scheduler.
100 	 */
101 	long sched_timeout;
102 
103 	/** @sched_props: scheduling properties */
104 	struct {
105 		/** @timeslice_us: timeslice period in micro-seconds */
106 		u32 timeslice_us;
107 		/** @preempt_timeout_us: preemption timeout in micro-seconds */
108 		u32 preempt_timeout_us;
109 	} sched_props;
110 
111 	/** @lrc: LRC Snapshot */
112 	struct lrc_snapshot *lrc;
113 
114 	/** @schedule_state: Schedule State at the moment of Crash */
115 	u32 schedule_state;
116 	/** @exec_queue_flags: Flags of the faulty exec_queue */
117 	unsigned long exec_queue_flags;
118 
119 	/** @guc: GuC Engine Snapshot */
120 	struct {
121 		/** @wqi_head: work queue item head */
122 		u32 wqi_head;
123 		/** @wqi_tail: work queue item tail */
124 		u32 wqi_tail;
125 		/** @id: GuC id for this exec_queue */
126 		u16 id;
127 	} guc;
128 
129 	/**
130 	 * @parallel_execution: Indication if the failure was during parallel
131 	 * execution
132 	 */
133 	bool parallel_execution;
134 	/** @parallel: snapshot of the useful parallel scratch */
135 	struct {
136 		/** @wq_desc: Workqueue description */
137 		struct {
138 			/** @head: Workqueue Head */
139 			u32 head;
140 			/** @tail: Workqueue Tail */
141 			u32 tail;
142 			/** @status: Workqueue Status */
143 			u32 status;
144 		} wq_desc;
145 		/** @wq: Workqueue Items */
146 		u32 wq[WQ_SIZE / sizeof(u32)];
147 	} parallel;
148 
149 	/** @pending_list_size: Size of the pending list snapshot array */
150 	int pending_list_size;
151 	/** @pending_list: snapshot of the pending list info */
152 	struct pending_list_snapshot *pending_list;
153 };
154 
155 #endif
156