1*3f2dd94aSFrançois Tigeot /*
2*3f2dd94aSFrançois Tigeot * Copyright © 2016-2017 Intel Corporation
3*3f2dd94aSFrançois Tigeot *
4*3f2dd94aSFrançois Tigeot * Permission is hereby granted, free of charge, to any person obtaining a
5*3f2dd94aSFrançois Tigeot * copy of this software and associated documentation files (the "Software"),
6*3f2dd94aSFrançois Tigeot * to deal in the Software without restriction, including without limitation
7*3f2dd94aSFrançois Tigeot * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8*3f2dd94aSFrançois Tigeot * and/or sell copies of the Software, and to permit persons to whom the
9*3f2dd94aSFrançois Tigeot * Software is furnished to do so, subject to the following conditions:
10*3f2dd94aSFrançois Tigeot *
11*3f2dd94aSFrançois Tigeot * The above copyright notice and this permission notice (including the next
12*3f2dd94aSFrançois Tigeot * paragraph) shall be included in all copies or substantial portions of the
13*3f2dd94aSFrançois Tigeot * Software.
14*3f2dd94aSFrançois Tigeot *
15*3f2dd94aSFrançois Tigeot * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16*3f2dd94aSFrançois Tigeot * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17*3f2dd94aSFrançois Tigeot * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18*3f2dd94aSFrançois Tigeot * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19*3f2dd94aSFrançois Tigeot * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20*3f2dd94aSFrançois Tigeot * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21*3f2dd94aSFrançois Tigeot * IN THE SOFTWARE.
22*3f2dd94aSFrançois Tigeot *
23*3f2dd94aSFrançois Tigeot */
24*3f2dd94aSFrançois Tigeot
25*3f2dd94aSFrançois Tigeot #include <linux/firmware.h>
26*3f2dd94aSFrançois Tigeot #include <drm/drm_print.h>
27*3f2dd94aSFrançois Tigeot
28*3f2dd94aSFrançois Tigeot #include "intel_uc_fw.h"
29*3f2dd94aSFrançois Tigeot #include "i915_drv.h"
30*3f2dd94aSFrançois Tigeot
31*3f2dd94aSFrançois Tigeot /**
32*3f2dd94aSFrançois Tigeot * intel_uc_fw_fetch - fetch uC firmware
33*3f2dd94aSFrançois Tigeot *
34*3f2dd94aSFrançois Tigeot * @dev_priv: device private
35*3f2dd94aSFrançois Tigeot * @uc_fw: uC firmware
36*3f2dd94aSFrançois Tigeot *
37*3f2dd94aSFrançois Tigeot * Fetch uC firmware into GEM obj.
38*3f2dd94aSFrançois Tigeot */
intel_uc_fw_fetch(struct drm_i915_private * dev_priv,struct intel_uc_fw * uc_fw)39*3f2dd94aSFrançois Tigeot void intel_uc_fw_fetch(struct drm_i915_private *dev_priv,
40*3f2dd94aSFrançois Tigeot struct intel_uc_fw *uc_fw)
41*3f2dd94aSFrançois Tigeot {
42*3f2dd94aSFrançois Tigeot struct pci_dev *pdev = dev_priv->drm.pdev;
43*3f2dd94aSFrançois Tigeot struct drm_i915_gem_object *obj;
44*3f2dd94aSFrançois Tigeot const struct firmware *fw = NULL;
45*3f2dd94aSFrançois Tigeot struct uc_css_header *css;
46*3f2dd94aSFrançois Tigeot size_t size;
47*3f2dd94aSFrançois Tigeot int err;
48*3f2dd94aSFrançois Tigeot
49*3f2dd94aSFrançois Tigeot DRM_DEBUG_DRIVER("%s fw fetch %s\n",
50*3f2dd94aSFrançois Tigeot intel_uc_fw_type_repr(uc_fw->type), uc_fw->path);
51*3f2dd94aSFrançois Tigeot
52*3f2dd94aSFrançois Tigeot if (!uc_fw->path)
53*3f2dd94aSFrançois Tigeot return;
54*3f2dd94aSFrançois Tigeot
55*3f2dd94aSFrançois Tigeot uc_fw->fetch_status = INTEL_UC_FIRMWARE_PENDING;
56*3f2dd94aSFrançois Tigeot DRM_DEBUG_DRIVER("%s fw fetch %s\n",
57*3f2dd94aSFrançois Tigeot intel_uc_fw_type_repr(uc_fw->type),
58*3f2dd94aSFrançois Tigeot intel_uc_fw_status_repr(uc_fw->fetch_status));
59*3f2dd94aSFrançois Tigeot
60*3f2dd94aSFrançois Tigeot err = request_firmware(&fw, uc_fw->path, &pdev->dev);
61*3f2dd94aSFrançois Tigeot if (err) {
62*3f2dd94aSFrançois Tigeot DRM_DEBUG_DRIVER("%s fw request_firmware err=%d\n",
63*3f2dd94aSFrançois Tigeot intel_uc_fw_type_repr(uc_fw->type), err);
64*3f2dd94aSFrançois Tigeot goto fail;
65*3f2dd94aSFrançois Tigeot }
66*3f2dd94aSFrançois Tigeot
67*3f2dd94aSFrançois Tigeot DRM_DEBUG_DRIVER("%s fw size %zu ptr %p\n",
68*3f2dd94aSFrançois Tigeot intel_uc_fw_type_repr(uc_fw->type), fw->datasize, fw);
69*3f2dd94aSFrançois Tigeot
70*3f2dd94aSFrançois Tigeot /* Check the size of the blob before examining buffer contents */
71*3f2dd94aSFrançois Tigeot if (fw->datasize < sizeof(struct uc_css_header)) {
72*3f2dd94aSFrançois Tigeot DRM_WARN("%s: Unexpected firmware size (%zu, min %zu)\n",
73*3f2dd94aSFrançois Tigeot intel_uc_fw_type_repr(uc_fw->type),
74*3f2dd94aSFrançois Tigeot fw->datasize, sizeof(struct uc_css_header));
75*3f2dd94aSFrançois Tigeot err = -ENODATA;
76*3f2dd94aSFrançois Tigeot goto fail;
77*3f2dd94aSFrançois Tigeot }
78*3f2dd94aSFrançois Tigeot
79*3f2dd94aSFrançois Tigeot css = (struct uc_css_header *)fw->data;
80*3f2dd94aSFrançois Tigeot
81*3f2dd94aSFrançois Tigeot /* Firmware bits always start from header */
82*3f2dd94aSFrançois Tigeot uc_fw->header_offset = 0;
83*3f2dd94aSFrançois Tigeot uc_fw->header_size = (css->header_size_dw - css->modulus_size_dw -
84*3f2dd94aSFrançois Tigeot css->key_size_dw - css->exponent_size_dw) *
85*3f2dd94aSFrançois Tigeot sizeof(u32);
86*3f2dd94aSFrançois Tigeot
87*3f2dd94aSFrançois Tigeot if (uc_fw->header_size != sizeof(struct uc_css_header)) {
88*3f2dd94aSFrançois Tigeot DRM_WARN("%s: Mismatched firmware header definition\n",
89*3f2dd94aSFrançois Tigeot intel_uc_fw_type_repr(uc_fw->type));
90*3f2dd94aSFrançois Tigeot err = -ENOEXEC;
91*3f2dd94aSFrançois Tigeot goto fail;
92*3f2dd94aSFrançois Tigeot }
93*3f2dd94aSFrançois Tigeot
94*3f2dd94aSFrançois Tigeot /* then, uCode */
95*3f2dd94aSFrançois Tigeot uc_fw->ucode_offset = uc_fw->header_offset + uc_fw->header_size;
96*3f2dd94aSFrançois Tigeot uc_fw->ucode_size = (css->size_dw - css->header_size_dw) * sizeof(u32);
97*3f2dd94aSFrançois Tigeot
98*3f2dd94aSFrançois Tigeot /* Header and uCode will be loaded to WOPCM */
99*3f2dd94aSFrançois Tigeot size = uc_fw->header_size + uc_fw->ucode_size;
100*3f2dd94aSFrançois Tigeot if (size > intel_guc_wopcm_size(dev_priv)) {
101*3f2dd94aSFrançois Tigeot DRM_WARN("%s: Firmware is too large to fit in WOPCM\n",
102*3f2dd94aSFrançois Tigeot intel_uc_fw_type_repr(uc_fw->type));
103*3f2dd94aSFrançois Tigeot err = -E2BIG;
104*3f2dd94aSFrançois Tigeot goto fail;
105*3f2dd94aSFrançois Tigeot }
106*3f2dd94aSFrançois Tigeot
107*3f2dd94aSFrançois Tigeot /* now RSA */
108*3f2dd94aSFrançois Tigeot if (css->key_size_dw != UOS_RSA_SCRATCH_MAX_COUNT) {
109*3f2dd94aSFrançois Tigeot DRM_WARN("%s: Mismatched firmware RSA key size (%u)\n",
110*3f2dd94aSFrançois Tigeot intel_uc_fw_type_repr(uc_fw->type), css->key_size_dw);
111*3f2dd94aSFrançois Tigeot err = -ENOEXEC;
112*3f2dd94aSFrançois Tigeot goto fail;
113*3f2dd94aSFrançois Tigeot }
114*3f2dd94aSFrançois Tigeot uc_fw->rsa_offset = uc_fw->ucode_offset + uc_fw->ucode_size;
115*3f2dd94aSFrançois Tigeot uc_fw->rsa_size = css->key_size_dw * sizeof(u32);
116*3f2dd94aSFrançois Tigeot
117*3f2dd94aSFrançois Tigeot /* At least, it should have header, uCode and RSA. Size of all three. */
118*3f2dd94aSFrançois Tigeot size = uc_fw->header_size + uc_fw->ucode_size + uc_fw->rsa_size;
119*3f2dd94aSFrançois Tigeot if (fw->datasize < size) {
120*3f2dd94aSFrançois Tigeot DRM_WARN("%s: Truncated firmware (%zu, expected %zu)\n",
121*3f2dd94aSFrançois Tigeot intel_uc_fw_type_repr(uc_fw->type), fw->datasize, size);
122*3f2dd94aSFrançois Tigeot err = -ENOEXEC;
123*3f2dd94aSFrançois Tigeot goto fail;
124*3f2dd94aSFrançois Tigeot }
125*3f2dd94aSFrançois Tigeot
126*3f2dd94aSFrançois Tigeot /*
127*3f2dd94aSFrançois Tigeot * The GuC firmware image has the version number embedded at a
128*3f2dd94aSFrançois Tigeot * well-known offset within the firmware blob; note that major / minor
129*3f2dd94aSFrançois Tigeot * version are TWO bytes each (i.e. u16), although all pointers and
130*3f2dd94aSFrançois Tigeot * offsets are defined in terms of bytes (u8).
131*3f2dd94aSFrançois Tigeot */
132*3f2dd94aSFrançois Tigeot switch (uc_fw->type) {
133*3f2dd94aSFrançois Tigeot case INTEL_UC_FW_TYPE_GUC:
134*3f2dd94aSFrançois Tigeot uc_fw->major_ver_found = css->guc.sw_version >> 16;
135*3f2dd94aSFrançois Tigeot uc_fw->minor_ver_found = css->guc.sw_version & 0xFFFF;
136*3f2dd94aSFrançois Tigeot break;
137*3f2dd94aSFrançois Tigeot
138*3f2dd94aSFrançois Tigeot case INTEL_UC_FW_TYPE_HUC:
139*3f2dd94aSFrançois Tigeot uc_fw->major_ver_found = css->huc.sw_version >> 16;
140*3f2dd94aSFrançois Tigeot uc_fw->minor_ver_found = css->huc.sw_version & 0xFFFF;
141*3f2dd94aSFrançois Tigeot break;
142*3f2dd94aSFrançois Tigeot
143*3f2dd94aSFrançois Tigeot default:
144*3f2dd94aSFrançois Tigeot MISSING_CASE(uc_fw->type);
145*3f2dd94aSFrançois Tigeot break;
146*3f2dd94aSFrançois Tigeot }
147*3f2dd94aSFrançois Tigeot
148*3f2dd94aSFrançois Tigeot DRM_DEBUG_DRIVER("%s fw version %u.%u (wanted %u.%u)\n",
149*3f2dd94aSFrançois Tigeot intel_uc_fw_type_repr(uc_fw->type),
150*3f2dd94aSFrançois Tigeot uc_fw->major_ver_found, uc_fw->minor_ver_found,
151*3f2dd94aSFrançois Tigeot uc_fw->major_ver_wanted, uc_fw->minor_ver_wanted);
152*3f2dd94aSFrançois Tigeot
153*3f2dd94aSFrançois Tigeot if (uc_fw->major_ver_wanted == 0 && uc_fw->minor_ver_wanted == 0) {
154*3f2dd94aSFrançois Tigeot DRM_NOTE("%s: Skipping firmware version check\n",
155*3f2dd94aSFrançois Tigeot intel_uc_fw_type_repr(uc_fw->type));
156*3f2dd94aSFrançois Tigeot } else if (uc_fw->major_ver_found != uc_fw->major_ver_wanted ||
157*3f2dd94aSFrançois Tigeot uc_fw->minor_ver_found < uc_fw->minor_ver_wanted) {
158*3f2dd94aSFrançois Tigeot DRM_NOTE("%s: Wrong firmware version (%u.%u, required %u.%u)\n",
159*3f2dd94aSFrançois Tigeot intel_uc_fw_type_repr(uc_fw->type),
160*3f2dd94aSFrançois Tigeot uc_fw->major_ver_found, uc_fw->minor_ver_found,
161*3f2dd94aSFrançois Tigeot uc_fw->major_ver_wanted, uc_fw->minor_ver_wanted);
162*3f2dd94aSFrançois Tigeot err = -ENOEXEC;
163*3f2dd94aSFrançois Tigeot goto fail;
164*3f2dd94aSFrançois Tigeot }
165*3f2dd94aSFrançois Tigeot
166*3f2dd94aSFrançois Tigeot obj = i915_gem_object_create_from_data(dev_priv, fw->data, fw->datasize);
167*3f2dd94aSFrançois Tigeot if (IS_ERR(obj)) {
168*3f2dd94aSFrançois Tigeot err = PTR_ERR(obj);
169*3f2dd94aSFrançois Tigeot DRM_DEBUG_DRIVER("%s fw object_create err=%d\n",
170*3f2dd94aSFrançois Tigeot intel_uc_fw_type_repr(uc_fw->type), err);
171*3f2dd94aSFrançois Tigeot goto fail;
172*3f2dd94aSFrançois Tigeot }
173*3f2dd94aSFrançois Tigeot
174*3f2dd94aSFrançois Tigeot uc_fw->obj = obj;
175*3f2dd94aSFrançois Tigeot uc_fw->size = fw->datasize;
176*3f2dd94aSFrançois Tigeot uc_fw->fetch_status = INTEL_UC_FIRMWARE_SUCCESS;
177*3f2dd94aSFrançois Tigeot DRM_DEBUG_DRIVER("%s fw fetch %s\n",
178*3f2dd94aSFrançois Tigeot intel_uc_fw_type_repr(uc_fw->type),
179*3f2dd94aSFrançois Tigeot intel_uc_fw_status_repr(uc_fw->fetch_status));
180*3f2dd94aSFrançois Tigeot
181*3f2dd94aSFrançois Tigeot release_firmware(fw);
182*3f2dd94aSFrançois Tigeot return;
183*3f2dd94aSFrançois Tigeot
184*3f2dd94aSFrançois Tigeot fail:
185*3f2dd94aSFrançois Tigeot uc_fw->fetch_status = INTEL_UC_FIRMWARE_FAIL;
186*3f2dd94aSFrançois Tigeot DRM_DEBUG_DRIVER("%s fw fetch %s\n",
187*3f2dd94aSFrançois Tigeot intel_uc_fw_type_repr(uc_fw->type),
188*3f2dd94aSFrançois Tigeot intel_uc_fw_status_repr(uc_fw->fetch_status));
189*3f2dd94aSFrançois Tigeot
190*3f2dd94aSFrançois Tigeot DRM_WARN("%s: Failed to fetch firmware %s (error %d)\n",
191*3f2dd94aSFrançois Tigeot intel_uc_fw_type_repr(uc_fw->type), uc_fw->path, err);
192*3f2dd94aSFrançois Tigeot DRM_INFO("%s: Firmware can be downloaded from %s\n",
193*3f2dd94aSFrançois Tigeot intel_uc_fw_type_repr(uc_fw->type), INTEL_UC_FIRMWARE_URL);
194*3f2dd94aSFrançois Tigeot
195*3f2dd94aSFrançois Tigeot release_firmware(fw); /* OK even if fw is NULL */
196*3f2dd94aSFrançois Tigeot }
197*3f2dd94aSFrançois Tigeot
198*3f2dd94aSFrançois Tigeot /**
199*3f2dd94aSFrançois Tigeot * intel_uc_fw_upload - load uC firmware using custom loader
200*3f2dd94aSFrançois Tigeot *
201*3f2dd94aSFrançois Tigeot * @uc_fw: uC firmware
202*3f2dd94aSFrançois Tigeot * @loader: custom uC firmware loader function
203*3f2dd94aSFrançois Tigeot *
204*3f2dd94aSFrançois Tigeot * Loads uC firmware using custom loader and updates internal flags.
205*3f2dd94aSFrançois Tigeot */
intel_uc_fw_upload(struct intel_uc_fw * uc_fw,int (* xfer)(struct intel_uc_fw * uc_fw,struct i915_vma * vma))206*3f2dd94aSFrançois Tigeot int intel_uc_fw_upload(struct intel_uc_fw *uc_fw,
207*3f2dd94aSFrançois Tigeot int (*xfer)(struct intel_uc_fw *uc_fw,
208*3f2dd94aSFrançois Tigeot struct i915_vma *vma))
209*3f2dd94aSFrançois Tigeot {
210*3f2dd94aSFrançois Tigeot struct i915_vma *vma;
211*3f2dd94aSFrançois Tigeot int err;
212*3f2dd94aSFrançois Tigeot
213*3f2dd94aSFrançois Tigeot DRM_DEBUG_DRIVER("%s fw load %s\n",
214*3f2dd94aSFrançois Tigeot intel_uc_fw_type_repr(uc_fw->type), uc_fw->path);
215*3f2dd94aSFrançois Tigeot
216*3f2dd94aSFrançois Tigeot if (uc_fw->fetch_status != INTEL_UC_FIRMWARE_SUCCESS)
217*3f2dd94aSFrançois Tigeot return -EIO;
218*3f2dd94aSFrançois Tigeot
219*3f2dd94aSFrançois Tigeot uc_fw->load_status = INTEL_UC_FIRMWARE_PENDING;
220*3f2dd94aSFrançois Tigeot DRM_DEBUG_DRIVER("%s fw load %s\n",
221*3f2dd94aSFrançois Tigeot intel_uc_fw_type_repr(uc_fw->type),
222*3f2dd94aSFrançois Tigeot intel_uc_fw_status_repr(uc_fw->load_status));
223*3f2dd94aSFrançois Tigeot
224*3f2dd94aSFrançois Tigeot /* Pin object with firmware */
225*3f2dd94aSFrançois Tigeot err = i915_gem_object_set_to_gtt_domain(uc_fw->obj, false);
226*3f2dd94aSFrançois Tigeot if (err) {
227*3f2dd94aSFrançois Tigeot DRM_DEBUG_DRIVER("%s fw set-domain err=%d\n",
228*3f2dd94aSFrançois Tigeot intel_uc_fw_type_repr(uc_fw->type), err);
229*3f2dd94aSFrançois Tigeot goto fail;
230*3f2dd94aSFrançois Tigeot }
231*3f2dd94aSFrançois Tigeot
232*3f2dd94aSFrançois Tigeot vma = i915_gem_object_ggtt_pin(uc_fw->obj, NULL, 0, 0,
233*3f2dd94aSFrançois Tigeot PIN_OFFSET_BIAS | GUC_WOPCM_TOP);
234*3f2dd94aSFrançois Tigeot if (IS_ERR(vma)) {
235*3f2dd94aSFrançois Tigeot err = PTR_ERR(vma);
236*3f2dd94aSFrançois Tigeot DRM_DEBUG_DRIVER("%s fw ggtt-pin err=%d\n",
237*3f2dd94aSFrançois Tigeot intel_uc_fw_type_repr(uc_fw->type), err);
238*3f2dd94aSFrançois Tigeot goto fail;
239*3f2dd94aSFrançois Tigeot }
240*3f2dd94aSFrançois Tigeot
241*3f2dd94aSFrançois Tigeot /* Call custom loader */
242*3f2dd94aSFrançois Tigeot err = xfer(uc_fw, vma);
243*3f2dd94aSFrançois Tigeot
244*3f2dd94aSFrançois Tigeot /*
245*3f2dd94aSFrançois Tigeot * We keep the object pages for reuse during resume. But we can unpin it
246*3f2dd94aSFrançois Tigeot * now that DMA has completed, so it doesn't continue to take up space.
247*3f2dd94aSFrançois Tigeot */
248*3f2dd94aSFrançois Tigeot i915_vma_unpin(vma);
249*3f2dd94aSFrançois Tigeot
250*3f2dd94aSFrançois Tigeot if (err)
251*3f2dd94aSFrançois Tigeot goto fail;
252*3f2dd94aSFrançois Tigeot
253*3f2dd94aSFrançois Tigeot uc_fw->load_status = INTEL_UC_FIRMWARE_SUCCESS;
254*3f2dd94aSFrançois Tigeot DRM_DEBUG_DRIVER("%s fw load %s\n",
255*3f2dd94aSFrançois Tigeot intel_uc_fw_type_repr(uc_fw->type),
256*3f2dd94aSFrançois Tigeot intel_uc_fw_status_repr(uc_fw->load_status));
257*3f2dd94aSFrançois Tigeot
258*3f2dd94aSFrançois Tigeot DRM_INFO("%s: Loaded firmware %s (version %u.%u)\n",
259*3f2dd94aSFrançois Tigeot intel_uc_fw_type_repr(uc_fw->type),
260*3f2dd94aSFrançois Tigeot uc_fw->path,
261*3f2dd94aSFrançois Tigeot uc_fw->major_ver_found, uc_fw->minor_ver_found);
262*3f2dd94aSFrançois Tigeot
263*3f2dd94aSFrançois Tigeot return 0;
264*3f2dd94aSFrançois Tigeot
265*3f2dd94aSFrançois Tigeot fail:
266*3f2dd94aSFrançois Tigeot uc_fw->load_status = INTEL_UC_FIRMWARE_FAIL;
267*3f2dd94aSFrançois Tigeot DRM_DEBUG_DRIVER("%s fw load %s\n",
268*3f2dd94aSFrançois Tigeot intel_uc_fw_type_repr(uc_fw->type),
269*3f2dd94aSFrançois Tigeot intel_uc_fw_status_repr(uc_fw->load_status));
270*3f2dd94aSFrançois Tigeot
271*3f2dd94aSFrançois Tigeot DRM_WARN("%s: Failed to load firmware %s (error %d)\n",
272*3f2dd94aSFrançois Tigeot intel_uc_fw_type_repr(uc_fw->type), uc_fw->path, err);
273*3f2dd94aSFrançois Tigeot
274*3f2dd94aSFrançois Tigeot return err;
275*3f2dd94aSFrançois Tigeot }
276*3f2dd94aSFrançois Tigeot
277*3f2dd94aSFrançois Tigeot /**
278*3f2dd94aSFrançois Tigeot * intel_uc_fw_fini - cleanup uC firmware
279*3f2dd94aSFrançois Tigeot *
280*3f2dd94aSFrançois Tigeot * @uc_fw: uC firmware
281*3f2dd94aSFrançois Tigeot *
282*3f2dd94aSFrançois Tigeot * Cleans up uC firmware by releasing the firmware GEM obj.
283*3f2dd94aSFrançois Tigeot */
intel_uc_fw_fini(struct intel_uc_fw * uc_fw)284*3f2dd94aSFrançois Tigeot void intel_uc_fw_fini(struct intel_uc_fw *uc_fw)
285*3f2dd94aSFrançois Tigeot {
286*3f2dd94aSFrançois Tigeot struct drm_i915_gem_object *obj;
287*3f2dd94aSFrançois Tigeot
288*3f2dd94aSFrançois Tigeot obj = fetch_and_zero(&uc_fw->obj);
289*3f2dd94aSFrançois Tigeot if (obj)
290*3f2dd94aSFrançois Tigeot i915_gem_object_put(obj);
291*3f2dd94aSFrançois Tigeot
292*3f2dd94aSFrançois Tigeot uc_fw->fetch_status = INTEL_UC_FIRMWARE_NONE;
293*3f2dd94aSFrançois Tigeot }
294*3f2dd94aSFrançois Tigeot
295*3f2dd94aSFrançois Tigeot /**
296*3f2dd94aSFrançois Tigeot * intel_uc_fw_dump - dump information about uC firmware
297*3f2dd94aSFrançois Tigeot * @uc_fw: uC firmware
298*3f2dd94aSFrançois Tigeot * @p: the &drm_printer
299*3f2dd94aSFrançois Tigeot *
300*3f2dd94aSFrançois Tigeot * Pretty printer for uC firmware.
301*3f2dd94aSFrançois Tigeot */
intel_uc_fw_dump(struct intel_uc_fw * uc_fw,struct drm_printer * p)302*3f2dd94aSFrançois Tigeot void intel_uc_fw_dump(struct intel_uc_fw *uc_fw, struct drm_printer *p)
303*3f2dd94aSFrançois Tigeot {
304*3f2dd94aSFrançois Tigeot drm_printf(p, "%s firmware: %s\n",
305*3f2dd94aSFrançois Tigeot intel_uc_fw_type_repr(uc_fw->type), uc_fw->path);
306*3f2dd94aSFrançois Tigeot drm_printf(p, "\tstatus: fetch %s, load %s\n",
307*3f2dd94aSFrançois Tigeot intel_uc_fw_status_repr(uc_fw->fetch_status),
308*3f2dd94aSFrançois Tigeot intel_uc_fw_status_repr(uc_fw->load_status));
309*3f2dd94aSFrançois Tigeot drm_printf(p, "\tversion: wanted %u.%u, found %u.%u\n",
310*3f2dd94aSFrançois Tigeot uc_fw->major_ver_wanted, uc_fw->minor_ver_wanted,
311*3f2dd94aSFrançois Tigeot uc_fw->major_ver_found, uc_fw->minor_ver_found);
312*3f2dd94aSFrançois Tigeot drm_printf(p, "\theader: offset %u, size %u\n",
313*3f2dd94aSFrançois Tigeot uc_fw->header_offset, uc_fw->header_size);
314*3f2dd94aSFrançois Tigeot drm_printf(p, "\tuCode: offset %u, size %u\n",
315*3f2dd94aSFrançois Tigeot uc_fw->ucode_offset, uc_fw->ucode_size);
316*3f2dd94aSFrançois Tigeot drm_printf(p, "\tRSA: offset %u, size %u\n",
317*3f2dd94aSFrançois Tigeot uc_fw->rsa_offset, uc_fw->rsa_size);
318*3f2dd94aSFrançois Tigeot }
319