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