xref: /linux/drivers/gpu/drm/xe/xe_guc_submit_types.h (revision 95f27831ee3c6afc2e3b7386c32545eba1f096d7)
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 /**
65  * struct xe_guc_submit_exec_queue_snapshot - Snapshot for devcoredump
66  */
67 struct xe_guc_submit_exec_queue_snapshot {
68 	/** @name: name of this exec queue */
69 	char name[MAX_FENCE_NAME_LEN];
70 	/** @class: class of this exec queue */
71 	enum xe_engine_class class;
72 	/**
73 	 * @logical_mask: logical mask of where job submitted to exec queue can run
74 	 */
75 	u32 logical_mask;
76 	/** @width: width (number BB submitted per exec) of this exec queue */
77 	u16 width;
78 	/** @refcount: ref count of this exec queue */
79 	u32 refcount;
80 	/**
81 	 * @sched_timeout: the time after which a job is removed from the
82 	 * scheduler.
83 	 */
84 	long sched_timeout;
85 
86 	/** @sched_props: scheduling properties */
87 	struct {
88 		/** @sched_props.timeslice_us: timeslice period in micro-seconds */
89 		u32 timeslice_us;
90 		/** @sched_props.preempt_timeout_us: preemption timeout in micro-seconds */
91 		u32 preempt_timeout_us;
92 	} sched_props;
93 
94 	/** @lrc: LRC Snapshot */
95 	struct xe_lrc_snapshot **lrc;
96 
97 	/** @schedule_state: Schedule State at the moment of Crash */
98 	u32 schedule_state;
99 	/** @exec_queue_flags: Flags of the faulty exec_queue */
100 	unsigned long exec_queue_flags;
101 
102 	/** @guc: GuC Engine Snapshot */
103 	struct {
104 		/** @guc.wqi_head: work queue item head */
105 		u32 wqi_head;
106 		/** @guc.wqi_tail: work queue item tail */
107 		u32 wqi_tail;
108 		/** @guc.id: GuC id for this exec_queue */
109 		u16 id;
110 	} guc;
111 
112 	/**
113 	 * @parallel_execution: Indication if the failure was during parallel
114 	 * execution
115 	 */
116 	bool parallel_execution;
117 	/** @parallel: snapshot of the useful parallel scratch */
118 	struct {
119 		/** @parallel.wq_desc: Workqueue description */
120 		struct {
121 			/** @parallel.wq_desc.head: Workqueue Head */
122 			u32 head;
123 			/** @parallel.wq_desc.tail: Workqueue Tail */
124 			u32 tail;
125 			/** @parallel.wq_desc.status: Workqueue Status */
126 			u32 status;
127 		} wq_desc;
128 		/** @wq: Workqueue Items */
129 		u32 wq[WQ_SIZE / sizeof(u32)];
130 	} parallel;
131 
132 	/** @multi_queue: snapshot of the multi queue information */
133 	struct {
134 		/**
135 		 * @multi_queue.primary: GuC id of the primary exec queue
136 		 * of the multi queue group.
137 		 */
138 		u32 primary;
139 		/** @multi_queue.pos: Position of the exec queue within the multi queue group */
140 		u8 pos;
141 		/** @valid: The exec queue is part of a multi queue group */
142 		bool valid;
143 	} multi_queue;
144 };
145 
146 #endif
147