| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: intel_guc_loader.c,v 1.7 2018/08/27 13:40:28 riastradh Exp $ */ | | 1 | /* $NetBSD: intel_guc_loader.c,v 1.8 2018/08/27 13:41:50 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.7 2018/08/27 13:40:28 riastradh Exp $"); | | 32 | __KERNEL_RCSID(0, "$NetBSD: intel_guc_loader.c,v 1.8 2018/08/27 13:41:50 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. |
| @@ -529,26 +529,55 @@ static void guc_fw_fetch(struct drm_devi | | | @@ -529,26 +529,55 @@ static void guc_fw_fetch(struct drm_devi |
529 | | | 529 | |
530 | DRM_DEBUG_DRIVER("firmware version %d.%d OK (minimum %d.%d)\n", | | 530 | DRM_DEBUG_DRIVER("firmware version %d.%d OK (minimum %d.%d)\n", |
531 | guc_fw->guc_fw_major_found, guc_fw->guc_fw_minor_found, | | 531 | guc_fw->guc_fw_major_found, guc_fw->guc_fw_minor_found, |
532 | guc_fw->guc_fw_major_wanted, guc_fw->guc_fw_minor_wanted); | | 532 | guc_fw->guc_fw_major_wanted, guc_fw->guc_fw_minor_wanted); |
533 | | | 533 | |
534 | mutex_lock(&dev->struct_mutex); | | 534 | mutex_lock(&dev->struct_mutex); |
535 | obj = i915_gem_object_create_from_data(dev, fw->data, fw->size); | | 535 | obj = i915_gem_object_create_from_data(dev, fw->data, fw->size); |
536 | mutex_unlock(&dev->struct_mutex); | | 536 | mutex_unlock(&dev->struct_mutex); |
537 | if (IS_ERR_OR_NULL(obj)) { | | 537 | if (IS_ERR_OR_NULL(obj)) { |
538 | err = obj ? PTR_ERR(obj) : -ENOMEM; | | 538 | err = obj ? PTR_ERR(obj) : -ENOMEM; |
539 | goto fail; | | 539 | goto fail; |
540 | } | | 540 | } |
541 | | | 541 | |
| | | 542 | #ifdef __NetBSD__ /* XXX temporary diagnostic kludge */ |
| | | 543 | { |
| | | 544 | void *buf = kmem_alloc(fw->size, KM_SLEEP); |
| | | 545 | struct iovec iov; |
| | | 546 | struct uio uio; |
| | | 547 | iov.iov_base = buf; |
| | | 548 | iov.iov_len = fw->size; |
| | | 549 | uio.uio_iov = &iov; |
| | | 550 | uio.uio_iovcnt = 1; |
| | | 551 | uio.uio_resid = fw->size; |
| | | 552 | uio.uio_rw = UIO_READ; |
| | | 553 | UIO_SETUP_SYSSPACE(&uio); |
| | | 554 | err = -ubc_uiomove(obj->base.filp, &uio, fw->size, |
| | | 555 | UVM_ADV_NORMAL, UBC_READ); |
| | | 556 | if (err) { |
| | | 557 | DRM_DEBUG_DRIVER("ubc_uiomove failed for test: %d\n", |
| | | 558 | err); |
| | | 559 | kmem_free(buf, fw->size); |
| | | 560 | goto fail; |
| | | 561 | } |
| | | 562 | if (memcmp(fw->data, buf, fw->size) != 0) { |
| | | 563 | DRM_DEBUG_DRIVER("firmware copy corrupted\n"); |
| | | 564 | kmem_free(buf, fw->size); |
| | | 565 | goto fail; |
| | | 566 | } |
| | | 567 | kmem_free(buf, fw->size); |
| | | 568 | } |
| | | 569 | #endif |
| | | 570 | |
542 | guc_fw->guc_fw_obj = obj; | | 571 | guc_fw->guc_fw_obj = obj; |
543 | guc_fw->guc_fw_size = fw->size; | | 572 | guc_fw->guc_fw_size = fw->size; |
544 | | | 573 | |
545 | DRM_DEBUG_DRIVER("GuC fw fetch status SUCCESS, obj %p\n", | | 574 | DRM_DEBUG_DRIVER("GuC fw fetch status SUCCESS, obj %p\n", |
546 | guc_fw->guc_fw_obj); | | 575 | guc_fw->guc_fw_obj); |
547 | | | 576 | |
548 | release_firmware(fw); | | 577 | release_firmware(fw); |
549 | guc_fw->guc_fw_fetch_status = GUC_FIRMWARE_SUCCESS; | | 578 | guc_fw->guc_fw_fetch_status = GUC_FIRMWARE_SUCCESS; |
550 | return; | | 579 | return; |
551 | | | 580 | |
552 | fail: | | 581 | fail: |
553 | DRM_DEBUG_DRIVER("GuC fw fetch status FAIL; err %d, fw %p, obj %p\n", | | 582 | DRM_DEBUG_DRIVER("GuC fw fetch status FAIL; err %d, fw %p, obj %p\n", |
554 | err, fw, guc_fw->guc_fw_obj); | | 583 | err, fw, guc_fw->guc_fw_obj); |