Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* i915_drv.c -- i830,i845,i855,i865,i915 driver -*- linux-c -*- |
| 2 | */ |
Dave Airlie | 0d6aa60 | 2006-01-02 20:14:23 +1100 | [diff] [blame] | 3 | /* |
Dave Airlie | bc54fd1 | 2005-06-23 22:46:46 +1000 | [diff] [blame] | 4 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. |
| 6 | * All Rights Reserved. |
Dave Airlie | bc54fd1 | 2005-06-23 22:46:46 +1000 | [diff] [blame] | 7 | * |
| 8 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 9 | * copy of this software and associated documentation files (the |
| 10 | * "Software"), to deal in the Software without restriction, including |
| 11 | * without limitation the rights to use, copy, modify, merge, publish, |
| 12 | * distribute, sub license, and/or sell copies of the Software, and to |
| 13 | * permit persons to whom the Software is furnished to do so, subject to |
| 14 | * the following conditions: |
| 15 | * |
| 16 | * The above copyright notice and this permission notice (including the |
| 17 | * next paragraph) shall be included in all copies or substantial portions |
| 18 | * of the Software. |
| 19 | * |
| 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 21 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. |
| 23 | * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR |
| 24 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 25 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 26 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 27 | * |
Dave Airlie | 0d6aa60 | 2006-01-02 20:14:23 +1100 | [diff] [blame] | 28 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | |
Jesse Barnes | e5747e3 | 2014-06-12 08:35:47 -0700 | [diff] [blame] | 30 | #include <linux/acpi.h> |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 31 | #include <linux/device.h> |
| 32 | #include <linux/oom.h> |
| 33 | #include <linux/module.h> |
| 34 | #include <linux/pci.h> |
| 35 | #include <linux/pm.h> |
| 36 | #include <linux/pm_runtime.h> |
| 37 | #include <linux/pnp.h> |
| 38 | #include <linux/slab.h> |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 39 | #include <linux/vga_switcheroo.h> |
| 40 | #include <linux/vt.h> |
| 41 | #include <acpi/video.h> |
| 42 | |
Maarten Lankhorst | a667fb4 | 2016-12-15 15:29:44 +0100 | [diff] [blame] | 43 | #include <drm/drm_atomic_helper.h> |
Sam Ravnborg | d0e9359 | 2019-01-26 13:25:24 +0100 | [diff] [blame] | 44 | #include <drm/drm_ioctl.h> |
| 45 | #include <drm/drm_irq.h> |
| 46 | #include <drm/drm_probe_helper.h> |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 47 | |
Jani Nikula | df0566a | 2019-06-13 11:44:16 +0300 | [diff] [blame] | 48 | #include "display/intel_acpi.h" |
| 49 | #include "display/intel_audio.h" |
| 50 | #include "display/intel_bw.h" |
| 51 | #include "display/intel_cdclk.h" |
Jani Nikula | 06d3ff6 | 2020-02-11 18:14:50 +0200 | [diff] [blame] | 52 | #include "display/intel_csr.h" |
Jani Nikula | 926b005 | 2020-02-11 18:14:51 +0200 | [diff] [blame] | 53 | #include "display/intel_display_debugfs.h" |
Jani Nikula | 1d455f8 | 2019-08-06 14:39:33 +0300 | [diff] [blame] | 54 | #include "display/intel_display_types.h" |
Jani Nikula | 379bc10 | 2019-06-13 11:44:15 +0300 | [diff] [blame] | 55 | #include "display/intel_dp.h" |
Jani Nikula | df0566a | 2019-06-13 11:44:16 +0300 | [diff] [blame] | 56 | #include "display/intel_fbdev.h" |
Jani Nikula | df0566a | 2019-06-13 11:44:16 +0300 | [diff] [blame] | 57 | #include "display/intel_hotplug.h" |
| 58 | #include "display/intel_overlay.h" |
| 59 | #include "display/intel_pipe_crc.h" |
José Roberto de Souza | df1a5bf | 2020-02-21 13:26:35 -0800 | [diff] [blame] | 60 | #include "display/intel_psr.h" |
Jani Nikula | df0566a | 2019-06-13 11:44:16 +0300 | [diff] [blame] | 61 | #include "display/intel_sprite.h" |
Jani Nikula | 4fb8783 | 2019-10-01 18:25:06 +0300 | [diff] [blame] | 62 | #include "display/intel_vga.h" |
Jani Nikula | 379bc10 | 2019-06-13 11:44:15 +0300 | [diff] [blame] | 63 | |
Chris Wilson | 10be98a | 2019-05-28 10:29:49 +0100 | [diff] [blame] | 64 | #include "gem/i915_gem_context.h" |
Chris Wilson | afa1308 | 2019-05-28 10:29:43 +0100 | [diff] [blame] | 65 | #include "gem/i915_gem_ioctls.h" |
Abdiel Janulgue | cc66212 | 2019-12-04 12:00:32 +0000 | [diff] [blame] | 66 | #include "gem/i915_gem_mman.h" |
Tvrtko Ursulin | 24635c5 | 2019-06-21 08:07:41 +0100 | [diff] [blame] | 67 | #include "gt/intel_gt.h" |
Chris Wilson | 79ffac85 | 2019-04-24 21:07:17 +0100 | [diff] [blame] | 68 | #include "gt/intel_gt_pm.h" |
Imre Deak | 2248a28 | 2019-10-17 16:38:31 +0300 | [diff] [blame] | 69 | #include "gt/intel_rc6.h" |
Chris Wilson | 112ed2d | 2019-04-24 18:48:39 +0100 | [diff] [blame] | 70 | |
Jani Nikula | 2126d3e | 2019-05-02 18:02:43 +0300 | [diff] [blame] | 71 | #include "i915_debugfs.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | #include "i915_drv.h" |
Jani Nikula | 440e2b3 | 2019-04-29 15:29:27 +0300 | [diff] [blame] | 73 | #include "i915_irq.h" |
Jani Nikula | 9c9082b | 2019-08-08 16:42:47 +0300 | [diff] [blame] | 74 | #include "i915_memcpy.h" |
Jani Nikula | db94e9f | 2019-08-08 16:42:44 +0300 | [diff] [blame] | 75 | #include "i915_perf.h" |
Lionel Landwerlin | a446ae2 | 2018-03-06 12:28:56 +0000 | [diff] [blame] | 76 | #include "i915_query.h" |
Jani Nikula | bdd1510 | 2019-08-08 16:42:46 +0300 | [diff] [blame] | 77 | #include "i915_suspend.h" |
Jani Nikula | 63bf830 | 2019-10-04 15:20:18 +0300 | [diff] [blame] | 78 | #include "i915_switcheroo.h" |
Jani Nikula | be68261 | 2019-08-08 16:42:45 +0300 | [diff] [blame] | 79 | #include "i915_sysfs.h" |
Jani Nikula | 331c201 | 2019-04-05 14:00:03 +0300 | [diff] [blame] | 80 | #include "i915_trace.h" |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 81 | #include "i915_vgpu.h" |
Jani Nikula | d28ae3b | 2020-02-25 13:15:07 +0200 | [diff] [blame^] | 82 | #include "intel_dram.h" |
Chris Wilson | 3fc794f | 2019-10-26 21:20:32 +0100 | [diff] [blame] | 83 | #include "intel_memory_region.h" |
Jani Nikula | 696173b | 2019-04-05 14:00:15 +0300 | [diff] [blame] | 84 | #include "intel_pm.h" |
Jani Nikula | fb5f432 | 2020-02-12 16:40:57 +0200 | [diff] [blame] | 85 | #include "vlv_suspend.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | |
Kristian Høgsberg | 112b715 | 2009-01-04 16:55:33 -0500 | [diff] [blame] | 87 | static struct drm_driver driver; |
| 88 | |
Tvrtko Ursulin | da5f53b | 2016-12-01 14:16:40 +0000 | [diff] [blame] | 89 | static int i915_get_bridge_dev(struct drm_i915_private *dev_priv) |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 90 | { |
Sinan Kaya | 57b29646 | 2017-11-27 11:57:46 -0500 | [diff] [blame] | 91 | int domain = pci_domain_nr(dev_priv->drm.pdev->bus); |
| 92 | |
| 93 | dev_priv->bridge_dev = |
| 94 | pci_get_domain_bus_and_slot(domain, 0, PCI_DEVFN(0, 0)); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 95 | if (!dev_priv->bridge_dev) { |
Wambui Karuga | 00376cc | 2020-01-31 12:34:12 +0300 | [diff] [blame] | 96 | drm_err(&dev_priv->drm, "bridge device not found\n"); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 97 | return -1; |
| 98 | } |
| 99 | return 0; |
| 100 | } |
| 101 | |
| 102 | /* Allocate space for the MCH regs if needed, return nonzero on error */ |
| 103 | static int |
Tvrtko Ursulin | da5f53b | 2016-12-01 14:16:40 +0000 | [diff] [blame] | 104 | intel_alloc_mchbar_resource(struct drm_i915_private *dev_priv) |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 105 | { |
Tvrtko Ursulin | 514e1d6 | 2016-11-04 14:42:48 +0000 | [diff] [blame] | 106 | int reg = INTEL_GEN(dev_priv) >= 4 ? MCHBAR_I965 : MCHBAR_I915; |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 107 | u32 temp_lo, temp_hi = 0; |
| 108 | u64 mchbar_addr; |
| 109 | int ret; |
| 110 | |
Tvrtko Ursulin | 514e1d6 | 2016-11-04 14:42:48 +0000 | [diff] [blame] | 111 | if (INTEL_GEN(dev_priv) >= 4) |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 112 | pci_read_config_dword(dev_priv->bridge_dev, reg + 4, &temp_hi); |
| 113 | pci_read_config_dword(dev_priv->bridge_dev, reg, &temp_lo); |
| 114 | mchbar_addr = ((u64)temp_hi << 32) | temp_lo; |
| 115 | |
| 116 | /* If ACPI doesn't have it, assume we need to allocate it ourselves */ |
| 117 | #ifdef CONFIG_PNP |
| 118 | if (mchbar_addr && |
| 119 | pnp_range_reserved(mchbar_addr, mchbar_addr + MCHBAR_SIZE)) |
| 120 | return 0; |
| 121 | #endif |
| 122 | |
| 123 | /* Get some space for it */ |
| 124 | dev_priv->mch_res.name = "i915 MCHBAR"; |
| 125 | dev_priv->mch_res.flags = IORESOURCE_MEM; |
| 126 | ret = pci_bus_alloc_resource(dev_priv->bridge_dev->bus, |
| 127 | &dev_priv->mch_res, |
| 128 | MCHBAR_SIZE, MCHBAR_SIZE, |
| 129 | PCIBIOS_MIN_MEM, |
| 130 | 0, pcibios_align_resource, |
| 131 | dev_priv->bridge_dev); |
| 132 | if (ret) { |
Wambui Karuga | 00376cc | 2020-01-31 12:34:12 +0300 | [diff] [blame] | 133 | drm_dbg(&dev_priv->drm, "failed bus alloc: %d\n", ret); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 134 | dev_priv->mch_res.start = 0; |
| 135 | return ret; |
| 136 | } |
| 137 | |
Tvrtko Ursulin | 514e1d6 | 2016-11-04 14:42:48 +0000 | [diff] [blame] | 138 | if (INTEL_GEN(dev_priv) >= 4) |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 139 | pci_write_config_dword(dev_priv->bridge_dev, reg + 4, |
| 140 | upper_32_bits(dev_priv->mch_res.start)); |
| 141 | |
| 142 | pci_write_config_dword(dev_priv->bridge_dev, reg, |
| 143 | lower_32_bits(dev_priv->mch_res.start)); |
| 144 | return 0; |
| 145 | } |
| 146 | |
| 147 | /* Setup MCHBAR if possible, return true if we should disable it again */ |
| 148 | static void |
Tvrtko Ursulin | da5f53b | 2016-12-01 14:16:40 +0000 | [diff] [blame] | 149 | intel_setup_mchbar(struct drm_i915_private *dev_priv) |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 150 | { |
Tvrtko Ursulin | 514e1d6 | 2016-11-04 14:42:48 +0000 | [diff] [blame] | 151 | int mchbar_reg = INTEL_GEN(dev_priv) >= 4 ? MCHBAR_I965 : MCHBAR_I915; |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 152 | u32 temp; |
| 153 | bool enabled; |
| 154 | |
Tvrtko Ursulin | 920a14b | 2016-10-14 10:13:44 +0100 | [diff] [blame] | 155 | if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 156 | return; |
| 157 | |
| 158 | dev_priv->mchbar_need_disable = false; |
| 159 | |
Tvrtko Ursulin | 50a0bc9 | 2016-10-13 11:02:58 +0100 | [diff] [blame] | 160 | if (IS_I915G(dev_priv) || IS_I915GM(dev_priv)) { |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 161 | pci_read_config_dword(dev_priv->bridge_dev, DEVEN, &temp); |
| 162 | enabled = !!(temp & DEVEN_MCHBAR_EN); |
| 163 | } else { |
| 164 | pci_read_config_dword(dev_priv->bridge_dev, mchbar_reg, &temp); |
| 165 | enabled = temp & 1; |
| 166 | } |
| 167 | |
| 168 | /* If it's already enabled, don't have to do anything */ |
| 169 | if (enabled) |
| 170 | return; |
| 171 | |
Tvrtko Ursulin | da5f53b | 2016-12-01 14:16:40 +0000 | [diff] [blame] | 172 | if (intel_alloc_mchbar_resource(dev_priv)) |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 173 | return; |
| 174 | |
| 175 | dev_priv->mchbar_need_disable = true; |
| 176 | |
| 177 | /* Space is allocated or reserved, so enable it. */ |
Tvrtko Ursulin | 50a0bc9 | 2016-10-13 11:02:58 +0100 | [diff] [blame] | 178 | if (IS_I915G(dev_priv) || IS_I915GM(dev_priv)) { |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 179 | pci_write_config_dword(dev_priv->bridge_dev, DEVEN, |
| 180 | temp | DEVEN_MCHBAR_EN); |
| 181 | } else { |
| 182 | pci_read_config_dword(dev_priv->bridge_dev, mchbar_reg, &temp); |
| 183 | pci_write_config_dword(dev_priv->bridge_dev, mchbar_reg, temp | 1); |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | static void |
Tvrtko Ursulin | da5f53b | 2016-12-01 14:16:40 +0000 | [diff] [blame] | 188 | intel_teardown_mchbar(struct drm_i915_private *dev_priv) |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 189 | { |
Tvrtko Ursulin | 514e1d6 | 2016-11-04 14:42:48 +0000 | [diff] [blame] | 190 | int mchbar_reg = INTEL_GEN(dev_priv) >= 4 ? MCHBAR_I965 : MCHBAR_I915; |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 191 | |
| 192 | if (dev_priv->mchbar_need_disable) { |
Tvrtko Ursulin | 50a0bc9 | 2016-10-13 11:02:58 +0100 | [diff] [blame] | 193 | if (IS_I915G(dev_priv) || IS_I915GM(dev_priv)) { |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 194 | u32 deven_val; |
| 195 | |
| 196 | pci_read_config_dword(dev_priv->bridge_dev, DEVEN, |
| 197 | &deven_val); |
| 198 | deven_val &= ~DEVEN_MCHBAR_EN; |
| 199 | pci_write_config_dword(dev_priv->bridge_dev, DEVEN, |
| 200 | deven_val); |
| 201 | } else { |
| 202 | u32 mchbar_val; |
| 203 | |
| 204 | pci_read_config_dword(dev_priv->bridge_dev, mchbar_reg, |
| 205 | &mchbar_val); |
| 206 | mchbar_val &= ~1; |
| 207 | pci_write_config_dword(dev_priv->bridge_dev, mchbar_reg, |
| 208 | mchbar_val); |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | if (dev_priv->mch_res.start) |
| 213 | release_resource(&dev_priv->mch_res); |
| 214 | } |
| 215 | |
Jani Nikula | b664259 | 2020-02-19 15:37:56 +0200 | [diff] [blame] | 216 | /* part #1: call before irq install */ |
| 217 | static int i915_driver_modeset_probe_noirq(struct drm_i915_private *i915) |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 218 | { |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 219 | int ret; |
| 220 | |
Jani Nikula | 5bcd53a | 2019-09-20 21:54:17 +0300 | [diff] [blame] | 221 | if (i915_inject_probe_failure(i915)) |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 222 | return -ENODEV; |
| 223 | |
Jani Nikula | 5bcd53a | 2019-09-20 21:54:17 +0300 | [diff] [blame] | 224 | if (HAS_DISPLAY(i915) && INTEL_DISPLAY_ENABLED(i915)) { |
| 225 | ret = drm_vblank_init(&i915->drm, |
| 226 | INTEL_NUM_PIPES(i915)); |
José Roberto de Souza | 8d3bf1a | 2018-11-07 16:16:44 -0800 | [diff] [blame] | 227 | if (ret) |
| 228 | goto out; |
| 229 | } |
| 230 | |
Jani Nikula | 5bcd53a | 2019-09-20 21:54:17 +0300 | [diff] [blame] | 231 | intel_bios_init(i915); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 232 | |
Jani Nikula | 4fb8783 | 2019-10-01 18:25:06 +0300 | [diff] [blame] | 233 | ret = intel_vga_register(i915); |
| 234 | if (ret) |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 235 | goto out; |
| 236 | |
Jani Nikula | 5bcd53a | 2019-09-20 21:54:17 +0300 | [diff] [blame] | 237 | intel_power_domains_init_hw(i915, false); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 238 | |
Jani Nikula | 5bcd53a | 2019-09-20 21:54:17 +0300 | [diff] [blame] | 239 | intel_csr_ucode_init(i915); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 240 | |
Jani Nikula | 80f286a | 2020-02-24 14:08:28 +0200 | [diff] [blame] | 241 | ret = intel_modeset_init_noirq(i915); |
| 242 | if (ret) |
| 243 | goto cleanup_vga_client; |
| 244 | |
Jani Nikula | b664259 | 2020-02-19 15:37:56 +0200 | [diff] [blame] | 245 | return 0; |
| 246 | |
Jani Nikula | 80f286a | 2020-02-24 14:08:28 +0200 | [diff] [blame] | 247 | cleanup_vga_client: |
| 248 | intel_vga_unregister(i915); |
Jani Nikula | b664259 | 2020-02-19 15:37:56 +0200 | [diff] [blame] | 249 | out: |
| 250 | return ret; |
| 251 | } |
| 252 | |
| 253 | /* part #2: call after irq install */ |
| 254 | static int i915_driver_modeset_probe(struct drm_i915_private *i915) |
| 255 | { |
| 256 | int ret; |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 257 | |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 258 | /* Important: The output setup functions called by modeset_init need |
| 259 | * working irqs for e.g. gmbus and dp aux transfers. */ |
Jani Nikula | 6cd02e7 | 2019-09-20 21:54:21 +0300 | [diff] [blame] | 260 | ret = intel_modeset_init(i915); |
Ville Syrjälä | b079bd17 | 2016-10-25 18:58:02 +0300 | [diff] [blame] | 261 | if (ret) |
Jani Nikula | b664259 | 2020-02-19 15:37:56 +0200 | [diff] [blame] | 262 | goto out; |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 263 | |
Jani Nikula | 5bcd53a | 2019-09-20 21:54:17 +0300 | [diff] [blame] | 264 | ret = i915_gem_init(i915); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 265 | if (ret) |
Chris Wilson | 73bad7c | 2018-07-10 10:44:21 +0100 | [diff] [blame] | 266 | goto cleanup_modeset; |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 267 | |
Jani Nikula | 5bcd53a | 2019-09-20 21:54:17 +0300 | [diff] [blame] | 268 | intel_overlay_setup(i915); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 269 | |
Jani Nikula | 5bcd53a | 2019-09-20 21:54:17 +0300 | [diff] [blame] | 270 | if (!HAS_DISPLAY(i915) || !INTEL_DISPLAY_ENABLED(i915)) |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 271 | return 0; |
| 272 | |
Jani Nikula | 5bcd53a | 2019-09-20 21:54:17 +0300 | [diff] [blame] | 273 | ret = intel_fbdev_init(&i915->drm); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 274 | if (ret) |
| 275 | goto cleanup_gem; |
| 276 | |
| 277 | /* Only enable hotplug handling once the fbdev is fully set up. */ |
Jani Nikula | 5bcd53a | 2019-09-20 21:54:17 +0300 | [diff] [blame] | 278 | intel_hpd_init(i915); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 279 | |
Jani Nikula | 5bcd53a | 2019-09-20 21:54:17 +0300 | [diff] [blame] | 280 | intel_init_ipc(i915); |
José Roberto de Souza | a8147d0 | 2018-11-07 16:16:46 -0800 | [diff] [blame] | 281 | |
José Roberto de Souza | df1a5bf | 2020-02-21 13:26:35 -0800 | [diff] [blame] | 282 | intel_psr_set_force_mode_changed(i915->psr.dp); |
| 283 | |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 284 | return 0; |
| 285 | |
| 286 | cleanup_gem: |
Jani Nikula | 5bcd53a | 2019-09-20 21:54:17 +0300 | [diff] [blame] | 287 | i915_gem_suspend(i915); |
| 288 | i915_gem_driver_remove(i915); |
| 289 | i915_gem_driver_release(i915); |
Chris Wilson | 73bad7c | 2018-07-10 10:44:21 +0100 | [diff] [blame] | 290 | cleanup_modeset: |
Jani Nikula | b664259 | 2020-02-19 15:37:56 +0200 | [diff] [blame] | 291 | /* FIXME */ |
Jani Nikula | 9980c3c | 2019-09-20 21:54:18 +0300 | [diff] [blame] | 292 | intel_modeset_driver_remove(i915); |
Jani Nikula | 93a0ed6 | 2020-02-14 15:50:57 +0200 | [diff] [blame] | 293 | intel_irq_uninstall(i915); |
| 294 | intel_modeset_driver_remove_noirq(i915); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 295 | out: |
| 296 | return ret; |
| 297 | } |
| 298 | |
Jani Nikula | f20a60f | 2020-02-14 15:50:58 +0200 | [diff] [blame] | 299 | /* part #1: call before irq uninstall */ |
Jani Nikula | 2d6f6f3 | 2019-09-20 21:54:16 +0300 | [diff] [blame] | 300 | static void i915_driver_modeset_remove(struct drm_i915_private *i915) |
| 301 | { |
Jani Nikula | 9980c3c | 2019-09-20 21:54:18 +0300 | [diff] [blame] | 302 | intel_modeset_driver_remove(i915); |
Jani Nikula | f20a60f | 2020-02-14 15:50:58 +0200 | [diff] [blame] | 303 | } |
Jani Nikula | 2d6f6f3 | 2019-09-20 21:54:16 +0300 | [diff] [blame] | 304 | |
Jani Nikula | f20a60f | 2020-02-14 15:50:58 +0200 | [diff] [blame] | 305 | /* part #2: call after irq uninstall */ |
| 306 | static void i915_driver_modeset_remove_noirq(struct drm_i915_private *i915) |
| 307 | { |
Jani Nikula | 93a0ed6 | 2020-02-14 15:50:57 +0200 | [diff] [blame] | 308 | intel_modeset_driver_remove_noirq(i915); |
| 309 | |
Jani Nikula | 2d6f6f3 | 2019-09-20 21:54:16 +0300 | [diff] [blame] | 310 | intel_bios_driver_remove(i915); |
| 311 | |
Jani Nikula | 4fb8783 | 2019-10-01 18:25:06 +0300 | [diff] [blame] | 312 | intel_vga_unregister(i915); |
Jani Nikula | 2d6f6f3 | 2019-09-20 21:54:16 +0300 | [diff] [blame] | 313 | |
| 314 | intel_csr_ucode_fini(i915); |
| 315 | } |
| 316 | |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 317 | static void intel_init_dpio(struct drm_i915_private *dev_priv) |
| 318 | { |
| 319 | /* |
| 320 | * IOSF_PORT_DPIO is used for VLV x2 PHY (DP/HDMI B and C), |
| 321 | * CHV x1 PHY (DP/HDMI D) |
| 322 | * IOSF_PORT_DPIO_2 is used for CHV x2 PHY (DP/HDMI B and C) |
| 323 | */ |
| 324 | if (IS_CHERRYVIEW(dev_priv)) { |
| 325 | DPIO_PHY_IOSF_PORT(DPIO_PHY0) = IOSF_PORT_DPIO_2; |
| 326 | DPIO_PHY_IOSF_PORT(DPIO_PHY1) = IOSF_PORT_DPIO; |
| 327 | } else if (IS_VALLEYVIEW(dev_priv)) { |
| 328 | DPIO_PHY_IOSF_PORT(DPIO_PHY0) = IOSF_PORT_DPIO; |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | static int i915_workqueues_init(struct drm_i915_private *dev_priv) |
| 333 | { |
| 334 | /* |
| 335 | * The i915 workqueue is primarily used for batched retirement of |
| 336 | * requests (and thus managing bo) once the task has been completed |
Chris Wilson | e61e0f5 | 2018-02-21 09:56:36 +0000 | [diff] [blame] | 337 | * by the GPU. i915_retire_requests() is called directly when we |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 338 | * need high-priority retirement, such as waiting for an explicit |
| 339 | * bo. |
| 340 | * |
| 341 | * It is also used for periodic low-priority events, such as |
| 342 | * idle-timers and recording error state. |
| 343 | * |
| 344 | * All tasks on the workqueue are expected to acquire the dev mutex |
| 345 | * so there is no point in running more than one instance of the |
| 346 | * workqueue at any time. Use an ordered one. |
| 347 | */ |
| 348 | dev_priv->wq = alloc_ordered_workqueue("i915", 0); |
| 349 | if (dev_priv->wq == NULL) |
| 350 | goto out_err; |
| 351 | |
| 352 | dev_priv->hotplug.dp_wq = alloc_ordered_workqueue("i915-dp", 0); |
| 353 | if (dev_priv->hotplug.dp_wq == NULL) |
| 354 | goto out_free_wq; |
| 355 | |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 356 | return 0; |
| 357 | |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 358 | out_free_wq: |
| 359 | destroy_workqueue(dev_priv->wq); |
| 360 | out_err: |
Wambui Karuga | 00376cc | 2020-01-31 12:34:12 +0300 | [diff] [blame] | 361 | drm_err(&dev_priv->drm, "Failed to allocate workqueues.\n"); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 362 | |
| 363 | return -ENOMEM; |
| 364 | } |
| 365 | |
| 366 | static void i915_workqueues_cleanup(struct drm_i915_private *dev_priv) |
| 367 | { |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 368 | destroy_workqueue(dev_priv->hotplug.dp_wq); |
| 369 | destroy_workqueue(dev_priv->wq); |
| 370 | } |
| 371 | |
Paulo Zanoni | 4fc7e84 | 2016-09-26 15:07:52 +0300 | [diff] [blame] | 372 | /* |
| 373 | * We don't keep the workarounds for pre-production hardware, so we expect our |
| 374 | * driver to fail on these machines in one way or another. A little warning on |
| 375 | * dmesg may help both the user and the bug triagers. |
Chris Wilson | 6a7a6a9 | 2017-11-17 10:26:35 +0000 | [diff] [blame] | 376 | * |
| 377 | * Our policy for removing pre-production workarounds is to keep the |
| 378 | * current gen workarounds as a guide to the bring-up of the next gen |
| 379 | * (workarounds have a habit of persisting!). Anything older than that |
| 380 | * should be removed along with the complications they introduce. |
Paulo Zanoni | 4fc7e84 | 2016-09-26 15:07:52 +0300 | [diff] [blame] | 381 | */ |
| 382 | static void intel_detect_preproduction_hw(struct drm_i915_private *dev_priv) |
| 383 | { |
Chris Wilson | 248a124 | 2017-01-30 10:44:56 +0000 | [diff] [blame] | 384 | bool pre = false; |
| 385 | |
| 386 | pre |= IS_HSW_EARLY_SDV(dev_priv); |
| 387 | pre |= IS_SKL_REVID(dev_priv, 0, SKL_REVID_F0); |
Chris Wilson | 0102ba1 | 2017-01-30 10:44:58 +0000 | [diff] [blame] | 388 | pre |= IS_BXT_REVID(dev_priv, 0, BXT_REVID_B_LAST); |
Chris Wilson | 1aca96c | 2018-11-28 13:53:25 +0000 | [diff] [blame] | 389 | pre |= IS_KBL_REVID(dev_priv, 0, KBL_REVID_A0); |
Chris Wilson | 248a124 | 2017-01-30 10:44:56 +0000 | [diff] [blame] | 390 | |
Chris Wilson | 7c5ff4a | 2017-01-30 10:44:57 +0000 | [diff] [blame] | 391 | if (pre) { |
Wambui Karuga | 00376cc | 2020-01-31 12:34:12 +0300 | [diff] [blame] | 392 | drm_err(&dev_priv->drm, "This is a pre-production stepping. " |
Paulo Zanoni | 4fc7e84 | 2016-09-26 15:07:52 +0300 | [diff] [blame] | 393 | "It may not be fully functional.\n"); |
Chris Wilson | 7c5ff4a | 2017-01-30 10:44:57 +0000 | [diff] [blame] | 394 | add_taint(TAINT_MACHINE_CHECK, LOCKDEP_STILL_OK); |
| 395 | } |
Paulo Zanoni | 4fc7e84 | 2016-09-26 15:07:52 +0300 | [diff] [blame] | 396 | } |
| 397 | |
Chris Wilson | 640b50f | 2019-12-28 11:12:55 +0000 | [diff] [blame] | 398 | static void sanitize_gpu(struct drm_i915_private *i915) |
| 399 | { |
| 400 | if (!INTEL_INFO(i915)->gpu_reset_clobbers_display) |
| 401 | __intel_gt_reset(&i915->gt, ALL_ENGINES); |
| 402 | } |
| 403 | |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 404 | /** |
Janusz Krzysztofik | 0b61b8b | 2019-07-12 13:24:30 +0200 | [diff] [blame] | 405 | * i915_driver_early_probe - setup state not requiring device access |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 406 | * @dev_priv: device private |
| 407 | * |
| 408 | * Initialize everything that is a "SW-only" state, that is state not |
| 409 | * requiring accessing the device or exposing the driver via kernel internal |
| 410 | * or userspace interfaces. Example steps belonging here: lock initialization, |
| 411 | * system memory allocation, setting up device specific attributes and |
| 412 | * function hooks not requiring accessing the device. |
| 413 | */ |
Janusz Krzysztofik | 0b61b8b | 2019-07-12 13:24:30 +0200 | [diff] [blame] | 414 | static int i915_driver_early_probe(struct drm_i915_private *dev_priv) |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 415 | { |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 416 | int ret = 0; |
| 417 | |
Michal Wajdeczko | 50d8441 | 2019-08-02 18:40:50 +0000 | [diff] [blame] | 418 | if (i915_inject_probe_failure(dev_priv)) |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 419 | return -ENODEV; |
| 420 | |
Tvrtko Ursulin | 805446c | 2019-03-27 14:23:28 +0000 | [diff] [blame] | 421 | intel_device_info_subplatform_init(dev_priv); |
| 422 | |
Daniele Ceraolo Spurio | 0a9b263 | 2019-08-09 07:31:16 +0100 | [diff] [blame] | 423 | intel_uncore_mmio_debug_init_early(&dev_priv->mmio_debug); |
Daniele Ceraolo Spurio | 0138575 | 2019-06-19 18:00:18 -0700 | [diff] [blame] | 424 | intel_uncore_init_early(&dev_priv->uncore, dev_priv); |
Daniele Ceraolo Spurio | 6cbe8830 | 2019-04-02 13:10:31 -0700 | [diff] [blame] | 425 | |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 426 | spin_lock_init(&dev_priv->irq_lock); |
| 427 | spin_lock_init(&dev_priv->gpu_error.lock); |
| 428 | mutex_init(&dev_priv->backlight_lock); |
Lyude | 317eaa9 | 2017-02-03 21:18:25 -0500 | [diff] [blame] | 429 | |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 430 | mutex_init(&dev_priv->sb_lock); |
Chris Wilson | a75d035 | 2019-04-26 09:17:18 +0100 | [diff] [blame] | 431 | pm_qos_add_request(&dev_priv->sb_qos, |
| 432 | PM_QOS_CPU_DMA_LATENCY, PM_QOS_DEFAULT_VALUE); |
| 433 | |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 434 | mutex_init(&dev_priv->av_mutex); |
| 435 | mutex_init(&dev_priv->wm.wm_mutex); |
| 436 | mutex_init(&dev_priv->pps_mutex); |
Ramalingam C | 9055aac | 2019-02-16 23:06:51 +0530 | [diff] [blame] | 437 | mutex_init(&dev_priv->hdcp_comp_mutex); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 438 | |
Chris Wilson | 0b1de5d | 2016-08-12 12:39:59 +0100 | [diff] [blame] | 439 | i915_memcpy_init_early(dev_priv); |
Daniele Ceraolo Spurio | 69c6635 | 2019-06-13 16:21:53 -0700 | [diff] [blame] | 440 | intel_runtime_pm_init_early(&dev_priv->runtime_pm); |
Chris Wilson | 0b1de5d | 2016-08-12 12:39:59 +0100 | [diff] [blame] | 441 | |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 442 | ret = i915_workqueues_init(dev_priv); |
| 443 | if (ret < 0) |
Chris Wilson | f3bcb0c | 2019-07-18 08:00:10 +0100 | [diff] [blame] | 444 | return ret; |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 445 | |
Jani Nikula | fb5f432 | 2020-02-12 16:40:57 +0200 | [diff] [blame] | 446 | ret = vlv_suspend_init(dev_priv); |
Daniele Ceraolo Spurio | 1bcd868 | 2019-08-19 19:01:46 -0700 | [diff] [blame] | 447 | if (ret < 0) |
| 448 | goto err_workqueues; |
| 449 | |
Daniele Ceraolo Spurio | 6f76098 | 2019-07-31 17:57:08 -0700 | [diff] [blame] | 450 | intel_wopcm_init_early(&dev_priv->wopcm); |
| 451 | |
Tvrtko Ursulin | 724e956 | 2019-06-21 08:07:42 +0100 | [diff] [blame] | 452 | intel_gt_init_early(&dev_priv->gt, dev_priv); |
Tvrtko Ursulin | 24635c5 | 2019-06-21 08:07:41 +0100 | [diff] [blame] | 453 | |
Matthew Auld | a3f356b | 2019-09-27 18:33:49 +0100 | [diff] [blame] | 454 | i915_gem_init_early(dev_priv); |
Michal Wajdeczko | a0de908 | 2018-03-23 12:34:49 +0000 | [diff] [blame] | 455 | |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 456 | /* This must be called before any calls to HAS_PCH_* */ |
Tvrtko Ursulin | da5f53b | 2016-12-01 14:16:40 +0000 | [diff] [blame] | 457 | intel_detect_pch(dev_priv); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 458 | |
Tvrtko Ursulin | 192aa18 | 2016-12-01 14:16:45 +0000 | [diff] [blame] | 459 | intel_pm_setup(dev_priv); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 460 | intel_init_dpio(dev_priv); |
Imre Deak | f28ec6f | 2018-08-06 12:58:37 +0300 | [diff] [blame] | 461 | ret = intel_power_domains_init(dev_priv); |
| 462 | if (ret < 0) |
Daniele Ceraolo Spurio | 6f76098 | 2019-07-31 17:57:08 -0700 | [diff] [blame] | 463 | goto err_gem; |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 464 | intel_irq_init(dev_priv); |
| 465 | intel_init_display_hooks(dev_priv); |
| 466 | intel_init_clock_gating_hooks(dev_priv); |
| 467 | intel_init_audio_hooks(dev_priv); |
David Weinehall | 36cdd01 | 2016-08-22 13:59:31 +0300 | [diff] [blame] | 468 | intel_display_crc_init(dev_priv); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 469 | |
Paulo Zanoni | 4fc7e84 | 2016-09-26 15:07:52 +0300 | [diff] [blame] | 470 | intel_detect_preproduction_hw(dev_priv); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 471 | |
| 472 | return 0; |
| 473 | |
Daniele Ceraolo Spurio | 6f76098 | 2019-07-31 17:57:08 -0700 | [diff] [blame] | 474 | err_gem: |
Imre Deak | f28ec6f | 2018-08-06 12:58:37 +0300 | [diff] [blame] | 475 | i915_gem_cleanup_early(dev_priv); |
Daniele Ceraolo Spurio | 6cf72db | 2019-07-31 17:57:07 -0700 | [diff] [blame] | 476 | intel_gt_driver_late_release(&dev_priv->gt); |
Jani Nikula | fb5f432 | 2020-02-12 16:40:57 +0200 | [diff] [blame] | 477 | vlv_suspend_cleanup(dev_priv); |
Daniele Ceraolo Spurio | 1bcd868 | 2019-08-19 19:01:46 -0700 | [diff] [blame] | 478 | err_workqueues: |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 479 | i915_workqueues_cleanup(dev_priv); |
| 480 | return ret; |
| 481 | } |
| 482 | |
| 483 | /** |
Janusz Krzysztofik | 3b58a94 | 2019-07-12 13:24:28 +0200 | [diff] [blame] | 484 | * i915_driver_late_release - cleanup the setup done in |
Janusz Krzysztofik | 0b61b8b | 2019-07-12 13:24:30 +0200 | [diff] [blame] | 485 | * i915_driver_early_probe() |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 486 | * @dev_priv: device private |
| 487 | */ |
Janusz Krzysztofik | 3b58a94 | 2019-07-12 13:24:28 +0200 | [diff] [blame] | 488 | static void i915_driver_late_release(struct drm_i915_private *dev_priv) |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 489 | { |
Joonas Lahtinen | cefcff8 | 2017-04-28 10:58:39 +0300 | [diff] [blame] | 490 | intel_irq_fini(dev_priv); |
Imre Deak | f28ec6f | 2018-08-06 12:58:37 +0300 | [diff] [blame] | 491 | intel_power_domains_cleanup(dev_priv); |
Michal Wajdeczko | a0de908 | 2018-03-23 12:34:49 +0000 | [diff] [blame] | 492 | i915_gem_cleanup_early(dev_priv); |
Daniele Ceraolo Spurio | 6cf72db | 2019-07-31 17:57:07 -0700 | [diff] [blame] | 493 | intel_gt_driver_late_release(&dev_priv->gt); |
Jani Nikula | fb5f432 | 2020-02-12 16:40:57 +0200 | [diff] [blame] | 494 | vlv_suspend_cleanup(dev_priv); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 495 | i915_workqueues_cleanup(dev_priv); |
Chris Wilson | a75d035 | 2019-04-26 09:17:18 +0100 | [diff] [blame] | 496 | |
| 497 | pm_qos_remove_request(&dev_priv->sb_qos); |
| 498 | mutex_destroy(&dev_priv->sb_lock); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 499 | } |
| 500 | |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 501 | /** |
Janusz Krzysztofik | 0b61b8b | 2019-07-12 13:24:30 +0200 | [diff] [blame] | 502 | * i915_driver_mmio_probe - setup device MMIO |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 503 | * @dev_priv: device private |
| 504 | * |
| 505 | * Setup minimal device state necessary for MMIO accesses later in the |
| 506 | * initialization sequence. The setup here should avoid any other device-wide |
| 507 | * side effects or exposing the driver via kernel internal or user space |
| 508 | * interfaces. |
| 509 | */ |
Janusz Krzysztofik | 0b61b8b | 2019-07-12 13:24:30 +0200 | [diff] [blame] | 510 | static int i915_driver_mmio_probe(struct drm_i915_private *dev_priv) |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 511 | { |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 512 | int ret; |
| 513 | |
Michal Wajdeczko | 50d8441 | 2019-08-02 18:40:50 +0000 | [diff] [blame] | 514 | if (i915_inject_probe_failure(dev_priv)) |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 515 | return -ENODEV; |
| 516 | |
Tvrtko Ursulin | da5f53b | 2016-12-01 14:16:40 +0000 | [diff] [blame] | 517 | if (i915_get_bridge_dev(dev_priv)) |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 518 | return -EIO; |
| 519 | |
Daniele Ceraolo Spurio | 3de6f85 | 2019-04-02 13:10:32 -0700 | [diff] [blame] | 520 | ret = intel_uncore_init_mmio(&dev_priv->uncore); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 521 | if (ret < 0) |
Joonas Lahtinen | 63ffbcd | 2017-04-28 10:53:36 +0300 | [diff] [blame] | 522 | goto err_bridge; |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 523 | |
Daniele Ceraolo Spurio | 25286aa | 2019-03-19 11:35:40 -0700 | [diff] [blame] | 524 | /* Try to make sure MCHBAR is enabled before poking at it */ |
| 525 | intel_setup_mchbar(dev_priv); |
Joonas Lahtinen | 63ffbcd | 2017-04-28 10:53:36 +0300 | [diff] [blame] | 526 | |
Oscar Mateo | 26376a7 | 2018-03-16 14:14:49 +0200 | [diff] [blame] | 527 | intel_device_info_init_mmio(dev_priv); |
| 528 | |
Daniele Ceraolo Spurio | 3de6f85 | 2019-04-02 13:10:32 -0700 | [diff] [blame] | 529 | intel_uncore_prune_mmio_domains(&dev_priv->uncore); |
Oscar Mateo | 26376a7 | 2018-03-16 14:14:49 +0200 | [diff] [blame] | 530 | |
Daniele Ceraolo Spurio | ca7b2c1 | 2019-07-13 11:00:13 +0100 | [diff] [blame] | 531 | intel_uc_init_mmio(&dev_priv->gt.uc); |
Sagar Arun Kamble | 1fc556f | 2017-10-04 15:33:24 +0000 | [diff] [blame] | 532 | |
Tvrtko Ursulin | adcb526 | 2019-10-22 10:47:15 +0100 | [diff] [blame] | 533 | ret = intel_engines_init_mmio(&dev_priv->gt); |
Joonas Lahtinen | 63ffbcd | 2017-04-28 10:53:36 +0300 | [diff] [blame] | 534 | if (ret) |
| 535 | goto err_uncore; |
| 536 | |
Chris Wilson | 640b50f | 2019-12-28 11:12:55 +0000 | [diff] [blame] | 537 | /* As early as possible, scrub existing GPU state before clobbering */ |
| 538 | sanitize_gpu(dev_priv); |
| 539 | |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 540 | return 0; |
| 541 | |
Joonas Lahtinen | 63ffbcd | 2017-04-28 10:53:36 +0300 | [diff] [blame] | 542 | err_uncore: |
Daniele Ceraolo Spurio | 25286aa | 2019-03-19 11:35:40 -0700 | [diff] [blame] | 543 | intel_teardown_mchbar(dev_priv); |
Daniele Ceraolo Spurio | 3de6f85 | 2019-04-02 13:10:32 -0700 | [diff] [blame] | 544 | intel_uncore_fini_mmio(&dev_priv->uncore); |
Joonas Lahtinen | 63ffbcd | 2017-04-28 10:53:36 +0300 | [diff] [blame] | 545 | err_bridge: |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 546 | pci_dev_put(dev_priv->bridge_dev); |
| 547 | |
| 548 | return ret; |
| 549 | } |
| 550 | |
| 551 | /** |
Janusz Krzysztofik | 0b61b8b | 2019-07-12 13:24:30 +0200 | [diff] [blame] | 552 | * i915_driver_mmio_release - cleanup the setup done in i915_driver_mmio_probe() |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 553 | * @dev_priv: device private |
| 554 | */ |
Janusz Krzysztofik | 3b58a94 | 2019-07-12 13:24:28 +0200 | [diff] [blame] | 555 | static void i915_driver_mmio_release(struct drm_i915_private *dev_priv) |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 556 | { |
Daniele Ceraolo Spurio | 25286aa | 2019-03-19 11:35:40 -0700 | [diff] [blame] | 557 | intel_teardown_mchbar(dev_priv); |
Daniele Ceraolo Spurio | 3de6f85 | 2019-04-02 13:10:32 -0700 | [diff] [blame] | 558 | intel_uncore_fini_mmio(&dev_priv->uncore); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 559 | pci_dev_put(dev_priv->bridge_dev); |
| 560 | } |
| 561 | |
Chris Wilson | 94b4f3b | 2016-07-05 10:40:20 +0100 | [diff] [blame] | 562 | static void intel_sanitize_options(struct drm_i915_private *dev_priv) |
| 563 | { |
Chuanxiao Dong | 67b7f33 | 2017-05-27 17:44:17 +0800 | [diff] [blame] | 564 | intel_gvt_sanitize_options(dev_priv); |
Chris Wilson | 94b4f3b | 2016-07-05 10:40:20 +0100 | [diff] [blame] | 565 | } |
| 566 | |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 567 | /** |
Janusz Krzysztofik | 0b61b8b | 2019-07-12 13:24:30 +0200 | [diff] [blame] | 568 | * i915_driver_hw_probe - setup state requiring device access |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 569 | * @dev_priv: device private |
| 570 | * |
| 571 | * Setup state that requires accessing the device, but doesn't require |
| 572 | * exposing the driver via kernel internal or userspace interfaces. |
| 573 | */ |
Janusz Krzysztofik | 0b61b8b | 2019-07-12 13:24:30 +0200 | [diff] [blame] | 574 | static int i915_driver_hw_probe(struct drm_i915_private *dev_priv) |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 575 | { |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 576 | struct pci_dev *pdev = dev_priv->drm.pdev; |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 577 | int ret; |
| 578 | |
Michal Wajdeczko | 50d8441 | 2019-08-02 18:40:50 +0000 | [diff] [blame] | 579 | if (i915_inject_probe_failure(dev_priv)) |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 580 | return -ENODEV; |
| 581 | |
Jani Nikula | 1400cc7 | 2018-12-31 16:56:43 +0200 | [diff] [blame] | 582 | intel_device_info_runtime_init(dev_priv); |
Chris Wilson | 94b4f3b | 2016-07-05 10:40:20 +0100 | [diff] [blame] | 583 | |
Chris Wilson | 4bdafb9 | 2018-09-26 21:12:22 +0100 | [diff] [blame] | 584 | if (HAS_PPGTT(dev_priv)) { |
| 585 | if (intel_vgpu_active(dev_priv) && |
Chris Wilson | ca6ac68 | 2019-03-14 22:38:35 +0000 | [diff] [blame] | 586 | !intel_vgpu_has_full_ppgtt(dev_priv)) { |
Chris Wilson | 4bdafb9 | 2018-09-26 21:12:22 +0100 | [diff] [blame] | 587 | i915_report_error(dev_priv, |
| 588 | "incompatible vGPU found, support for isolated ppGTT required\n"); |
| 589 | return -ENXIO; |
| 590 | } |
| 591 | } |
| 592 | |
Chris Wilson | 4659289 | 2018-11-30 12:59:54 +0000 | [diff] [blame] | 593 | if (HAS_EXECLISTS(dev_priv)) { |
| 594 | /* |
| 595 | * Older GVT emulation depends upon intercepting CSB mmio, |
| 596 | * which we no longer use, preferring to use the HWSP cache |
| 597 | * instead. |
| 598 | */ |
| 599 | if (intel_vgpu_active(dev_priv) && |
| 600 | !intel_vgpu_has_hwsp_emulation(dev_priv)) { |
| 601 | i915_report_error(dev_priv, |
| 602 | "old vGPU host found, support for HWSP emulation required\n"); |
| 603 | return -ENXIO; |
| 604 | } |
| 605 | } |
| 606 | |
Chris Wilson | 94b4f3b | 2016-07-05 10:40:20 +0100 | [diff] [blame] | 607 | intel_sanitize_options(dev_priv); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 608 | |
Daniele Ceraolo Spurio | f6ac993 | 2019-03-28 10:45:32 -0700 | [diff] [blame] | 609 | /* needs to be done before ggtt probe */ |
Jani Nikula | d28ae3b | 2020-02-25 13:15:07 +0200 | [diff] [blame^] | 610 | intel_dram_edram_detect(dev_priv); |
Daniele Ceraolo Spurio | f6ac993 | 2019-03-28 10:45:32 -0700 | [diff] [blame] | 611 | |
Lionel Landwerlin | 9f9b279 | 2017-10-27 15:59:31 +0100 | [diff] [blame] | 612 | i915_perf_init(dev_priv); |
| 613 | |
Chris Wilson | 97d6d7a | 2016-08-04 07:52:22 +0100 | [diff] [blame] | 614 | ret = i915_ggtt_probe_hw(dev_priv); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 615 | if (ret) |
Chris Wilson | 9f172f6 | 2018-04-14 10:12:33 +0100 | [diff] [blame] | 616 | goto err_perf; |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 617 | |
Gerd Hoffmann | f2521f7 | 2019-08-22 11:06:45 +0200 | [diff] [blame] | 618 | ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, "inteldrmfb"); |
| 619 | if (ret) |
Chris Wilson | 9f172f6 | 2018-04-14 10:12:33 +0100 | [diff] [blame] | 620 | goto err_ggtt; |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 621 | |
Chris Wilson | 97d6d7a | 2016-08-04 07:52:22 +0100 | [diff] [blame] | 622 | ret = i915_ggtt_init_hw(dev_priv); |
Chris Wilson | 0088e52 | 2016-08-04 07:52:21 +0100 | [diff] [blame] | 623 | if (ret) |
Chris Wilson | 9f172f6 | 2018-04-14 10:12:33 +0100 | [diff] [blame] | 624 | goto err_ggtt; |
Chris Wilson | 0088e52 | 2016-08-04 07:52:21 +0100 | [diff] [blame] | 625 | |
Chris Wilson | 3fc794f | 2019-10-26 21:20:32 +0100 | [diff] [blame] | 626 | ret = intel_memory_regions_hw_probe(dev_priv); |
| 627 | if (ret) |
| 628 | goto err_ggtt; |
| 629 | |
Chris Wilson | 797a615 | 2019-11-01 14:10:06 +0000 | [diff] [blame] | 630 | intel_gt_init_hw_early(&dev_priv->gt, &dev_priv->ggtt); |
Tvrtko Ursulin | d8a4424 | 2019-06-21 08:08:06 +0100 | [diff] [blame] | 631 | |
Chris Wilson | 97d6d7a | 2016-08-04 07:52:22 +0100 | [diff] [blame] | 632 | ret = i915_ggtt_enable_hw(dev_priv); |
Chris Wilson | 0088e52 | 2016-08-04 07:52:21 +0100 | [diff] [blame] | 633 | if (ret) { |
Wambui Karuga | 00376cc | 2020-01-31 12:34:12 +0300 | [diff] [blame] | 634 | drm_err(&dev_priv->drm, "failed to enable GGTT\n"); |
Chris Wilson | 3fc794f | 2019-10-26 21:20:32 +0100 | [diff] [blame] | 635 | goto err_mem_regions; |
Chris Wilson | 0088e52 | 2016-08-04 07:52:21 +0100 | [diff] [blame] | 636 | } |
| 637 | |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 638 | pci_set_master(pdev); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 639 | |
Lyude Paul | acd674a | 2019-08-23 16:52:51 -0400 | [diff] [blame] | 640 | /* |
| 641 | * We don't have a max segment size, so set it to the max so sg's |
| 642 | * debugging layer doesn't complain |
| 643 | */ |
| 644 | dma_set_max_seg_size(&pdev->dev, UINT_MAX); |
| 645 | |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 646 | /* overlay on gen2 is broken and can't address above 1G */ |
Lucas De Marchi | cf819ef | 2018-12-12 10:10:43 -0800 | [diff] [blame] | 647 | if (IS_GEN(dev_priv, 2)) { |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 648 | ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(30)); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 649 | if (ret) { |
Wambui Karuga | 00376cc | 2020-01-31 12:34:12 +0300 | [diff] [blame] | 650 | drm_err(&dev_priv->drm, "failed to set DMA mask\n"); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 651 | |
Chris Wilson | 3fc794f | 2019-10-26 21:20:32 +0100 | [diff] [blame] | 652 | goto err_mem_regions; |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 653 | } |
| 654 | } |
| 655 | |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 656 | /* 965GM sometimes incorrectly writes to hardware status page (HWS) |
| 657 | * using 32bit addressing, overwriting memory if HWS is located |
| 658 | * above 4GB. |
| 659 | * |
| 660 | * The documentation also mentions an issue with undefined |
| 661 | * behaviour if any general state is accessed within a page above 4GB, |
| 662 | * which also needs to be handled carefully. |
| 663 | */ |
Jani Nikula | c0f8683 | 2016-12-07 12:13:04 +0200 | [diff] [blame] | 664 | if (IS_I965G(dev_priv) || IS_I965GM(dev_priv)) { |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 665 | ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 666 | |
| 667 | if (ret) { |
Wambui Karuga | 00376cc | 2020-01-31 12:34:12 +0300 | [diff] [blame] | 668 | drm_err(&dev_priv->drm, "failed to set DMA mask\n"); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 669 | |
Chris Wilson | 3fc794f | 2019-10-26 21:20:32 +0100 | [diff] [blame] | 670 | goto err_mem_regions; |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 671 | } |
| 672 | } |
| 673 | |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 674 | pm_qos_add_request(&dev_priv->pm_qos, PM_QOS_CPU_DMA_LATENCY, |
| 675 | PM_QOS_DEFAULT_VALUE); |
| 676 | |
Tvrtko Ursulin | 25d140f | 2018-12-03 13:33:19 +0000 | [diff] [blame] | 677 | intel_gt_init_workarounds(dev_priv); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 678 | |
| 679 | /* On the 945G/GM, the chipset reports the MSI capability on the |
| 680 | * integrated graphics even though the support isn't actually there |
| 681 | * according to the published specs. It doesn't appear to function |
| 682 | * correctly in testing on 945G. |
| 683 | * This may be a side effect of MSI having been made available for PEG |
| 684 | * and the registers being closely associated. |
| 685 | * |
| 686 | * According to chipset errata, on the 965GM, MSI interrupts may |
Ville Syrjälä | e38c2da | 2017-06-26 23:30:51 +0300 | [diff] [blame] | 687 | * be lost or delayed, and was defeatured. MSI interrupts seem to |
| 688 | * get lost on g4x as well, and interrupt delivery seems to stay |
| 689 | * properly dead afterwards. So we'll just disable them for all |
| 690 | * pre-gen5 chipsets. |
Lucas De Marchi | 8a29c77 | 2018-05-23 11:04:35 -0700 | [diff] [blame] | 691 | * |
| 692 | * dp aux and gmbus irq on gen4 seems to be able to generate legacy |
| 693 | * interrupts even when in MSI mode. This results in spurious |
| 694 | * interrupt warnings if the legacy irq no. is shared with another |
| 695 | * device. The kernel then disables that interrupt source and so |
| 696 | * prevents the other device from working properly. |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 697 | */ |
Ville Syrjälä | e38c2da | 2017-06-26 23:30:51 +0300 | [diff] [blame] | 698 | if (INTEL_GEN(dev_priv) >= 5) { |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 699 | if (pci_enable_msi(pdev) < 0) |
Wambui Karuga | 00376cc | 2020-01-31 12:34:12 +0300 | [diff] [blame] | 700 | drm_dbg(&dev_priv->drm, "can't enable MSI"); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 701 | } |
| 702 | |
Zhenyu Wang | 26f837e | 2017-01-13 10:46:09 +0800 | [diff] [blame] | 703 | ret = intel_gvt_init(dev_priv); |
| 704 | if (ret) |
Chris Wilson | 7ab87ed | 2018-07-10 15:38:21 +0100 | [diff] [blame] | 705 | goto err_msi; |
| 706 | |
| 707 | intel_opregion_setup(dev_priv); |
Mahesh Kumar | cbfa59d | 2018-08-24 15:02:21 +0530 | [diff] [blame] | 708 | /* |
| 709 | * Fill the dram structure to get the system raw bandwidth and |
| 710 | * dram info. This will be used for memory latency calculation. |
| 711 | */ |
Jani Nikula | d28ae3b | 2020-02-25 13:15:07 +0200 | [diff] [blame^] | 712 | intel_dram_detect(dev_priv); |
Mahesh Kumar | cbfa59d | 2018-08-24 15:02:21 +0530 | [diff] [blame] | 713 | |
Ville Syrjälä | c457d9c | 2019-05-24 18:36:14 +0300 | [diff] [blame] | 714 | intel_bw_init_hw(dev_priv); |
Zhenyu Wang | 26f837e | 2017-01-13 10:46:09 +0800 | [diff] [blame] | 715 | |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 716 | return 0; |
| 717 | |
Chris Wilson | 7ab87ed | 2018-07-10 15:38:21 +0100 | [diff] [blame] | 718 | err_msi: |
| 719 | if (pdev->msi_enabled) |
| 720 | pci_disable_msi(pdev); |
| 721 | pm_qos_remove_request(&dev_priv->pm_qos); |
Chris Wilson | 3fc794f | 2019-10-26 21:20:32 +0100 | [diff] [blame] | 722 | err_mem_regions: |
| 723 | intel_memory_regions_driver_release(dev_priv); |
Chris Wilson | 9f172f6 | 2018-04-14 10:12:33 +0100 | [diff] [blame] | 724 | err_ggtt: |
Janusz Krzysztofik | 3b58a94 | 2019-07-12 13:24:28 +0200 | [diff] [blame] | 725 | i915_ggtt_driver_release(dev_priv); |
Chris Wilson | 9f172f6 | 2018-04-14 10:12:33 +0100 | [diff] [blame] | 726 | err_perf: |
| 727 | i915_perf_fini(dev_priv); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 728 | return ret; |
| 729 | } |
| 730 | |
| 731 | /** |
Janusz Krzysztofik | 78dae1a | 2019-07-12 13:24:29 +0200 | [diff] [blame] | 732 | * i915_driver_hw_remove - cleanup the setup done in i915_driver_hw_probe() |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 733 | * @dev_priv: device private |
| 734 | */ |
Janusz Krzysztofik | 78dae1a | 2019-07-12 13:24:29 +0200 | [diff] [blame] | 735 | static void i915_driver_hw_remove(struct drm_i915_private *dev_priv) |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 736 | { |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 737 | struct pci_dev *pdev = dev_priv->drm.pdev; |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 738 | |
Lionel Landwerlin | 9f9b279 | 2017-10-27 15:59:31 +0100 | [diff] [blame] | 739 | i915_perf_fini(dev_priv); |
| 740 | |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 741 | if (pdev->msi_enabled) |
| 742 | pci_disable_msi(pdev); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 743 | |
| 744 | pm_qos_remove_request(&dev_priv->pm_qos); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 745 | } |
| 746 | |
| 747 | /** |
| 748 | * i915_driver_register - register the driver with the rest of the system |
| 749 | * @dev_priv: device private |
| 750 | * |
| 751 | * Perform any steps necessary to make the driver available via kernel |
| 752 | * internal or userspace interfaces. |
| 753 | */ |
| 754 | static void i915_driver_register(struct drm_i915_private *dev_priv) |
| 755 | { |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 756 | struct drm_device *dev = &dev_priv->drm; |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 757 | |
Chris Wilson | c29579d | 2019-08-06 13:42:59 +0100 | [diff] [blame] | 758 | i915_gem_driver_register(dev_priv); |
Tvrtko Ursulin | b46a33e | 2017-11-21 18:18:45 +0000 | [diff] [blame] | 759 | i915_pmu_register(dev_priv); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 760 | |
| 761 | /* |
| 762 | * Notify a valid surface after modesetting, |
| 763 | * when running inside a VM. |
| 764 | */ |
| 765 | if (intel_vgpu_active(dev_priv)) |
| 766 | I915_WRITE(vgtif_reg(display_ready), VGT_DRV_DISPLAY_READY); |
| 767 | |
| 768 | /* Reveal our presence to userspace */ |
| 769 | if (drm_dev_register(dev, 0) == 0) { |
| 770 | i915_debugfs_register(dev_priv); |
Jani Nikula | 926b005 | 2020-02-11 18:14:51 +0200 | [diff] [blame] | 771 | intel_display_debugfs_register(dev_priv); |
David Weinehall | 694c282 | 2016-08-22 13:32:43 +0300 | [diff] [blame] | 772 | i915_setup_sysfs(dev_priv); |
Robert Bragg | 442b8c0 | 2016-11-07 19:49:53 +0000 | [diff] [blame] | 773 | |
| 774 | /* Depends on sysfs having been initialized */ |
| 775 | i915_perf_register(dev_priv); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 776 | } else |
Wambui Karuga | 00376cc | 2020-01-31 12:34:12 +0300 | [diff] [blame] | 777 | drm_err(&dev_priv->drm, |
| 778 | "Failed to register driver for userspace access!\n"); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 779 | |
Jani Nikula | a2b69ea | 2019-09-13 13:04:07 +0300 | [diff] [blame] | 780 | if (HAS_DISPLAY(dev_priv) && INTEL_DISPLAY_ENABLED(dev_priv)) { |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 781 | /* Must be done after probing outputs */ |
| 782 | intel_opregion_register(dev_priv); |
| 783 | acpi_video_register(); |
| 784 | } |
| 785 | |
Andi Shyti | 42014f6 | 2019-09-05 14:14:03 +0300 | [diff] [blame] | 786 | intel_gt_driver_register(&dev_priv->gt); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 787 | |
Jerome Anand | eef5732 | 2017-01-25 04:27:49 +0530 | [diff] [blame] | 788 | intel_audio_init(dev_priv); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 789 | |
| 790 | /* |
| 791 | * Some ports require correctly set-up hpd registers for detection to |
| 792 | * work properly (leading to ghost connected connector status), e.g. VGA |
| 793 | * on gm45. Hence we can only set up the initial fbdev config after hpd |
| 794 | * irqs are fully enabled. We do it last so that the async config |
| 795 | * cannot run before the connectors are registered. |
| 796 | */ |
| 797 | intel_fbdev_initial_config_async(dev); |
Chris Wilson | 448aa91 | 2017-11-28 11:01:47 +0000 | [diff] [blame] | 798 | |
| 799 | /* |
| 800 | * We need to coordinate the hotplugs with the asynchronous fbdev |
| 801 | * configuration, for which we use the fbdev->async_cookie. |
| 802 | */ |
Jani Nikula | a2b69ea | 2019-09-13 13:04:07 +0300 | [diff] [blame] | 803 | if (HAS_DISPLAY(dev_priv) && INTEL_DISPLAY_ENABLED(dev_priv)) |
Chris Wilson | 448aa91 | 2017-11-28 11:01:47 +0000 | [diff] [blame] | 804 | drm_kms_helper_poll_init(dev); |
Chris Wilson | 07d8057 | 2018-08-16 15:37:56 +0300 | [diff] [blame] | 805 | |
Imre Deak | 2cd9a68 | 2018-08-16 15:37:57 +0300 | [diff] [blame] | 806 | intel_power_domains_enable(dev_priv); |
Daniele Ceraolo Spurio | 69c6635 | 2019-06-13 16:21:53 -0700 | [diff] [blame] | 807 | intel_runtime_pm_enable(&dev_priv->runtime_pm); |
Jani Nikula | 46edcdb | 2020-02-11 18:28:01 +0200 | [diff] [blame] | 808 | |
| 809 | intel_register_dsm_handler(); |
| 810 | |
| 811 | if (i915_switcheroo_register(dev_priv)) |
| 812 | drm_err(&dev_priv->drm, "Failed to register vga switcheroo!\n"); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 813 | } |
| 814 | |
| 815 | /** |
| 816 | * i915_driver_unregister - cleanup the registration done in i915_driver_regiser() |
| 817 | * @dev_priv: device private |
| 818 | */ |
| 819 | static void i915_driver_unregister(struct drm_i915_private *dev_priv) |
| 820 | { |
Jani Nikula | 46edcdb | 2020-02-11 18:28:01 +0200 | [diff] [blame] | 821 | i915_switcheroo_unregister(dev_priv); |
| 822 | |
| 823 | intel_unregister_dsm_handler(); |
| 824 | |
Daniele Ceraolo Spurio | 69c6635 | 2019-06-13 16:21:53 -0700 | [diff] [blame] | 825 | intel_runtime_pm_disable(&dev_priv->runtime_pm); |
Imre Deak | 2cd9a68 | 2018-08-16 15:37:57 +0300 | [diff] [blame] | 826 | intel_power_domains_disable(dev_priv); |
Chris Wilson | 07d8057 | 2018-08-16 15:37:56 +0300 | [diff] [blame] | 827 | |
Daniel Vetter | 4f256d8 | 2017-07-15 00:46:55 +0200 | [diff] [blame] | 828 | intel_fbdev_unregister(dev_priv); |
Jerome Anand | eef5732 | 2017-01-25 04:27:49 +0530 | [diff] [blame] | 829 | intel_audio_deinit(dev_priv); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 830 | |
Chris Wilson | 448aa91 | 2017-11-28 11:01:47 +0000 | [diff] [blame] | 831 | /* |
| 832 | * After flushing the fbdev (incl. a late async config which will |
| 833 | * have delayed queuing of a hotplug event), then flush the hotplug |
| 834 | * events. |
| 835 | */ |
| 836 | drm_kms_helper_poll_fini(&dev_priv->drm); |
| 837 | |
Andi Shyti | 42014f6 | 2019-09-05 14:14:03 +0300 | [diff] [blame] | 838 | intel_gt_driver_unregister(&dev_priv->gt); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 839 | acpi_video_unregister(); |
| 840 | intel_opregion_unregister(dev_priv); |
| 841 | |
Robert Bragg | 442b8c0 | 2016-11-07 19:49:53 +0000 | [diff] [blame] | 842 | i915_perf_unregister(dev_priv); |
Tvrtko Ursulin | b46a33e | 2017-11-21 18:18:45 +0000 | [diff] [blame] | 843 | i915_pmu_unregister(dev_priv); |
Robert Bragg | 442b8c0 | 2016-11-07 19:49:53 +0000 | [diff] [blame] | 844 | |
David Weinehall | 694c282 | 2016-08-22 13:32:43 +0300 | [diff] [blame] | 845 | i915_teardown_sysfs(dev_priv); |
Janusz Krzysztofik | d69990e | 2019-04-05 15:02:34 +0200 | [diff] [blame] | 846 | drm_dev_unplug(&dev_priv->drm); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 847 | |
Chris Wilson | c29579d | 2019-08-06 13:42:59 +0100 | [diff] [blame] | 848 | i915_gem_driver_unregister(dev_priv); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 849 | } |
| 850 | |
Michal Wajdeczko | 27d558a | 2017-12-21 21:57:35 +0000 | [diff] [blame] | 851 | static void i915_welcome_messages(struct drm_i915_private *dev_priv) |
| 852 | { |
Jani Nikula | bdbf43d | 2019-10-28 12:38:15 +0200 | [diff] [blame] | 853 | if (drm_debug_enabled(DRM_UT_DRIVER)) { |
Michal Wajdeczko | 27d558a | 2017-12-21 21:57:35 +0000 | [diff] [blame] | 854 | struct drm_printer p = drm_debug_printer("i915 device info:"); |
| 855 | |
Tvrtko Ursulin | 805446c | 2019-03-27 14:23:28 +0000 | [diff] [blame] | 856 | drm_printf(&p, "pciid=0x%04x rev=0x%02x platform=%s (subplatform=0x%x) gen=%i\n", |
Jani Nikula | 1787a98 | 2018-12-31 16:56:45 +0200 | [diff] [blame] | 857 | INTEL_DEVID(dev_priv), |
| 858 | INTEL_REVID(dev_priv), |
| 859 | intel_platform_name(INTEL_INFO(dev_priv)->platform), |
Tvrtko Ursulin | 805446c | 2019-03-27 14:23:28 +0000 | [diff] [blame] | 860 | intel_subplatform(RUNTIME_INFO(dev_priv), |
| 861 | INTEL_INFO(dev_priv)->platform), |
Jani Nikula | 1787a98 | 2018-12-31 16:56:45 +0200 | [diff] [blame] | 862 | INTEL_GEN(dev_priv)); |
| 863 | |
Chris Wilson | 7240497 | 2019-12-07 18:29:37 +0000 | [diff] [blame] | 864 | intel_device_info_print_static(INTEL_INFO(dev_priv), &p); |
| 865 | intel_device_info_print_runtime(RUNTIME_INFO(dev_priv), &p); |
Michal Wajdeczko | 27d558a | 2017-12-21 21:57:35 +0000 | [diff] [blame] | 866 | } |
| 867 | |
| 868 | if (IS_ENABLED(CONFIG_DRM_I915_DEBUG)) |
Wambui Karuga | 00376cc | 2020-01-31 12:34:12 +0300 | [diff] [blame] | 869 | drm_info(&dev_priv->drm, "DRM_I915_DEBUG enabled\n"); |
Michal Wajdeczko | 27d558a | 2017-12-21 21:57:35 +0000 | [diff] [blame] | 870 | if (IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM)) |
Wambui Karuga | 00376cc | 2020-01-31 12:34:12 +0300 | [diff] [blame] | 871 | drm_info(&dev_priv->drm, "DRM_I915_DEBUG_GEM enabled\n"); |
Imre Deak | 6dfc4a8 | 2018-08-16 22:34:14 +0300 | [diff] [blame] | 872 | if (IS_ENABLED(CONFIG_DRM_I915_DEBUG_RUNTIME_PM)) |
Wambui Karuga | 00376cc | 2020-01-31 12:34:12 +0300 | [diff] [blame] | 873 | drm_info(&dev_priv->drm, |
| 874 | "DRM_I915_DEBUG_RUNTIME_PM enabled\n"); |
Michal Wajdeczko | 27d558a | 2017-12-21 21:57:35 +0000 | [diff] [blame] | 875 | } |
| 876 | |
Chris Wilson | 55ac5a1 | 2018-09-05 15:09:20 +0100 | [diff] [blame] | 877 | static struct drm_i915_private * |
| 878 | i915_driver_create(struct pci_dev *pdev, const struct pci_device_id *ent) |
| 879 | { |
| 880 | const struct intel_device_info *match_info = |
| 881 | (struct intel_device_info *)ent->driver_data; |
| 882 | struct intel_device_info *device_info; |
| 883 | struct drm_i915_private *i915; |
Andi Shyti | 2ddcc98 | 2018-10-02 12:20:47 +0300 | [diff] [blame] | 884 | int err; |
Chris Wilson | 55ac5a1 | 2018-09-05 15:09:20 +0100 | [diff] [blame] | 885 | |
| 886 | i915 = kzalloc(sizeof(*i915), GFP_KERNEL); |
| 887 | if (!i915) |
Andi Shyti | 2ddcc98 | 2018-10-02 12:20:47 +0300 | [diff] [blame] | 888 | return ERR_PTR(-ENOMEM); |
Chris Wilson | 55ac5a1 | 2018-09-05 15:09:20 +0100 | [diff] [blame] | 889 | |
Andi Shyti | 2ddcc98 | 2018-10-02 12:20:47 +0300 | [diff] [blame] | 890 | err = drm_dev_init(&i915->drm, &driver, &pdev->dev); |
| 891 | if (err) { |
Chris Wilson | 55ac5a1 | 2018-09-05 15:09:20 +0100 | [diff] [blame] | 892 | kfree(i915); |
Andi Shyti | 2ddcc98 | 2018-10-02 12:20:47 +0300 | [diff] [blame] | 893 | return ERR_PTR(err); |
Chris Wilson | 55ac5a1 | 2018-09-05 15:09:20 +0100 | [diff] [blame] | 894 | } |
| 895 | |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 896 | i915->drm.pdev = pdev; |
| 897 | pci_set_drvdata(pdev, i915); |
Chris Wilson | 55ac5a1 | 2018-09-05 15:09:20 +0100 | [diff] [blame] | 898 | |
| 899 | /* Setup the write-once "constant" device info */ |
| 900 | device_info = mkwrite_device_info(i915); |
| 901 | memcpy(device_info, match_info, sizeof(*device_info)); |
Jani Nikula | 0258404 | 2018-12-31 16:56:41 +0200 | [diff] [blame] | 902 | RUNTIME_INFO(i915)->device_id = pdev->device; |
Chris Wilson | 55ac5a1 | 2018-09-05 15:09:20 +0100 | [diff] [blame] | 903 | |
Chris Wilson | 74f6e18 | 2018-09-26 11:47:07 +0100 | [diff] [blame] | 904 | BUG_ON(device_info->gen > BITS_PER_TYPE(device_info->gen_mask)); |
Chris Wilson | 55ac5a1 | 2018-09-05 15:09:20 +0100 | [diff] [blame] | 905 | |
| 906 | return i915; |
| 907 | } |
| 908 | |
Chris Wilson | 31962ca | 2018-09-05 15:09:21 +0100 | [diff] [blame] | 909 | static void i915_driver_destroy(struct drm_i915_private *i915) |
| 910 | { |
| 911 | struct pci_dev *pdev = i915->drm.pdev; |
| 912 | |
| 913 | drm_dev_fini(&i915->drm); |
| 914 | kfree(i915); |
| 915 | |
| 916 | /* And make sure we never chase our dangling pointer from pci_dev */ |
| 917 | pci_set_drvdata(pdev, NULL); |
| 918 | } |
| 919 | |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 920 | /** |
Janusz Krzysztofik | b01558e | 2019-07-12 13:24:26 +0200 | [diff] [blame] | 921 | * i915_driver_probe - setup chip and create an initial config |
Joonas Lahtinen | d2ad3ae | 2016-11-10 15:36:34 +0200 | [diff] [blame] | 922 | * @pdev: PCI device |
| 923 | * @ent: matching PCI ID entry |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 924 | * |
Janusz Krzysztofik | b01558e | 2019-07-12 13:24:26 +0200 | [diff] [blame] | 925 | * The driver probe routine has to do several things: |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 926 | * - drive output discovery via intel_modeset_init() |
| 927 | * - initialize the memory manager |
| 928 | * - allocate initial config memory |
| 929 | * - setup the DRM framebuffer with the allocated memory |
| 930 | */ |
Janusz Krzysztofik | b01558e | 2019-07-12 13:24:26 +0200 | [diff] [blame] | 931 | int i915_driver_probe(struct pci_dev *pdev, const struct pci_device_id *ent) |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 932 | { |
Maarten Lankhorst | 8d2b47d | 2017-02-02 08:41:42 +0100 | [diff] [blame] | 933 | const struct intel_device_info *match_info = |
| 934 | (struct intel_device_info *)ent->driver_data; |
Jani Nikula | 8eecfb3 | 2020-02-11 18:28:02 +0200 | [diff] [blame] | 935 | struct drm_i915_private *i915; |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 936 | int ret; |
| 937 | |
Jani Nikula | 8eecfb3 | 2020-02-11 18:28:02 +0200 | [diff] [blame] | 938 | i915 = i915_driver_create(pdev, ent); |
| 939 | if (IS_ERR(i915)) |
| 940 | return PTR_ERR(i915); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 941 | |
Ville Syrjälä | 1feb64c | 2018-09-13 16:16:22 +0300 | [diff] [blame] | 942 | /* Disable nuclear pageflip by default on pre-ILK */ |
| 943 | if (!i915_modparams.nuclear_pageflip && match_info->gen < 5) |
Jani Nikula | 8eecfb3 | 2020-02-11 18:28:02 +0200 | [diff] [blame] | 944 | i915->drm.driver_features &= ~DRIVER_ATOMIC; |
Ville Syrjälä | 1feb64c | 2018-09-13 16:16:22 +0300 | [diff] [blame] | 945 | |
Matthew Auld | 1629224 | 2019-10-30 17:33:20 +0000 | [diff] [blame] | 946 | /* |
| 947 | * Check if we support fake LMEM -- for now we only unleash this for |
| 948 | * the live selftests(test-and-exit). |
| 949 | */ |
Chris Wilson | 292a27b | 2019-11-01 09:51:47 +0000 | [diff] [blame] | 950 | #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST) |
Matthew Auld | 1629224 | 2019-10-30 17:33:20 +0000 | [diff] [blame] | 951 | if (IS_ENABLED(CONFIG_DRM_I915_UNSTABLE_FAKE_LMEM)) { |
Jani Nikula | 8eecfb3 | 2020-02-11 18:28:02 +0200 | [diff] [blame] | 952 | if (INTEL_GEN(i915) >= 9 && i915_selftest.live < 0 && |
Matthew Auld | 1629224 | 2019-10-30 17:33:20 +0000 | [diff] [blame] | 953 | i915_modparams.fake_lmem_start) { |
Jani Nikula | 8eecfb3 | 2020-02-11 18:28:02 +0200 | [diff] [blame] | 954 | mkwrite_device_info(i915)->memory_regions = |
Matthew Auld | 1629224 | 2019-10-30 17:33:20 +0000 | [diff] [blame] | 955 | REGION_SMEM | REGION_LMEM | REGION_STOLEN; |
Jani Nikula | 8eecfb3 | 2020-02-11 18:28:02 +0200 | [diff] [blame] | 956 | mkwrite_device_info(i915)->is_dgfx = true; |
| 957 | GEM_BUG_ON(!HAS_LMEM(i915)); |
| 958 | GEM_BUG_ON(!IS_DGFX(i915)); |
Matthew Auld | 1629224 | 2019-10-30 17:33:20 +0000 | [diff] [blame] | 959 | } |
| 960 | } |
Chris Wilson | 292a27b | 2019-11-01 09:51:47 +0000 | [diff] [blame] | 961 | #endif |
Matthew Auld | 1629224 | 2019-10-30 17:33:20 +0000 | [diff] [blame] | 962 | |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 963 | ret = pci_enable_device(pdev); |
| 964 | if (ret) |
Chris Wilson | cad3688 | 2017-02-10 16:35:21 +0000 | [diff] [blame] | 965 | goto out_fini; |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 966 | |
Jani Nikula | 8eecfb3 | 2020-02-11 18:28:02 +0200 | [diff] [blame] | 967 | ret = i915_driver_early_probe(i915); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 968 | if (ret < 0) |
| 969 | goto out_pci_disable; |
| 970 | |
Jani Nikula | 8eecfb3 | 2020-02-11 18:28:02 +0200 | [diff] [blame] | 971 | disable_rpm_wakeref_asserts(&i915->runtime_pm); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 972 | |
Jani Nikula | 8eecfb3 | 2020-02-11 18:28:02 +0200 | [diff] [blame] | 973 | i915_detect_vgpu(i915); |
Daniele Ceraolo Spurio | 9e138ea | 2019-06-19 18:00:21 -0700 | [diff] [blame] | 974 | |
Jani Nikula | 8eecfb3 | 2020-02-11 18:28:02 +0200 | [diff] [blame] | 975 | ret = i915_driver_mmio_probe(i915); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 976 | if (ret < 0) |
| 977 | goto out_runtime_pm_put; |
| 978 | |
Jani Nikula | 8eecfb3 | 2020-02-11 18:28:02 +0200 | [diff] [blame] | 979 | ret = i915_driver_hw_probe(i915); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 980 | if (ret < 0) |
| 981 | goto out_cleanup_mmio; |
| 982 | |
Jani Nikula | b664259 | 2020-02-19 15:37:56 +0200 | [diff] [blame] | 983 | ret = i915_driver_modeset_probe_noirq(i915); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 984 | if (ret < 0) |
Daniel Vetter | baf5438 | 2017-06-21 10:28:41 +0200 | [diff] [blame] | 985 | goto out_cleanup_hw; |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 986 | |
Jani Nikula | b664259 | 2020-02-19 15:37:56 +0200 | [diff] [blame] | 987 | ret = intel_irq_install(i915); |
| 988 | if (ret) |
| 989 | goto out_cleanup_modeset; |
| 990 | |
| 991 | ret = i915_driver_modeset_probe(i915); |
| 992 | if (ret < 0) |
| 993 | goto out_cleanup_irq; |
| 994 | |
Jani Nikula | 8eecfb3 | 2020-02-11 18:28:02 +0200 | [diff] [blame] | 995 | i915_driver_register(i915); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 996 | |
Jani Nikula | 8eecfb3 | 2020-02-11 18:28:02 +0200 | [diff] [blame] | 997 | enable_rpm_wakeref_asserts(&i915->runtime_pm); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 998 | |
Jani Nikula | 8eecfb3 | 2020-02-11 18:28:02 +0200 | [diff] [blame] | 999 | i915_welcome_messages(i915); |
Michal Wajdeczko | 27d558a | 2017-12-21 21:57:35 +0000 | [diff] [blame] | 1000 | |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 1001 | return 0; |
| 1002 | |
Jani Nikula | b664259 | 2020-02-19 15:37:56 +0200 | [diff] [blame] | 1003 | out_cleanup_irq: |
| 1004 | intel_irq_uninstall(i915); |
| 1005 | out_cleanup_modeset: |
| 1006 | /* FIXME */ |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 1007 | out_cleanup_hw: |
Jani Nikula | 8eecfb3 | 2020-02-11 18:28:02 +0200 | [diff] [blame] | 1008 | i915_driver_hw_remove(i915); |
| 1009 | intel_memory_regions_driver_release(i915); |
| 1010 | i915_ggtt_driver_release(i915); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 1011 | out_cleanup_mmio: |
Jani Nikula | 8eecfb3 | 2020-02-11 18:28:02 +0200 | [diff] [blame] | 1012 | i915_driver_mmio_release(i915); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 1013 | out_runtime_pm_put: |
Jani Nikula | 8eecfb3 | 2020-02-11 18:28:02 +0200 | [diff] [blame] | 1014 | enable_rpm_wakeref_asserts(&i915->runtime_pm); |
| 1015 | i915_driver_late_release(i915); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 1016 | out_pci_disable: |
| 1017 | pci_disable_device(pdev); |
Chris Wilson | cad3688 | 2017-02-10 16:35:21 +0000 | [diff] [blame] | 1018 | out_fini: |
Jani Nikula | 8eecfb3 | 2020-02-11 18:28:02 +0200 | [diff] [blame] | 1019 | i915_probe_error(i915, "Device initialization failed (%d)\n", ret); |
| 1020 | i915_driver_destroy(i915); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 1021 | return ret; |
| 1022 | } |
| 1023 | |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1024 | void i915_driver_remove(struct drm_i915_private *i915) |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 1025 | { |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1026 | disable_rpm_wakeref_asserts(&i915->runtime_pm); |
Chris Wilson | 07d8057 | 2018-08-16 15:37:56 +0300 | [diff] [blame] | 1027 | |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1028 | i915_driver_unregister(i915); |
Daniel Vetter | 99c539b | 2017-07-15 00:46:56 +0200 | [diff] [blame] | 1029 | |
Chris Wilson | 4a8ab5e | 2019-01-14 14:21:29 +0000 | [diff] [blame] | 1030 | /* Flush any external code that still may be under the RCU lock */ |
| 1031 | synchronize_rcu(); |
| 1032 | |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1033 | i915_gem_suspend(i915); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 1034 | |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1035 | drm_atomic_helper_shutdown(&i915->drm); |
Maarten Lankhorst | a667fb4 | 2016-12-15 15:29:44 +0100 | [diff] [blame] | 1036 | |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1037 | intel_gvt_driver_remove(i915); |
Zhenyu Wang | 26f837e | 2017-01-13 10:46:09 +0800 | [diff] [blame] | 1038 | |
Jani Nikula | 2d6f6f3 | 2019-09-20 21:54:16 +0300 | [diff] [blame] | 1039 | i915_driver_modeset_remove(i915); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 1040 | |
Jani Nikula | f20a60f | 2020-02-14 15:50:58 +0200 | [diff] [blame] | 1041 | intel_irq_uninstall(i915); |
| 1042 | |
| 1043 | i915_driver_modeset_remove_noirq(i915); |
| 1044 | |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1045 | i915_reset_error_state(i915); |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1046 | i915_gem_driver_remove(i915); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 1047 | |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1048 | intel_power_domains_driver_remove(i915); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 1049 | |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1050 | i915_driver_hw_remove(i915); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 1051 | |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1052 | enable_rpm_wakeref_asserts(&i915->runtime_pm); |
Chris Wilson | cad3688 | 2017-02-10 16:35:21 +0000 | [diff] [blame] | 1053 | } |
| 1054 | |
| 1055 | static void i915_driver_release(struct drm_device *dev) |
| 1056 | { |
| 1057 | struct drm_i915_private *dev_priv = to_i915(dev); |
Daniele Ceraolo Spurio | 69c6635 | 2019-06-13 16:21:53 -0700 | [diff] [blame] | 1058 | struct intel_runtime_pm *rpm = &dev_priv->runtime_pm; |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 1059 | |
Daniele Ceraolo Spurio | 69c6635 | 2019-06-13 16:21:53 -0700 | [diff] [blame] | 1060 | disable_rpm_wakeref_asserts(rpm); |
Janusz Krzysztofik | 47bc28d | 2019-05-30 15:31:05 +0200 | [diff] [blame] | 1061 | |
Janusz Krzysztofik | 3b58a94 | 2019-07-12 13:24:28 +0200 | [diff] [blame] | 1062 | i915_gem_driver_release(dev_priv); |
Janusz Krzysztofik | 47bc28d | 2019-05-30 15:31:05 +0200 | [diff] [blame] | 1063 | |
Chris Wilson | 3fc794f | 2019-10-26 21:20:32 +0100 | [diff] [blame] | 1064 | intel_memory_regions_driver_release(dev_priv); |
Janusz Krzysztofik | 3b58a94 | 2019-07-12 13:24:28 +0200 | [diff] [blame] | 1065 | i915_ggtt_driver_release(dev_priv); |
Daniele Ceraolo Spurio | 19e0a8d | 2019-06-19 18:00:17 -0700 | [diff] [blame] | 1066 | |
Janusz Krzysztofik | 3b58a94 | 2019-07-12 13:24:28 +0200 | [diff] [blame] | 1067 | i915_driver_mmio_release(dev_priv); |
Janusz Krzysztofik | 47bc28d | 2019-05-30 15:31:05 +0200 | [diff] [blame] | 1068 | |
Daniele Ceraolo Spurio | 69c6635 | 2019-06-13 16:21:53 -0700 | [diff] [blame] | 1069 | enable_rpm_wakeref_asserts(rpm); |
Janusz Krzysztofik | 3b58a94 | 2019-07-12 13:24:28 +0200 | [diff] [blame] | 1070 | intel_runtime_pm_driver_release(rpm); |
Janusz Krzysztofik | 47bc28d | 2019-05-30 15:31:05 +0200 | [diff] [blame] | 1071 | |
Janusz Krzysztofik | 3b58a94 | 2019-07-12 13:24:28 +0200 | [diff] [blame] | 1072 | i915_driver_late_release(dev_priv); |
Chris Wilson | 31962ca | 2018-09-05 15:09:21 +0100 | [diff] [blame] | 1073 | i915_driver_destroy(dev_priv); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 1074 | } |
| 1075 | |
| 1076 | static int i915_driver_open(struct drm_device *dev, struct drm_file *file) |
| 1077 | { |
Chris Wilson | 829a0af | 2017-06-20 12:05:45 +0100 | [diff] [blame] | 1078 | struct drm_i915_private *i915 = to_i915(dev); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 1079 | int ret; |
| 1080 | |
Chris Wilson | 829a0af | 2017-06-20 12:05:45 +0100 | [diff] [blame] | 1081 | ret = i915_gem_open(i915, file); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 1082 | if (ret) |
| 1083 | return ret; |
| 1084 | |
| 1085 | return 0; |
| 1086 | } |
| 1087 | |
| 1088 | /** |
| 1089 | * i915_driver_lastclose - clean up after all DRM clients have exited |
| 1090 | * @dev: DRM device |
| 1091 | * |
| 1092 | * Take care of cleaning up after all DRM clients have exited. In the |
| 1093 | * mode setting case, we want to restore the kernel's initial mode (just |
| 1094 | * in case the last client left us in a bad state). |
| 1095 | * |
| 1096 | * Additionally, in the non-mode setting case, we'll tear down the GTT |
| 1097 | * and DMA structures, since the kernel won't be using them, and clea |
| 1098 | * up any GEM state. |
| 1099 | */ |
| 1100 | static void i915_driver_lastclose(struct drm_device *dev) |
| 1101 | { |
| 1102 | intel_fbdev_restore_mode(dev); |
| 1103 | vga_switcheroo_process_delayed_switch(); |
| 1104 | } |
| 1105 | |
Daniel Vetter | 7d2ec88 | 2017-03-08 15:12:45 +0100 | [diff] [blame] | 1106 | static void i915_driver_postclose(struct drm_device *dev, struct drm_file *file) |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 1107 | { |
Daniel Vetter | 7d2ec88 | 2017-03-08 15:12:45 +0100 | [diff] [blame] | 1108 | struct drm_i915_file_private *file_priv = file->driver_priv; |
| 1109 | |
Chris Wilson | 829a0af | 2017-06-20 12:05:45 +0100 | [diff] [blame] | 1110 | i915_gem_context_close(file); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 1111 | i915_gem_release(dev, file); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 1112 | |
Chris Wilson | 7771590 | 2019-08-23 19:14:55 +0100 | [diff] [blame] | 1113 | kfree_rcu(file_priv, rcu); |
Chris Wilson | 515b8b7 | 2019-08-02 22:21:37 +0100 | [diff] [blame] | 1114 | |
| 1115 | /* Catch up with all the deferred frees from "this" client */ |
| 1116 | i915_gem_flush_free_objects(to_i915(dev)); |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 1117 | } |
| 1118 | |
Imre Deak | 07f9cd0 | 2014-08-18 14:42:45 +0300 | [diff] [blame] | 1119 | static void intel_suspend_encoders(struct drm_i915_private *dev_priv) |
| 1120 | { |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 1121 | struct drm_device *dev = &dev_priv->drm; |
Jani Nikula | 19c8054 | 2015-12-16 12:48:16 +0200 | [diff] [blame] | 1122 | struct intel_encoder *encoder; |
Imre Deak | 07f9cd0 | 2014-08-18 14:42:45 +0300 | [diff] [blame] | 1123 | |
| 1124 | drm_modeset_lock_all(dev); |
Jani Nikula | 19c8054 | 2015-12-16 12:48:16 +0200 | [diff] [blame] | 1125 | for_each_intel_encoder(dev, encoder) |
| 1126 | if (encoder->suspend) |
| 1127 | encoder->suspend(encoder); |
Imre Deak | 07f9cd0 | 2014-08-18 14:42:45 +0300 | [diff] [blame] | 1128 | drm_modeset_unlock_all(dev); |
| 1129 | } |
| 1130 | |
Imre Deak | bc87229 | 2015-11-18 17:32:30 +0200 | [diff] [blame] | 1131 | static bool suspend_to_idle(struct drm_i915_private *dev_priv) |
| 1132 | { |
| 1133 | #if IS_ENABLED(CONFIG_ACPI_SLEEP) |
| 1134 | if (acpi_target_system_state() < ACPI_STATE_S3) |
| 1135 | return true; |
| 1136 | #endif |
| 1137 | return false; |
| 1138 | } |
Sagar Kamble | ebc3282 | 2014-08-13 23:07:05 +0530 | [diff] [blame] | 1139 | |
Chris Wilson | 73b66f8 | 2018-05-25 10:26:29 +0100 | [diff] [blame] | 1140 | static int i915_drm_prepare(struct drm_device *dev) |
| 1141 | { |
| 1142 | struct drm_i915_private *i915 = to_i915(dev); |
Chris Wilson | 73b66f8 | 2018-05-25 10:26:29 +0100 | [diff] [blame] | 1143 | |
| 1144 | /* |
| 1145 | * NB intel_display_suspend() may issue new requests after we've |
| 1146 | * ostensibly marked the GPU as ready-to-sleep here. We need to |
| 1147 | * split out that work and pull it forward so that after point, |
| 1148 | * the GPU is not woken again. |
| 1149 | */ |
Chris Wilson | 5861b01 | 2019-03-08 09:36:54 +0000 | [diff] [blame] | 1150 | i915_gem_suspend(i915); |
Chris Wilson | 73b66f8 | 2018-05-25 10:26:29 +0100 | [diff] [blame] | 1151 | |
Chris Wilson | 5861b01 | 2019-03-08 09:36:54 +0000 | [diff] [blame] | 1152 | return 0; |
Chris Wilson | 73b66f8 | 2018-05-25 10:26:29 +0100 | [diff] [blame] | 1153 | } |
| 1154 | |
Imre Deak | 5e365c3 | 2014-10-23 19:23:25 +0300 | [diff] [blame] | 1155 | static int i915_drm_suspend(struct drm_device *dev) |
Rafael J. Wysocki | 84b79f8 | 2010-02-07 21:48:24 +0100 | [diff] [blame] | 1156 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1157 | struct drm_i915_private *dev_priv = to_i915(dev); |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 1158 | struct pci_dev *pdev = dev_priv->drm.pdev; |
Jesse Barnes | e5747e3 | 2014-06-12 08:35:47 -0700 | [diff] [blame] | 1159 | pci_power_t opregion_target_state; |
Rafael J. Wysocki | 61caf87 | 2010-02-18 23:06:27 +0100 | [diff] [blame] | 1160 | |
Daniele Ceraolo Spurio | 9102650 | 2019-06-13 16:21:51 -0700 | [diff] [blame] | 1161 | disable_rpm_wakeref_asserts(&dev_priv->runtime_pm); |
Imre Deak | 1f814da | 2015-12-16 02:52:19 +0200 | [diff] [blame] | 1162 | |
Paulo Zanoni | c67a470 | 2013-08-19 13:18:09 -0300 | [diff] [blame] | 1163 | /* We do a lot of poking in a lot of registers, make sure they work |
| 1164 | * properly. */ |
Imre Deak | 2cd9a68 | 2018-08-16 15:37:57 +0300 | [diff] [blame] | 1165 | intel_power_domains_disable(dev_priv); |
Paulo Zanoni | cb10799 | 2013-01-25 16:59:15 -0200 | [diff] [blame] | 1166 | |
Dave Airlie | 5bcf719 | 2010-12-07 09:20:40 +1000 | [diff] [blame] | 1167 | drm_kms_helper_poll_disable(dev); |
| 1168 | |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 1169 | pci_save_state(pdev); |
Rafael J. Wysocki | 84b79f8 | 2010-02-07 21:48:24 +0100 | [diff] [blame] | 1170 | |
Maarten Lankhorst | 6b72d48 | 2015-06-01 12:49:47 +0200 | [diff] [blame] | 1171 | intel_display_suspend(dev); |
Daniel Vetter | d581893 | 2015-02-23 12:03:26 +0100 | [diff] [blame] | 1172 | |
Ville Syrjälä | 1a4313d | 2018-07-05 19:43:52 +0300 | [diff] [blame] | 1173 | intel_dp_mst_suspend(dev_priv); |
Daniel Vetter | d581893 | 2015-02-23 12:03:26 +0100 | [diff] [blame] | 1174 | |
| 1175 | intel_runtime_pm_disable_interrupts(dev_priv); |
| 1176 | intel_hpd_cancel_work(dev_priv); |
| 1177 | |
| 1178 | intel_suspend_encoders(dev_priv); |
| 1179 | |
Ville Syrjälä | 712bf36 | 2016-10-31 22:37:23 +0200 | [diff] [blame] | 1180 | intel_suspend_hw(dev_priv); |
Daniel Vetter | d581893 | 2015-02-23 12:03:26 +0100 | [diff] [blame] | 1181 | |
Chris Wilson | e986209 | 2020-01-30 18:17:09 +0000 | [diff] [blame] | 1182 | i915_ggtt_suspend(&dev_priv->ggtt); |
Ben Widawsky | 828c790 | 2013-10-16 09:21:30 -0700 | [diff] [blame] | 1183 | |
Tvrtko Ursulin | af6dc74 | 2016-12-01 14:16:44 +0000 | [diff] [blame] | 1184 | i915_save_state(dev_priv); |
Rafael J. Wysocki | 84b79f8 | 2010-02-07 21:48:24 +0100 | [diff] [blame] | 1185 | |
Imre Deak | bc87229 | 2015-11-18 17:32:30 +0200 | [diff] [blame] | 1186 | opregion_target_state = suspend_to_idle(dev_priv) ? PCI_D1 : PCI_D3cold; |
Chris Wilson | a950adc | 2018-10-30 11:05:54 +0000 | [diff] [blame] | 1187 | intel_opregion_suspend(dev_priv, opregion_target_state); |
Rafael J. Wysocki | 84b79f8 | 2010-02-07 21:48:24 +0100 | [diff] [blame] | 1188 | |
Chris Wilson | 82e3b8c | 2014-08-13 13:09:46 +0100 | [diff] [blame] | 1189 | intel_fbdev_set_suspend(dev, FBINFO_STATE_SUSPENDED, true); |
Dave Airlie | 3fa016a | 2012-03-28 10:48:49 +0100 | [diff] [blame] | 1190 | |
Mika Kuoppala | 62d5d69 | 2014-02-25 17:11:28 +0200 | [diff] [blame] | 1191 | dev_priv->suspend_count++; |
| 1192 | |
Imre Deak | f74ed08 | 2016-04-18 14:48:21 +0300 | [diff] [blame] | 1193 | intel_csr_ucode_suspend(dev_priv); |
Imre Deak | f514c2d | 2015-10-28 23:59:06 +0200 | [diff] [blame] | 1194 | |
Daniele Ceraolo Spurio | 9102650 | 2019-06-13 16:21:51 -0700 | [diff] [blame] | 1195 | enable_rpm_wakeref_asserts(&dev_priv->runtime_pm); |
Imre Deak | 1f814da | 2015-12-16 02:52:19 +0200 | [diff] [blame] | 1196 | |
Chris Wilson | 73b66f8 | 2018-05-25 10:26:29 +0100 | [diff] [blame] | 1197 | return 0; |
Rafael J. Wysocki | 84b79f8 | 2010-02-07 21:48:24 +0100 | [diff] [blame] | 1198 | } |
| 1199 | |
Imre Deak | 2cd9a68 | 2018-08-16 15:37:57 +0300 | [diff] [blame] | 1200 | static enum i915_drm_suspend_mode |
| 1201 | get_suspend_mode(struct drm_i915_private *dev_priv, bool hibernate) |
| 1202 | { |
| 1203 | if (hibernate) |
| 1204 | return I915_DRM_SUSPEND_HIBERNATE; |
| 1205 | |
| 1206 | if (suspend_to_idle(dev_priv)) |
| 1207 | return I915_DRM_SUSPEND_IDLE; |
| 1208 | |
| 1209 | return I915_DRM_SUSPEND_MEM; |
| 1210 | } |
| 1211 | |
David Weinehall | c49d13e | 2016-08-22 13:32:42 +0300 | [diff] [blame] | 1212 | static int i915_drm_suspend_late(struct drm_device *dev, bool hibernation) |
Imre Deak | c3c09c9 | 2014-10-23 19:23:15 +0300 | [diff] [blame] | 1213 | { |
David Weinehall | c49d13e | 2016-08-22 13:32:42 +0300 | [diff] [blame] | 1214 | struct drm_i915_private *dev_priv = to_i915(dev); |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 1215 | struct pci_dev *pdev = dev_priv->drm.pdev; |
Daniele Ceraolo Spurio | 69c6635 | 2019-06-13 16:21:53 -0700 | [diff] [blame] | 1216 | struct intel_runtime_pm *rpm = &dev_priv->runtime_pm; |
Jani Nikula | fb5f432 | 2020-02-12 16:40:57 +0200 | [diff] [blame] | 1217 | int ret; |
Imre Deak | c3c09c9 | 2014-10-23 19:23:15 +0300 | [diff] [blame] | 1218 | |
Daniele Ceraolo Spurio | 69c6635 | 2019-06-13 16:21:53 -0700 | [diff] [blame] | 1219 | disable_rpm_wakeref_asserts(rpm); |
Imre Deak | 1f814da | 2015-12-16 02:52:19 +0200 | [diff] [blame] | 1220 | |
Chris Wilson | ec92ad0 | 2018-05-31 09:22:46 +0100 | [diff] [blame] | 1221 | i915_gem_suspend_late(dev_priv); |
| 1222 | |
Daniele Ceraolo Spurio | f7de502 | 2019-03-19 11:35:37 -0700 | [diff] [blame] | 1223 | intel_uncore_suspend(&dev_priv->uncore); |
Imre Deak | 4c494a5 | 2016-10-13 14:34:06 +0300 | [diff] [blame] | 1224 | |
Imre Deak | 2cd9a68 | 2018-08-16 15:37:57 +0300 | [diff] [blame] | 1225 | intel_power_domains_suspend(dev_priv, |
| 1226 | get_suspend_mode(dev_priv, hibernation)); |
Imre Deak | 73dfc22 | 2015-11-17 17:33:53 +0200 | [diff] [blame] | 1227 | |
Rodrigo Vivi | 071b68c | 2019-08-06 15:22:08 +0300 | [diff] [blame] | 1228 | intel_display_power_suspend_late(dev_priv); |
| 1229 | |
Jani Nikula | fb5f432 | 2020-02-12 16:40:57 +0200 | [diff] [blame] | 1230 | ret = vlv_suspend_complete(dev_priv); |
Imre Deak | c3c09c9 | 2014-10-23 19:23:15 +0300 | [diff] [blame] | 1231 | if (ret) { |
Wambui Karuga | 00376cc | 2020-01-31 12:34:12 +0300 | [diff] [blame] | 1232 | drm_err(&dev_priv->drm, "Suspend complete failed: %d\n", ret); |
Imre Deak | 2cd9a68 | 2018-08-16 15:37:57 +0300 | [diff] [blame] | 1233 | intel_power_domains_resume(dev_priv); |
Imre Deak | c3c09c9 | 2014-10-23 19:23:15 +0300 | [diff] [blame] | 1234 | |
Imre Deak | 1f814da | 2015-12-16 02:52:19 +0200 | [diff] [blame] | 1235 | goto out; |
Imre Deak | c3c09c9 | 2014-10-23 19:23:15 +0300 | [diff] [blame] | 1236 | } |
| 1237 | |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 1238 | pci_disable_device(pdev); |
Imre Deak | ab3be73 | 2015-03-02 13:04:41 +0200 | [diff] [blame] | 1239 | /* |
Imre Deak | 5487557 | 2015-06-30 17:06:47 +0300 | [diff] [blame] | 1240 | * During hibernation on some platforms the BIOS may try to access |
Imre Deak | ab3be73 | 2015-03-02 13:04:41 +0200 | [diff] [blame] | 1241 | * the device even though it's already in D3 and hang the machine. So |
| 1242 | * leave the device in D0 on those platforms and hope the BIOS will |
Imre Deak | 5487557 | 2015-06-30 17:06:47 +0300 | [diff] [blame] | 1243 | * power down the device properly. The issue was seen on multiple old |
| 1244 | * GENs with different BIOS vendors, so having an explicit blacklist |
| 1245 | * is inpractical; apply the workaround on everything pre GEN6. The |
| 1246 | * platforms where the issue was seen: |
| 1247 | * Lenovo Thinkpad X301, X61s, X60, T60, X41 |
| 1248 | * Fujitsu FSC S7110 |
| 1249 | * Acer Aspire 1830T |
Imre Deak | ab3be73 | 2015-03-02 13:04:41 +0200 | [diff] [blame] | 1250 | */ |
Tvrtko Ursulin | 514e1d6 | 2016-11-04 14:42:48 +0000 | [diff] [blame] | 1251 | if (!(hibernation && INTEL_GEN(dev_priv) < 6)) |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 1252 | pci_set_power_state(pdev, PCI_D3hot); |
Imre Deak | c3c09c9 | 2014-10-23 19:23:15 +0300 | [diff] [blame] | 1253 | |
Imre Deak | 1f814da | 2015-12-16 02:52:19 +0200 | [diff] [blame] | 1254 | out: |
Daniele Ceraolo Spurio | 69c6635 | 2019-06-13 16:21:53 -0700 | [diff] [blame] | 1255 | enable_rpm_wakeref_asserts(rpm); |
Daniele Ceraolo Spurio | 0a9b263 | 2019-08-09 07:31:16 +0100 | [diff] [blame] | 1256 | if (!dev_priv->uncore.user_forcewake_count) |
Janusz Krzysztofik | 3b58a94 | 2019-07-12 13:24:28 +0200 | [diff] [blame] | 1257 | intel_runtime_pm_driver_release(rpm); |
Imre Deak | 1f814da | 2015-12-16 02:52:19 +0200 | [diff] [blame] | 1258 | |
| 1259 | return ret; |
Imre Deak | c3c09c9 | 2014-10-23 19:23:15 +0300 | [diff] [blame] | 1260 | } |
| 1261 | |
Jani Nikula | 63bf830 | 2019-10-04 15:20:18 +0300 | [diff] [blame] | 1262 | int i915_suspend_switcheroo(struct drm_i915_private *i915, pm_message_t state) |
Rafael J. Wysocki | 84b79f8 | 2010-02-07 21:48:24 +0100 | [diff] [blame] | 1263 | { |
| 1264 | int error; |
| 1265 | |
Pankaj Bharadiya | 48a1b8d | 2020-01-15 09:14:53 +0530 | [diff] [blame] | 1266 | if (drm_WARN_ON_ONCE(&i915->drm, state.event != PM_EVENT_SUSPEND && |
| 1267 | state.event != PM_EVENT_FREEZE)) |
Imre Deak | 0b14cbd | 2014-09-10 18:16:55 +0300 | [diff] [blame] | 1268 | return -EINVAL; |
Dave Airlie | 5bcf719 | 2010-12-07 09:20:40 +1000 | [diff] [blame] | 1269 | |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1270 | if (i915->drm.switch_power_state == DRM_SWITCH_POWER_OFF) |
Dave Airlie | 5bcf719 | 2010-12-07 09:20:40 +1000 | [diff] [blame] | 1271 | return 0; |
Chris Wilson | 6eecba3 | 2010-09-08 09:45:11 +0100 | [diff] [blame] | 1272 | |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1273 | error = i915_drm_suspend(&i915->drm); |
Rafael J. Wysocki | 84b79f8 | 2010-02-07 21:48:24 +0100 | [diff] [blame] | 1274 | if (error) |
| 1275 | return error; |
Jesse Barnes | ba8bbcf | 2007-11-22 14:14:14 +1000 | [diff] [blame] | 1276 | |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1277 | return i915_drm_suspend_late(&i915->drm, false); |
Jesse Barnes | ba8bbcf | 2007-11-22 14:14:14 +1000 | [diff] [blame] | 1278 | } |
| 1279 | |
Imre Deak | 5e365c3 | 2014-10-23 19:23:25 +0300 | [diff] [blame] | 1280 | static int i915_drm_resume(struct drm_device *dev) |
Jesse Barnes | ba8bbcf | 2007-11-22 14:14:14 +1000 | [diff] [blame] | 1281 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1282 | struct drm_i915_private *dev_priv = to_i915(dev); |
Ville Syrjälä | ac840ae | 2016-05-06 21:35:55 +0300 | [diff] [blame] | 1283 | int ret; |
Matthew Garrett | 8ee1c3d | 2008-08-05 19:37:25 +0100 | [diff] [blame] | 1284 | |
Daniele Ceraolo Spurio | 9102650 | 2019-06-13 16:21:51 -0700 | [diff] [blame] | 1285 | disable_rpm_wakeref_asserts(&dev_priv->runtime_pm); |
Imre Deak | 1f814da | 2015-12-16 02:52:19 +0200 | [diff] [blame] | 1286 | |
Chris Wilson | 640b50f | 2019-12-28 11:12:55 +0000 | [diff] [blame] | 1287 | sanitize_gpu(dev_priv); |
| 1288 | |
Chris Wilson | 97d6d7a | 2016-08-04 07:52:22 +0100 | [diff] [blame] | 1289 | ret = i915_ggtt_enable_hw(dev_priv); |
Ville Syrjälä | ac840ae | 2016-05-06 21:35:55 +0300 | [diff] [blame] | 1290 | if (ret) |
Wambui Karuga | 00376cc | 2020-01-31 12:34:12 +0300 | [diff] [blame] | 1291 | drm_err(&dev_priv->drm, "failed to re-enable GGTT\n"); |
Ville Syrjälä | ac840ae | 2016-05-06 21:35:55 +0300 | [diff] [blame] | 1292 | |
Chris Wilson | e986209 | 2020-01-30 18:17:09 +0000 | [diff] [blame] | 1293 | i915_ggtt_resume(&dev_priv->ggtt); |
Chris Wilson | e9d4c92 | 2019-10-16 15:32:33 +0100 | [diff] [blame] | 1294 | i915_gem_restore_fences(&dev_priv->ggtt); |
Chris Wilson | cec5ca0 | 2019-09-09 12:00:08 +0100 | [diff] [blame] | 1295 | |
Imre Deak | f74ed08 | 2016-04-18 14:48:21 +0300 | [diff] [blame] | 1296 | intel_csr_ucode_resume(dev_priv); |
| 1297 | |
Tvrtko Ursulin | af6dc74 | 2016-12-01 14:16:44 +0000 | [diff] [blame] | 1298 | i915_restore_state(dev_priv); |
Imre Deak | 8090ba8 | 2016-08-10 14:07:33 +0300 | [diff] [blame] | 1299 | intel_pps_unlock_regs_wa(dev_priv); |
Rafael J. Wysocki | 61caf87 | 2010-02-18 23:06:27 +0100 | [diff] [blame] | 1300 | |
Ander Conselvan de Oliveira | c39055b | 2016-11-23 16:21:44 +0200 | [diff] [blame] | 1301 | intel_init_pch_refclk(dev_priv); |
Chris Wilson | 1833b13 | 2012-05-09 11:56:28 +0100 | [diff] [blame] | 1302 | |
Peter Antoine | 364aece | 2015-05-11 08:50:45 +0100 | [diff] [blame] | 1303 | /* |
| 1304 | * Interrupts have to be enabled before any batches are run. If not the |
| 1305 | * GPU will hang. i915_gem_init_hw() will initiate batches to |
| 1306 | * update/restore the context. |
| 1307 | * |
Imre Deak | 908764f | 2016-11-29 21:40:29 +0200 | [diff] [blame] | 1308 | * drm_mode_config_reset() needs AUX interrupts. |
| 1309 | * |
Peter Antoine | 364aece | 2015-05-11 08:50:45 +0100 | [diff] [blame] | 1310 | * Modeset enabling in intel_modeset_init_hw() also needs working |
| 1311 | * interrupts. |
| 1312 | */ |
| 1313 | intel_runtime_pm_enable_interrupts(dev_priv); |
| 1314 | |
Imre Deak | 908764f | 2016-11-29 21:40:29 +0200 | [diff] [blame] | 1315 | drm_mode_config_reset(dev); |
| 1316 | |
Chris Wilson | 37cd330 | 2017-11-12 11:27:38 +0000 | [diff] [blame] | 1317 | i915_gem_resume(dev_priv); |
Daniel Vetter | d581893 | 2015-02-23 12:03:26 +0100 | [diff] [blame] | 1318 | |
Jani Nikula | 6cd02e7 | 2019-09-20 21:54:21 +0300 | [diff] [blame] | 1319 | intel_modeset_init_hw(dev_priv); |
Ville Syrjälä | 675f7ff | 2017-11-16 18:02:15 +0200 | [diff] [blame] | 1320 | intel_init_clock_gating(dev_priv); |
Daniel Vetter | d581893 | 2015-02-23 12:03:26 +0100 | [diff] [blame] | 1321 | |
| 1322 | spin_lock_irq(&dev_priv->irq_lock); |
| 1323 | if (dev_priv->display.hpd_irq_setup) |
Tvrtko Ursulin | 91d1425 | 2016-05-06 14:48:28 +0100 | [diff] [blame] | 1324 | dev_priv->display.hpd_irq_setup(dev_priv); |
Daniel Vetter | d581893 | 2015-02-23 12:03:26 +0100 | [diff] [blame] | 1325 | spin_unlock_irq(&dev_priv->irq_lock); |
| 1326 | |
Ville Syrjälä | 1a4313d | 2018-07-05 19:43:52 +0300 | [diff] [blame] | 1327 | intel_dp_mst_resume(dev_priv); |
Daniel Vetter | d581893 | 2015-02-23 12:03:26 +0100 | [diff] [blame] | 1328 | |
Lyude | a16b765 | 2016-03-11 10:57:01 -0500 | [diff] [blame] | 1329 | intel_display_resume(dev); |
| 1330 | |
Lyude | e0b7006 | 2016-11-01 21:06:30 -0400 | [diff] [blame] | 1331 | drm_kms_helper_poll_enable(dev); |
| 1332 | |
Daniel Vetter | d581893 | 2015-02-23 12:03:26 +0100 | [diff] [blame] | 1333 | /* |
| 1334 | * ... but also need to make sure that hotplug processing |
| 1335 | * doesn't cause havoc. Like in the driver load code we don't |
Gwan-gyeong Mun | c444ad7 | 2018-08-03 19:41:50 +0300 | [diff] [blame] | 1336 | * bother with the tiny race here where we might lose hotplug |
Daniel Vetter | d581893 | 2015-02-23 12:03:26 +0100 | [diff] [blame] | 1337 | * notifications. |
| 1338 | * */ |
| 1339 | intel_hpd_init(dev_priv); |
Jesse Barnes | 1daed3f | 2011-01-05 12:01:25 -0800 | [diff] [blame] | 1340 | |
Chris Wilson | a950adc | 2018-10-30 11:05:54 +0000 | [diff] [blame] | 1341 | intel_opregion_resume(dev_priv); |
Chris Wilson | 44834a6 | 2010-08-19 16:09:23 +0100 | [diff] [blame] | 1342 | |
Chris Wilson | 82e3b8c | 2014-08-13 13:09:46 +0100 | [diff] [blame] | 1343 | intel_fbdev_set_suspend(dev, FBINFO_STATE_RUNNING, false); |
Jesse Barnes | 073f34d | 2012-11-02 11:13:59 -0700 | [diff] [blame] | 1344 | |
Imre Deak | 2cd9a68 | 2018-08-16 15:37:57 +0300 | [diff] [blame] | 1345 | intel_power_domains_enable(dev_priv); |
| 1346 | |
Daniele Ceraolo Spurio | 9102650 | 2019-06-13 16:21:51 -0700 | [diff] [blame] | 1347 | enable_rpm_wakeref_asserts(&dev_priv->runtime_pm); |
Imre Deak | 1f814da | 2015-12-16 02:52:19 +0200 | [diff] [blame] | 1348 | |
Chris Wilson | 074c6ad | 2014-04-09 09:19:43 +0100 | [diff] [blame] | 1349 | return 0; |
Rafael J. Wysocki | 84b79f8 | 2010-02-07 21:48:24 +0100 | [diff] [blame] | 1350 | } |
| 1351 | |
Imre Deak | 5e365c3 | 2014-10-23 19:23:25 +0300 | [diff] [blame] | 1352 | static int i915_drm_resume_early(struct drm_device *dev) |
Rafael J. Wysocki | 84b79f8 | 2010-02-07 21:48:24 +0100 | [diff] [blame] | 1353 | { |
Chris Wilson | fac5e23 | 2016-07-04 11:34:36 +0100 | [diff] [blame] | 1354 | struct drm_i915_private *dev_priv = to_i915(dev); |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 1355 | struct pci_dev *pdev = dev_priv->drm.pdev; |
Imre Deak | 44410cd | 2016-04-18 14:45:54 +0300 | [diff] [blame] | 1356 | int ret; |
Imre Deak | 36d61e6 | 2014-10-23 19:23:24 +0300 | [diff] [blame] | 1357 | |
Imre Deak | 76c4b25 | 2014-04-01 19:55:22 +0300 | [diff] [blame] | 1358 | /* |
| 1359 | * We have a resume ordering issue with the snd-hda driver also |
| 1360 | * requiring our device to be power up. Due to the lack of a |
| 1361 | * parent/child relationship we currently solve this with an early |
| 1362 | * resume hook. |
| 1363 | * |
| 1364 | * FIXME: This should be solved with a special hdmi sink device or |
| 1365 | * similar so that power domains can be employed. |
| 1366 | */ |
Imre Deak | 44410cd | 2016-04-18 14:45:54 +0300 | [diff] [blame] | 1367 | |
| 1368 | /* |
| 1369 | * Note that we need to set the power state explicitly, since we |
| 1370 | * powered off the device during freeze and the PCI core won't power |
| 1371 | * it back up for us during thaw. Powering off the device during |
| 1372 | * freeze is not a hard requirement though, and during the |
| 1373 | * suspend/resume phases the PCI core makes sure we get here with the |
| 1374 | * device powered on. So in case we change our freeze logic and keep |
| 1375 | * the device powered we can also remove the following set power state |
| 1376 | * call. |
| 1377 | */ |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 1378 | ret = pci_set_power_state(pdev, PCI_D0); |
Imre Deak | 44410cd | 2016-04-18 14:45:54 +0300 | [diff] [blame] | 1379 | if (ret) { |
Wambui Karuga | 00376cc | 2020-01-31 12:34:12 +0300 | [diff] [blame] | 1380 | drm_err(&dev_priv->drm, |
| 1381 | "failed to set PCI D0 power state (%d)\n", ret); |
Imre Deak | 2cd9a68 | 2018-08-16 15:37:57 +0300 | [diff] [blame] | 1382 | return ret; |
Imre Deak | 44410cd | 2016-04-18 14:45:54 +0300 | [diff] [blame] | 1383 | } |
| 1384 | |
| 1385 | /* |
| 1386 | * Note that pci_enable_device() first enables any parent bridge |
| 1387 | * device and only then sets the power state for this device. The |
| 1388 | * bridge enabling is a nop though, since bridge devices are resumed |
| 1389 | * first. The order of enabling power and enabling the device is |
| 1390 | * imposed by the PCI core as described above, so here we preserve the |
| 1391 | * same order for the freeze/thaw phases. |
| 1392 | * |
| 1393 | * TODO: eventually we should remove pci_disable_device() / |
| 1394 | * pci_enable_enable_device() from suspend/resume. Due to how they |
| 1395 | * depend on the device enable refcount we can't anyway depend on them |
| 1396 | * disabling/enabling the device. |
| 1397 | */ |
Imre Deak | 2cd9a68 | 2018-08-16 15:37:57 +0300 | [diff] [blame] | 1398 | if (pci_enable_device(pdev)) |
| 1399 | return -EIO; |
Rafael J. Wysocki | 84b79f8 | 2010-02-07 21:48:24 +0100 | [diff] [blame] | 1400 | |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 1401 | pci_set_master(pdev); |
Rafael J. Wysocki | 84b79f8 | 2010-02-07 21:48:24 +0100 | [diff] [blame] | 1402 | |
Daniele Ceraolo Spurio | 9102650 | 2019-06-13 16:21:51 -0700 | [diff] [blame] | 1403 | disable_rpm_wakeref_asserts(&dev_priv->runtime_pm); |
Imre Deak | 1f814da | 2015-12-16 02:52:19 +0200 | [diff] [blame] | 1404 | |
Jani Nikula | fb5f432 | 2020-02-12 16:40:57 +0200 | [diff] [blame] | 1405 | ret = vlv_resume_prepare(dev_priv, false); |
Imre Deak | 36d61e6 | 2014-10-23 19:23:24 +0300 | [diff] [blame] | 1406 | if (ret) |
Wambui Karuga | 00376cc | 2020-01-31 12:34:12 +0300 | [diff] [blame] | 1407 | drm_err(&dev_priv->drm, |
Jani Nikula | fb5f432 | 2020-02-12 16:40:57 +0200 | [diff] [blame] | 1408 | "Resume prepare failed: %d, continuing anyway\n", ret); |
Imre Deak | 36d61e6 | 2014-10-23 19:23:24 +0300 | [diff] [blame] | 1409 | |
Daniele Ceraolo Spurio | f7de502 | 2019-03-19 11:35:37 -0700 | [diff] [blame] | 1410 | intel_uncore_resume_early(&dev_priv->uncore); |
| 1411 | |
Tvrtko Ursulin | eaf522f | 2019-06-21 08:07:44 +0100 | [diff] [blame] | 1412 | intel_gt_check_and_clear_faults(&dev_priv->gt); |
Paulo Zanoni | efee833 | 2014-10-27 17:54:33 -0200 | [diff] [blame] | 1413 | |
Rodrigo Vivi | 071b68c | 2019-08-06 15:22:08 +0300 | [diff] [blame] | 1414 | intel_display_power_resume_early(dev_priv); |
Paulo Zanoni | efee833 | 2014-10-27 17:54:33 -0200 | [diff] [blame] | 1415 | |
Imre Deak | 2cd9a68 | 2018-08-16 15:37:57 +0300 | [diff] [blame] | 1416 | intel_power_domains_resume(dev_priv); |
Imre Deak | bc87229 | 2015-11-18 17:32:30 +0200 | [diff] [blame] | 1417 | |
Daniele Ceraolo Spurio | 9102650 | 2019-06-13 16:21:51 -0700 | [diff] [blame] | 1418 | enable_rpm_wakeref_asserts(&dev_priv->runtime_pm); |
Imre Deak | 6e35e8a | 2016-04-18 10:04:19 +0300 | [diff] [blame] | 1419 | |
Imre Deak | 36d61e6 | 2014-10-23 19:23:24 +0300 | [diff] [blame] | 1420 | return ret; |
Imre Deak | 76c4b25 | 2014-04-01 19:55:22 +0300 | [diff] [blame] | 1421 | } |
| 1422 | |
Jani Nikula | 63bf830 | 2019-10-04 15:20:18 +0300 | [diff] [blame] | 1423 | int i915_resume_switcheroo(struct drm_i915_private *i915) |
Imre Deak | 76c4b25 | 2014-04-01 19:55:22 +0300 | [diff] [blame] | 1424 | { |
Imre Deak | 50a0072 | 2014-10-23 19:23:17 +0300 | [diff] [blame] | 1425 | int ret; |
Imre Deak | 76c4b25 | 2014-04-01 19:55:22 +0300 | [diff] [blame] | 1426 | |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1427 | if (i915->drm.switch_power_state == DRM_SWITCH_POWER_OFF) |
Imre Deak | 097dd83 | 2014-10-23 19:23:19 +0300 | [diff] [blame] | 1428 | return 0; |
| 1429 | |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1430 | ret = i915_drm_resume_early(&i915->drm); |
Imre Deak | 50a0072 | 2014-10-23 19:23:17 +0300 | [diff] [blame] | 1431 | if (ret) |
| 1432 | return ret; |
| 1433 | |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1434 | return i915_drm_resume(&i915->drm); |
Imre Deak | 5a17514 | 2014-10-23 19:23:18 +0300 | [diff] [blame] | 1435 | } |
| 1436 | |
Chris Wilson | 73b66f8 | 2018-05-25 10:26:29 +0100 | [diff] [blame] | 1437 | static int i915_pm_prepare(struct device *kdev) |
| 1438 | { |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1439 | struct drm_i915_private *i915 = kdev_to_i915(kdev); |
Chris Wilson | 73b66f8 | 2018-05-25 10:26:29 +0100 | [diff] [blame] | 1440 | |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1441 | if (!i915) { |
Chris Wilson | 73b66f8 | 2018-05-25 10:26:29 +0100 | [diff] [blame] | 1442 | dev_err(kdev, "DRM not initialized, aborting suspend.\n"); |
| 1443 | return -ENODEV; |
| 1444 | } |
| 1445 | |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1446 | if (i915->drm.switch_power_state == DRM_SWITCH_POWER_OFF) |
Chris Wilson | 73b66f8 | 2018-05-25 10:26:29 +0100 | [diff] [blame] | 1447 | return 0; |
| 1448 | |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1449 | return i915_drm_prepare(&i915->drm); |
Chris Wilson | 73b66f8 | 2018-05-25 10:26:29 +0100 | [diff] [blame] | 1450 | } |
| 1451 | |
David Weinehall | c49d13e | 2016-08-22 13:32:42 +0300 | [diff] [blame] | 1452 | static int i915_pm_suspend(struct device *kdev) |
Kristian Høgsberg | 112b715 | 2009-01-04 16:55:33 -0500 | [diff] [blame] | 1453 | { |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1454 | struct drm_i915_private *i915 = kdev_to_i915(kdev); |
Kristian Høgsberg | 112b715 | 2009-01-04 16:55:33 -0500 | [diff] [blame] | 1455 | |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1456 | if (!i915) { |
David Weinehall | c49d13e | 2016-08-22 13:32:42 +0300 | [diff] [blame] | 1457 | dev_err(kdev, "DRM not initialized, aborting suspend.\n"); |
Rafael J. Wysocki | 84b79f8 | 2010-02-07 21:48:24 +0100 | [diff] [blame] | 1458 | return -ENODEV; |
| 1459 | } |
Kristian Høgsberg | 112b715 | 2009-01-04 16:55:33 -0500 | [diff] [blame] | 1460 | |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1461 | if (i915->drm.switch_power_state == DRM_SWITCH_POWER_OFF) |
Dave Airlie | 5bcf719 | 2010-12-07 09:20:40 +1000 | [diff] [blame] | 1462 | return 0; |
| 1463 | |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1464 | return i915_drm_suspend(&i915->drm); |
Imre Deak | 76c4b25 | 2014-04-01 19:55:22 +0300 | [diff] [blame] | 1465 | } |
| 1466 | |
David Weinehall | c49d13e | 2016-08-22 13:32:42 +0300 | [diff] [blame] | 1467 | static int i915_pm_suspend_late(struct device *kdev) |
Imre Deak | 76c4b25 | 2014-04-01 19:55:22 +0300 | [diff] [blame] | 1468 | { |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1469 | struct drm_i915_private *i915 = kdev_to_i915(kdev); |
Imre Deak | 76c4b25 | 2014-04-01 19:55:22 +0300 | [diff] [blame] | 1470 | |
| 1471 | /* |
Damien Lespiau | c965d995 | 2015-05-18 19:53:48 +0100 | [diff] [blame] | 1472 | * We have a suspend ordering issue with the snd-hda driver also |
Imre Deak | 76c4b25 | 2014-04-01 19:55:22 +0300 | [diff] [blame] | 1473 | * requiring our device to be power up. Due to the lack of a |
| 1474 | * parent/child relationship we currently solve this with an late |
| 1475 | * suspend hook. |
| 1476 | * |
| 1477 | * FIXME: This should be solved with a special hdmi sink device or |
| 1478 | * similar so that power domains can be employed. |
| 1479 | */ |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1480 | if (i915->drm.switch_power_state == DRM_SWITCH_POWER_OFF) |
Imre Deak | 76c4b25 | 2014-04-01 19:55:22 +0300 | [diff] [blame] | 1481 | return 0; |
Kristian Høgsberg | 112b715 | 2009-01-04 16:55:33 -0500 | [diff] [blame] | 1482 | |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1483 | return i915_drm_suspend_late(&i915->drm, false); |
Imre Deak | ab3be73 | 2015-03-02 13:04:41 +0200 | [diff] [blame] | 1484 | } |
| 1485 | |
David Weinehall | c49d13e | 2016-08-22 13:32:42 +0300 | [diff] [blame] | 1486 | static int i915_pm_poweroff_late(struct device *kdev) |
Imre Deak | ab3be73 | 2015-03-02 13:04:41 +0200 | [diff] [blame] | 1487 | { |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1488 | struct drm_i915_private *i915 = kdev_to_i915(kdev); |
Imre Deak | ab3be73 | 2015-03-02 13:04:41 +0200 | [diff] [blame] | 1489 | |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1490 | if (i915->drm.switch_power_state == DRM_SWITCH_POWER_OFF) |
Imre Deak | ab3be73 | 2015-03-02 13:04:41 +0200 | [diff] [blame] | 1491 | return 0; |
| 1492 | |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1493 | return i915_drm_suspend_late(&i915->drm, true); |
Zhenyu Wang | cbda12d | 2009-12-16 13:36:10 +0800 | [diff] [blame] | 1494 | } |
| 1495 | |
David Weinehall | c49d13e | 2016-08-22 13:32:42 +0300 | [diff] [blame] | 1496 | static int i915_pm_resume_early(struct device *kdev) |
Imre Deak | 76c4b25 | 2014-04-01 19:55:22 +0300 | [diff] [blame] | 1497 | { |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1498 | struct drm_i915_private *i915 = kdev_to_i915(kdev); |
Imre Deak | 76c4b25 | 2014-04-01 19:55:22 +0300 | [diff] [blame] | 1499 | |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1500 | if (i915->drm.switch_power_state == DRM_SWITCH_POWER_OFF) |
Imre Deak | 097dd83 | 2014-10-23 19:23:19 +0300 | [diff] [blame] | 1501 | return 0; |
| 1502 | |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1503 | return i915_drm_resume_early(&i915->drm); |
Imre Deak | 76c4b25 | 2014-04-01 19:55:22 +0300 | [diff] [blame] | 1504 | } |
| 1505 | |
David Weinehall | c49d13e | 2016-08-22 13:32:42 +0300 | [diff] [blame] | 1506 | static int i915_pm_resume(struct device *kdev) |
Zhenyu Wang | cbda12d | 2009-12-16 13:36:10 +0800 | [diff] [blame] | 1507 | { |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1508 | struct drm_i915_private *i915 = kdev_to_i915(kdev); |
Rafael J. Wysocki | 84b79f8 | 2010-02-07 21:48:24 +0100 | [diff] [blame] | 1509 | |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1510 | if (i915->drm.switch_power_state == DRM_SWITCH_POWER_OFF) |
Imre Deak | 097dd83 | 2014-10-23 19:23:19 +0300 | [diff] [blame] | 1511 | return 0; |
| 1512 | |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1513 | return i915_drm_resume(&i915->drm); |
Zhenyu Wang | cbda12d | 2009-12-16 13:36:10 +0800 | [diff] [blame] | 1514 | } |
| 1515 | |
Chris Wilson | 1f19ac2 | 2016-05-14 07:26:32 +0100 | [diff] [blame] | 1516 | /* freeze: before creating the hibernation_image */ |
David Weinehall | c49d13e | 2016-08-22 13:32:42 +0300 | [diff] [blame] | 1517 | static int i915_pm_freeze(struct device *kdev) |
Chris Wilson | 1f19ac2 | 2016-05-14 07:26:32 +0100 | [diff] [blame] | 1518 | { |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1519 | struct drm_i915_private *i915 = kdev_to_i915(kdev); |
Chris Wilson | 6a800ea | 2016-09-21 14:51:07 +0100 | [diff] [blame] | 1520 | int ret; |
| 1521 | |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1522 | if (i915->drm.switch_power_state != DRM_SWITCH_POWER_OFF) { |
| 1523 | ret = i915_drm_suspend(&i915->drm); |
Imre Deak | dd9f31c | 2017-08-16 17:46:07 +0300 | [diff] [blame] | 1524 | if (ret) |
| 1525 | return ret; |
| 1526 | } |
Chris Wilson | 6a800ea | 2016-09-21 14:51:07 +0100 | [diff] [blame] | 1527 | |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1528 | ret = i915_gem_freeze(i915); |
Chris Wilson | 6a800ea | 2016-09-21 14:51:07 +0100 | [diff] [blame] | 1529 | if (ret) |
| 1530 | return ret; |
| 1531 | |
| 1532 | return 0; |
Chris Wilson | 1f19ac2 | 2016-05-14 07:26:32 +0100 | [diff] [blame] | 1533 | } |
| 1534 | |
David Weinehall | c49d13e | 2016-08-22 13:32:42 +0300 | [diff] [blame] | 1535 | static int i915_pm_freeze_late(struct device *kdev) |
Chris Wilson | 1f19ac2 | 2016-05-14 07:26:32 +0100 | [diff] [blame] | 1536 | { |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1537 | struct drm_i915_private *i915 = kdev_to_i915(kdev); |
Chris Wilson | 461fb99 | 2016-05-14 07:26:33 +0100 | [diff] [blame] | 1538 | int ret; |
| 1539 | |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1540 | if (i915->drm.switch_power_state != DRM_SWITCH_POWER_OFF) { |
| 1541 | ret = i915_drm_suspend_late(&i915->drm, true); |
Imre Deak | dd9f31c | 2017-08-16 17:46:07 +0300 | [diff] [blame] | 1542 | if (ret) |
| 1543 | return ret; |
| 1544 | } |
Chris Wilson | 461fb99 | 2016-05-14 07:26:33 +0100 | [diff] [blame] | 1545 | |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1546 | ret = i915_gem_freeze_late(i915); |
Chris Wilson | 461fb99 | 2016-05-14 07:26:33 +0100 | [diff] [blame] | 1547 | if (ret) |
| 1548 | return ret; |
| 1549 | |
| 1550 | return 0; |
Chris Wilson | 1f19ac2 | 2016-05-14 07:26:32 +0100 | [diff] [blame] | 1551 | } |
| 1552 | |
| 1553 | /* thaw: called after creating the hibernation image, but before turning off. */ |
David Weinehall | c49d13e | 2016-08-22 13:32:42 +0300 | [diff] [blame] | 1554 | static int i915_pm_thaw_early(struct device *kdev) |
Chris Wilson | 1f19ac2 | 2016-05-14 07:26:32 +0100 | [diff] [blame] | 1555 | { |
David Weinehall | c49d13e | 2016-08-22 13:32:42 +0300 | [diff] [blame] | 1556 | return i915_pm_resume_early(kdev); |
Chris Wilson | 1f19ac2 | 2016-05-14 07:26:32 +0100 | [diff] [blame] | 1557 | } |
| 1558 | |
David Weinehall | c49d13e | 2016-08-22 13:32:42 +0300 | [diff] [blame] | 1559 | static int i915_pm_thaw(struct device *kdev) |
Chris Wilson | 1f19ac2 | 2016-05-14 07:26:32 +0100 | [diff] [blame] | 1560 | { |
David Weinehall | c49d13e | 2016-08-22 13:32:42 +0300 | [diff] [blame] | 1561 | return i915_pm_resume(kdev); |
Chris Wilson | 1f19ac2 | 2016-05-14 07:26:32 +0100 | [diff] [blame] | 1562 | } |
| 1563 | |
| 1564 | /* restore: called after loading the hibernation image. */ |
David Weinehall | c49d13e | 2016-08-22 13:32:42 +0300 | [diff] [blame] | 1565 | static int i915_pm_restore_early(struct device *kdev) |
Chris Wilson | 1f19ac2 | 2016-05-14 07:26:32 +0100 | [diff] [blame] | 1566 | { |
David Weinehall | c49d13e | 2016-08-22 13:32:42 +0300 | [diff] [blame] | 1567 | return i915_pm_resume_early(kdev); |
Chris Wilson | 1f19ac2 | 2016-05-14 07:26:32 +0100 | [diff] [blame] | 1568 | } |
| 1569 | |
David Weinehall | c49d13e | 2016-08-22 13:32:42 +0300 | [diff] [blame] | 1570 | static int i915_pm_restore(struct device *kdev) |
Chris Wilson | 1f19ac2 | 2016-05-14 07:26:32 +0100 | [diff] [blame] | 1571 | { |
David Weinehall | c49d13e | 2016-08-22 13:32:42 +0300 | [diff] [blame] | 1572 | return i915_pm_resume(kdev); |
Chris Wilson | 1f19ac2 | 2016-05-14 07:26:32 +0100 | [diff] [blame] | 1573 | } |
| 1574 | |
David Weinehall | c49d13e | 2016-08-22 13:32:42 +0300 | [diff] [blame] | 1575 | static int intel_runtime_suspend(struct device *kdev) |
Paulo Zanoni | 8a18745 | 2013-12-06 20:32:13 -0200 | [diff] [blame] | 1576 | { |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1577 | struct drm_i915_private *dev_priv = kdev_to_i915(kdev); |
Daniele Ceraolo Spurio | 1bf676c | 2019-06-13 16:21:52 -0700 | [diff] [blame] | 1578 | struct intel_runtime_pm *rpm = &dev_priv->runtime_pm; |
Jani Nikula | fb5f432 | 2020-02-12 16:40:57 +0200 | [diff] [blame] | 1579 | int ret; |
Paulo Zanoni | 8a18745 | 2013-12-06 20:32:13 -0200 | [diff] [blame] | 1580 | |
Pankaj Bharadiya | 48a1b8d | 2020-01-15 09:14:53 +0530 | [diff] [blame] | 1581 | if (drm_WARN_ON_ONCE(&dev_priv->drm, !HAS_RUNTIME_PM(dev_priv))) |
Imre Deak | 604effb | 2014-08-26 13:26:56 +0300 | [diff] [blame] | 1582 | return -ENODEV; |
| 1583 | |
Wambui Karuga | 00376cc | 2020-01-31 12:34:12 +0300 | [diff] [blame] | 1584 | drm_dbg_kms(&dev_priv->drm, "Suspending device\n"); |
Paulo Zanoni | 8a18745 | 2013-12-06 20:32:13 -0200 | [diff] [blame] | 1585 | |
Daniele Ceraolo Spurio | 9102650 | 2019-06-13 16:21:51 -0700 | [diff] [blame] | 1586 | disable_rpm_wakeref_asserts(rpm); |
Imre Deak | 1f814da | 2015-12-16 02:52:19 +0200 | [diff] [blame] | 1587 | |
Imre Deak | d610297 | 2014-05-07 19:57:49 +0300 | [diff] [blame] | 1588 | /* |
| 1589 | * We are safe here against re-faults, since the fault handler takes |
| 1590 | * an RPM reference. |
| 1591 | */ |
Chris Wilson | 7c108fd | 2016-10-24 13:42:18 +0100 | [diff] [blame] | 1592 | i915_gem_runtime_suspend(dev_priv); |
Imre Deak | d610297 | 2014-05-07 19:57:49 +0300 | [diff] [blame] | 1593 | |
Daniele Ceraolo Spurio | 9dfe345 | 2019-07-31 17:57:09 -0700 | [diff] [blame] | 1594 | intel_gt_runtime_suspend(&dev_priv->gt); |
Alex Dai | a1c4199 | 2015-09-30 09:46:37 -0700 | [diff] [blame] | 1595 | |
Imre Deak | 2eb5252 | 2014-11-19 15:30:05 +0200 | [diff] [blame] | 1596 | intel_runtime_pm_disable_interrupts(dev_priv); |
Imre Deak | b5478bc | 2014-04-14 20:24:37 +0300 | [diff] [blame] | 1597 | |
Daniele Ceraolo Spurio | f7de502 | 2019-03-19 11:35:37 -0700 | [diff] [blame] | 1598 | intel_uncore_suspend(&dev_priv->uncore); |
Hans de Goede | 01c799c | 2017-11-14 14:55:18 +0100 | [diff] [blame] | 1599 | |
Rodrigo Vivi | 071b68c | 2019-08-06 15:22:08 +0300 | [diff] [blame] | 1600 | intel_display_power_suspend(dev_priv); |
| 1601 | |
Jani Nikula | fb5f432 | 2020-02-12 16:40:57 +0200 | [diff] [blame] | 1602 | ret = vlv_suspend_complete(dev_priv); |
Imre Deak | 0ab9cfe | 2014-04-15 16:39:45 +0300 | [diff] [blame] | 1603 | if (ret) { |
Wambui Karuga | 00376cc | 2020-01-31 12:34:12 +0300 | [diff] [blame] | 1604 | drm_err(&dev_priv->drm, |
| 1605 | "Runtime suspend failed, disabling it (%d)\n", ret); |
Daniele Ceraolo Spurio | f7de502 | 2019-03-19 11:35:37 -0700 | [diff] [blame] | 1606 | intel_uncore_runtime_resume(&dev_priv->uncore); |
Hans de Goede | 01c799c | 2017-11-14 14:55:18 +0100 | [diff] [blame] | 1607 | |
Daniel Vetter | b963291 | 2014-09-30 10:56:44 +0200 | [diff] [blame] | 1608 | intel_runtime_pm_enable_interrupts(dev_priv); |
Imre Deak | 0ab9cfe | 2014-04-15 16:39:45 +0300 | [diff] [blame] | 1609 | |
Daniele Ceraolo Spurio | 9dfe345 | 2019-07-31 17:57:09 -0700 | [diff] [blame] | 1610 | intel_gt_runtime_resume(&dev_priv->gt); |
Sagar Arun Kamble | 1ed21cb | 2018-01-24 21:16:57 +0530 | [diff] [blame] | 1611 | |
Chris Wilson | e9d4c92 | 2019-10-16 15:32:33 +0100 | [diff] [blame] | 1612 | i915_gem_restore_fences(&dev_priv->ggtt); |
Sagar Arun Kamble | 1ed21cb | 2018-01-24 21:16:57 +0530 | [diff] [blame] | 1613 | |
Daniele Ceraolo Spurio | 9102650 | 2019-06-13 16:21:51 -0700 | [diff] [blame] | 1614 | enable_rpm_wakeref_asserts(rpm); |
Imre Deak | 1f814da | 2015-12-16 02:52:19 +0200 | [diff] [blame] | 1615 | |
Imre Deak | 0ab9cfe | 2014-04-15 16:39:45 +0300 | [diff] [blame] | 1616 | return ret; |
| 1617 | } |
Paulo Zanoni | a8a8bd5 | 2014-03-07 20:08:05 -0300 | [diff] [blame] | 1618 | |
Daniele Ceraolo Spurio | 9102650 | 2019-06-13 16:21:51 -0700 | [diff] [blame] | 1619 | enable_rpm_wakeref_asserts(rpm); |
Janusz Krzysztofik | 3b58a94 | 2019-07-12 13:24:28 +0200 | [diff] [blame] | 1620 | intel_runtime_pm_driver_release(rpm); |
Mika Kuoppala | 55ec45c | 2015-12-15 16:25:08 +0200 | [diff] [blame] | 1621 | |
Daniele Ceraolo Spurio | 2cf7bf6 | 2019-03-25 14:49:34 -0700 | [diff] [blame] | 1622 | if (intel_uncore_arm_unclaimed_mmio_detection(&dev_priv->uncore)) |
Wambui Karuga | 00376cc | 2020-01-31 12:34:12 +0300 | [diff] [blame] | 1623 | drm_err(&dev_priv->drm, |
| 1624 | "Unclaimed access detected prior to suspending\n"); |
Mika Kuoppala | 55ec45c | 2015-12-15 16:25:08 +0200 | [diff] [blame] | 1625 | |
Daniele Ceraolo Spurio | 9102650 | 2019-06-13 16:21:51 -0700 | [diff] [blame] | 1626 | rpm->suspended = true; |
Kristen Carlson Accardi | 1fb2362 | 2014-01-14 15:36:15 -0800 | [diff] [blame] | 1627 | |
| 1628 | /* |
Paulo Zanoni | c8a0bd4 | 2014-08-21 17:09:38 -0300 | [diff] [blame] | 1629 | * FIXME: We really should find a document that references the arguments |
| 1630 | * used below! |
Kristen Carlson Accardi | 1fb2362 | 2014-01-14 15:36:15 -0800 | [diff] [blame] | 1631 | */ |
Chris Wilson | 6f9f4b7 | 2016-05-23 15:08:09 +0100 | [diff] [blame] | 1632 | if (IS_BROADWELL(dev_priv)) { |
Paulo Zanoni | d37ae19 | 2015-07-30 18:20:29 -0300 | [diff] [blame] | 1633 | /* |
| 1634 | * On Broadwell, if we use PCI_D1 the PCH DDI ports will stop |
| 1635 | * being detected, and the call we do at intel_runtime_resume() |
| 1636 | * won't be able to restore them. Since PCI_D3hot matches the |
| 1637 | * actual specification and appears to be working, use it. |
| 1638 | */ |
Chris Wilson | 6f9f4b7 | 2016-05-23 15:08:09 +0100 | [diff] [blame] | 1639 | intel_opregion_notify_adapter(dev_priv, PCI_D3hot); |
Paulo Zanoni | d37ae19 | 2015-07-30 18:20:29 -0300 | [diff] [blame] | 1640 | } else { |
Paulo Zanoni | c8a0bd4 | 2014-08-21 17:09:38 -0300 | [diff] [blame] | 1641 | /* |
| 1642 | * current versions of firmware which depend on this opregion |
| 1643 | * notification have repurposed the D1 definition to mean |
| 1644 | * "runtime suspended" vs. what you would normally expect (D3) |
| 1645 | * to distinguish it from notifications that might be sent via |
| 1646 | * the suspend path. |
| 1647 | */ |
Chris Wilson | 6f9f4b7 | 2016-05-23 15:08:09 +0100 | [diff] [blame] | 1648 | intel_opregion_notify_adapter(dev_priv, PCI_D1); |
Paulo Zanoni | c8a0bd4 | 2014-08-21 17:09:38 -0300 | [diff] [blame] | 1649 | } |
Paulo Zanoni | 8a18745 | 2013-12-06 20:32:13 -0200 | [diff] [blame] | 1650 | |
Daniele Ceraolo Spurio | f568eee | 2019-03-19 11:35:35 -0700 | [diff] [blame] | 1651 | assert_forcewakes_inactive(&dev_priv->uncore); |
Chris Wilson | dc9fb09 | 2015-01-16 11:34:34 +0200 | [diff] [blame] | 1652 | |
Ander Conselvan de Oliveira | 21d6e0b | 2017-01-20 16:28:43 +0200 | [diff] [blame] | 1653 | if (!IS_VALLEYVIEW(dev_priv) && !IS_CHERRYVIEW(dev_priv)) |
Lyude | 19625e8 | 2016-06-21 17:03:44 -0400 | [diff] [blame] | 1654 | intel_hpd_poll_init(dev_priv); |
| 1655 | |
Wambui Karuga | 00376cc | 2020-01-31 12:34:12 +0300 | [diff] [blame] | 1656 | drm_dbg_kms(&dev_priv->drm, "Device suspended\n"); |
Paulo Zanoni | 8a18745 | 2013-12-06 20:32:13 -0200 | [diff] [blame] | 1657 | return 0; |
| 1658 | } |
| 1659 | |
David Weinehall | c49d13e | 2016-08-22 13:32:42 +0300 | [diff] [blame] | 1660 | static int intel_runtime_resume(struct device *kdev) |
Paulo Zanoni | 8a18745 | 2013-12-06 20:32:13 -0200 | [diff] [blame] | 1661 | { |
Chris Wilson | 361f9dc | 2019-08-06 08:42:19 +0100 | [diff] [blame] | 1662 | struct drm_i915_private *dev_priv = kdev_to_i915(kdev); |
Daniele Ceraolo Spurio | 1bf676c | 2019-06-13 16:21:52 -0700 | [diff] [blame] | 1663 | struct intel_runtime_pm *rpm = &dev_priv->runtime_pm; |
Jani Nikula | fb5f432 | 2020-02-12 16:40:57 +0200 | [diff] [blame] | 1664 | int ret; |
Paulo Zanoni | 8a18745 | 2013-12-06 20:32:13 -0200 | [diff] [blame] | 1665 | |
Pankaj Bharadiya | 48a1b8d | 2020-01-15 09:14:53 +0530 | [diff] [blame] | 1666 | if (drm_WARN_ON_ONCE(&dev_priv->drm, !HAS_RUNTIME_PM(dev_priv))) |
Imre Deak | 604effb | 2014-08-26 13:26:56 +0300 | [diff] [blame] | 1667 | return -ENODEV; |
Paulo Zanoni | 8a18745 | 2013-12-06 20:32:13 -0200 | [diff] [blame] | 1668 | |
Wambui Karuga | 00376cc | 2020-01-31 12:34:12 +0300 | [diff] [blame] | 1669 | drm_dbg_kms(&dev_priv->drm, "Resuming device\n"); |
Paulo Zanoni | 8a18745 | 2013-12-06 20:32:13 -0200 | [diff] [blame] | 1670 | |
Pankaj Bharadiya | 48a1b8d | 2020-01-15 09:14:53 +0530 | [diff] [blame] | 1671 | drm_WARN_ON_ONCE(&dev_priv->drm, atomic_read(&rpm->wakeref_count)); |
Daniele Ceraolo Spurio | 9102650 | 2019-06-13 16:21:51 -0700 | [diff] [blame] | 1672 | disable_rpm_wakeref_asserts(rpm); |
Imre Deak | 1f814da | 2015-12-16 02:52:19 +0200 | [diff] [blame] | 1673 | |
Chris Wilson | 6f9f4b7 | 2016-05-23 15:08:09 +0100 | [diff] [blame] | 1674 | intel_opregion_notify_adapter(dev_priv, PCI_D0); |
Daniele Ceraolo Spurio | 9102650 | 2019-06-13 16:21:51 -0700 | [diff] [blame] | 1675 | rpm->suspended = false; |
Daniele Ceraolo Spurio | 2cf7bf6 | 2019-03-25 14:49:34 -0700 | [diff] [blame] | 1676 | if (intel_uncore_unclaimed_mmio(&dev_priv->uncore)) |
Wambui Karuga | 00376cc | 2020-01-31 12:34:12 +0300 | [diff] [blame] | 1677 | drm_dbg(&dev_priv->drm, |
| 1678 | "Unclaimed access during suspend, bios?\n"); |
Paulo Zanoni | 8a18745 | 2013-12-06 20:32:13 -0200 | [diff] [blame] | 1679 | |
Rodrigo Vivi | 071b68c | 2019-08-06 15:22:08 +0300 | [diff] [blame] | 1680 | intel_display_power_resume(dev_priv); |
| 1681 | |
Jani Nikula | fb5f432 | 2020-02-12 16:40:57 +0200 | [diff] [blame] | 1682 | ret = vlv_resume_prepare(dev_priv, true); |
Paulo Zanoni | 1a5df18 | 2014-10-27 17:54:32 -0200 | [diff] [blame] | 1683 | |
Daniele Ceraolo Spurio | f7de502 | 2019-03-19 11:35:37 -0700 | [diff] [blame] | 1684 | intel_uncore_runtime_resume(&dev_priv->uncore); |
Hans de Goede | bedf4d7 | 2017-11-14 14:55:17 +0100 | [diff] [blame] | 1685 | |
Sagar Arun Kamble | 1ed21cb | 2018-01-24 21:16:57 +0530 | [diff] [blame] | 1686 | intel_runtime_pm_enable_interrupts(dev_priv); |
| 1687 | |
Imre Deak | 0ab9cfe | 2014-04-15 16:39:45 +0300 | [diff] [blame] | 1688 | /* |
| 1689 | * No point of rolling back things in case of an error, as the best |
| 1690 | * we can do is to hope that things will still work (and disable RPM). |
| 1691 | */ |
Daniele Ceraolo Spurio | 9dfe345 | 2019-07-31 17:57:09 -0700 | [diff] [blame] | 1692 | intel_gt_runtime_resume(&dev_priv->gt); |
Chris Wilson | e9d4c92 | 2019-10-16 15:32:33 +0100 | [diff] [blame] | 1693 | i915_gem_restore_fences(&dev_priv->ggtt); |
Imre Deak | 92b806d | 2014-04-14 20:24:39 +0300 | [diff] [blame] | 1694 | |
Ville Syrjälä | 08d8a23 | 2015-08-27 23:56:08 +0300 | [diff] [blame] | 1695 | /* |
| 1696 | * On VLV/CHV display interrupts are part of the display |
| 1697 | * power well, so hpd is reinitialized from there. For |
| 1698 | * everyone else do it here. |
| 1699 | */ |
Wayne Boyer | 666a453 | 2015-12-09 12:29:35 -0800 | [diff] [blame] | 1700 | if (!IS_VALLEYVIEW(dev_priv) && !IS_CHERRYVIEW(dev_priv)) |
Ville Syrjälä | 08d8a23 | 2015-08-27 23:56:08 +0300 | [diff] [blame] | 1701 | intel_hpd_init(dev_priv); |
| 1702 | |
Kumar, Mahesh | 2503a0f | 2017-08-17 19:15:28 +0530 | [diff] [blame] | 1703 | intel_enable_ipc(dev_priv); |
| 1704 | |
Daniele Ceraolo Spurio | 9102650 | 2019-06-13 16:21:51 -0700 | [diff] [blame] | 1705 | enable_rpm_wakeref_asserts(rpm); |
Imre Deak | 1f814da | 2015-12-16 02:52:19 +0200 | [diff] [blame] | 1706 | |
Imre Deak | 0ab9cfe | 2014-04-15 16:39:45 +0300 | [diff] [blame] | 1707 | if (ret) |
Wambui Karuga | 00376cc | 2020-01-31 12:34:12 +0300 | [diff] [blame] | 1708 | drm_err(&dev_priv->drm, |
| 1709 | "Runtime resume failed, disabling it (%d)\n", ret); |
Imre Deak | 0ab9cfe | 2014-04-15 16:39:45 +0300 | [diff] [blame] | 1710 | else |
Wambui Karuga | 00376cc | 2020-01-31 12:34:12 +0300 | [diff] [blame] | 1711 | drm_dbg_kms(&dev_priv->drm, "Device resumed\n"); |
Imre Deak | 0ab9cfe | 2014-04-15 16:39:45 +0300 | [diff] [blame] | 1712 | |
| 1713 | return ret; |
Paulo Zanoni | 8a18745 | 2013-12-06 20:32:13 -0200 | [diff] [blame] | 1714 | } |
| 1715 | |
Chris Wilson | 42f5551 | 2016-06-24 14:00:26 +0100 | [diff] [blame] | 1716 | const struct dev_pm_ops i915_pm_ops = { |
Imre Deak | 5545dbb | 2014-10-23 19:23:28 +0300 | [diff] [blame] | 1717 | /* |
| 1718 | * S0ix (via system suspend) and S3 event handlers [PMSG_SUSPEND, |
| 1719 | * PMSG_RESUME] |
| 1720 | */ |
Chris Wilson | 73b66f8 | 2018-05-25 10:26:29 +0100 | [diff] [blame] | 1721 | .prepare = i915_pm_prepare, |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 1722 | .suspend = i915_pm_suspend, |
Imre Deak | 76c4b25 | 2014-04-01 19:55:22 +0300 | [diff] [blame] | 1723 | .suspend_late = i915_pm_suspend_late, |
| 1724 | .resume_early = i915_pm_resume_early, |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 1725 | .resume = i915_pm_resume, |
Imre Deak | 5545dbb | 2014-10-23 19:23:28 +0300 | [diff] [blame] | 1726 | |
| 1727 | /* |
| 1728 | * S4 event handlers |
| 1729 | * @freeze, @freeze_late : called (1) before creating the |
| 1730 | * hibernation image [PMSG_FREEZE] and |
| 1731 | * (2) after rebooting, before restoring |
| 1732 | * the image [PMSG_QUIESCE] |
| 1733 | * @thaw, @thaw_early : called (1) after creating the hibernation |
| 1734 | * image, before writing it [PMSG_THAW] |
| 1735 | * and (2) after failing to create or |
| 1736 | * restore the image [PMSG_RECOVER] |
| 1737 | * @poweroff, @poweroff_late: called after writing the hibernation |
| 1738 | * image, before rebooting [PMSG_HIBERNATE] |
| 1739 | * @restore, @restore_early : called after rebooting and restoring the |
| 1740 | * hibernation image [PMSG_RESTORE] |
| 1741 | */ |
Chris Wilson | 1f19ac2 | 2016-05-14 07:26:32 +0100 | [diff] [blame] | 1742 | .freeze = i915_pm_freeze, |
| 1743 | .freeze_late = i915_pm_freeze_late, |
| 1744 | .thaw_early = i915_pm_thaw_early, |
| 1745 | .thaw = i915_pm_thaw, |
Imre Deak | 36d61e6 | 2014-10-23 19:23:24 +0300 | [diff] [blame] | 1746 | .poweroff = i915_pm_suspend, |
Imre Deak | ab3be73 | 2015-03-02 13:04:41 +0200 | [diff] [blame] | 1747 | .poweroff_late = i915_pm_poweroff_late, |
Chris Wilson | 1f19ac2 | 2016-05-14 07:26:32 +0100 | [diff] [blame] | 1748 | .restore_early = i915_pm_restore_early, |
| 1749 | .restore = i915_pm_restore, |
Imre Deak | 5545dbb | 2014-10-23 19:23:28 +0300 | [diff] [blame] | 1750 | |
| 1751 | /* S0ix (via runtime suspend) event handlers */ |
Paulo Zanoni | 97bea20 | 2014-03-07 20:12:33 -0300 | [diff] [blame] | 1752 | .runtime_suspend = intel_runtime_suspend, |
| 1753 | .runtime_resume = intel_runtime_resume, |
Zhenyu Wang | cbda12d | 2009-12-16 13:36:10 +0800 | [diff] [blame] | 1754 | }; |
| 1755 | |
Arjan van de Ven | e08e96d | 2011-10-31 07:28:57 -0700 | [diff] [blame] | 1756 | static const struct file_operations i915_driver_fops = { |
| 1757 | .owner = THIS_MODULE, |
| 1758 | .open = drm_open, |
Chris Wilson | 7a2c65dd | 2020-01-24 12:56:26 +0000 | [diff] [blame] | 1759 | .release = drm_release_noglobal, |
Arjan van de Ven | e08e96d | 2011-10-31 07:28:57 -0700 | [diff] [blame] | 1760 | .unlocked_ioctl = drm_ioctl, |
Abdiel Janulgue | cc66212 | 2019-12-04 12:00:32 +0000 | [diff] [blame] | 1761 | .mmap = i915_gem_mmap, |
Arjan van de Ven | e08e96d | 2011-10-31 07:28:57 -0700 | [diff] [blame] | 1762 | .poll = drm_poll, |
Arjan van de Ven | e08e96d | 2011-10-31 07:28:57 -0700 | [diff] [blame] | 1763 | .read = drm_read, |
Arjan van de Ven | e08e96d | 2011-10-31 07:28:57 -0700 | [diff] [blame] | 1764 | .compat_ioctl = i915_compat_ioctl, |
Arjan van de Ven | e08e96d | 2011-10-31 07:28:57 -0700 | [diff] [blame] | 1765 | .llseek = noop_llseek, |
| 1766 | }; |
| 1767 | |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 1768 | static int |
| 1769 | i915_gem_reject_pin_ioctl(struct drm_device *dev, void *data, |
| 1770 | struct drm_file *file) |
| 1771 | { |
| 1772 | return -ENODEV; |
| 1773 | } |
| 1774 | |
| 1775 | static const struct drm_ioctl_desc i915_ioctls[] = { |
| 1776 | DRM_IOCTL_DEF_DRV(I915_INIT, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 1777 | DRM_IOCTL_DEF_DRV(I915_FLUSH, drm_noop, DRM_AUTH), |
| 1778 | DRM_IOCTL_DEF_DRV(I915_FLIP, drm_noop, DRM_AUTH), |
| 1779 | DRM_IOCTL_DEF_DRV(I915_BATCHBUFFER, drm_noop, DRM_AUTH), |
| 1780 | DRM_IOCTL_DEF_DRV(I915_IRQ_EMIT, drm_noop, DRM_AUTH), |
| 1781 | DRM_IOCTL_DEF_DRV(I915_IRQ_WAIT, drm_noop, DRM_AUTH), |
Christian König | b972fff | 2019-04-17 13:25:24 +0200 | [diff] [blame] | 1782 | DRM_IOCTL_DEF_DRV(I915_GETPARAM, i915_getparam_ioctl, DRM_RENDER_ALLOW), |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 1783 | DRM_IOCTL_DEF_DRV(I915_SETPARAM, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 1784 | DRM_IOCTL_DEF_DRV(I915_ALLOC, drm_noop, DRM_AUTH), |
| 1785 | DRM_IOCTL_DEF_DRV(I915_FREE, drm_noop, DRM_AUTH), |
| 1786 | DRM_IOCTL_DEF_DRV(I915_INIT_HEAP, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 1787 | DRM_IOCTL_DEF_DRV(I915_CMDBUFFER, drm_noop, DRM_AUTH), |
| 1788 | DRM_IOCTL_DEF_DRV(I915_DESTROY_HEAP, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 1789 | DRM_IOCTL_DEF_DRV(I915_SET_VBLANK_PIPE, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 1790 | DRM_IOCTL_DEF_DRV(I915_GET_VBLANK_PIPE, drm_noop, DRM_AUTH), |
| 1791 | DRM_IOCTL_DEF_DRV(I915_VBLANK_SWAP, drm_noop, DRM_AUTH), |
| 1792 | DRM_IOCTL_DEF_DRV(I915_HWS_ADDR, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 1793 | DRM_IOCTL_DEF_DRV(I915_GEM_INIT, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
Ville Syrjälä | 6a20fe7 | 2018-02-07 18:48:41 +0200 | [diff] [blame] | 1794 | DRM_IOCTL_DEF_DRV(I915_GEM_EXECBUFFER, i915_gem_execbuffer_ioctl, DRM_AUTH), |
Christian König | b972fff | 2019-04-17 13:25:24 +0200 | [diff] [blame] | 1795 | DRM_IOCTL_DEF_DRV(I915_GEM_EXECBUFFER2_WR, i915_gem_execbuffer2_ioctl, DRM_RENDER_ALLOW), |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 1796 | DRM_IOCTL_DEF_DRV(I915_GEM_PIN, i915_gem_reject_pin_ioctl, DRM_AUTH|DRM_ROOT_ONLY), |
| 1797 | DRM_IOCTL_DEF_DRV(I915_GEM_UNPIN, i915_gem_reject_pin_ioctl, DRM_AUTH|DRM_ROOT_ONLY), |
Christian König | b972fff | 2019-04-17 13:25:24 +0200 | [diff] [blame] | 1798 | DRM_IOCTL_DEF_DRV(I915_GEM_BUSY, i915_gem_busy_ioctl, DRM_RENDER_ALLOW), |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 1799 | DRM_IOCTL_DEF_DRV(I915_GEM_SET_CACHING, i915_gem_set_caching_ioctl, DRM_RENDER_ALLOW), |
| 1800 | DRM_IOCTL_DEF_DRV(I915_GEM_GET_CACHING, i915_gem_get_caching_ioctl, DRM_RENDER_ALLOW), |
Christian König | b972fff | 2019-04-17 13:25:24 +0200 | [diff] [blame] | 1801 | DRM_IOCTL_DEF_DRV(I915_GEM_THROTTLE, i915_gem_throttle_ioctl, DRM_RENDER_ALLOW), |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 1802 | DRM_IOCTL_DEF_DRV(I915_GEM_ENTERVT, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 1803 | DRM_IOCTL_DEF_DRV(I915_GEM_LEAVEVT, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 1804 | DRM_IOCTL_DEF_DRV(I915_GEM_CREATE, i915_gem_create_ioctl, DRM_RENDER_ALLOW), |
| 1805 | DRM_IOCTL_DEF_DRV(I915_GEM_PREAD, i915_gem_pread_ioctl, DRM_RENDER_ALLOW), |
| 1806 | DRM_IOCTL_DEF_DRV(I915_GEM_PWRITE, i915_gem_pwrite_ioctl, DRM_RENDER_ALLOW), |
| 1807 | DRM_IOCTL_DEF_DRV(I915_GEM_MMAP, i915_gem_mmap_ioctl, DRM_RENDER_ALLOW), |
Abdiel Janulgue | cc66212 | 2019-12-04 12:00:32 +0000 | [diff] [blame] | 1808 | DRM_IOCTL_DEF_DRV(I915_GEM_MMAP_OFFSET, i915_gem_mmap_offset_ioctl, DRM_RENDER_ALLOW), |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 1809 | DRM_IOCTL_DEF_DRV(I915_GEM_SET_DOMAIN, i915_gem_set_domain_ioctl, DRM_RENDER_ALLOW), |
| 1810 | DRM_IOCTL_DEF_DRV(I915_GEM_SW_FINISH, i915_gem_sw_finish_ioctl, DRM_RENDER_ALLOW), |
Chris Wilson | 111dbca | 2017-01-10 12:10:44 +0000 | [diff] [blame] | 1811 | DRM_IOCTL_DEF_DRV(I915_GEM_SET_TILING, i915_gem_set_tiling_ioctl, DRM_RENDER_ALLOW), |
| 1812 | DRM_IOCTL_DEF_DRV(I915_GEM_GET_TILING, i915_gem_get_tiling_ioctl, DRM_RENDER_ALLOW), |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 1813 | DRM_IOCTL_DEF_DRV(I915_GEM_GET_APERTURE, i915_gem_get_aperture_ioctl, DRM_RENDER_ALLOW), |
Ville Syrjälä | 6a20fe7 | 2018-02-07 18:48:41 +0200 | [diff] [blame] | 1814 | DRM_IOCTL_DEF_DRV(I915_GET_PIPE_FROM_CRTC_ID, intel_get_pipe_from_crtc_id_ioctl, 0), |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 1815 | DRM_IOCTL_DEF_DRV(I915_GEM_MADVISE, i915_gem_madvise_ioctl, DRM_RENDER_ALLOW), |
Daniel Vetter | 0cd54b0 | 2018-04-20 08:51:57 +0200 | [diff] [blame] | 1816 | DRM_IOCTL_DEF_DRV(I915_OVERLAY_PUT_IMAGE, intel_overlay_put_image_ioctl, DRM_MASTER), |
| 1817 | DRM_IOCTL_DEF_DRV(I915_OVERLAY_ATTRS, intel_overlay_attrs_ioctl, DRM_MASTER), |
| 1818 | DRM_IOCTL_DEF_DRV(I915_SET_SPRITE_COLORKEY, intel_sprite_set_colorkey_ioctl, DRM_MASTER), |
| 1819 | DRM_IOCTL_DEF_DRV(I915_GET_SPRITE_COLORKEY, drm_noop, DRM_MASTER), |
Christian König | b972fff | 2019-04-17 13:25:24 +0200 | [diff] [blame] | 1820 | DRM_IOCTL_DEF_DRV(I915_GEM_WAIT, i915_gem_wait_ioctl, DRM_RENDER_ALLOW), |
Chris Wilson | b917154 | 2019-03-22 09:23:24 +0000 | [diff] [blame] | 1821 | DRM_IOCTL_DEF_DRV(I915_GEM_CONTEXT_CREATE_EXT, i915_gem_context_create_ioctl, DRM_RENDER_ALLOW), |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 1822 | DRM_IOCTL_DEF_DRV(I915_GEM_CONTEXT_DESTROY, i915_gem_context_destroy_ioctl, DRM_RENDER_ALLOW), |
| 1823 | DRM_IOCTL_DEF_DRV(I915_REG_READ, i915_reg_read_ioctl, DRM_RENDER_ALLOW), |
| 1824 | DRM_IOCTL_DEF_DRV(I915_GET_RESET_STATS, i915_gem_context_reset_stats_ioctl, DRM_RENDER_ALLOW), |
| 1825 | DRM_IOCTL_DEF_DRV(I915_GEM_USERPTR, i915_gem_userptr_ioctl, DRM_RENDER_ALLOW), |
| 1826 | DRM_IOCTL_DEF_DRV(I915_GEM_CONTEXT_GETPARAM, i915_gem_context_getparam_ioctl, DRM_RENDER_ALLOW), |
| 1827 | DRM_IOCTL_DEF_DRV(I915_GEM_CONTEXT_SETPARAM, i915_gem_context_setparam_ioctl, DRM_RENDER_ALLOW), |
Robert Bragg | eec688e | 2016-11-07 19:49:47 +0000 | [diff] [blame] | 1828 | DRM_IOCTL_DEF_DRV(I915_PERF_OPEN, i915_perf_open_ioctl, DRM_RENDER_ALLOW), |
Emil Velikov | b4023756 | 2019-05-22 16:47:01 +0100 | [diff] [blame] | 1829 | DRM_IOCTL_DEF_DRV(I915_PERF_ADD_CONFIG, i915_perf_add_config_ioctl, DRM_RENDER_ALLOW), |
| 1830 | DRM_IOCTL_DEF_DRV(I915_PERF_REMOVE_CONFIG, i915_perf_remove_config_ioctl, DRM_RENDER_ALLOW), |
| 1831 | DRM_IOCTL_DEF_DRV(I915_QUERY, i915_query_ioctl, DRM_RENDER_ALLOW), |
Chris Wilson | 7f3f317a | 2019-05-21 22:11:25 +0100 | [diff] [blame] | 1832 | DRM_IOCTL_DEF_DRV(I915_GEM_VM_CREATE, i915_gem_vm_create_ioctl, DRM_RENDER_ALLOW), |
| 1833 | DRM_IOCTL_DEF_DRV(I915_GEM_VM_DESTROY, i915_gem_vm_destroy_ioctl, DRM_RENDER_ALLOW), |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 1834 | }; |
| 1835 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1836 | static struct drm_driver driver = { |
Michael Witten | 0c54781 | 2011-08-25 17:55:54 +0000 | [diff] [blame] | 1837 | /* Don't use MTRRs here; the Xserver or userspace app should |
| 1838 | * deal with them for Intel hardware. |
Dave Airlie | 792d2b9 | 2005-11-11 23:30:27 +1100 | [diff] [blame] | 1839 | */ |
Eric Anholt | 673a394 | 2008-07-30 12:06:12 -0700 | [diff] [blame] | 1840 | .driver_features = |
Daniel Vetter | 0424fda | 2019-06-17 17:39:24 +0200 | [diff] [blame] | 1841 | DRIVER_GEM | |
Jason Ekstrand | cf6e7ba | 2017-08-15 15:57:33 +0100 | [diff] [blame] | 1842 | DRIVER_RENDER | DRIVER_MODESET | DRIVER_ATOMIC | DRIVER_SYNCOBJ, |
Chris Wilson | cad3688 | 2017-02-10 16:35:21 +0000 | [diff] [blame] | 1843 | .release = i915_driver_release, |
Eric Anholt | 673a394 | 2008-07-30 12:06:12 -0700 | [diff] [blame] | 1844 | .open = i915_driver_open, |
Dave Airlie | 22eae94 | 2005-11-10 22:16:34 +1100 | [diff] [blame] | 1845 | .lastclose = i915_driver_lastclose, |
Eric Anholt | 673a394 | 2008-07-30 12:06:12 -0700 | [diff] [blame] | 1846 | .postclose = i915_driver_postclose, |
Rafael J. Wysocki | d8e2920 | 2010-01-09 00:45:33 +0100 | [diff] [blame] | 1847 | |
Chris Wilson | b1f788c | 2016-08-04 07:52:45 +0100 | [diff] [blame] | 1848 | .gem_close_object = i915_gem_close_object, |
Chris Wilson | f0cd518 | 2016-10-28 13:58:43 +0100 | [diff] [blame] | 1849 | .gem_free_object_unlocked = i915_gem_free_object, |
Daniel Vetter | 1286ff7 | 2012-05-10 15:25:09 +0200 | [diff] [blame] | 1850 | |
| 1851 | .prime_handle_to_fd = drm_gem_prime_handle_to_fd, |
| 1852 | .prime_fd_to_handle = drm_gem_prime_fd_to_handle, |
| 1853 | .gem_prime_export = i915_gem_prime_export, |
| 1854 | .gem_prime_import = i915_gem_prime_import, |
| 1855 | |
Ville Syrjälä | 7d23e59 | 2019-06-19 20:08:42 +0300 | [diff] [blame] | 1856 | .get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos, |
| 1857 | .get_scanout_position = i915_get_crtc_scanoutpos, |
| 1858 | |
Dave Airlie | ff72145b | 2011-02-07 12:16:14 +1000 | [diff] [blame] | 1859 | .dumb_create = i915_gem_dumb_create, |
Abdiel Janulgue | cc66212 | 2019-12-04 12:00:32 +0000 | [diff] [blame] | 1860 | .dumb_map_offset = i915_gem_dumb_mmap_offset, |
| 1861 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1862 | .ioctls = i915_ioctls, |
Chris Wilson | 0673ad4 | 2016-06-24 14:00:22 +0100 | [diff] [blame] | 1863 | .num_ioctls = ARRAY_SIZE(i915_ioctls), |
Arjan van de Ven | e08e96d | 2011-10-31 07:28:57 -0700 | [diff] [blame] | 1864 | .fops = &i915_driver_fops, |
Dave Airlie | 22eae94 | 2005-11-10 22:16:34 +1100 | [diff] [blame] | 1865 | .name = DRIVER_NAME, |
| 1866 | .desc = DRIVER_DESC, |
| 1867 | .date = DRIVER_DATE, |
| 1868 | .major = DRIVER_MAJOR, |
| 1869 | .minor = DRIVER_MINOR, |
| 1870 | .patchlevel = DRIVER_PATCHLEVEL, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1871 | }; |