Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2014 Intel Corporation |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | * copy of this software and associated documentation files (the "Software"), |
| 6 | * to deal in the Software without restriction, including without limitation |
| 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 | * and/or sell copies of the Software, and to permit persons to whom the |
| 9 | * Software is furnished to do so, subject to the following conditions: |
| 10 | * |
| 11 | * The above copyright notice and this permission notice (including the next |
| 12 | * paragraph) shall be included in all copies or substantial portions of the |
| 13 | * Software. |
| 14 | * |
| 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
| 21 | * IN THE SOFTWARE. |
| 22 | * |
| 23 | */ |
Arkadiusz Hiler | 8c4f24f | 2016-11-25 18:59:33 +0100 | [diff] [blame] | 24 | #ifndef _INTEL_UC_H_ |
| 25 | #define _INTEL_UC_H_ |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 26 | |
Michal Wajdeczko | a16b431 | 2017-10-04 15:33:25 +0000 | [diff] [blame] | 27 | #include "intel_uc_fw.h" |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 28 | #include "intel_guc_fwif.h" |
| 29 | #include "i915_guc_reg.h" |
Dave Gordon | 0b63bb1 | 2016-06-20 15:18:07 +0100 | [diff] [blame] | 30 | #include "intel_ringbuffer.h" |
Michal Wajdeczko | f8a58d6 | 2017-05-26 11:13:25 +0000 | [diff] [blame] | 31 | #include "intel_guc_ct.h" |
Michal Wajdeczko | d62e2bf | 2017-10-04 18:13:39 +0000 | [diff] [blame] | 32 | #include "intel_guc_log.h" |
Chris Wilson | 4741da9 | 2016-12-24 19:31:46 +0000 | [diff] [blame] | 33 | #include "i915_vma.h" |
Michal Wajdeczko | d56d63d | 2017-10-04 15:33:26 +0000 | [diff] [blame] | 34 | #include "intel_huc.h" |
Chris Wilson | 4741da9 | 2016-12-24 19:31:46 +0000 | [diff] [blame] | 35 | |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 36 | struct intel_guc { |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 37 | struct intel_uc_fw fw; |
Akash Goel | d6b40b4 | 2016-10-12 21:54:29 +0530 | [diff] [blame] | 38 | struct intel_guc_log log; |
Michal Wajdeczko | f8a58d6 | 2017-05-26 11:13:25 +0000 | [diff] [blame] | 39 | struct intel_guc_ct ct; |
Alex Dai | bac427f | 2015-08-12 15:43:39 +0100 | [diff] [blame] | 40 | |
Daniele Ceraolo Spurio | ac58d2a | 2017-05-22 10:50:28 -0700 | [diff] [blame] | 41 | /* Log snapshot if GuC errors during load */ |
| 42 | struct drm_i915_gem_object *load_err_log; |
| 43 | |
Arkadiusz Hiler | a80bc45 | 2016-11-25 18:59:34 +0100 | [diff] [blame] | 44 | /* intel_guc_recv interrupt related state */ |
Sagar Arun Kamble | 26705e2 | 2016-10-12 21:54:31 +0530 | [diff] [blame] | 45 | bool interrupts_enabled; |
| 46 | |
Chris Wilson | 8b797af | 2016-08-15 10:48:51 +0100 | [diff] [blame] | 47 | struct i915_vma *ads_vma; |
Oscar Mateo | b09935a | 2017-03-22 10:39:53 -0700 | [diff] [blame] | 48 | struct i915_vma *stage_desc_pool; |
| 49 | void *stage_desc_pool_vaddr; |
| 50 | struct ida stage_ids; |
Dave Gordon | 44a28b1 | 2015-08-12 15:43:41 +0100 | [diff] [blame] | 51 | |
| 52 | struct i915_guc_client *execbuf_client; |
| 53 | |
Joonas Lahtinen | abddffd | 2017-03-22 10:39:44 -0700 | [diff] [blame] | 54 | DECLARE_BITMAP(doorbell_bitmap, GUC_NUM_DOORBELLS); |
Dave Gordon | 44a28b1 | 2015-08-12 15:43:41 +0100 | [diff] [blame] | 55 | uint32_t db_cacheline; /* Cyclic counter mod pagesize */ |
| 56 | |
Michal Wajdeczko | a0c1fe2 | 2017-05-10 12:59:27 +0000 | [diff] [blame] | 57 | /* GuC's FW specific registers used in MMIO send */ |
| 58 | struct { |
| 59 | u32 base; |
| 60 | unsigned int count; |
| 61 | enum forcewake_domains fw_domains; |
| 62 | } send_regs; |
| 63 | |
Arkadiusz Hiler | a80bc45 | 2016-11-25 18:59:34 +0100 | [diff] [blame] | 64 | /* To serialize the intel_guc_send actions */ |
| 65 | struct mutex send_mutex; |
Oscar Mateo | 5e7cd37 | 2017-03-22 10:39:49 -0700 | [diff] [blame] | 66 | |
| 67 | /* GuC's FW specific send function */ |
| 68 | int (*send)(struct intel_guc *guc, const u32 *data, u32 len); |
Michal Wajdeczko | a03aac4 | 2017-05-10 12:59:26 +0000 | [diff] [blame] | 69 | |
| 70 | /* GuC's FW specific notify function */ |
| 71 | void (*notify)(struct intel_guc *guc); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 72 | }; |
| 73 | |
Arkadiusz Hiler | 2d803c2 | 2016-11-25 18:59:35 +0100 | [diff] [blame] | 74 | /* intel_uc.c */ |
Arkadiusz Hiler | d2be9f2 | 2017-03-14 15:28:10 +0100 | [diff] [blame] | 75 | void intel_uc_sanitize_options(struct drm_i915_private *dev_priv); |
Arkadiusz Hiler | 413e8fd | 2016-11-25 18:59:36 +0100 | [diff] [blame] | 76 | void intel_uc_init_early(struct drm_i915_private *dev_priv); |
Sagar Arun Kamble | 1fc556f | 2017-10-04 15:33:24 +0000 | [diff] [blame] | 77 | void intel_uc_init_mmio(struct drm_i915_private *dev_priv); |
Arkadiusz Hiler | 29ad6a3 | 2017-03-14 15:28:09 +0100 | [diff] [blame] | 78 | void intel_uc_init_fw(struct drm_i915_private *dev_priv); |
Oscar Mateo | 3950bf3 | 2017-03-22 10:39:46 -0700 | [diff] [blame] | 79 | void intel_uc_fini_fw(struct drm_i915_private *dev_priv); |
Arkadiusz Hiler | 6cd5a72 | 2017-03-14 15:28:11 +0100 | [diff] [blame] | 80 | int intel_uc_init_hw(struct drm_i915_private *dev_priv); |
Oscar Mateo | 3950bf3 | 2017-03-22 10:39:46 -0700 | [diff] [blame] | 81 | void intel_uc_fini_hw(struct drm_i915_private *dev_priv); |
Arkadiusz Hiler | 2d803c2 | 2016-11-25 18:59:35 +0100 | [diff] [blame] | 82 | int intel_guc_sample_forcewake(struct intel_guc *guc); |
Michal Wajdeczko | 789a625 | 2017-05-02 10:32:42 +0000 | [diff] [blame] | 83 | int intel_guc_send_nop(struct intel_guc *guc, const u32 *action, u32 len); |
Oscar Mateo | 5e7cd37 | 2017-03-22 10:39:49 -0700 | [diff] [blame] | 84 | int intel_guc_send_mmio(struct intel_guc *guc, const u32 *action, u32 len); |
Sagar Arun Kamble | 9a2cbf2 | 2017-09-26 12:47:16 +0530 | [diff] [blame] | 85 | int intel_guc_auth_huc(struct intel_guc *guc, u32 rsa_offset); |
Michal Wajdeczko | a03aac4 | 2017-05-10 12:59:26 +0000 | [diff] [blame] | 86 | |
Oscar Mateo | 5e7cd37 | 2017-03-22 10:39:49 -0700 | [diff] [blame] | 87 | static inline int intel_guc_send(struct intel_guc *guc, const u32 *action, u32 len) |
| 88 | { |
| 89 | return guc->send(guc, action, len); |
| 90 | } |
Arkadiusz Hiler | 2d803c2 | 2016-11-25 18:59:35 +0100 | [diff] [blame] | 91 | |
Michal Wajdeczko | a03aac4 | 2017-05-10 12:59:26 +0000 | [diff] [blame] | 92 | static inline void intel_guc_notify(struct intel_guc *guc) |
| 93 | { |
| 94 | guc->notify(guc); |
| 95 | } |
| 96 | |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 97 | /* intel_guc_loader.c */ |
Arkadiusz Hiler | b551f61 | 2017-03-14 15:28:13 +0100 | [diff] [blame] | 98 | int intel_guc_select_fw(struct intel_guc *guc); |
Arkadiusz Hiler | 882d1db | 2017-03-14 15:28:07 +0100 | [diff] [blame] | 99 | int intel_guc_init_hw(struct intel_guc *guc); |
Arkadiusz Hiler | 0417a2b | 2017-03-14 15:28:05 +0100 | [diff] [blame] | 100 | int intel_guc_suspend(struct drm_i915_private *dev_priv); |
| 101 | int intel_guc_resume(struct drm_i915_private *dev_priv); |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 102 | u32 intel_guc_wopcm_size(struct drm_i915_private *dev_priv); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 103 | |
Michal Wajdeczko | f9cda04 | 2017-01-13 17:41:57 +0000 | [diff] [blame] | 104 | struct i915_vma *intel_guc_allocate_vma(struct intel_guc *guc, u32 size); |
| 105 | |
Chris Wilson | 4741da9 | 2016-12-24 19:31:46 +0000 | [diff] [blame] | 106 | static inline u32 guc_ggtt_offset(struct i915_vma *vma) |
| 107 | { |
| 108 | u32 offset = i915_ggtt_offset(vma); |
| 109 | GEM_BUG_ON(offset < GUC_WOPCM_TOP); |
Chris Wilson | db9309a | 2017-01-05 15:30:23 +0000 | [diff] [blame] | 110 | GEM_BUG_ON(range_overflows_t(u64, offset, vma->size, GUC_GGTT_TOP)); |
Chris Wilson | 4741da9 | 2016-12-24 19:31:46 +0000 | [diff] [blame] | 111 | return offset; |
| 112 | } |
| 113 | |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 114 | #endif |