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 | */ |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 29 | #include "i915_drv.h" |
Arkadiusz Hiler | 8c4f24f | 2016-11-25 18:59:33 +0100 | [diff] [blame] | 30 | #include "intel_uc.h" |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 31 | |
| 32 | /** |
Alex Dai | feda33e | 2015-10-19 16:10:54 -0700 | [diff] [blame] | 33 | * DOC: GuC-specific firmware loader |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 34 | * |
| 35 | * intel_guc: |
| 36 | * Top level structure of guc. It handles firmware loading and manages client |
| 37 | * pool and doorbells. intel_guc owns a i915_guc_client to replace the legacy |
| 38 | * ExecList submission. |
| 39 | * |
| 40 | * Firmware versioning: |
| 41 | * The firmware build process will generate a version header file with major and |
| 42 | * minor version defined. The versions are built into CSS header of firmware. |
| 43 | * i915 kernel driver set the minimal firmware version required per platform. |
| 44 | * The firmware installation package will install (symbolic link) proper version |
| 45 | * of firmware. |
| 46 | * |
| 47 | * GuC address space: |
| 48 | * GuC does not allow any gfx GGTT address that falls into range [0, WOPCM_TOP), |
| 49 | * which is reserved for Boot ROM, SRAM and WOPCM. Currently this top address is |
| 50 | * 512K. In order to exclude 0-512K address space from GGTT, all gfx objects |
| 51 | * used by GuC is pinned with PIN_OFFSET_BIAS along with size of WOPCM. |
| 52 | * |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 53 | */ |
| 54 | |
Tvrtko Ursulin | 5e334c1 | 2016-08-10 16:16:46 +0100 | [diff] [blame] | 55 | #define SKL_FW_MAJOR 6 |
| 56 | #define SKL_FW_MINOR 1 |
| 57 | |
| 58 | #define BXT_FW_MAJOR 8 |
| 59 | #define BXT_FW_MINOR 7 |
| 60 | |
| 61 | #define KBL_FW_MAJOR 9 |
| 62 | #define KBL_FW_MINOR 14 |
| 63 | |
| 64 | #define GUC_FW_PATH(platform, major, minor) \ |
| 65 | "i915/" __stringify(platform) "_guc_ver" __stringify(major) "_" __stringify(minor) ".bin" |
| 66 | |
| 67 | #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] | 68 | MODULE_FIRMWARE(I915_SKL_GUC_UCODE); |
| 69 | |
Tvrtko Ursulin | 5e334c1 | 2016-08-10 16:16:46 +0100 | [diff] [blame] | 70 | #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] | 71 | MODULE_FIRMWARE(I915_BXT_GUC_UCODE); |
| 72 | |
Tvrtko Ursulin | 5e334c1 | 2016-08-10 16:16:46 +0100 | [diff] [blame] | 73 | #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] | 74 | MODULE_FIRMWARE(I915_KBL_GUC_UCODE); |
| 75 | |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 76 | /* User-friendly representation of an enum */ |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 77 | 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] | 78 | { |
| 79 | switch (status) { |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 80 | case INTEL_UC_FIRMWARE_FAIL: |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 81 | return "FAIL"; |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 82 | case INTEL_UC_FIRMWARE_NONE: |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 83 | return "NONE"; |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 84 | case INTEL_UC_FIRMWARE_PENDING: |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 85 | return "PENDING"; |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 86 | case INTEL_UC_FIRMWARE_SUCCESS: |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 87 | return "SUCCESS"; |
| 88 | default: |
| 89 | return "UNKNOWN!"; |
| 90 | } |
| 91 | }; |
| 92 | |
| 93 | static u32 get_gttype(struct drm_i915_private *dev_priv) |
| 94 | { |
| 95 | /* XXX: GT type based on PCI device ID? field seems unused by fw */ |
| 96 | return 0; |
| 97 | } |
| 98 | |
| 99 | static u32 get_core_family(struct drm_i915_private *dev_priv) |
| 100 | { |
Dave Gordon | fc32de9 | 2016-08-18 18:17:24 +0100 | [diff] [blame] | 101 | u32 gen = INTEL_GEN(dev_priv); |
| 102 | |
| 103 | switch (gen) { |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 104 | case 9: |
| 105 | return GFXCORE_FAMILY_GEN9; |
| 106 | |
| 107 | default: |
Dave Gordon | fc32de9 | 2016-08-18 18:17:24 +0100 | [diff] [blame] | 108 | WARN(1, "GEN%d does not support GuC operation!\n", gen); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 109 | return GFXCORE_FAMILY_UNKNOWN; |
| 110 | } |
| 111 | } |
| 112 | |
Dave Gordon | 0c5664e | 2016-09-12 21:19:36 +0100 | [diff] [blame] | 113 | /* |
| 114 | * Initialise the GuC parameter block before starting the firmware |
| 115 | * transfer. These parameters are read by the firmware on startup |
| 116 | * and cannot be changed thereafter. |
| 117 | */ |
| 118 | static void guc_params_init(struct drm_i915_private *dev_priv) |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 119 | { |
| 120 | struct intel_guc *guc = &dev_priv->guc; |
| 121 | u32 params[GUC_CTL_MAX_DWORDS]; |
| 122 | int i; |
| 123 | |
| 124 | memset(¶ms, 0, sizeof(params)); |
| 125 | |
| 126 | params[GUC_CTL_DEVICE_INFO] |= |
| 127 | (get_gttype(dev_priv) << GUC_CTL_GTTYPE_SHIFT) | |
| 128 | (get_core_family(dev_priv) << GUC_CTL_COREFAMILY_SHIFT); |
| 129 | |
| 130 | /* |
| 131 | * GuC ARAT increment is 10 ns. GuC default scheduler quantum is one |
| 132 | * second. This ARAR is calculated by: |
| 133 | * Scheduler-Quantum-in-ns / ARAT-increment-in-ns = 1000000000 / 10 |
| 134 | */ |
| 135 | params[GUC_CTL_ARAT_HIGH] = 0; |
| 136 | params[GUC_CTL_ARAT_LOW] = 100000000; |
| 137 | |
| 138 | params[GUC_CTL_WA] |= GUC_CTL_WA_UK_BY_DRIVER; |
| 139 | |
| 140 | params[GUC_CTL_FEATURE] |= GUC_CTL_DISABLE_SCHEDULER | |
| 141 | GUC_CTL_VCS2_ENABLED; |
| 142 | |
Akash Goel | d6b40b4 | 2016-10-12 21:54:29 +0530 | [diff] [blame] | 143 | params[GUC_CTL_LOG_PARAMS] = guc->log.flags; |
Sagar Arun Kamble | b1e3710 | 2016-10-12 21:54:27 +0530 | [diff] [blame] | 144 | |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 145 | if (i915.guc_log_level >= 0) { |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 146 | params[GUC_CTL_DEBUG] = |
| 147 | i915.guc_log_level << GUC_LOG_VERBOSITY_SHIFT; |
Sagar Arun Kamble | b1e3710 | 2016-10-12 21:54:27 +0530 | [diff] [blame] | 148 | } else |
| 149 | params[GUC_CTL_DEBUG] = GUC_LOG_DISABLED; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 150 | |
Chris Wilson | 8b797af | 2016-08-15 10:48:51 +0100 | [diff] [blame] | 151 | if (guc->ads_vma) { |
Chris Wilson | 4741da9 | 2016-12-24 19:31:46 +0000 | [diff] [blame] | 152 | u32 ads = guc_ggtt_offset(guc->ads_vma) >> PAGE_SHIFT; |
Alex Dai | b6a5cd7 | 2015-12-18 12:00:12 -0800 | [diff] [blame] | 153 | params[GUC_CTL_DEBUG] |= ads << GUC_ADS_ADDR_SHIFT; |
| 154 | params[GUC_CTL_DEBUG] |= GUC_ADS_ENABLED; |
| 155 | } |
| 156 | |
Alex Dai | bac427f | 2015-08-12 15:43:39 +0100 | [diff] [blame] | 157 | /* If GuC submission is enabled, set up additional parameters here */ |
| 158 | if (i915.enable_guc_submission) { |
Chris Wilson | 4741da9 | 2016-12-24 19:31:46 +0000 | [diff] [blame] | 159 | u32 pgs = guc_ggtt_offset(dev_priv->guc.ctx_pool_vma); |
Alex Dai | bac427f | 2015-08-12 15:43:39 +0100 | [diff] [blame] | 160 | u32 ctx_in_16 = GUC_MAX_GPU_CONTEXTS / 16; |
| 161 | |
| 162 | pgs >>= PAGE_SHIFT; |
| 163 | params[GUC_CTL_CTXINFO] = (pgs << GUC_CTL_BASE_ADDR_SHIFT) | |
| 164 | (ctx_in_16 << GUC_CTL_CTXNUM_IN16_SHIFT); |
| 165 | |
| 166 | params[GUC_CTL_FEATURE] |= GUC_CTL_KERNEL_SUBMISSIONS; |
| 167 | |
| 168 | /* Unmask this bit to enable the GuC's internal scheduler */ |
| 169 | params[GUC_CTL_FEATURE] &= ~GUC_CTL_DISABLE_SCHEDULER; |
| 170 | } |
| 171 | |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 172 | I915_WRITE(SOFT_SCRATCH(0), 0); |
| 173 | |
| 174 | for (i = 0; i < GUC_CTL_MAX_DWORDS; i++) |
| 175 | I915_WRITE(SOFT_SCRATCH(1 + i), params[i]); |
| 176 | } |
| 177 | |
| 178 | /* |
| 179 | * Read the GuC status register (GUC_STATUS) and store it in the |
| 180 | * specified location; then return a boolean indicating whether |
| 181 | * the value matches either of two values representing completion |
| 182 | * of the GuC boot process. |
| 183 | * |
Tvrtko Ursulin | 36894e8 | 2016-02-11 10:27:31 +0000 | [diff] [blame] | 184 | * This is used for polling the GuC status in a wait_for() |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 185 | * loop below. |
| 186 | */ |
| 187 | static inline bool guc_ucode_response(struct drm_i915_private *dev_priv, |
| 188 | u32 *status) |
| 189 | { |
| 190 | u32 val = I915_READ(GUC_STATUS); |
Alex Dai | 0d44d3f | 2015-09-22 13:48:40 -0700 | [diff] [blame] | 191 | u32 uk_val = val & GS_UKERNEL_MASK; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 192 | *status = val; |
Alex Dai | 0d44d3f | 2015-09-22 13:48:40 -0700 | [diff] [blame] | 193 | return (uk_val == GS_UKERNEL_READY || |
| 194 | ((val & GS_MIA_CORE_STATE) && uk_val == GS_UKERNEL_LAPIC_DONE)); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | /* |
| 198 | * Transfer the firmware image to RAM for execution by the microcontroller. |
| 199 | * |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 200 | * Architecturally, the DMA engine is bidirectional, and can potentially even |
| 201 | * transfer between GTT locations. This functionality is left out of the API |
| 202 | * for now as there is no need for it. |
| 203 | * |
| 204 | * Note that GuC needs the CSS header plus uKernel code to be copied by the |
| 205 | * DMA engine in one operation, whereas the RSA signature is loaded via MMIO. |
| 206 | */ |
Chris Wilson | 058d88c | 2016-08-15 10:49:06 +0100 | [diff] [blame] | 207 | static int guc_ucode_xfer_dma(struct drm_i915_private *dev_priv, |
| 208 | struct i915_vma *vma) |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 209 | { |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 210 | struct intel_uc_fw *guc_fw = &dev_priv->guc.fw; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 211 | unsigned long offset; |
Chris Wilson | 058d88c | 2016-08-15 10:49:06 +0100 | [diff] [blame] | 212 | struct sg_table *sg = vma->pages; |
Alex Dai | feda33e | 2015-10-19 16:10:54 -0700 | [diff] [blame] | 213 | u32 status, rsa[UOS_RSA_SCRATCH_MAX_COUNT]; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 214 | int i, ret = 0; |
| 215 | |
Alex Dai | feda33e | 2015-10-19 16:10:54 -0700 | [diff] [blame] | 216 | /* where RSA signature starts */ |
| 217 | offset = guc_fw->rsa_offset; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 218 | |
| 219 | /* Copy RSA signature from the fw image to HW for verification */ |
Alex Dai | feda33e | 2015-10-19 16:10:54 -0700 | [diff] [blame] | 220 | sg_pcopy_to_buffer(sg->sgl, sg->nents, rsa, sizeof(rsa), offset); |
| 221 | for (i = 0; i < UOS_RSA_SCRATCH_MAX_COUNT; i++) |
Ville Syrjälä | ab9cc55 | 2015-09-18 20:03:24 +0300 | [diff] [blame] | 222 | I915_WRITE(UOS_RSA_SCRATCH(i), rsa[i]); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 223 | |
Alex Dai | feda33e | 2015-10-19 16:10:54 -0700 | [diff] [blame] | 224 | /* The header plus uCode will be copied to WOPCM via DMA, excluding any |
| 225 | * other components */ |
| 226 | I915_WRITE(DMA_COPY_SIZE, guc_fw->header_size + guc_fw->ucode_size); |
| 227 | |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 228 | /* Set the source address for the new blob */ |
Chris Wilson | 4741da9 | 2016-12-24 19:31:46 +0000 | [diff] [blame] | 229 | offset = guc_ggtt_offset(vma) + guc_fw->header_offset; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 230 | I915_WRITE(DMA_ADDR_0_LOW, lower_32_bits(offset)); |
| 231 | I915_WRITE(DMA_ADDR_0_HIGH, upper_32_bits(offset) & 0xFFFF); |
| 232 | |
| 233 | /* |
| 234 | * Set the DMA destination. Current uCode expects the code to be |
| 235 | * loaded at 8k; locations below this are used for the stack. |
| 236 | */ |
| 237 | I915_WRITE(DMA_ADDR_1_LOW, 0x2000); |
| 238 | I915_WRITE(DMA_ADDR_1_HIGH, DMA_ADDRESS_SPACE_WOPCM); |
| 239 | |
| 240 | /* Finally start the DMA */ |
| 241 | I915_WRITE(DMA_CTRL, _MASKED_BIT_ENABLE(UOS_MOVE | START_DMA)); |
| 242 | |
| 243 | /* |
Tvrtko Ursulin | 36894e8 | 2016-02-11 10:27:31 +0000 | [diff] [blame] | 244 | * Wait for the DMA to complete & the GuC to start up. |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 245 | * NB: Docs recommend not using the interrupt for completion. |
| 246 | * Measurements indicate this should take no more than 20ms, so a |
| 247 | * timeout here indicates that the GuC has failed and is unusable. |
| 248 | * (Higher levels of the driver will attempt to fall back to |
| 249 | * execlist mode if this happens.) |
| 250 | */ |
Tvrtko Ursulin | 36894e8 | 2016-02-11 10:27:31 +0000 | [diff] [blame] | 251 | ret = wait_for(guc_ucode_response(dev_priv, &status), 100); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 252 | |
| 253 | DRM_DEBUG_DRIVER("DMA status 0x%x, GuC status 0x%x\n", |
| 254 | I915_READ(DMA_CTRL), status); |
| 255 | |
| 256 | if ((status & GS_BOOTROM_MASK) == GS_BOOTROM_RSA_FAILED) { |
| 257 | DRM_ERROR("GuC firmware signature verification failed\n"); |
| 258 | ret = -ENOEXEC; |
| 259 | } |
| 260 | |
| 261 | DRM_DEBUG_DRIVER("returning %d\n", ret); |
| 262 | |
| 263 | return ret; |
| 264 | } |
| 265 | |
Anusha Srivatsa | bd132858 | 2017-01-18 08:05:53 -0800 | [diff] [blame] | 266 | u32 intel_guc_wopcm_size(struct drm_i915_private *dev_priv) |
Peter Antoine | 74aa156 | 2016-05-17 15:12:45 +0100 | [diff] [blame] | 267 | { |
| 268 | u32 wopcm_size = GUC_WOPCM_TOP; |
| 269 | |
| 270 | /* On BXT, the top of WOPCM is reserved for RC6 context */ |
Michel Thierry | 254e093 | 2017-01-09 16:51:35 +0200 | [diff] [blame] | 271 | if (IS_GEN9_LP(dev_priv)) |
Peter Antoine | 74aa156 | 2016-05-17 15:12:45 +0100 | [diff] [blame] | 272 | wopcm_size -= BXT_GUC_WOPCM_RC6_RESERVED; |
| 273 | |
| 274 | return wopcm_size; |
| 275 | } |
| 276 | |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 277 | /* |
| 278 | * Load the GuC firmware blob into the MinuteIA. |
| 279 | */ |
| 280 | static int guc_ucode_xfer(struct drm_i915_private *dev_priv) |
| 281 | { |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 282 | struct intel_uc_fw *guc_fw = &dev_priv->guc.fw; |
Chris Wilson | 058d88c | 2016-08-15 10:49:06 +0100 | [diff] [blame] | 283 | struct i915_vma *vma; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 284 | int ret; |
| 285 | |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 286 | ret = i915_gem_object_set_to_gtt_domain(guc_fw->obj, false); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 287 | if (ret) { |
| 288 | DRM_DEBUG_DRIVER("set-domain failed %d\n", ret); |
| 289 | return ret; |
| 290 | } |
| 291 | |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 292 | vma = i915_gem_object_ggtt_pin(guc_fw->obj, NULL, 0, 0, |
Michał Winiarski | 83796f2 | 2017-01-11 16:17:39 +0100 | [diff] [blame] | 293 | PIN_OFFSET_BIAS | GUC_WOPCM_TOP); |
Chris Wilson | 058d88c | 2016-08-15 10:49:06 +0100 | [diff] [blame] | 294 | if (IS_ERR(vma)) { |
| 295 | DRM_DEBUG_DRIVER("pin failed %d\n", (int)PTR_ERR(vma)); |
| 296 | return PTR_ERR(vma); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 297 | } |
| 298 | |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 299 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
| 300 | |
| 301 | /* init WOPCM */ |
Anusha Srivatsa | bd132858 | 2017-01-18 08:05:53 -0800 | [diff] [blame] | 302 | I915_WRITE(GUC_WOPCM_SIZE, intel_guc_wopcm_size(dev_priv)); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 303 | I915_WRITE(DMA_GUC_WOPCM_OFFSET, GUC_WOPCM_OFFSET_VALUE); |
| 304 | |
| 305 | /* Enable MIA caching. GuC clock gating is disabled. */ |
| 306 | I915_WRITE(GUC_SHIM_CONTROL, GUC_SHIM_CONTROL_VALUE); |
| 307 | |
Jani Nikula | a117f37 | 2016-09-16 16:59:44 +0300 | [diff] [blame] | 308 | /* WaDisableMinuteIaClockGating:bxt */ |
Tvrtko Ursulin | e2d214a | 2016-10-13 11:03:04 +0100 | [diff] [blame] | 309 | if (IS_BXT_REVID(dev_priv, 0, BXT_REVID_A1)) { |
Nick Hoath | b970b48 | 2015-09-08 10:31:53 +0100 | [diff] [blame] | 310 | I915_WRITE(GUC_SHIM_CONTROL, (I915_READ(GUC_SHIM_CONTROL) & |
| 311 | ~GUC_ENABLE_MIA_CLOCK_GATING)); |
| 312 | } |
| 313 | |
Jani Nikula | 4ff40a4 | 2016-09-26 15:07:51 +0300 | [diff] [blame] | 314 | /* WaC6DisallowByGfxPause:bxt */ |
Tvrtko Ursulin | e2d214a | 2016-10-13 11:03:04 +0100 | [diff] [blame] | 315 | if (IS_BXT_REVID(dev_priv, 0, BXT_REVID_B0)) |
Tim Gore | 65fe29e | 2016-07-20 11:00:25 +0100 | [diff] [blame] | 316 | I915_WRITE(GEN6_GFXPAUSE, 0x30FFF); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 317 | |
Michel Thierry | 254e093 | 2017-01-09 16:51:35 +0200 | [diff] [blame] | 318 | if (IS_GEN9_LP(dev_priv)) |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 319 | I915_WRITE(GEN9LP_GT_PM_CONFIG, GT_DOORBELL_ENABLE); |
| 320 | else |
| 321 | I915_WRITE(GEN9_GT_PM_CONFIG, GT_DOORBELL_ENABLE); |
| 322 | |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 323 | if (IS_GEN9(dev_priv)) { |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 324 | /* DOP Clock Gating Enable for GuC clocks */ |
| 325 | I915_WRITE(GEN7_MISCCPCTL, (GEN8_DOP_CLOCK_GATE_GUC_ENABLE | |
| 326 | I915_READ(GEN7_MISCCPCTL))); |
| 327 | |
Dave Gordon | 0c5664e | 2016-09-12 21:19:36 +0100 | [diff] [blame] | 328 | /* allows for 5us (in 10ns units) before GT can go to RC6 */ |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 329 | I915_WRITE(GUC_ARAT_C6DIS, 0x1FF); |
| 330 | } |
| 331 | |
Dave Gordon | 0c5664e | 2016-09-12 21:19:36 +0100 | [diff] [blame] | 332 | guc_params_init(dev_priv); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 333 | |
Chris Wilson | 058d88c | 2016-08-15 10:49:06 +0100 | [diff] [blame] | 334 | ret = guc_ucode_xfer_dma(dev_priv, vma); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 335 | |
| 336 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
| 337 | |
| 338 | /* |
| 339 | * We keep the object pages for reuse during resume. But we can unpin it |
| 340 | * now that DMA has completed, so it doesn't continue to take up space. |
| 341 | */ |
Chris Wilson | 058d88c | 2016-08-15 10:49:06 +0100 | [diff] [blame] | 342 | i915_vma_unpin(vma); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 343 | |
| 344 | return ret; |
| 345 | } |
| 346 | |
Dave Gordon | 0c5664e | 2016-09-12 21:19:36 +0100 | [diff] [blame] | 347 | static int guc_hw_reset(struct drm_i915_private *dev_priv) |
Arun Siluvery | 6b332fa | 2016-04-04 18:50:56 +0100 | [diff] [blame] | 348 | { |
| 349 | int ret; |
| 350 | u32 guc_status; |
| 351 | |
| 352 | ret = intel_guc_reset(dev_priv); |
| 353 | if (ret) { |
| 354 | DRM_ERROR("GuC reset failed, ret = %d\n", ret); |
| 355 | return ret; |
| 356 | } |
| 357 | |
| 358 | guc_status = I915_READ(GUC_STATUS); |
| 359 | WARN(!(guc_status & GS_MIA_IN_RESET), |
| 360 | "GuC status: 0x%x, MIA core expected to be in reset\n", guc_status); |
| 361 | |
| 362 | return ret; |
| 363 | } |
| 364 | |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 365 | /** |
Arkadiusz Hiler | 882d1db | 2017-03-14 15:28:07 +0100 | [diff] [blame] | 366 | * intel_guc_init_hw() - finish preparing the GuC for activity |
| 367 | * @guc: intel_guc structure |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 368 | * |
Arkadiusz Hiler | 882d1db | 2017-03-14 15:28:07 +0100 | [diff] [blame] | 369 | * Called during driver loading and also after a GPU reset. |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 370 | * |
Dave Gordon | f09d675 | 2016-05-13 15:36:29 +0100 | [diff] [blame] | 371 | * 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] | 372 | * The firmware image should have already been fetched into memory by the |
Arkadiusz Hiler | 882d1db | 2017-03-14 15:28:07 +0100 | [diff] [blame] | 373 | * earlier call to intel_guc_init(), so here we need only check that |
| 374 | * worked, and then transfer the image to the h/w. |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 375 | * |
| 376 | * Return: non-zero code on error |
| 377 | */ |
Arkadiusz Hiler | 882d1db | 2017-03-14 15:28:07 +0100 | [diff] [blame] | 378 | int intel_guc_init_hw(struct intel_guc *guc) |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 379 | { |
Arkadiusz Hiler | 882d1db | 2017-03-14 15:28:07 +0100 | [diff] [blame] | 380 | struct drm_i915_private *dev_priv = guc_to_i915(guc); |
| 381 | const char *fw_path = guc->fw.path; |
Dave Gordon | fce91f2 | 2016-05-20 11:42:42 +0100 | [diff] [blame] | 382 | int retries, ret, err; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 383 | |
Dave Gordon | fce91f2 | 2016-05-20 11:42:42 +0100 | [diff] [blame] | 384 | DRM_DEBUG_DRIVER("GuC fw status: path %s, fetch %s, load %s\n", |
| 385 | fw_path, |
Arkadiusz Hiler | 882d1db | 2017-03-14 15:28:07 +0100 | [diff] [blame] | 386 | intel_uc_fw_status_repr(guc->fw.fetch_status), |
| 387 | intel_uc_fw_status_repr(guc->fw.load_status)); |
Dave Gordon | fce91f2 | 2016-05-20 11:42:42 +0100 | [diff] [blame] | 388 | |
| 389 | /* Loading forbidden, or no firmware to load? */ |
| 390 | if (!i915.enable_guc_loading) { |
| 391 | err = 0; |
| 392 | goto fail; |
Dave Gordon | e556f7c | 2016-06-07 09:14:49 +0100 | [diff] [blame] | 393 | } else if (fw_path == NULL) { |
| 394 | /* Device is known to have no uCode (e.g. no GuC) */ |
| 395 | err = -ENXIO; |
| 396 | goto fail; |
| 397 | } else if (*fw_path == '\0') { |
| 398 | /* 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] | 399 | WARN(1, "No GuC firmware known for this platform!\n"); |
Dave Gordon | fce91f2 | 2016-05-20 11:42:42 +0100 | [diff] [blame] | 400 | err = -ENODEV; |
| 401 | goto fail; |
| 402 | } |
| 403 | |
| 404 | /* Fetch failed, or already fetched but failed to load? */ |
Arkadiusz Hiler | 882d1db | 2017-03-14 15:28:07 +0100 | [diff] [blame] | 405 | if (guc->fw.fetch_status != INTEL_UC_FIRMWARE_SUCCESS) { |
Dave Gordon | fce91f2 | 2016-05-20 11:42:42 +0100 | [diff] [blame] | 406 | err = -EIO; |
| 407 | goto fail; |
Arkadiusz Hiler | 882d1db | 2017-03-14 15:28:07 +0100 | [diff] [blame] | 408 | } else if (guc->fw.load_status == INTEL_UC_FIRMWARE_FAIL) { |
Dave Gordon | fce91f2 | 2016-05-20 11:42:42 +0100 | [diff] [blame] | 409 | err = -ENOEXEC; |
| 410 | goto fail; |
| 411 | } |
| 412 | |
Sagar Arun Kamble | 26705e2 | 2016-10-12 21:54:31 +0530 | [diff] [blame] | 413 | gen9_reset_guc_interrupts(dev_priv); |
Dave Gordon | fce91f2 | 2016-05-20 11:42:42 +0100 | [diff] [blame] | 414 | |
Chris Wilson | 7c3f86b | 2017-01-12 11:00:49 +0000 | [diff] [blame] | 415 | /* We need to notify the guc whenever we change the GGTT */ |
| 416 | i915_ggtt_enable_guc(dev_priv); |
| 417 | |
Arkadiusz Hiler | 882d1db | 2017-03-14 15:28:07 +0100 | [diff] [blame] | 418 | guc->fw.load_status = INTEL_UC_FIRMWARE_PENDING; |
Daniel Vetter | 9f9e539 | 2015-10-23 11:10:59 +0200 | [diff] [blame] | 419 | |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 420 | DRM_DEBUG_DRIVER("GuC fw status: fetch %s, load %s\n", |
Arkadiusz Hiler | 882d1db | 2017-03-14 15:28:07 +0100 | [diff] [blame] | 421 | intel_uc_fw_status_repr(guc->fw.fetch_status), |
| 422 | intel_uc_fw_status_repr(guc->fw.load_status)); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 423 | |
Dave Gordon | beffa51 | 2016-06-10 18:29:26 +0100 | [diff] [blame] | 424 | err = i915_guc_submission_init(dev_priv); |
Alex Dai | bac427f | 2015-08-12 15:43:39 +0100 | [diff] [blame] | 425 | if (err) |
| 426 | goto fail; |
| 427 | |
Arun Siluvery | 6b332fa | 2016-04-04 18:50:56 +0100 | [diff] [blame] | 428 | /* |
| 429 | * WaEnableuKernelHeaderValidFix:skl,bxt |
| 430 | * For BXT, this is only upto B0 but below WA is required for later |
| 431 | * steppings also so this is extended as well. |
| 432 | */ |
| 433 | /* WaEnableGuCBootHashCheckNotSet:skl,bxt */ |
Dave Gordon | d761701 | 2016-04-04 18:50:57 +0100 | [diff] [blame] | 434 | for (retries = 3; ; ) { |
| 435 | /* |
| 436 | * Always reset the GuC just before (re)loading, so |
| 437 | * that the state and timing are fairly predictable |
| 438 | */ |
Dave Gordon | 0c5664e | 2016-09-12 21:19:36 +0100 | [diff] [blame] | 439 | err = guc_hw_reset(dev_priv); |
Dave Gordon | fc32de9 | 2016-08-18 18:17:24 +0100 | [diff] [blame] | 440 | if (err) |
Arun Siluvery | 6b332fa | 2016-04-04 18:50:56 +0100 | [diff] [blame] | 441 | goto fail; |
Dave Gordon | d761701 | 2016-04-04 18:50:57 +0100 | [diff] [blame] | 442 | |
Arkadiusz Hiler | 882d1db | 2017-03-14 15:28:07 +0100 | [diff] [blame] | 443 | intel_huc_init_hw(&dev_priv->huc); |
Dave Gordon | d761701 | 2016-04-04 18:50:57 +0100 | [diff] [blame] | 444 | err = guc_ucode_xfer(dev_priv); |
| 445 | if (!err) |
| 446 | break; |
| 447 | |
| 448 | if (--retries == 0) |
| 449 | goto fail; |
| 450 | |
Dave Gordon | fce91f2 | 2016-05-20 11:42:42 +0100 | [diff] [blame] | 451 | DRM_INFO("GuC fw load failed: %d; will reset and " |
| 452 | "retry %d more time(s)\n", err, retries); |
Arun Siluvery | 6b332fa | 2016-04-04 18:50:56 +0100 | [diff] [blame] | 453 | } |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 454 | |
Arkadiusz Hiler | 882d1db | 2017-03-14 15:28:07 +0100 | [diff] [blame] | 455 | guc->fw.load_status = INTEL_UC_FIRMWARE_SUCCESS; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 456 | |
Anusha Srivatsa | dac84a3 | 2017-01-18 08:05:57 -0800 | [diff] [blame] | 457 | intel_guc_auth_huc(dev_priv); |
| 458 | |
Dave Gordon | 44a28b1 | 2015-08-12 15:43:41 +0100 | [diff] [blame] | 459 | if (i915.enable_guc_submission) { |
Sagar Arun Kamble | 26705e2 | 2016-10-12 21:54:31 +0530 | [diff] [blame] | 460 | if (i915.guc_log_level >= 0) |
| 461 | gen9_enable_guc_interrupts(dev_priv); |
| 462 | |
Dave Gordon | beffa51 | 2016-06-10 18:29:26 +0100 | [diff] [blame] | 463 | err = i915_guc_submission_enable(dev_priv); |
Dave Gordon | 44a28b1 | 2015-08-12 15:43:41 +0100 | [diff] [blame] | 464 | if (err) |
| 465 | goto fail; |
| 466 | } |
| 467 | |
Tvrtko Ursulin | fb51ff4 | 2017-02-07 08:50:25 +0000 | [diff] [blame] | 468 | DRM_INFO("GuC %s (firmware %s [version %u.%u])\n", |
| 469 | i915.enable_guc_submission ? "submission enabled" : "loaded", |
Arkadiusz Hiler | 882d1db | 2017-03-14 15:28:07 +0100 | [diff] [blame] | 470 | guc->fw.path, |
| 471 | guc->fw.major_ver_found, guc->fw.minor_ver_found); |
Tvrtko Ursulin | fb51ff4 | 2017-02-07 08:50:25 +0000 | [diff] [blame] | 472 | |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 473 | return 0; |
| 474 | |
| 475 | fail: |
Arkadiusz Hiler | 882d1db | 2017-03-14 15:28:07 +0100 | [diff] [blame] | 476 | if (guc->fw.load_status == INTEL_UC_FIRMWARE_PENDING) |
| 477 | guc->fw.load_status = INTEL_UC_FIRMWARE_FAIL; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 478 | |
Dave Gordon | beffa51 | 2016-06-10 18:29:26 +0100 | [diff] [blame] | 479 | i915_guc_submission_disable(dev_priv); |
| 480 | i915_guc_submission_fini(dev_priv); |
Chris Wilson | 7c3f86b | 2017-01-12 11:00:49 +0000 | [diff] [blame] | 481 | i915_ggtt_disable_guc(dev_priv); |
Dave Gordon | 44a28b1 | 2015-08-12 15:43:41 +0100 | [diff] [blame] | 482 | |
Dave Gordon | fce91f2 | 2016-05-20 11:42:42 +0100 | [diff] [blame] | 483 | /* |
| 484 | * We've failed to load the firmware :( |
| 485 | * |
| 486 | * Decide whether to disable GuC submission and fall back to |
| 487 | * execlist mode, and whether to hide the error by returning |
| 488 | * zero or to return -EIO, which the caller will treat as a |
| 489 | * nonfatal error (i.e. it doesn't prevent driver load, but |
| 490 | * marks the GPU as wedged until reset). |
| 491 | */ |
| 492 | if (i915.enable_guc_loading > 1) { |
| 493 | ret = -EIO; |
| 494 | } else if (i915.enable_guc_submission > 1) { |
| 495 | ret = -EIO; |
| 496 | } else { |
| 497 | ret = 0; |
| 498 | } |
| 499 | |
Tvrtko Ursulin | 4805fe8 | 2016-11-04 14:42:46 +0000 | [diff] [blame] | 500 | if (err == 0 && !HAS_GUC_UCODE(dev_priv)) |
Dave Gordon | 4e50f79 | 2016-06-10 17:21:25 +0100 | [diff] [blame] | 501 | ; /* Don't mention the GuC! */ |
| 502 | else if (err == 0) |
Dave Gordon | fce91f2 | 2016-05-20 11:42:42 +0100 | [diff] [blame] | 503 | DRM_INFO("GuC firmware load skipped\n"); |
Dave Gordon | 4e50f79 | 2016-06-10 17:21:25 +0100 | [diff] [blame] | 504 | else if (ret != -EIO) |
Dave Gordon | fc32de9 | 2016-08-18 18:17:24 +0100 | [diff] [blame] | 505 | DRM_NOTE("GuC firmware load failed: %d\n", err); |
Dave Gordon | 4e50f79 | 2016-06-10 17:21:25 +0100 | [diff] [blame] | 506 | else |
Dave Gordon | fc32de9 | 2016-08-18 18:17:24 +0100 | [diff] [blame] | 507 | DRM_WARN("GuC firmware load failed: %d\n", err); |
Dave Gordon | fce91f2 | 2016-05-20 11:42:42 +0100 | [diff] [blame] | 508 | |
| 509 | if (i915.enable_guc_submission) { |
| 510 | if (fw_path == NULL) |
| 511 | DRM_INFO("GuC submission without firmware not supported\n"); |
| 512 | if (ret == 0) |
Dave Gordon | fc32de9 | 2016-08-18 18:17:24 +0100 | [diff] [blame] | 513 | DRM_NOTE("Falling back from GuC submission to execlist mode\n"); |
Dave Gordon | fce91f2 | 2016-05-20 11:42:42 +0100 | [diff] [blame] | 514 | else |
| 515 | DRM_ERROR("GuC init failed: %d\n", ret); |
| 516 | } |
| 517 | i915.enable_guc_submission = 0; |
| 518 | |
| 519 | return ret; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 520 | } |
| 521 | |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 522 | |
| 523 | /** |
Arkadiusz Hiler | 29ad6a3 | 2017-03-14 15:28:09 +0100 | [diff] [blame] | 524 | * intel_guc_init_fw() - select and prepare firmware for loading |
| 525 | * @guc: intel_guc struct |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 526 | * |
| 527 | * Called early during driver load, but after GEM is initialised. |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 528 | * |
| 529 | * The firmware will be transferred to the GuC's memory later, |
Arkadiusz Hiler | 882d1db | 2017-03-14 15:28:07 +0100 | [diff] [blame] | 530 | * when intel_guc_init_hw() is called. |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 531 | */ |
Arkadiusz Hiler | 29ad6a3 | 2017-03-14 15:28:09 +0100 | [diff] [blame] | 532 | void intel_guc_init_fw(struct intel_guc *guc) |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 533 | { |
Arkadiusz Hiler | 29ad6a3 | 2017-03-14 15:28:09 +0100 | [diff] [blame] | 534 | struct drm_i915_private *dev_priv = guc_to_i915(guc); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 535 | const char *fw_path; |
| 536 | |
Arkadiusz Hiler | d2be9f2 | 2017-03-14 15:28:10 +0100 | [diff] [blame^] | 537 | if (IS_SKYLAKE(dev_priv)) { |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 538 | fw_path = I915_SKL_GUC_UCODE; |
Arkadiusz Hiler | 29ad6a3 | 2017-03-14 15:28:09 +0100 | [diff] [blame] | 539 | guc->fw.major_ver_wanted = SKL_FW_MAJOR; |
| 540 | guc->fw.minor_ver_wanted = SKL_FW_MINOR; |
Tvrtko Ursulin | e2d214a | 2016-10-13 11:03:04 +0100 | [diff] [blame] | 541 | } else if (IS_BROXTON(dev_priv)) { |
Nick Hoath | 57bf5c8 | 2016-05-06 11:42:53 +0100 | [diff] [blame] | 542 | fw_path = I915_BXT_GUC_UCODE; |
Arkadiusz Hiler | 29ad6a3 | 2017-03-14 15:28:09 +0100 | [diff] [blame] | 543 | guc->fw.major_ver_wanted = BXT_FW_MAJOR; |
| 544 | guc->fw.minor_ver_wanted = BXT_FW_MINOR; |
Tvrtko Ursulin | 0853723 | 2016-10-13 11:03:02 +0100 | [diff] [blame] | 545 | } else if (IS_KABYLAKE(dev_priv)) { |
Peter Antoine | ff64cc1 | 2016-06-30 09:37:52 -0700 | [diff] [blame] | 546 | fw_path = I915_KBL_GUC_UCODE; |
Arkadiusz Hiler | 29ad6a3 | 2017-03-14 15:28:09 +0100 | [diff] [blame] | 547 | guc->fw.major_ver_wanted = KBL_FW_MAJOR; |
| 548 | guc->fw.minor_ver_wanted = KBL_FW_MINOR; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 549 | } else { |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 550 | fw_path = ""; /* unknown device */ |
| 551 | } |
| 552 | |
Arkadiusz Hiler | 29ad6a3 | 2017-03-14 15:28:09 +0100 | [diff] [blame] | 553 | guc->fw.path = fw_path; |
| 554 | guc->fw.fetch_status = INTEL_UC_FIRMWARE_NONE; |
| 555 | guc->fw.load_status = INTEL_UC_FIRMWARE_NONE; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 556 | |
| 557 | if (fw_path == NULL) |
| 558 | return; |
Dave Gordon | fce91f2 | 2016-05-20 11:42:42 +0100 | [diff] [blame] | 559 | if (*fw_path == '\0') |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 560 | return; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 561 | |
Arkadiusz Hiler | 29ad6a3 | 2017-03-14 15:28:09 +0100 | [diff] [blame] | 562 | guc->fw.fetch_status = INTEL_UC_FIRMWARE_PENDING; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 563 | DRM_DEBUG_DRIVER("GuC firmware pending, path %s\n", fw_path); |
Arkadiusz Hiler | 29ad6a3 | 2017-03-14 15:28:09 +0100 | [diff] [blame] | 564 | intel_uc_prepare_fw(dev_priv, &guc->fw); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 565 | /* status must now be FAIL or SUCCESS */ |
| 566 | } |
| 567 | |
| 568 | /** |
Dave Gordon | f09d675 | 2016-05-13 15:36:29 +0100 | [diff] [blame] | 569 | * intel_guc_fini() - clean up all allocated resources |
Tvrtko Ursulin | b6ea8b4 | 2016-12-02 08:43:53 +0000 | [diff] [blame] | 570 | * @dev_priv: i915 device private |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 571 | */ |
Tvrtko Ursulin | bf9e842 | 2016-12-01 14:16:38 +0000 | [diff] [blame] | 572 | void intel_guc_fini(struct drm_i915_private *dev_priv) |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 573 | { |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 574 | struct intel_uc_fw *guc_fw = &dev_priv->guc.fw; |
Chris Wilson | 65300b1 | 2017-02-14 13:34:20 +0000 | [diff] [blame] | 575 | struct drm_i915_gem_object *obj; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 576 | |
Tvrtko Ursulin | bf9e842 | 2016-12-01 14:16:38 +0000 | [diff] [blame] | 577 | mutex_lock(&dev_priv->drm.struct_mutex); |
Dave Gordon | beffa51 | 2016-06-10 18:29:26 +0100 | [diff] [blame] | 578 | i915_guc_submission_disable(dev_priv); |
| 579 | i915_guc_submission_fini(dev_priv); |
Tvrtko Ursulin | bf9e842 | 2016-12-01 14:16:38 +0000 | [diff] [blame] | 580 | mutex_unlock(&dev_priv->drm.struct_mutex); |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 581 | |
Chris Wilson | 65300b1 | 2017-02-14 13:34:20 +0000 | [diff] [blame] | 582 | obj = fetch_and_zero(&guc_fw->obj); |
| 583 | if (obj) |
| 584 | i915_gem_object_put(obj); |
| 585 | |
Anusha Srivatsa | db0a091 | 2017-01-13 17:17:04 -0800 | [diff] [blame] | 586 | guc_fw->fetch_status = INTEL_UC_FIRMWARE_NONE; |
Alex Dai | 33a732f | 2015-08-12 15:43:36 +0100 | [diff] [blame] | 587 | } |