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 | * Authors: |
| 24 | * Vinit Azad <vinit.azad@intel.com> |
| 25 | * Ben Widawsky <ben@bwidawsk.net> |
| 26 | * Dave Gordon <david.s.gordon@intel.com> |
| 27 | * Alex Dai <yu.dai@intel.com> |
| 28 | */ |
| 29 | #include <linux/firmware.h> |
| 30 | #include "i915_drv.h" |
Arkadiusz Hiler | 8c4f24f | 2016-11-25 18:59:33 +0100 | [diff] [blame] | 31 | #include "intel_uc.h" |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 32 | |
| 33 | /** |
Alex Dai | feda33e | 2015-10-19 16:10:54 -0700 | [diff] [blame] | 34 | * DOC: GuC-specific firmware loader |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 35 | * |
| 36 | * intel_guc: |
| 37 | * Top level structure of guc. It handles firmware loading and manages client |
| 38 | * pool and doorbells. intel_guc owns a i915_guc_client to replace the legacy |
| 39 | * ExecList submission. |
| 40 | * |
| 41 | * Firmware versioning: |
| 42 | * The firmware build process will generate a version header file with major and |
| 43 | * minor version defined. The versions are built into CSS header of firmware. |
| 44 | * i915 kernel driver set the minimal firmware version required per platform. |
| 45 | * The firmware installation package will install (symbolic link) proper version |
| 46 | * of firmware. |
| 47 | * |
| 48 | * GuC address space: |
| 49 | * GuC does not allow any gfx GGTT address that falls into range [0, WOPCM_TOP), |
| 50 | * which is reserved for Boot ROM, SRAM and WOPCM. Currently this top address is |
| 51 | * 512K. In order to exclude 0-512K address space from GGTT, all gfx objects |
| 52 | * used by GuC is pinned with PIN_OFFSET_BIAS along with size of WOPCM. |
| 53 | * |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 54 | */ |
| 55 | |
Tvrtko Ursulin | 5e334c1 | 2016-08-10 16:16:46 +0100 | [diff] [blame] | 56 | #define SKL_FW_MAJOR 6 |
| 57 | #define SKL_FW_MINOR 1 |
| 58 | |
| 59 | #define BXT_FW_MAJOR 8 |
| 60 | #define BXT_FW_MINOR 7 |
| 61 | |
| 62 | #define KBL_FW_MAJOR 9 |
| 63 | #define KBL_FW_MINOR 14 |
| 64 | |
| 65 | #define GUC_FW_PATH(platform, major, minor) \ |
| 66 | "i915/" __stringify(platform) "_guc_ver" __stringify(major) "_" __stringify(minor) ".bin" |
| 67 | |
| 68 | #define I915_SKL_GUC_UCODE GUC_FW_PATH(skl, SKL_FW_MAJOR, SKL_FW_MINOR) |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 69 | MODULE_FIRMWARE(I915_SKL_GUC_UCODE); |
| 70 | |
Tvrtko Ursulin | 5e334c1 | 2016-08-10 16:16:46 +0100 | [diff] [blame] | 71 | #define I915_BXT_GUC_UCODE GUC_FW_PATH(bxt, BXT_FW_MAJOR, BXT_FW_MINOR) |
Nick Hoath | 57bf5c8 | 2016-05-06 11:42:53 +0100 | [diff] [blame] | 72 | MODULE_FIRMWARE(I915_BXT_GUC_UCODE); |
| 73 | |
Tvrtko Ursulin | 5e334c1 | 2016-08-10 16:16:46 +0100 | [diff] [blame] | 74 | #define I915_KBL_GUC_UCODE GUC_FW_PATH(kbl, KBL_FW_MAJOR, KBL_FW_MINOR) |
Peter Antoine | ff64cc1 | 2016-06-30 09:37:52 -0700 | [diff] [blame] | 75 | MODULE_FIRMWARE(I915_KBL_GUC_UCODE); |
| 76 | |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 77 | /* User-friendly representation of an enum */ |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 78 | const char *intel_uc_fw_status_repr(enum intel_uc_fw_status status) |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 79 | { |
| 80 | switch (status) { |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 81 | case INTEL_UC_FIRMWARE_FAIL: |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 82 | return "FAIL"; |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 83 | case INTEL_UC_FIRMWARE_NONE: |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 84 | return "NONE"; |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 85 | case INTEL_UC_FIRMWARE_PENDING: |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 86 | return "PENDING"; |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 87 | case INTEL_UC_FIRMWARE_SUCCESS: |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 88 | return "SUCCESS"; |
| 89 | default: |
| 90 | return "UNKNOWN!"; |
| 91 | } |
| 92 | }; |
| 93 | |
Dave Gordon | 0c5664e | 2016-09-12 21:19:36 +0100 | [diff] [blame] | 94 | static void guc_interrupts_release(struct drm_i915_private *dev_priv) |
Dave Gordon | 4df001d | 2015-08-12 15:43:42 +0100 | [diff] [blame] | 95 | { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 96 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 97 | enum intel_engine_id id; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 98 | int irqs; |
Dave Gordon | 4df001d | 2015-08-12 15:43:42 +0100 | [diff] [blame] | 99 | |
Dave Gordon | fa7545a | 2016-06-24 15:57:57 +0100 | [diff] [blame] | 100 | /* tell all command streamers NOT to forward interrupts or vblank to GuC */ |
Dave Gordon | 4df001d | 2015-08-12 15:43:42 +0100 | [diff] [blame] | 101 | irqs = _MASKED_FIELD(GFX_FORWARD_VBLANK_MASK, GFX_FORWARD_VBLANK_NEVER); |
| 102 | irqs |= _MASKED_BIT_DISABLE(GFX_INTERRUPT_STEERING); |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 103 | for_each_engine(engine, dev_priv, id) |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 104 | I915_WRITE(RING_MODE_GEN7(engine), irqs); |
Dave Gordon | 4df001d | 2015-08-12 15:43:42 +0100 | [diff] [blame] | 105 | |
Dave Gordon | 4df001d | 2015-08-12 15:43:42 +0100 | [diff] [blame] | 106 | /* route all GT interrupts to the host */ |
| 107 | I915_WRITE(GUC_BCS_RCS_IER, 0); |
| 108 | I915_WRITE(GUC_VCS2_VCS1_IER, 0); |
| 109 | I915_WRITE(GUC_WD_VECS_IER, 0); |
| 110 | } |
| 111 | |
Dave Gordon | 0c5664e | 2016-09-12 21:19:36 +0100 | [diff] [blame] | 112 | static void guc_interrupts_capture(struct drm_i915_private *dev_priv) |
Dave Gordon | 4df001d | 2015-08-12 15:43:42 +0100 | [diff] [blame] | 113 | { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 114 | struct intel_engine_cs *engine; |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 115 | enum intel_engine_id id; |
Dave Gordon | b4ac5af | 2016-03-24 11:20:38 +0000 | [diff] [blame] | 116 | int irqs; |
Sagar Arun Kamble | 1800ad2 | 2016-05-31 13:58:27 +0530 | [diff] [blame] | 117 | u32 tmp; |
Dave Gordon | 4df001d | 2015-08-12 15:43:42 +0100 | [diff] [blame] | 118 | |
Dave Gordon | fa7545a | 2016-06-24 15:57:57 +0100 | [diff] [blame] | 119 | /* tell all command streamers to forward interrupts (but not vblank) to GuC */ |
| 120 | irqs = _MASKED_BIT_ENABLE(GFX_INTERRUPT_STEERING); |
Akash Goel | 3b3f165 | 2016-10-13 22:44:48 +0530 | [diff] [blame] | 121 | for_each_engine(engine, dev_priv, id) |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 122 | I915_WRITE(RING_MODE_GEN7(engine), irqs); |
Dave Gordon | 4df001d | 2015-08-12 15:43:42 +0100 | [diff] [blame] | 123 | |
Dave Gordon | 4df001d | 2015-08-12 15:43:42 +0100 | [diff] [blame] | 124 | /* route USER_INTERRUPT to Host, all others are sent to GuC. */ |
| 125 | irqs = GT_RENDER_USER_INTERRUPT << GEN8_RCS_IRQ_SHIFT | |
| 126 | GT_RENDER_USER_INTERRUPT << GEN8_BCS_IRQ_SHIFT; |
| 127 | /* These three registers have the same bit definitions */ |
| 128 | I915_WRITE(GUC_BCS_RCS_IER, ~irqs); |
| 129 | I915_WRITE(GUC_VCS2_VCS1_IER, ~irqs); |
| 130 | I915_WRITE(GUC_WD_VECS_IER, ~irqs); |
Sagar Arun Kamble | 1800ad2 | 2016-05-31 13:58:27 +0530 | [diff] [blame] | 131 | |
| 132 | /* |
Dave Gordon | b20e3cf | 2016-09-12 21:19:35 +0100 | [diff] [blame] | 133 | * The REDIRECT_TO_GUC bit of the PMINTRMSK register directs all |
| 134 | * (unmasked) PM interrupts to the GuC. All other bits of this |
| 135 | * register *disable* generation of a specific interrupt. |
| 136 | * |
| 137 | * 'pm_intr_keep' indicates bits that are NOT to be set when |
| 138 | * writing to the PM interrupt mask register, i.e. interrupts |
| 139 | * that must not be disabled. |
| 140 | * |
| 141 | * If the GuC is handling these interrupts, then we must not let |
| 142 | * the PM code disable ANY interrupt that the GuC is expecting. |
| 143 | * So for each ENABLED (0) bit in this register, we must SET the |
| 144 | * bit in pm_intr_keep so that it's left enabled for the GuC. |
| 145 | * |
| 146 | * OTOH the REDIRECT_TO_GUC bit is initially SET in pm_intr_keep |
| 147 | * (so interrupts go to the DISPLAY unit at first); but here we |
| 148 | * need to CLEAR that bit, which will result in the register bit |
| 149 | * being left SET! |
| 150 | */ |
Sagar Arun Kamble | 1800ad2 | 2016-05-31 13:58:27 +0530 | [diff] [blame] | 151 | tmp = I915_READ(GEN6_PMINTRMSK); |
Dave Gordon | b20e3cf | 2016-09-12 21:19:35 +0100 | [diff] [blame] | 152 | if (tmp & GEN8_PMINTR_REDIRECT_TO_GUC) { |
| 153 | dev_priv->rps.pm_intr_keep |= ~tmp; |
| 154 | dev_priv->rps.pm_intr_keep &= ~GEN8_PMINTR_REDIRECT_TO_GUC; |
Sagar Arun Kamble | 1800ad2 | 2016-05-31 13:58:27 +0530 | [diff] [blame] | 155 | } |
Dave Gordon | 4df001d | 2015-08-12 15:43:42 +0100 | [diff] [blame] | 156 | } |
| 157 | |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 158 | static u32 get_gttype(struct drm_i915_private *dev_priv) |
| 159 | { |
| 160 | /* XXX: GT type based on PCI device ID? field seems unused by fw */ |
| 161 | return 0; |
| 162 | } |
| 163 | |
| 164 | static u32 get_core_family(struct drm_i915_private *dev_priv) |
| 165 | { |
Dave Gordon | fc32de9 | 2016-08-18 18:17:24 +0100 | [diff] [blame] | 166 | u32 gen = INTEL_GEN(dev_priv); |
| 167 | |
| 168 | switch (gen) { |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 169 | case 9: |
| 170 | return GFXCORE_FAMILY_GEN9; |
| 171 | |
| 172 | default: |
Dave Gordon | fc32de9 | 2016-08-18 18:17:24 +0100 | [diff] [blame] | 173 | WARN(1, "GEN%d does not support GuC operation!\n", gen); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 174 | return GFXCORE_FAMILY_UNKNOWN; |
| 175 | } |
| 176 | } |
| 177 | |
Dave Gordon | 0c5664e | 2016-09-12 21:19:36 +0100 | [diff] [blame] | 178 | /* |
| 179 | * Initialise the GuC parameter block before starting the firmware |
| 180 | * transfer. These parameters are read by the firmware on startup |
| 181 | * and cannot be changed thereafter. |
| 182 | */ |
| 183 | static void guc_params_init(struct drm_i915_private *dev_priv) |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 184 | { |
| 185 | struct intel_guc *guc = &dev_priv->guc; |
| 186 | u32 params[GUC_CTL_MAX_DWORDS]; |
| 187 | int i; |
| 188 | |
| 189 | memset(¶ms, 0, sizeof(params)); |
| 190 | |
| 191 | params[GUC_CTL_DEVICE_INFO] |= |
| 192 | (get_gttype(dev_priv) << GUC_CTL_GTTYPE_SHIFT) | |
| 193 | (get_core_family(dev_priv) << GUC_CTL_COREFAMILY_SHIFT); |
| 194 | |
| 195 | /* |
| 196 | * GuC ARAT increment is 10 ns. GuC default scheduler quantum is one |
| 197 | * second. This ARAR is calculated by: |
| 198 | * Scheduler-Quantum-in-ns / ARAT-increment-in-ns = 1000000000 / 10 |
| 199 | */ |
| 200 | params[GUC_CTL_ARAT_HIGH] = 0; |
| 201 | params[GUC_CTL_ARAT_LOW] = 100000000; |
| 202 | |
| 203 | params[GUC_CTL_WA] |= GUC_CTL_WA_UK_BY_DRIVER; |
| 204 | |
| 205 | params[GUC_CTL_FEATURE] |= GUC_CTL_DISABLE_SCHEDULER | |
| 206 | GUC_CTL_VCS2_ENABLED; |
| 207 | |
Akash Goel | d6b40b4 | 2016-10-12 21:54:29 +0530 | [diff] [blame] | 208 | params[GUC_CTL_LOG_PARAMS] = guc->log.flags; |
Sagar Arun Kamble | b1e3710 | 2016-10-12 21:54:27 +0530 | [diff] [blame] | 209 | |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 210 | if (i915.guc_log_level >= 0) { |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 211 | params[GUC_CTL_DEBUG] = |
| 212 | i915.guc_log_level << GUC_LOG_VERBOSITY_SHIFT; |
Sagar Arun Kamble | b1e3710 | 2016-10-12 21:54:27 +0530 | [diff] [blame] | 213 | } else |
| 214 | params[GUC_CTL_DEBUG] = GUC_LOG_DISABLED; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 215 | |
Chris Wilson | 8b797af | 2016-08-15 10:48:51 +0100 | [diff] [blame] | 216 | if (guc->ads_vma) { |
Chris Wilson | 4741da9 | 2016-12-24 19:31:46 +0000 | [diff] [blame] | 217 | u32 ads = guc_ggtt_offset(guc->ads_vma) >> PAGE_SHIFT; |
Alex Dai | b6a5cd7 | 2015-12-18 12:00:12 -0800 | [diff] [blame] | 218 | params[GUC_CTL_DEBUG] |= ads << GUC_ADS_ADDR_SHIFT; |
| 219 | params[GUC_CTL_DEBUG] |= GUC_ADS_ENABLED; |
| 220 | } |
| 221 | |
Alex Dai | bac427f | 2015-08-12 15:43:39 +0100 | [diff] [blame] | 222 | /* If GuC submission is enabled, set up additional parameters here */ |
| 223 | if (i915.enable_guc_submission) { |
Chris Wilson | 4741da9 | 2016-12-24 19:31:46 +0000 | [diff] [blame] | 224 | u32 pgs = guc_ggtt_offset(dev_priv->guc.ctx_pool_vma); |
Alex Dai | bac427f | 2015-08-12 15:43:39 +0100 | [diff] [blame] | 225 | u32 ctx_in_16 = GUC_MAX_GPU_CONTEXTS / 16; |
| 226 | |
| 227 | pgs >>= PAGE_SHIFT; |
| 228 | params[GUC_CTL_CTXINFO] = (pgs << GUC_CTL_BASE_ADDR_SHIFT) | |
| 229 | (ctx_in_16 << GUC_CTL_CTXNUM_IN16_SHIFT); |
| 230 | |
| 231 | params[GUC_CTL_FEATURE] |= GUC_CTL_KERNEL_SUBMISSIONS; |
| 232 | |
| 233 | /* Unmask this bit to enable the GuC's internal scheduler */ |
| 234 | params[GUC_CTL_FEATURE] &= ~GUC_CTL_DISABLE_SCHEDULER; |
| 235 | } |
| 236 | |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 237 | I915_WRITE(SOFT_SCRATCH(0), 0); |
| 238 | |
| 239 | for (i = 0; i < GUC_CTL_MAX_DWORDS; i++) |
| 240 | I915_WRITE(SOFT_SCRATCH(1 + i), params[i]); |
| 241 | } |
| 242 | |
| 243 | /* |
| 244 | * Read the GuC status register (GUC_STATUS) and store it in the |
| 245 | * specified location; then return a boolean indicating whether |
| 246 | * the value matches either of two values representing completion |
| 247 | * of the GuC boot process. |
| 248 | * |
Tvrtko Ursulin | 36894e8 | 2016-02-11 10:27:31 +0000 | [diff] [blame] | 249 | * This is used for polling the GuC status in a wait_for() |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 250 | * loop below. |
| 251 | */ |
| 252 | static inline bool guc_ucode_response(struct drm_i915_private *dev_priv, |
| 253 | u32 *status) |
| 254 | { |
| 255 | u32 val = I915_READ(GUC_STATUS); |
Alex Dai | 0d44d3f | 2015-09-22 13:48:40 -0700 | [diff] [blame] | 256 | u32 uk_val = val & GS_UKERNEL_MASK; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 257 | *status = val; |
Alex Dai | 0d44d3f | 2015-09-22 13:48:40 -0700 | [diff] [blame] | 258 | return (uk_val == GS_UKERNEL_READY || |
| 259 | ((val & GS_MIA_CORE_STATE) && uk_val == GS_UKERNEL_LAPIC_DONE)); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 260 | } |
| 261 | |
| 262 | /* |
| 263 | * Transfer the firmware image to RAM for execution by the microcontroller. |
| 264 | * |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 265 | * Architecturally, the DMA engine is bidirectional, and can potentially even |
| 266 | * transfer between GTT locations. This functionality is left out of the API |
| 267 | * for now as there is no need for it. |
| 268 | * |
| 269 | * Note that GuC needs the CSS header plus uKernel code to be copied by the |
| 270 | * DMA engine in one operation, whereas the RSA signature is loaded via MMIO. |
| 271 | */ |
Chris Wilson | 058d88c | 2016-08-15 10:49:06 +0100 | [diff] [blame] | 272 | static int guc_ucode_xfer_dma(struct drm_i915_private *dev_priv, |
| 273 | struct i915_vma *vma) |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 274 | { |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 275 | struct intel_uc_fw *guc_fw = &dev_priv->guc.fw; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 276 | unsigned long offset; |
Chris Wilson | 058d88c | 2016-08-15 10:49:06 +0100 | [diff] [blame] | 277 | struct sg_table *sg = vma->pages; |
Alex Dai | feda33e | 2015-10-19 16:10:54 -0700 | [diff] [blame] | 278 | u32 status, rsa[UOS_RSA_SCRATCH_MAX_COUNT]; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 279 | int i, ret = 0; |
| 280 | |
Alex Dai | feda33e | 2015-10-19 16:10:54 -0700 | [diff] [blame] | 281 | /* where RSA signature starts */ |
| 282 | offset = guc_fw->rsa_offset; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 283 | |
| 284 | /* Copy RSA signature from the fw image to HW for verification */ |
Alex Dai | feda33e | 2015-10-19 16:10:54 -0700 | [diff] [blame] | 285 | sg_pcopy_to_buffer(sg->sgl, sg->nents, rsa, sizeof(rsa), offset); |
| 286 | for (i = 0; i < UOS_RSA_SCRATCH_MAX_COUNT; i++) |
Ville Syrjälä | ab9cc55 | 2015-09-18 20:03:24 +0300 | [diff] [blame] | 287 | I915_WRITE(UOS_RSA_SCRATCH(i), rsa[i]); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 288 | |
Alex Dai | feda33e | 2015-10-19 16:10:54 -0700 | [diff] [blame] | 289 | /* The header plus uCode will be copied to WOPCM via DMA, excluding any |
| 290 | * other components */ |
| 291 | I915_WRITE(DMA_COPY_SIZE, guc_fw->header_size + guc_fw->ucode_size); |
| 292 | |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 293 | /* Set the source address for the new blob */ |
Chris Wilson | 4741da9 | 2016-12-24 19:31:46 +0000 | [diff] [blame] | 294 | offset = guc_ggtt_offset(vma) + guc_fw->header_offset; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 295 | I915_WRITE(DMA_ADDR_0_LOW, lower_32_bits(offset)); |
| 296 | I915_WRITE(DMA_ADDR_0_HIGH, upper_32_bits(offset) & 0xFFFF); |
| 297 | |
| 298 | /* |
| 299 | * Set the DMA destination. Current uCode expects the code to be |
| 300 | * loaded at 8k; locations below this are used for the stack. |
| 301 | */ |
| 302 | I915_WRITE(DMA_ADDR_1_LOW, 0x2000); |
| 303 | I915_WRITE(DMA_ADDR_1_HIGH, DMA_ADDRESS_SPACE_WOPCM); |
| 304 | |
| 305 | /* Finally start the DMA */ |
| 306 | I915_WRITE(DMA_CTRL, _MASKED_BIT_ENABLE(UOS_MOVE | START_DMA)); |
| 307 | |
| 308 | /* |
Tvrtko Ursulin | 36894e8 | 2016-02-11 10:27:31 +0000 | [diff] [blame] | 309 | * Wait for the DMA to complete & the GuC to start up. |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 310 | * NB: Docs recommend not using the interrupt for completion. |
| 311 | * Measurements indicate this should take no more than 20ms, so a |
| 312 | * timeout here indicates that the GuC has failed and is unusable. |
| 313 | * (Higher levels of the driver will attempt to fall back to |
| 314 | * execlist mode if this happens.) |
| 315 | */ |
Tvrtko Ursulin | 36894e8 | 2016-02-11 10:27:31 +0000 | [diff] [blame] | 316 | ret = wait_for(guc_ucode_response(dev_priv, &status), 100); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 317 | |
| 318 | DRM_DEBUG_DRIVER("DMA status 0x%x, GuC status 0x%x\n", |
| 319 | I915_READ(DMA_CTRL), status); |
| 320 | |
| 321 | if ((status & GS_BOOTROM_MASK) == GS_BOOTROM_RSA_FAILED) { |
| 322 | DRM_ERROR("GuC firmware signature verification failed\n"); |
| 323 | ret = -ENOEXEC; |
| 324 | } |
| 325 | |
| 326 | DRM_DEBUG_DRIVER("returning %d\n", ret); |
| 327 | |
| 328 | return ret; |
| 329 | } |
| 330 | |
Anusha Srivatsa | bd132858 | 2017-01-18 08:05:53 -0800 | [diff] [blame] | 331 | u32 intel_guc_wopcm_size(struct drm_i915_private *dev_priv) |
Peter Antoine | 74aa156 | 2016-05-17 15:12:45 +0100 | [diff] [blame] | 332 | { |
| 333 | u32 wopcm_size = GUC_WOPCM_TOP; |
| 334 | |
| 335 | /* On BXT, the top of WOPCM is reserved for RC6 context */ |
Michel Thierry | 254e093 | 2017-01-09 16:51:35 +0200 | [diff] [blame] | 336 | if (IS_GEN9_LP(dev_priv)) |
Peter Antoine | 74aa156 | 2016-05-17 15:12:45 +0100 | [diff] [blame] | 337 | wopcm_size -= BXT_GUC_WOPCM_RC6_RESERVED; |
| 338 | |
| 339 | return wopcm_size; |
| 340 | } |
| 341 | |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 342 | /* |
| 343 | * Load the GuC firmware blob into the MinuteIA. |
| 344 | */ |
| 345 | static int guc_ucode_xfer(struct drm_i915_private *dev_priv) |
| 346 | { |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 347 | struct intel_uc_fw *guc_fw = &dev_priv->guc.fw; |
Chris Wilson | 058d88c | 2016-08-15 10:49:06 +0100 | [diff] [blame] | 348 | struct i915_vma *vma; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 349 | int ret; |
| 350 | |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 351 | ret = i915_gem_object_set_to_gtt_domain(guc_fw->obj, false); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 352 | if (ret) { |
| 353 | DRM_DEBUG_DRIVER("set-domain failed %d\n", ret); |
| 354 | return ret; |
| 355 | } |
| 356 | |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 357 | vma = i915_gem_object_ggtt_pin(guc_fw->obj, NULL, 0, 0, |
Michał Winiarski | 83796f2 | 2017-01-11 16:17:39 +0100 | [diff] [blame] | 358 | PIN_OFFSET_BIAS | GUC_WOPCM_TOP); |
Chris Wilson | 058d88c | 2016-08-15 10:49:06 +0100 | [diff] [blame] | 359 | if (IS_ERR(vma)) { |
| 360 | DRM_DEBUG_DRIVER("pin failed %d\n", (int)PTR_ERR(vma)); |
| 361 | return PTR_ERR(vma); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 362 | } |
| 363 | |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 364 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
| 365 | |
| 366 | /* init WOPCM */ |
Anusha Srivatsa | bd132858 | 2017-01-18 08:05:53 -0800 | [diff] [blame] | 367 | I915_WRITE(GUC_WOPCM_SIZE, intel_guc_wopcm_size(dev_priv)); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 368 | I915_WRITE(DMA_GUC_WOPCM_OFFSET, GUC_WOPCM_OFFSET_VALUE); |
| 369 | |
| 370 | /* Enable MIA caching. GuC clock gating is disabled. */ |
| 371 | I915_WRITE(GUC_SHIM_CONTROL, GUC_SHIM_CONTROL_VALUE); |
| 372 | |
Jani Nikula | a117f37 | 2016-09-16 16:59:44 +0300 | [diff] [blame] | 373 | /* WaDisableMinuteIaClockGating:bxt */ |
Tvrtko Ursulin | e2d214a | 2016-10-13 11:03:04 +0100 | [diff] [blame] | 374 | if (IS_BXT_REVID(dev_priv, 0, BXT_REVID_A1)) { |
Nick Hoath | b970b48 | 2015-09-08 10:31:53 +0100 | [diff] [blame] | 375 | I915_WRITE(GUC_SHIM_CONTROL, (I915_READ(GUC_SHIM_CONTROL) & |
| 376 | ~GUC_ENABLE_MIA_CLOCK_GATING)); |
| 377 | } |
| 378 | |
Jani Nikula | 4ff40a4 | 2016-09-26 15:07:51 +0300 | [diff] [blame] | 379 | /* WaC6DisallowByGfxPause:bxt */ |
Tvrtko Ursulin | e2d214a | 2016-10-13 11:03:04 +0100 | [diff] [blame] | 380 | if (IS_BXT_REVID(dev_priv, 0, BXT_REVID_B0)) |
Tim Gore | 65fe29e | 2016-07-20 11:00:25 +0100 | [diff] [blame] | 381 | I915_WRITE(GEN6_GFXPAUSE, 0x30FFF); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 382 | |
Michel Thierry | 254e093 | 2017-01-09 16:51:35 +0200 | [diff] [blame] | 383 | if (IS_GEN9_LP(dev_priv)) |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 384 | I915_WRITE(GEN9LP_GT_PM_CONFIG, GT_DOORBELL_ENABLE); |
| 385 | else |
| 386 | I915_WRITE(GEN9_GT_PM_CONFIG, GT_DOORBELL_ENABLE); |
| 387 | |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 388 | if (IS_GEN9(dev_priv)) { |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 389 | /* DOP Clock Gating Enable for GuC clocks */ |
| 390 | I915_WRITE(GEN7_MISCCPCTL, (GEN8_DOP_CLOCK_GATE_GUC_ENABLE | |
| 391 | I915_READ(GEN7_MISCCPCTL))); |
| 392 | |
Dave Gordon | 0c5664e | 2016-09-12 21:19:36 +0100 | [diff] [blame] | 393 | /* allows for 5us (in 10ns units) before GT can go to RC6 */ |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 394 | I915_WRITE(GUC_ARAT_C6DIS, 0x1FF); |
| 395 | } |
| 396 | |
Dave Gordon | 0c5664e | 2016-09-12 21:19:36 +0100 | [diff] [blame] | 397 | guc_params_init(dev_priv); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 398 | |
Chris Wilson | 058d88c | 2016-08-15 10:49:06 +0100 | [diff] [blame] | 399 | ret = guc_ucode_xfer_dma(dev_priv, vma); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 400 | |
| 401 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
| 402 | |
| 403 | /* |
| 404 | * We keep the object pages for reuse during resume. But we can unpin it |
| 405 | * now that DMA has completed, so it doesn't continue to take up space. |
| 406 | */ |
Chris Wilson | 058d88c | 2016-08-15 10:49:06 +0100 | [diff] [blame] | 407 | i915_vma_unpin(vma); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 408 | |
| 409 | return ret; |
| 410 | } |
| 411 | |
Dave Gordon | 0c5664e | 2016-09-12 21:19:36 +0100 | [diff] [blame] | 412 | static int guc_hw_reset(struct drm_i915_private *dev_priv) |
Arun Siluvery | 6b332fa | 2016-04-04 18:50:56 +0100 | [diff] [blame] | 413 | { |
| 414 | int ret; |
| 415 | u32 guc_status; |
| 416 | |
| 417 | ret = intel_guc_reset(dev_priv); |
| 418 | if (ret) { |
| 419 | DRM_ERROR("GuC reset failed, ret = %d\n", ret); |
| 420 | return ret; |
| 421 | } |
| 422 | |
| 423 | guc_status = I915_READ(GUC_STATUS); |
| 424 | WARN(!(guc_status & GS_MIA_IN_RESET), |
| 425 | "GuC status: 0x%x, MIA core expected to be in reset\n", guc_status); |
| 426 | |
| 427 | return ret; |
| 428 | } |
| 429 | |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 430 | /** |
Dave Gordon | f09d675 | 2016-05-13 15:36:29 +0100 | [diff] [blame] | 431 | * intel_guc_setup() - finish preparing the GuC for activity |
Tvrtko Ursulin | bf9e842 | 2016-12-01 14:16:38 +0000 | [diff] [blame] | 432 | * @dev_priv: i915 device private |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 433 | * |
| 434 | * Called from gem_init_hw() during driver loading and also after a GPU reset. |
| 435 | * |
Dave Gordon | f09d675 | 2016-05-13 15:36:29 +0100 | [diff] [blame] | 436 | * The main action required here it to load the GuC uCode into the device. |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 437 | * The firmware image should have already been fetched into memory by the |
Dave Gordon | f09d675 | 2016-05-13 15:36:29 +0100 | [diff] [blame] | 438 | * earlier call to intel_guc_init(), so here we need only check that worked, |
| 439 | * and then transfer the image to the h/w. |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 440 | * |
| 441 | * Return: non-zero code on error |
| 442 | */ |
Tvrtko Ursulin | bf9e842 | 2016-12-01 14:16:38 +0000 | [diff] [blame] | 443 | int intel_guc_setup(struct drm_i915_private *dev_priv) |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 444 | { |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 445 | struct intel_uc_fw *guc_fw = &dev_priv->guc.fw; |
| 446 | const char *fw_path = guc_fw->path; |
Dave Gordon | fce91f2 | 2016-05-20 11:42:42 +0100 | [diff] [blame] | 447 | int retries, ret, err; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 448 | |
Dave Gordon | fce91f2 | 2016-05-20 11:42:42 +0100 | [diff] [blame] | 449 | DRM_DEBUG_DRIVER("GuC fw status: path %s, fetch %s, load %s\n", |
| 450 | fw_path, |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 451 | intel_uc_fw_status_repr(guc_fw->fetch_status), |
| 452 | intel_uc_fw_status_repr(guc_fw->load_status)); |
Dave Gordon | fce91f2 | 2016-05-20 11:42:42 +0100 | [diff] [blame] | 453 | |
| 454 | /* Loading forbidden, or no firmware to load? */ |
| 455 | if (!i915.enable_guc_loading) { |
| 456 | err = 0; |
| 457 | goto fail; |
Dave Gordon | e556f7c | 2016-06-07 09:14:49 +0100 | [diff] [blame] | 458 | } else if (fw_path == NULL) { |
| 459 | /* Device is known to have no uCode (e.g. no GuC) */ |
| 460 | err = -ENXIO; |
| 461 | goto fail; |
| 462 | } else if (*fw_path == '\0') { |
| 463 | /* Device has a GuC but we don't know what f/w to load? */ |
Dave Gordon | fc32de9 | 2016-08-18 18:17:24 +0100 | [diff] [blame] | 464 | WARN(1, "No GuC firmware known for this platform!\n"); |
Dave Gordon | fce91f2 | 2016-05-20 11:42:42 +0100 | [diff] [blame] | 465 | err = -ENODEV; |
| 466 | goto fail; |
| 467 | } |
| 468 | |
| 469 | /* Fetch failed, or already fetched but failed to load? */ |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 470 | if (guc_fw->fetch_status != INTEL_UC_FIRMWARE_SUCCESS) { |
Dave Gordon | fce91f2 | 2016-05-20 11:42:42 +0100 | [diff] [blame] | 471 | err = -EIO; |
| 472 | goto fail; |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 473 | } else if (guc_fw->load_status == INTEL_UC_FIRMWARE_FAIL) { |
Dave Gordon | fce91f2 | 2016-05-20 11:42:42 +0100 | [diff] [blame] | 474 | err = -ENOEXEC; |
| 475 | goto fail; |
| 476 | } |
| 477 | |
Dave Gordon | 0c5664e | 2016-09-12 21:19:36 +0100 | [diff] [blame] | 478 | guc_interrupts_release(dev_priv); |
Sagar Arun Kamble | 26705e2 | 2016-10-12 21:54:31 +0530 | [diff] [blame] | 479 | gen9_reset_guc_interrupts(dev_priv); |
Dave Gordon | fce91f2 | 2016-05-20 11:42:42 +0100 | [diff] [blame] | 480 | |
Chris Wilson | 7c3f86b | 2017-01-12 11:00:49 +0000 | [diff] [blame] | 481 | /* We need to notify the guc whenever we change the GGTT */ |
| 482 | i915_ggtt_enable_guc(dev_priv); |
| 483 | |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 484 | guc_fw->load_status = INTEL_UC_FIRMWARE_PENDING; |
Daniel Vetter | 9f9e539 | 2015-10-23 11:10:59 +0200 | [diff] [blame] | 485 | |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 486 | DRM_DEBUG_DRIVER("GuC fw status: fetch %s, load %s\n", |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 487 | intel_uc_fw_status_repr(guc_fw->fetch_status), |
| 488 | intel_uc_fw_status_repr(guc_fw->load_status)); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 489 | |
Dave Gordon | beffa51 | 2016-06-10 18:29:26 +0100 | [diff] [blame] | 490 | err = i915_guc_submission_init(dev_priv); |
Alex Dai | bac427f | 2015-08-12 15:43:39 +0100 | [diff] [blame] | 491 | if (err) |
| 492 | goto fail; |
| 493 | |
Arun Siluvery | 6b332fa | 2016-04-04 18:50:56 +0100 | [diff] [blame] | 494 | /* |
| 495 | * WaEnableuKernelHeaderValidFix:skl,bxt |
| 496 | * For BXT, this is only upto B0 but below WA is required for later |
| 497 | * steppings also so this is extended as well. |
| 498 | */ |
| 499 | /* WaEnableGuCBootHashCheckNotSet:skl,bxt */ |
Dave Gordon | d761701 | 2016-04-04 18:50:57 +0100 | [diff] [blame] | 500 | for (retries = 3; ; ) { |
| 501 | /* |
| 502 | * Always reset the GuC just before (re)loading, so |
| 503 | * that the state and timing are fairly predictable |
| 504 | */ |
Dave Gordon | 0c5664e | 2016-09-12 21:19:36 +0100 | [diff] [blame] | 505 | err = guc_hw_reset(dev_priv); |
Dave Gordon | fc32de9 | 2016-08-18 18:17:24 +0100 | [diff] [blame] | 506 | if (err) |
Arun Siluvery | 6b332fa | 2016-04-04 18:50:56 +0100 | [diff] [blame] | 507 | goto fail; |
Dave Gordon | d761701 | 2016-04-04 18:50:57 +0100 | [diff] [blame] | 508 | |
Anusha Srivatsa | bd132858 | 2017-01-18 08:05:53 -0800 | [diff] [blame] | 509 | intel_huc_load(dev_priv); |
Dave Gordon | d761701 | 2016-04-04 18:50:57 +0100 | [diff] [blame] | 510 | err = guc_ucode_xfer(dev_priv); |
| 511 | if (!err) |
| 512 | break; |
| 513 | |
| 514 | if (--retries == 0) |
| 515 | goto fail; |
| 516 | |
Dave Gordon | fce91f2 | 2016-05-20 11:42:42 +0100 | [diff] [blame] | 517 | DRM_INFO("GuC fw load failed: %d; will reset and " |
| 518 | "retry %d more time(s)\n", err, retries); |
Arun Siluvery | 6b332fa | 2016-04-04 18:50:56 +0100 | [diff] [blame] | 519 | } |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 520 | |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 521 | guc_fw->load_status = INTEL_UC_FIRMWARE_SUCCESS; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 522 | |
Anusha Srivatsa | dac84a3 | 2017-01-18 08:05:57 -0800 | [diff] [blame] | 523 | intel_guc_auth_huc(dev_priv); |
| 524 | |
Dave Gordon | 44a28b1 | 2015-08-12 15:43:41 +0100 | [diff] [blame] | 525 | if (i915.enable_guc_submission) { |
Sagar Arun Kamble | 26705e2 | 2016-10-12 21:54:31 +0530 | [diff] [blame] | 526 | if (i915.guc_log_level >= 0) |
| 527 | gen9_enable_guc_interrupts(dev_priv); |
| 528 | |
Dave Gordon | beffa51 | 2016-06-10 18:29:26 +0100 | [diff] [blame] | 529 | err = i915_guc_submission_enable(dev_priv); |
Dave Gordon | 44a28b1 | 2015-08-12 15:43:41 +0100 | [diff] [blame] | 530 | if (err) |
| 531 | goto fail; |
Dave Gordon | 0c5664e | 2016-09-12 21:19:36 +0100 | [diff] [blame] | 532 | guc_interrupts_capture(dev_priv); |
Dave Gordon | 44a28b1 | 2015-08-12 15:43:41 +0100 | [diff] [blame] | 533 | } |
| 534 | |
Tvrtko Ursulin | fb51ff4 | 2017-02-07 08:50:25 +0000 | [diff] [blame] | 535 | DRM_INFO("GuC %s (firmware %s [version %u.%u])\n", |
| 536 | i915.enable_guc_submission ? "submission enabled" : "loaded", |
| 537 | guc_fw->path, |
| 538 | guc_fw->major_ver_found, guc_fw->minor_ver_found); |
| 539 | |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 540 | return 0; |
| 541 | |
| 542 | fail: |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 543 | if (guc_fw->load_status == INTEL_UC_FIRMWARE_PENDING) |
| 544 | guc_fw->load_status = INTEL_UC_FIRMWARE_FAIL; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 545 | |
Dave Gordon | 0c5664e | 2016-09-12 21:19:36 +0100 | [diff] [blame] | 546 | guc_interrupts_release(dev_priv); |
Dave Gordon | beffa51 | 2016-06-10 18:29:26 +0100 | [diff] [blame] | 547 | i915_guc_submission_disable(dev_priv); |
| 548 | i915_guc_submission_fini(dev_priv); |
Chris Wilson | 7c3f86b | 2017-01-12 11:00:49 +0000 | [diff] [blame] | 549 | i915_ggtt_disable_guc(dev_priv); |
Dave Gordon | 44a28b1 | 2015-08-12 15:43:41 +0100 | [diff] [blame] | 550 | |
Dave Gordon | fce91f2 | 2016-05-20 11:42:42 +0100 | [diff] [blame] | 551 | /* |
| 552 | * We've failed to load the firmware :( |
| 553 | * |
| 554 | * Decide whether to disable GuC submission and fall back to |
| 555 | * execlist mode, and whether to hide the error by returning |
| 556 | * zero or to return -EIO, which the caller will treat as a |
| 557 | * nonfatal error (i.e. it doesn't prevent driver load, but |
| 558 | * marks the GPU as wedged until reset). |
| 559 | */ |
| 560 | if (i915.enable_guc_loading > 1) { |
| 561 | ret = -EIO; |
| 562 | } else if (i915.enable_guc_submission > 1) { |
| 563 | ret = -EIO; |
| 564 | } else { |
| 565 | ret = 0; |
| 566 | } |
| 567 | |
Tvrtko Ursulin | 4805fe8 | 2016-11-04 14:42:46 +0000 | [diff] [blame] | 568 | if (err == 0 && !HAS_GUC_UCODE(dev_priv)) |
Dave Gordon | 4e50f79 | 2016-06-10 17:21:25 +0100 | [diff] [blame] | 569 | ; /* Don't mention the GuC! */ |
| 570 | else if (err == 0) |
Dave Gordon | fce91f2 | 2016-05-20 11:42:42 +0100 | [diff] [blame] | 571 | DRM_INFO("GuC firmware load skipped\n"); |
Dave Gordon | 4e50f79 | 2016-06-10 17:21:25 +0100 | [diff] [blame] | 572 | else if (ret != -EIO) |
Dave Gordon | fc32de9 | 2016-08-18 18:17:24 +0100 | [diff] [blame] | 573 | DRM_NOTE("GuC firmware load failed: %d\n", err); |
Dave Gordon | 4e50f79 | 2016-06-10 17:21:25 +0100 | [diff] [blame] | 574 | else |
Dave Gordon | fc32de9 | 2016-08-18 18:17:24 +0100 | [diff] [blame] | 575 | DRM_WARN("GuC firmware load failed: %d\n", err); |
Dave Gordon | fce91f2 | 2016-05-20 11:42:42 +0100 | [diff] [blame] | 576 | |
| 577 | if (i915.enable_guc_submission) { |
| 578 | if (fw_path == NULL) |
| 579 | DRM_INFO("GuC submission without firmware not supported\n"); |
| 580 | if (ret == 0) |
Dave Gordon | fc32de9 | 2016-08-18 18:17:24 +0100 | [diff] [blame] | 581 | DRM_NOTE("Falling back from GuC submission to execlist mode\n"); |
Dave Gordon | fce91f2 | 2016-05-20 11:42:42 +0100 | [diff] [blame] | 582 | else |
| 583 | DRM_ERROR("GuC init failed: %d\n", ret); |
| 584 | } |
| 585 | i915.enable_guc_submission = 0; |
| 586 | |
| 587 | return ret; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 588 | } |
| 589 | |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 590 | void intel_uc_fw_fetch(struct drm_i915_private *dev_priv, |
| 591 | struct intel_uc_fw *uc_fw) |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 592 | { |
Tvrtko Ursulin | bf9e842 | 2016-12-01 14:16:38 +0000 | [diff] [blame] | 593 | struct pci_dev *pdev = dev_priv->drm.pdev; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 594 | struct drm_i915_gem_object *obj; |
Jérémy Lefaure | 3aaa8ab | 2016-11-28 18:43:19 -0500 | [diff] [blame] | 595 | const struct firmware *fw = NULL; |
Anusha Srivatsa | fbbad73 | 2017-01-13 17:17:05 -0800 | [diff] [blame] | 596 | struct uc_css_header *css; |
Alex Dai | feda33e | 2015-10-19 16:10:54 -0700 | [diff] [blame] | 597 | size_t size; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 598 | int err; |
| 599 | |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 600 | DRM_DEBUG_DRIVER("before requesting firmware: uC fw fetch status %s\n", |
| 601 | intel_uc_fw_status_repr(uc_fw->fetch_status)); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 602 | |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 603 | err = request_firmware(&fw, uc_fw->path, &pdev->dev); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 604 | if (err) |
| 605 | goto fail; |
| 606 | if (!fw) |
| 607 | goto fail; |
| 608 | |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 609 | DRM_DEBUG_DRIVER("fetch uC fw from %s succeeded, fw %p\n", |
| 610 | uc_fw->path, fw); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 611 | |
Alex Dai | feda33e | 2015-10-19 16:10:54 -0700 | [diff] [blame] | 612 | /* Check the size of the blob before examining buffer contents */ |
Anusha Srivatsa | fbbad73 | 2017-01-13 17:17:05 -0800 | [diff] [blame] | 613 | if (fw->size < sizeof(struct uc_css_header)) { |
Dave Gordon | fc32de9 | 2016-08-18 18:17:24 +0100 | [diff] [blame] | 614 | DRM_NOTE("Firmware header is missing\n"); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 615 | goto fail; |
Alex Dai | feda33e | 2015-10-19 16:10:54 -0700 | [diff] [blame] | 616 | } |
| 617 | |
Anusha Srivatsa | fbbad73 | 2017-01-13 17:17:05 -0800 | [diff] [blame] | 618 | css = (struct uc_css_header *)fw->data; |
Alex Dai | feda33e | 2015-10-19 16:10:54 -0700 | [diff] [blame] | 619 | |
| 620 | /* Firmware bits always start from header */ |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 621 | uc_fw->header_offset = 0; |
| 622 | uc_fw->header_size = (css->header_size_dw - css->modulus_size_dw - |
Alex Dai | feda33e | 2015-10-19 16:10:54 -0700 | [diff] [blame] | 623 | css->key_size_dw - css->exponent_size_dw) * sizeof(u32); |
| 624 | |
Anusha Srivatsa | fbbad73 | 2017-01-13 17:17:05 -0800 | [diff] [blame] | 625 | if (uc_fw->header_size != sizeof(struct uc_css_header)) { |
Dave Gordon | fc32de9 | 2016-08-18 18:17:24 +0100 | [diff] [blame] | 626 | DRM_NOTE("CSS header definition mismatch\n"); |
Alex Dai | feda33e | 2015-10-19 16:10:54 -0700 | [diff] [blame] | 627 | goto fail; |
| 628 | } |
| 629 | |
| 630 | /* then, uCode */ |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 631 | uc_fw->ucode_offset = uc_fw->header_offset + uc_fw->header_size; |
| 632 | uc_fw->ucode_size = (css->size_dw - css->header_size_dw) * sizeof(u32); |
Alex Dai | feda33e | 2015-10-19 16:10:54 -0700 | [diff] [blame] | 633 | |
| 634 | /* now RSA */ |
| 635 | if (css->key_size_dw != UOS_RSA_SCRATCH_MAX_COUNT) { |
Dave Gordon | fc32de9 | 2016-08-18 18:17:24 +0100 | [diff] [blame] | 636 | DRM_NOTE("RSA key size is bad\n"); |
Alex Dai | feda33e | 2015-10-19 16:10:54 -0700 | [diff] [blame] | 637 | goto fail; |
| 638 | } |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 639 | uc_fw->rsa_offset = uc_fw->ucode_offset + uc_fw->ucode_size; |
| 640 | uc_fw->rsa_size = css->key_size_dw * sizeof(u32); |
Alex Dai | feda33e | 2015-10-19 16:10:54 -0700 | [diff] [blame] | 641 | |
| 642 | /* At least, it should have header, uCode and RSA. Size of all three. */ |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 643 | size = uc_fw->header_size + uc_fw->ucode_size + uc_fw->rsa_size; |
Alex Dai | feda33e | 2015-10-19 16:10:54 -0700 | [diff] [blame] | 644 | if (fw->size < size) { |
Dave Gordon | fc32de9 | 2016-08-18 18:17:24 +0100 | [diff] [blame] | 645 | DRM_NOTE("Missing firmware components\n"); |
Alex Dai | feda33e | 2015-10-19 16:10:54 -0700 | [diff] [blame] | 646 | goto fail; |
| 647 | } |
| 648 | |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 649 | /* |
| 650 | * The GuC firmware image has the version number embedded at a well-known |
| 651 | * offset within the firmware blob; note that major / minor version are |
| 652 | * TWO bytes each (i.e. u16), although all pointers and offsets are defined |
| 653 | * in terms of bytes (u8). |
| 654 | */ |
Anusha Srivatsa | fbbad73 | 2017-01-13 17:17:05 -0800 | [diff] [blame] | 655 | switch (uc_fw->fw) { |
| 656 | case INTEL_UC_FW_TYPE_GUC: |
| 657 | /* Header and uCode will be loaded to WOPCM. Size of the two. */ |
| 658 | size = uc_fw->header_size + uc_fw->ucode_size; |
| 659 | |
| 660 | /* Top 32k of WOPCM is reserved (8K stack + 24k RC6 context). */ |
Anusha Srivatsa | bd132858 | 2017-01-18 08:05:53 -0800 | [diff] [blame] | 661 | if (size > intel_guc_wopcm_size(dev_priv)) { |
Anusha Srivatsa | fbbad73 | 2017-01-13 17:17:05 -0800 | [diff] [blame] | 662 | DRM_ERROR("Firmware is too large to fit in WOPCM\n"); |
| 663 | goto fail; |
| 664 | } |
| 665 | uc_fw->major_ver_found = css->guc.sw_version >> 16; |
| 666 | uc_fw->minor_ver_found = css->guc.sw_version & 0xFFFF; |
| 667 | break; |
| 668 | |
| 669 | case INTEL_UC_FW_TYPE_HUC: |
| 670 | uc_fw->major_ver_found = css->huc.sw_version >> 16; |
| 671 | uc_fw->minor_ver_found = css->huc.sw_version & 0xFFFF; |
| 672 | break; |
| 673 | |
| 674 | default: |
| 675 | DRM_ERROR("Unknown firmware type %d\n", uc_fw->fw); |
| 676 | err = -ENOEXEC; |
| 677 | goto fail; |
| 678 | } |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 679 | |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 680 | if (uc_fw->major_ver_found != uc_fw->major_ver_wanted || |
| 681 | uc_fw->minor_ver_found < uc_fw->minor_ver_wanted) { |
| 682 | DRM_NOTE("uC firmware version %d.%d, required %d.%d\n", |
| 683 | uc_fw->major_ver_found, uc_fw->minor_ver_found, |
| 684 | uc_fw->major_ver_wanted, uc_fw->minor_ver_wanted); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 685 | err = -ENOEXEC; |
| 686 | goto fail; |
| 687 | } |
| 688 | |
| 689 | DRM_DEBUG_DRIVER("firmware version %d.%d OK (minimum %d.%d)\n", |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 690 | uc_fw->major_ver_found, uc_fw->minor_ver_found, |
| 691 | uc_fw->major_ver_wanted, uc_fw->minor_ver_wanted); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 692 | |
Tvrtko Ursulin | bf9e842 | 2016-12-01 14:16:38 +0000 | [diff] [blame] | 693 | mutex_lock(&dev_priv->drm.struct_mutex); |
Tvrtko Ursulin | 12d79d7 | 2016-12-01 14:16:37 +0000 | [diff] [blame] | 694 | obj = i915_gem_object_create_from_data(dev_priv, fw->data, fw->size); |
Tvrtko Ursulin | bf9e842 | 2016-12-01 14:16:38 +0000 | [diff] [blame] | 695 | mutex_unlock(&dev_priv->drm.struct_mutex); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 696 | if (IS_ERR_OR_NULL(obj)) { |
| 697 | err = obj ? PTR_ERR(obj) : -ENOMEM; |
| 698 | goto fail; |
| 699 | } |
| 700 | |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 701 | uc_fw->obj = obj; |
| 702 | uc_fw->size = fw->size; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 703 | |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 704 | DRM_DEBUG_DRIVER("uC fw fetch status SUCCESS, obj %p\n", |
| 705 | uc_fw->obj); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 706 | |
| 707 | release_firmware(fw); |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 708 | uc_fw->fetch_status = INTEL_UC_FIRMWARE_SUCCESS; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 709 | return; |
| 710 | |
| 711 | fail: |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 712 | DRM_WARN("Failed to fetch valid uC firmware from %s (error %d)\n", |
| 713 | uc_fw->path, err); |
| 714 | DRM_DEBUG_DRIVER("uC fw fetch status FAIL; err %d, fw %p, obj %p\n", |
| 715 | err, fw, uc_fw->obj); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 716 | |
Chris Wilson | 65300b1 | 2017-02-14 13:34:20 +0000 | [diff] [blame^] | 717 | obj = fetch_and_zero(&uc_fw->obj); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 718 | if (obj) |
Chris Wilson | f8c417c | 2016-07-20 13:31:53 +0100 | [diff] [blame] | 719 | i915_gem_object_put(obj); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 720 | |
| 721 | release_firmware(fw); /* OK even if fw is NULL */ |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 722 | uc_fw->fetch_status = INTEL_UC_FIRMWARE_FAIL; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 723 | } |
| 724 | |
| 725 | /** |
Dave Gordon | f09d675 | 2016-05-13 15:36:29 +0100 | [diff] [blame] | 726 | * intel_guc_init() - define parameters and fetch firmware |
Tvrtko Ursulin | bf9e842 | 2016-12-01 14:16:38 +0000 | [diff] [blame] | 727 | * @dev_priv: i915 device private |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 728 | * |
| 729 | * Called early during driver load, but after GEM is initialised. |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 730 | * |
| 731 | * The firmware will be transferred to the GuC's memory later, |
Dave Gordon | f09d675 | 2016-05-13 15:36:29 +0100 | [diff] [blame] | 732 | * when intel_guc_setup() is called. |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 733 | */ |
Tvrtko Ursulin | bf9e842 | 2016-12-01 14:16:38 +0000 | [diff] [blame] | 734 | void intel_guc_init(struct drm_i915_private *dev_priv) |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 735 | { |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 736 | struct intel_uc_fw *guc_fw = &dev_priv->guc.fw; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 737 | const char *fw_path; |
| 738 | |
Tvrtko Ursulin | 4805fe8 | 2016-11-04 14:42:46 +0000 | [diff] [blame] | 739 | if (!HAS_GUC(dev_priv)) { |
Anusha Srivatsa | 21e3302 | 2016-10-14 16:47:05 -0700 | [diff] [blame] | 740 | i915.enable_guc_loading = 0; |
| 741 | i915.enable_guc_submission = 0; |
| 742 | } else { |
| 743 | /* A negative value means "use platform default" */ |
| 744 | if (i915.enable_guc_loading < 0) |
Tvrtko Ursulin | 4805fe8 | 2016-11-04 14:42:46 +0000 | [diff] [blame] | 745 | i915.enable_guc_loading = HAS_GUC_UCODE(dev_priv); |
Anusha Srivatsa | 21e3302 | 2016-10-14 16:47:05 -0700 | [diff] [blame] | 746 | if (i915.enable_guc_submission < 0) |
Tvrtko Ursulin | 4805fe8 | 2016-11-04 14:42:46 +0000 | [diff] [blame] | 747 | i915.enable_guc_submission = HAS_GUC_SCHED(dev_priv); |
Anusha Srivatsa | 21e3302 | 2016-10-14 16:47:05 -0700 | [diff] [blame] | 748 | } |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 749 | |
Tvrtko Ursulin | 4805fe8 | 2016-11-04 14:42:46 +0000 | [diff] [blame] | 750 | if (!HAS_GUC_UCODE(dev_priv)) { |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 751 | fw_path = NULL; |
Tvrtko Ursulin | d9486e6 | 2016-10-13 11:03:03 +0100 | [diff] [blame] | 752 | } else if (IS_SKYLAKE(dev_priv)) { |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 753 | fw_path = I915_SKL_GUC_UCODE; |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 754 | guc_fw->major_ver_wanted = SKL_FW_MAJOR; |
| 755 | guc_fw->minor_ver_wanted = SKL_FW_MINOR; |
Tvrtko Ursulin | e2d214a | 2016-10-13 11:03:04 +0100 | [diff] [blame] | 756 | } else if (IS_BROXTON(dev_priv)) { |
Nick Hoath | 57bf5c8 | 2016-05-06 11:42:53 +0100 | [diff] [blame] | 757 | fw_path = I915_BXT_GUC_UCODE; |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 758 | guc_fw->major_ver_wanted = BXT_FW_MAJOR; |
| 759 | guc_fw->minor_ver_wanted = BXT_FW_MINOR; |
Tvrtko Ursulin | 0853723 | 2016-10-13 11:03:02 +0100 | [diff] [blame] | 760 | } else if (IS_KABYLAKE(dev_priv)) { |
Peter Antoine | ff64cc1 | 2016-06-30 09:37:52 -0700 | [diff] [blame] | 761 | fw_path = I915_KBL_GUC_UCODE; |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 762 | guc_fw->major_ver_wanted = KBL_FW_MAJOR; |
| 763 | guc_fw->minor_ver_wanted = KBL_FW_MINOR; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 764 | } else { |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 765 | fw_path = ""; /* unknown device */ |
| 766 | } |
| 767 | |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 768 | guc_fw->path = fw_path; |
| 769 | guc_fw->fetch_status = INTEL_UC_FIRMWARE_NONE; |
| 770 | guc_fw->load_status = INTEL_UC_FIRMWARE_NONE; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 771 | |
Dave Gordon | fce91f2 | 2016-05-20 11:42:42 +0100 | [diff] [blame] | 772 | /* Early (and silent) return if GuC loading is disabled */ |
| 773 | if (!i915.enable_guc_loading) |
| 774 | return; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 775 | if (fw_path == NULL) |
| 776 | return; |
Dave Gordon | fce91f2 | 2016-05-20 11:42:42 +0100 | [diff] [blame] | 777 | if (*fw_path == '\0') |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 778 | return; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 779 | |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 780 | guc_fw->fetch_status = INTEL_UC_FIRMWARE_PENDING; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 781 | DRM_DEBUG_DRIVER("GuC firmware pending, path %s\n", fw_path); |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 782 | intel_uc_fw_fetch(dev_priv, guc_fw); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 783 | /* status must now be FAIL or SUCCESS */ |
| 784 | } |
| 785 | |
| 786 | /** |
Dave Gordon | f09d675 | 2016-05-13 15:36:29 +0100 | [diff] [blame] | 787 | * intel_guc_fini() - clean up all allocated resources |
Tvrtko Ursulin | b6ea8b4 | 2016-12-02 08:43:53 +0000 | [diff] [blame] | 788 | * @dev_priv: i915 device private |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 789 | */ |
Tvrtko Ursulin | bf9e842 | 2016-12-01 14:16:38 +0000 | [diff] [blame] | 790 | void intel_guc_fini(struct drm_i915_private *dev_priv) |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 791 | { |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 792 | struct intel_uc_fw *guc_fw = &dev_priv->guc.fw; |
Chris Wilson | 65300b1 | 2017-02-14 13:34:20 +0000 | [diff] [blame^] | 793 | struct drm_i915_gem_object *obj; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 794 | |
Tvrtko Ursulin | bf9e842 | 2016-12-01 14:16:38 +0000 | [diff] [blame] | 795 | mutex_lock(&dev_priv->drm.struct_mutex); |
Dave Gordon | 0c5664e | 2016-09-12 21:19:36 +0100 | [diff] [blame] | 796 | guc_interrupts_release(dev_priv); |
Dave Gordon | beffa51 | 2016-06-10 18:29:26 +0100 | [diff] [blame] | 797 | i915_guc_submission_disable(dev_priv); |
| 798 | i915_guc_submission_fini(dev_priv); |
Tvrtko Ursulin | bf9e842 | 2016-12-01 14:16:38 +0000 | [diff] [blame] | 799 | mutex_unlock(&dev_priv->drm.struct_mutex); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 800 | |
Chris Wilson | 65300b1 | 2017-02-14 13:34:20 +0000 | [diff] [blame^] | 801 | obj = fetch_and_zero(&guc_fw->obj); |
| 802 | if (obj) |
| 803 | i915_gem_object_put(obj); |
| 804 | |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 805 | guc_fw->fetch_status = INTEL_UC_FIRMWARE_NONE; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 806 | } |