| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: intel_guc_loader.c,v 1.3 2018/08/27 07:22:27 riastradh Exp $ */ | | 1 | /* $NetBSD: intel_guc_loader.c,v 1.4 2018/08/27 07:22:38 riastradh Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright © 2014 Intel Corporation | | 4 | * Copyright © 2014 Intel Corporation |
5 | * | | 5 | * |
6 | * Permission is hereby granted, free of charge, to any person obtaining a | | 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
7 | * copy of this software and associated documentation files (the "Software"), | | 7 | * copy of this software and associated documentation files (the "Software"), |
8 | * to deal in the Software without restriction, including without limitation | | 8 | * to deal in the Software without restriction, including without limitation |
9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | | 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
10 | * and/or sell copies of the Software, and to permit persons to whom the | | 10 | * and/or sell copies of the Software, and to permit persons to whom the |
11 | * Software is furnished to do so, subject to the following conditions: | | 11 | * Software is furnished to do so, subject to the following conditions: |
12 | * | | 12 | * |
13 | * The above copyright notice and this permission notice (including the next | | 13 | * The above copyright notice and this permission notice (including the next |
14 | * paragraph) shall be included in all copies or substantial portions of the | | 14 | * paragraph) shall be included in all copies or substantial portions of the |
| @@ -19,27 +19,27 @@ | | | @@ -19,27 +19,27 @@ |
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | | 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
20 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | | 20 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | | 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | | 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
23 | * IN THE SOFTWARE. | | 23 | * IN THE SOFTWARE. |
24 | * | | 24 | * |
25 | * Authors: | | 25 | * Authors: |
26 | * Vinit Azad <vinit.azad@intel.com> | | 26 | * Vinit Azad <vinit.azad@intel.com> |
27 | * Ben Widawsky <ben@bwidawsk.net> | | 27 | * Ben Widawsky <ben@bwidawsk.net> |
28 | * Dave Gordon <david.s.gordon@intel.com> | | 28 | * Dave Gordon <david.s.gordon@intel.com> |
29 | * Alex Dai <yu.dai@intel.com> | | 29 | * Alex Dai <yu.dai@intel.com> |
30 | */ | | 30 | */ |
31 | #include <sys/cdefs.h> | | 31 | #include <sys/cdefs.h> |
32 | __KERNEL_RCSID(0, "$NetBSD: intel_guc_loader.c,v 1.3 2018/08/27 07:22:27 riastradh Exp $"); | | 32 | __KERNEL_RCSID(0, "$NetBSD: intel_guc_loader.c,v 1.4 2018/08/27 07:22:38 riastradh Exp $"); |
33 | | | 33 | |
34 | #include <linux/firmware.h> | | 34 | #include <linux/firmware.h> |
35 | #include <linux/module.h> | | 35 | #include <linux/module.h> |
36 | #include "i915_drv.h" | | 36 | #include "i915_drv.h" |
37 | #include "intel_guc.h" | | 37 | #include "intel_guc.h" |
38 | | | 38 | |
39 | /** | | 39 | /** |
40 | * DOC: GuC | | 40 | * DOC: GuC |
41 | * | | 41 | * |
42 | * intel_guc: | | 42 | * intel_guc: |
43 | * Top level structure of guc. It handles firmware loading and manages client | | 43 | * Top level structure of guc. It handles firmware loading and manages client |
44 | * pool and doorbells. intel_guc owns a i915_guc_client to replace the legacy | | 44 | * pool and doorbells. intel_guc owns a i915_guc_client to replace the legacy |
45 | * ExecList submission. | | 45 | * ExecList submission. |
| @@ -233,36 +233,55 @@ static inline bool guc_ucode_response(st | | | @@ -233,36 +233,55 @@ static inline bool guc_ucode_response(st |
233 | */ | | 233 | */ |
234 | | | 234 | |
235 | #define UOS_CSS_HEADER_OFFSET 0 | | 235 | #define UOS_CSS_HEADER_OFFSET 0 |
236 | #define UOS_VER_MINOR_OFFSET 0x44 | | 236 | #define UOS_VER_MINOR_OFFSET 0x44 |
237 | #define UOS_VER_MAJOR_OFFSET 0x46 | | 237 | #define UOS_VER_MAJOR_OFFSET 0x46 |
238 | #define UOS_CSS_HEADER_SIZE 0x80 | | 238 | #define UOS_CSS_HEADER_SIZE 0x80 |
239 | #define UOS_RSA_SIG_SIZE 0x100 | | 239 | #define UOS_RSA_SIG_SIZE 0x100 |
240 | | | 240 | |
241 | static int guc_ucode_xfer_dma(struct drm_i915_private *dev_priv) | | 241 | static int guc_ucode_xfer_dma(struct drm_i915_private *dev_priv) |
242 | { | | 242 | { |
243 | struct intel_guc_fw *guc_fw = &dev_priv->guc.guc_fw; | | 243 | struct intel_guc_fw *guc_fw = &dev_priv->guc.guc_fw; |
244 | struct drm_i915_gem_object *fw_obj = guc_fw->guc_fw_obj; | | 244 | struct drm_i915_gem_object *fw_obj = guc_fw->guc_fw_obj; |
245 | unsigned long offset; | | 245 | unsigned long offset; |
| | | 246 | #ifdef __NetBSD__ |
| | | 247 | struct iovec iov; |
| | | 248 | struct uio uio; |
| | | 249 | #else |
246 | struct sg_table *sg = fw_obj->pages; | | 250 | struct sg_table *sg = fw_obj->pages; |
| | | 251 | #endif |
247 | u32 status, ucode_size, rsa[UOS_RSA_SIG_SIZE / sizeof(u32)]; | | 252 | u32 status, ucode_size, rsa[UOS_RSA_SIG_SIZE / sizeof(u32)]; |
248 | int i, ret = 0; | | 253 | int i, ret = 0; |
249 | | | 254 | |
250 | /* uCode size, also is where RSA signature starts */ | | 255 | /* uCode size, also is where RSA signature starts */ |
251 | offset = ucode_size = guc_fw->guc_fw_size - UOS_RSA_SIG_SIZE; | | 256 | offset = ucode_size = guc_fw->guc_fw_size - UOS_RSA_SIG_SIZE; |
252 | I915_WRITE(DMA_COPY_SIZE, ucode_size); | | 257 | I915_WRITE(DMA_COPY_SIZE, ucode_size); |
253 | | | 258 | |
254 | /* Copy RSA signature from the fw image to HW for verification */ | | 259 | /* Copy RSA signature from the fw image to HW for verification */ |
| | | 260 | #ifdef __NetBSD__ |
| | | 261 | iov.iov_base = rsa; |
| | | 262 | iov.iov_len = UOS_RSA_SIG_SIZE; |
| | | 263 | uio.uio_iov = &iov; |
| | | 264 | uio.uio_iovcnt = 1; |
| | | 265 | uio.uio_resid = UOS_RSA_SIG_SIZE; |
| | | 266 | uio.uio_rw = UIO_READ; |
| | | 267 | /* XXX errno NetBSD->Linux */ |
| | | 268 | ret = -ubc_uiomove(fw_obj->base.filp, &uio, UOS_RSA_SIG_SIZE, |
| | | 269 | UVM_ADV_NORMAL, UBC_READ); |
| | | 270 | if (ret) |
| | | 271 | return ret; |
| | | 272 | #else |
255 | sg_pcopy_to_buffer(sg->sgl, sg->nents, rsa, UOS_RSA_SIG_SIZE, offset); | | 273 | sg_pcopy_to_buffer(sg->sgl, sg->nents, rsa, UOS_RSA_SIG_SIZE, offset); |
| | | 274 | #endif |
256 | for (i = 0; i < UOS_RSA_SIG_SIZE / sizeof(u32); i++) | | 275 | for (i = 0; i < UOS_RSA_SIG_SIZE / sizeof(u32); i++) |
257 | I915_WRITE(UOS_RSA_SCRATCH(i), rsa[i]); | | 276 | I915_WRITE(UOS_RSA_SCRATCH(i), rsa[i]); |
258 | | | 277 | |
259 | /* Set the source address for the new blob */ | | 278 | /* Set the source address for the new blob */ |
260 | offset = i915_gem_obj_ggtt_offset(fw_obj); | | 279 | offset = i915_gem_obj_ggtt_offset(fw_obj); |
261 | I915_WRITE(DMA_ADDR_0_LOW, lower_32_bits(offset)); | | 280 | I915_WRITE(DMA_ADDR_0_LOW, lower_32_bits(offset)); |
262 | I915_WRITE(DMA_ADDR_0_HIGH, upper_32_bits(offset) & 0xFFFF); | | 281 | I915_WRITE(DMA_ADDR_0_HIGH, upper_32_bits(offset) & 0xFFFF); |
263 | | | 282 | |
264 | /* | | 283 | /* |
265 | * Set the DMA destination. Current uCode expects the code to be | | 284 | * Set the DMA destination. Current uCode expects the code to be |
266 | * loaded at 8k; locations below this are used for the stack. | | 285 | * loaded at 8k; locations below this are used for the stack. |
267 | */ | | 286 | */ |
268 | I915_WRITE(DMA_ADDR_1_LOW, 0x2000); | | 287 | I915_WRITE(DMA_ADDR_1_LOW, 0x2000); |