This source file includes following definitions.
- intel_uc_fw_change_status
- intel_uc_fw_status_repr
- intel_uc_fw_status_to_error
- intel_uc_fw_type_repr
- __intel_uc_fw_status
- intel_uc_fw_is_supported
- intel_uc_fw_is_enabled
- intel_uc_fw_is_available
- intel_uc_fw_is_loaded
- intel_uc_fw_is_running
- intel_uc_fw_is_overridden
- intel_uc_fw_sanitize
- __intel_uc_fw_get_upload_size
- intel_uc_fw_get_upload_size
1
2
3
4
5
6 #ifndef _INTEL_UC_FW_H_
7 #define _INTEL_UC_FW_H_
8
9 #include <linux/types.h>
10 #include "intel_uc_fw_abi.h"
11 #include "intel_device_info.h"
12 #include "i915_gem.h"
13
14 struct drm_printer;
15 struct drm_i915_private;
16 struct intel_gt;
17
18
19 #define INTEL_UC_FIRMWARE_URL "https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/i915"
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41 enum intel_uc_fw_status {
42 INTEL_UC_FIRMWARE_NOT_SUPPORTED = -1,
43 INTEL_UC_FIRMWARE_UNINITIALIZED = 0,
44 INTEL_UC_FIRMWARE_DISABLED,
45 INTEL_UC_FIRMWARE_SELECTED,
46 INTEL_UC_FIRMWARE_MISSING,
47 INTEL_UC_FIRMWARE_ERROR,
48 INTEL_UC_FIRMWARE_AVAILABLE,
49 INTEL_UC_FIRMWARE_FAIL,
50 INTEL_UC_FIRMWARE_TRANSFERRED,
51 INTEL_UC_FIRMWARE_RUNNING
52 };
53
54 enum intel_uc_fw_type {
55 INTEL_UC_FW_TYPE_GUC = 0,
56 INTEL_UC_FW_TYPE_HUC
57 };
58 #define INTEL_UC_FW_NUM_TYPES 2
59
60
61
62
63
64 struct intel_uc_fw {
65 enum intel_uc_fw_type type;
66 union {
67 const enum intel_uc_fw_status status;
68 enum intel_uc_fw_status __status;
69 };
70 const char *path;
71 bool user_overridden;
72 size_t size;
73 struct drm_i915_gem_object *obj;
74
75
76
77
78
79
80 u16 major_ver_wanted;
81 u16 minor_ver_wanted;
82 u16 major_ver_found;
83 u16 minor_ver_found;
84
85 u32 rsa_size;
86 u32 ucode_size;
87 };
88
89 #ifdef CONFIG_DRM_I915_DEBUG_GUC
90 void intel_uc_fw_change_status(struct intel_uc_fw *uc_fw,
91 enum intel_uc_fw_status status);
92 #else
93 static inline void intel_uc_fw_change_status(struct intel_uc_fw *uc_fw,
94 enum intel_uc_fw_status status)
95 {
96 uc_fw->__status = status;
97 }
98 #endif
99
100 static inline
101 const char *intel_uc_fw_status_repr(enum intel_uc_fw_status status)
102 {
103 switch (status) {
104 case INTEL_UC_FIRMWARE_NOT_SUPPORTED:
105 return "N/A";
106 case INTEL_UC_FIRMWARE_UNINITIALIZED:
107 return "UNINITIALIZED";
108 case INTEL_UC_FIRMWARE_DISABLED:
109 return "DISABLED";
110 case INTEL_UC_FIRMWARE_SELECTED:
111 return "SELECTED";
112 case INTEL_UC_FIRMWARE_MISSING:
113 return "MISSING";
114 case INTEL_UC_FIRMWARE_ERROR:
115 return "ERROR";
116 case INTEL_UC_FIRMWARE_AVAILABLE:
117 return "AVAILABLE";
118 case INTEL_UC_FIRMWARE_FAIL:
119 return "FAIL";
120 case INTEL_UC_FIRMWARE_TRANSFERRED:
121 return "TRANSFERRED";
122 case INTEL_UC_FIRMWARE_RUNNING:
123 return "RUNNING";
124 }
125 return "<invalid>";
126 }
127
128 static inline int intel_uc_fw_status_to_error(enum intel_uc_fw_status status)
129 {
130 switch (status) {
131 case INTEL_UC_FIRMWARE_NOT_SUPPORTED:
132 return -ENODEV;
133 case INTEL_UC_FIRMWARE_UNINITIALIZED:
134 return -EACCES;
135 case INTEL_UC_FIRMWARE_DISABLED:
136 return -EPERM;
137 case INTEL_UC_FIRMWARE_MISSING:
138 return -ENOENT;
139 case INTEL_UC_FIRMWARE_ERROR:
140 return -ENOEXEC;
141 case INTEL_UC_FIRMWARE_FAIL:
142 return -EIO;
143 case INTEL_UC_FIRMWARE_SELECTED:
144 return -ESTALE;
145 case INTEL_UC_FIRMWARE_AVAILABLE:
146 case INTEL_UC_FIRMWARE_TRANSFERRED:
147 case INTEL_UC_FIRMWARE_RUNNING:
148 return 0;
149 }
150 return -EINVAL;
151 }
152
153 static inline const char *intel_uc_fw_type_repr(enum intel_uc_fw_type type)
154 {
155 switch (type) {
156 case INTEL_UC_FW_TYPE_GUC:
157 return "GuC";
158 case INTEL_UC_FW_TYPE_HUC:
159 return "HuC";
160 }
161 return "uC";
162 }
163
164 static inline enum intel_uc_fw_status
165 __intel_uc_fw_status(struct intel_uc_fw *uc_fw)
166 {
167
168 GEM_BUG_ON(uc_fw->status == INTEL_UC_FIRMWARE_UNINITIALIZED);
169 return uc_fw->status;
170 }
171
172 static inline bool intel_uc_fw_is_supported(struct intel_uc_fw *uc_fw)
173 {
174 return __intel_uc_fw_status(uc_fw) != INTEL_UC_FIRMWARE_NOT_SUPPORTED;
175 }
176
177 static inline bool intel_uc_fw_is_enabled(struct intel_uc_fw *uc_fw)
178 {
179 return __intel_uc_fw_status(uc_fw) > INTEL_UC_FIRMWARE_DISABLED;
180 }
181
182 static inline bool intel_uc_fw_is_available(struct intel_uc_fw *uc_fw)
183 {
184 return __intel_uc_fw_status(uc_fw) >= INTEL_UC_FIRMWARE_AVAILABLE;
185 }
186
187 static inline bool intel_uc_fw_is_loaded(struct intel_uc_fw *uc_fw)
188 {
189 return __intel_uc_fw_status(uc_fw) >= INTEL_UC_FIRMWARE_TRANSFERRED;
190 }
191
192 static inline bool intel_uc_fw_is_running(struct intel_uc_fw *uc_fw)
193 {
194 return __intel_uc_fw_status(uc_fw) == INTEL_UC_FIRMWARE_RUNNING;
195 }
196
197 static inline bool intel_uc_fw_is_overridden(const struct intel_uc_fw *uc_fw)
198 {
199 return uc_fw->user_overridden;
200 }
201
202 static inline void intel_uc_fw_sanitize(struct intel_uc_fw *uc_fw)
203 {
204 if (intel_uc_fw_is_loaded(uc_fw))
205 intel_uc_fw_change_status(uc_fw, INTEL_UC_FIRMWARE_AVAILABLE);
206 }
207
208 static inline u32 __intel_uc_fw_get_upload_size(struct intel_uc_fw *uc_fw)
209 {
210 return sizeof(struct uc_css_header) + uc_fw->ucode_size;
211 }
212
213
214
215
216
217
218
219
220
221 static inline u32 intel_uc_fw_get_upload_size(struct intel_uc_fw *uc_fw)
222 {
223 if (!intel_uc_fw_is_available(uc_fw))
224 return 0;
225
226 return __intel_uc_fw_get_upload_size(uc_fw);
227 }
228
229 void intel_uc_fw_init_early(struct intel_uc_fw *uc_fw,
230 enum intel_uc_fw_type type, bool supported,
231 enum intel_platform platform, u8 rev);
232 int intel_uc_fw_fetch(struct intel_uc_fw *uc_fw, struct drm_i915_private *i915);
233 void intel_uc_fw_cleanup_fetch(struct intel_uc_fw *uc_fw);
234 int intel_uc_fw_upload(struct intel_uc_fw *uc_fw, struct intel_gt *gt,
235 u32 wopcm_offset, u32 dma_flags);
236 int intel_uc_fw_init(struct intel_uc_fw *uc_fw);
237 void intel_uc_fw_fini(struct intel_uc_fw *uc_fw);
238 size_t intel_uc_fw_copy_rsa(struct intel_uc_fw *uc_fw, void *dst, u32 max_len);
239 void intel_uc_fw_dump(const struct intel_uc_fw *uc_fw, struct drm_printer *p);
240
241 #endif