Rev 3746 | Rev 4126 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2325 | Serge | 1 | /* i915_drv.c -- i830,i845,i855,i865,i915 driver -*- linux-c -*- |
2 | */ |
||
3 | /* |
||
4 | * |
||
5 | * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. |
||
6 | * All Rights Reserved. |
||
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 | * |
||
28 | */ |
||
29 | |||
2330 | Serge | 30 | //#include |
3031 | serge | 31 | #include |
32 | #include |
||
2330 | Serge | 33 | #include "i915_drv.h" |
34 | #include "intel_drv.h" |
||
2325 | Serge | 35 | |
36 | #include |
||
37 | #include |
||
38 | #include |
||
39 | #include |
||
40 | #include |
||
41 | |||
3031 | serge | 42 | #include |
43 | |||
2325 | Serge | 44 | #include |
45 | |||
2330 | Serge | 46 | #define __read_mostly |
2327 | Serge | 47 | |
2338 | Serge | 48 | int init_display_kms(struct drm_device *dev); |
2330 | Serge | 49 | |
3031 | serge | 50 | static int i915_modeset __read_mostly = 1; |
3480 | Serge | 51 | module_param_named(modeset, i915_modeset, int, 0400); |
3031 | serge | 52 | MODULE_PARM_DESC(modeset, |
53 | "Use kernel modesetting [KMS] (0=DRM_I915_KMS from .config, " |
||
54 | "1=on, -1=force vga console preference [default])"); |
||
55 | |||
3746 | Serge | 56 | unsigned int i915_fbpercrtc __always_unused = 0; |
57 | module_param_named(fbpercrtc, i915_fbpercrtc, int, 0400); |
||
3031 | serge | 58 | |
3480 | Serge | 59 | int i915_panel_ignore_lid __read_mostly = 1; |
60 | module_param_named(panel_ignore_lid, i915_panel_ignore_lid, int, 0600); |
||
3031 | serge | 61 | MODULE_PARM_DESC(panel_ignore_lid, |
3480 | Serge | 62 | "Override lid status (0=autodetect, 1=autodetect disabled [default], " |
63 | "-1=force lid closed, -2=force lid open)"); |
||
2330 | Serge | 64 | |
3482 | Serge | 65 | unsigned int i915_powersave __read_mostly = 1; |
3480 | Serge | 66 | module_param_named(powersave, i915_powersave, int, 0600); |
3031 | serge | 67 | MODULE_PARM_DESC(powersave, |
68 | "Enable powersavings, fbc, downclocking, etc. (default: true)"); |
||
2330 | Serge | 69 | |
3031 | serge | 70 | int i915_semaphores __read_mostly = -1; |
3480 | Serge | 71 | module_param_named(semaphores, i915_semaphores, int, 0600); |
3031 | serge | 72 | MODULE_PARM_DESC(semaphores, |
73 | "Use semaphores for inter-ring sync (default: -1 (use per-chip defaults))"); |
||
2330 | Serge | 74 | |
3482 | Serge | 75 | int i915_enable_rc6 __read_mostly = -1; |
3480 | Serge | 76 | module_param_named(i915_enable_rc6, i915_enable_rc6, int, 0400); |
3031 | serge | 77 | MODULE_PARM_DESC(i915_enable_rc6, |
78 | "Enable power-saving render C-state 6. " |
||
79 | "Different stages can be selected via bitmask values " |
||
80 | "(0 = disable; 1 = enable rc6; 2 = enable deep rc6; 4 = enable deepest rc6). " |
||
81 | "For example, 3 would enable rc6 and deep rc6, and 7 would enable everything. " |
||
82 | "default: -1 (use per-chip default)"); |
||
83 | |||
3482 | Serge | 84 | int i915_enable_fbc __read_mostly = -1; |
3480 | Serge | 85 | module_param_named(i915_enable_fbc, i915_enable_fbc, int, 0600); |
3031 | serge | 86 | MODULE_PARM_DESC(i915_enable_fbc, |
87 | "Enable frame buffer compression for power savings " |
||
88 | "(default: -1 (use per-chip default))"); |
||
89 | |||
2330 | Serge | 90 | unsigned int i915_lvds_downclock __read_mostly = 0; |
3480 | Serge | 91 | module_param_named(lvds_downclock, i915_lvds_downclock, int, 0400); |
3031 | serge | 92 | MODULE_PARM_DESC(lvds_downclock, |
93 | "Use panel (LVDS/eDP) downclocking for power savings " |
||
94 | "(default: false)"); |
||
2330 | Serge | 95 | |
3031 | serge | 96 | int i915_lvds_channel_mode __read_mostly; |
3480 | Serge | 97 | module_param_named(lvds_channel_mode, i915_lvds_channel_mode, int, 0600); |
3031 | serge | 98 | MODULE_PARM_DESC(lvds_channel_mode, |
99 | "Specify LVDS channel mode " |
||
100 | "(0=probe BIOS [default], 1=single-channel, 2=dual-channel)"); |
||
2330 | Serge | 101 | |
3031 | serge | 102 | int i915_panel_use_ssc __read_mostly = -1; |
3480 | Serge | 103 | module_param_named(lvds_use_ssc, i915_panel_use_ssc, int, 0600); |
3031 | serge | 104 | MODULE_PARM_DESC(lvds_use_ssc, |
105 | "Use Spread Spectrum Clock with panels [LVDS/eDP] " |
||
106 | "(default: auto from VBT)"); |
||
107 | |||
2332 | Serge | 108 | int i915_vbt_sdvo_panel_type __read_mostly = -1; |
3480 | Serge | 109 | module_param_named(vbt_sdvo_panel_type, i915_vbt_sdvo_panel_type, int, 0600); |
3031 | serge | 110 | MODULE_PARM_DESC(vbt_sdvo_panel_type, |
111 | "Override/Ignore selection of SDVO panel mode in the VBT " |
||
112 | "(-2=ignore, -1=auto [default], index in VBT BIOS table)"); |
||
2330 | Serge | 113 | |
3031 | serge | 114 | static bool i915_try_reset __read_mostly = true; |
3480 | Serge | 115 | module_param_named(reset, i915_try_reset, bool, 0600); |
3031 | serge | 116 | MODULE_PARM_DESC(reset, "Attempt GPU resets (default: true)"); |
117 | |||
118 | bool i915_enable_hangcheck __read_mostly = false; |
||
3480 | Serge | 119 | module_param_named(enable_hangcheck, i915_enable_hangcheck, bool, 0644); |
3031 | serge | 120 | MODULE_PARM_DESC(enable_hangcheck, |
121 | "Periodically check GPU activity for detecting hangs. " |
||
122 | "WARNING: Disabling this can cause system wide hangs. " |
||
123 | "(default: true)"); |
||
124 | |||
3746 | Serge | 125 | int i915_enable_ppgtt __read_mostly = 0; |
3480 | Serge | 126 | module_param_named(i915_enable_ppgtt, i915_enable_ppgtt, int, 0600); |
3031 | serge | 127 | MODULE_PARM_DESC(i915_enable_ppgtt, |
128 | "Enable PPGTT (default: true)"); |
||
129 | |||
4104 | Serge | 130 | int i915_enable_psr __read_mostly = 0; |
131 | module_param_named(enable_psr, i915_enable_psr, int, 0600); |
||
132 | MODULE_PARM_DESC(enable_psr, "Enable PSR (default: false)"); |
||
133 | |||
134 | unsigned int i915_preliminary_hw_support __read_mostly = IS_ENABLED(CONFIG_DRM_I915_PRELIMINARY_HW_SUPPORT); |
||
3480 | Serge | 135 | module_param_named(preliminary_hw_support, i915_preliminary_hw_support, int, 0600); |
3031 | serge | 136 | MODULE_PARM_DESC(preliminary_hw_support, |
4104 | Serge | 137 | "Enable preliminary hardware support."); |
3031 | serge | 138 | |
3482 | Serge | 139 | int i915_disable_power_well __read_mostly = 0; |
140 | module_param_named(disable_power_well, i915_disable_power_well, int, 0600); |
||
141 | MODULE_PARM_DESC(disable_power_well, |
||
4104 | Serge | 142 | "Disable the power well when possible (default: true)"); |
3031 | serge | 143 | |
4104 | Serge | 144 | int i915_enable_ips __read_mostly = 1; |
145 | module_param_named(enable_ips, i915_enable_ips, int, 0600); |
||
146 | MODULE_PARM_DESC(enable_ips, "Enable IPS (default: true)"); |
||
147 | |||
148 | bool i915_fastboot __read_mostly = 0; |
||
149 | module_param_named(fastboot, i915_fastboot, bool, 0600); |
||
150 | MODULE_PARM_DESC(fastboot, "Try to skip unnecessary mode sets at boot time " |
||
151 | "(default: false)"); |
||
152 | |||
153 | int i915_enable_pc8 __read_mostly = 0; |
||
154 | module_param_named(enable_pc8, i915_enable_pc8, int, 0600); |
||
155 | MODULE_PARM_DESC(enable_pc8, "Enable support for low power package C states (PC8+) (default: true)"); |
||
156 | |||
157 | int i915_pc8_timeout __read_mostly = 5000; |
||
158 | module_param_named(pc8_timeout, i915_pc8_timeout, int, 0600); |
||
159 | MODULE_PARM_DESC(pc8_timeout, "Number of msecs of idleness required to enter PC8+ (default: 5000)"); |
||
160 | |||
161 | bool i915_prefault_disable __read_mostly; |
||
162 | module_param_named(prefault_disable, i915_prefault_disable, bool, 0600); |
||
163 | MODULE_PARM_DESC(prefault_disable, |
||
164 | "Disable page prefaulting for pread/pwrite/reloc (default:false). For developers only."); |
||
165 | |||
166 | static struct drm_driver driver; |
||
167 | extern int intel_agp_enabled; |
||
168 | |||
2326 | Serge | 169 | #define PCI_VENDOR_ID_INTEL 0x8086 |
170 | |||
2325 | Serge | 171 | |
2339 | Serge | 172 | static const struct intel_device_info intel_i915g_info = { |
3746 | Serge | 173 | .gen = 3, .is_i915g = 1, .cursor_needs_physical = 1, .num_pipes = 2, |
2339 | Serge | 174 | .has_overlay = 1, .overlay_needs_physical = 1, |
175 | }; |
||
176 | static const struct intel_device_info intel_i915gm_info = { |
||
3746 | Serge | 177 | .gen = 3, .is_mobile = 1, .num_pipes = 2, |
2339 | Serge | 178 | .cursor_needs_physical = 1, |
179 | .has_overlay = 1, .overlay_needs_physical = 1, |
||
180 | .supports_tv = 1, |
||
181 | }; |
||
182 | static const struct intel_device_info intel_i945g_info = { |
||
3746 | Serge | 183 | .gen = 3, .has_hotplug = 1, .cursor_needs_physical = 1, .num_pipes = 2, |
2339 | Serge | 184 | .has_overlay = 1, .overlay_needs_physical = 1, |
185 | }; |
||
186 | static const struct intel_device_info intel_i945gm_info = { |
||
3746 | Serge | 187 | .gen = 3, .is_i945gm = 1, .is_mobile = 1, .num_pipes = 2, |
2339 | Serge | 188 | .has_hotplug = 1, .cursor_needs_physical = 1, |
189 | .has_overlay = 1, .overlay_needs_physical = 1, |
||
190 | .supports_tv = 1, |
||
191 | }; |
||
192 | |||
193 | static const struct intel_device_info intel_i965g_info = { |
||
3746 | Serge | 194 | .gen = 4, .is_broadwater = 1, .num_pipes = 2, |
2339 | Serge | 195 | .has_hotplug = 1, |
196 | .has_overlay = 1, |
||
197 | }; |
||
198 | |||
199 | static const struct intel_device_info intel_i965gm_info = { |
||
3746 | Serge | 200 | .gen = 4, .is_crestline = 1, .num_pipes = 2, |
2339 | Serge | 201 | .is_mobile = 1, .has_fbc = 1, .has_hotplug = 1, |
202 | .has_overlay = 1, |
||
203 | .supports_tv = 1, |
||
204 | }; |
||
205 | |||
206 | static const struct intel_device_info intel_g33_info = { |
||
3746 | Serge | 207 | .gen = 3, .is_g33 = 1, .num_pipes = 2, |
2339 | Serge | 208 | .need_gfx_hws = 1, .has_hotplug = 1, |
209 | .has_overlay = 1, |
||
210 | }; |
||
211 | |||
212 | static const struct intel_device_info intel_g45_info = { |
||
3746 | Serge | 213 | .gen = 4, .is_g4x = 1, .need_gfx_hws = 1, .num_pipes = 2, |
2339 | Serge | 214 | .has_pipe_cxsr = 1, .has_hotplug = 1, |
215 | .has_bsd_ring = 1, |
||
216 | }; |
||
217 | |||
218 | static const struct intel_device_info intel_gm45_info = { |
||
3746 | Serge | 219 | .gen = 4, .is_g4x = 1, .num_pipes = 2, |
2339 | Serge | 220 | .is_mobile = 1, .need_gfx_hws = 1, .has_fbc = 1, |
221 | .has_pipe_cxsr = 1, .has_hotplug = 1, |
||
222 | .supports_tv = 1, |
||
223 | .has_bsd_ring = 1, |
||
224 | }; |
||
225 | |||
226 | static const struct intel_device_info intel_pineview_info = { |
||
3746 | Serge | 227 | .gen = 3, .is_g33 = 1, .is_pineview = 1, .is_mobile = 1, .num_pipes = 2, |
2339 | Serge | 228 | .need_gfx_hws = 1, .has_hotplug = 1, |
229 | .has_overlay = 1, |
||
230 | }; |
||
231 | |||
232 | static const struct intel_device_info intel_ironlake_d_info = { |
||
3746 | Serge | 233 | .gen = 5, .num_pipes = 2, |
3031 | serge | 234 | .need_gfx_hws = 1, .has_hotplug = 1, |
2339 | Serge | 235 | .has_bsd_ring = 1, |
236 | }; |
||
237 | |||
238 | static const struct intel_device_info intel_ironlake_m_info = { |
||
3746 | Serge | 239 | .gen = 5, .is_mobile = 1, .num_pipes = 2, |
2339 | Serge | 240 | .need_gfx_hws = 1, .has_hotplug = 1, |
241 | .has_fbc = 1, |
||
242 | .has_bsd_ring = 1, |
||
243 | }; |
||
244 | |||
2325 | Serge | 245 | static const struct intel_device_info intel_sandybridge_d_info = { |
3746 | Serge | 246 | .gen = 6, .num_pipes = 2, |
2330 | Serge | 247 | .need_gfx_hws = 1, .has_hotplug = 1, |
2325 | Serge | 248 | .has_bsd_ring = 1, |
249 | .has_blt_ring = 1, |
||
3031 | serge | 250 | .has_llc = 1, |
251 | .has_force_wake = 1, |
||
2325 | Serge | 252 | }; |
253 | |||
254 | static const struct intel_device_info intel_sandybridge_m_info = { |
||
3746 | Serge | 255 | .gen = 6, .is_mobile = 1, .num_pipes = 2, |
2330 | Serge | 256 | .need_gfx_hws = 1, .has_hotplug = 1, |
2325 | Serge | 257 | .has_fbc = 1, |
258 | .has_bsd_ring = 1, |
||
259 | .has_blt_ring = 1, |
||
3031 | serge | 260 | .has_llc = 1, |
261 | .has_force_wake = 1, |
||
2325 | Serge | 262 | }; |
263 | |||
3746 | Serge | 264 | #define GEN7_FEATURES \ |
265 | .gen = 7, .num_pipes = 3, \ |
||
266 | .need_gfx_hws = 1, .has_hotplug = 1, \ |
||
267 | .has_bsd_ring = 1, \ |
||
268 | .has_blt_ring = 1, \ |
||
269 | .has_llc = 1, \ |
||
270 | .has_force_wake = 1 |
||
271 | |||
2339 | Serge | 272 | static const struct intel_device_info intel_ivybridge_d_info = { |
3746 | Serge | 273 | GEN7_FEATURES, |
274 | .is_ivybridge = 1, |
||
2339 | Serge | 275 | }; |
2325 | Serge | 276 | |
2339 | Serge | 277 | static const struct intel_device_info intel_ivybridge_m_info = { |
3746 | Serge | 278 | GEN7_FEATURES, |
279 | .is_ivybridge = 1, |
||
280 | .is_mobile = 1, |
||
4104 | Serge | 281 | .has_fbc = 1, |
2339 | Serge | 282 | }; |
283 | |||
3746 | Serge | 284 | static const struct intel_device_info intel_ivybridge_q_info = { |
285 | GEN7_FEATURES, |
||
286 | .is_ivybridge = 1, |
||
287 | .num_pipes = 0, /* legal, last one wins */ |
||
288 | }; |
||
289 | |||
3031 | serge | 290 | static const struct intel_device_info intel_valleyview_m_info = { |
3746 | Serge | 291 | GEN7_FEATURES, |
292 | .is_mobile = 1, |
||
293 | .num_pipes = 2, |
||
3031 | serge | 294 | .is_valleyview = 1, |
3480 | Serge | 295 | .display_mmio_offset = VLV_DISPLAY_BASE, |
3746 | Serge | 296 | .has_llc = 0, /* legal, last one wins */ |
3031 | serge | 297 | }; |
298 | |||
299 | static const struct intel_device_info intel_valleyview_d_info = { |
||
3746 | Serge | 300 | GEN7_FEATURES, |
301 | .num_pipes = 2, |
||
3031 | serge | 302 | .is_valleyview = 1, |
3480 | Serge | 303 | .display_mmio_offset = VLV_DISPLAY_BASE, |
3746 | Serge | 304 | .has_llc = 0, /* legal, last one wins */ |
3031 | serge | 305 | }; |
306 | |||
307 | static const struct intel_device_info intel_haswell_d_info = { |
||
3746 | Serge | 308 | GEN7_FEATURES, |
309 | .is_haswell = 1, |
||
4104 | Serge | 310 | .has_ddi = 1, |
311 | .has_fpga_dbg = 1, |
||
312 | .has_vebox_ring = 1, |
||
3031 | serge | 313 | }; |
314 | |||
315 | static const struct intel_device_info intel_haswell_m_info = { |
||
3746 | Serge | 316 | GEN7_FEATURES, |
317 | .is_haswell = 1, |
||
318 | .is_mobile = 1, |
||
4104 | Serge | 319 | .has_ddi = 1, |
320 | .has_fpga_dbg = 1, |
||
321 | .has_fbc = 1, |
||
322 | .has_vebox_ring = 1, |
||
3031 | serge | 323 | }; |
324 | |||
4104 | Serge | 325 | /* |
326 | * Make sure any device matches here are from most specific to most |
||
327 | * general. For example, since the Quanta match is based on the subsystem |
||
328 | * and subvendor IDs, we need it to come before the more general IVB |
||
329 | * PCI ID matches, otherwise we'll use the wrong info struct above. |
||
330 | */ |
||
331 | #define INTEL_PCI_IDS \ |
||
332 | INTEL_I915G_IDS(&intel_i915g_info), \ |
||
333 | INTEL_I915GM_IDS(&intel_i915gm_info), \ |
||
334 | INTEL_I945G_IDS(&intel_i945g_info), \ |
||
335 | INTEL_I945GM_IDS(&intel_i945gm_info), \ |
||
336 | INTEL_I965G_IDS(&intel_i965g_info), \ |
||
337 | INTEL_G33_IDS(&intel_g33_info), \ |
||
338 | INTEL_I965GM_IDS(&intel_i965gm_info), \ |
||
339 | INTEL_GM45_IDS(&intel_gm45_info), \ |
||
340 | INTEL_G45_IDS(&intel_g45_info), \ |
||
341 | INTEL_PINEVIEW_IDS(&intel_pineview_info), \ |
||
342 | INTEL_IRONLAKE_D_IDS(&intel_ironlake_d_info), \ |
||
343 | INTEL_IRONLAKE_M_IDS(&intel_ironlake_m_info), \ |
||
344 | INTEL_SNB_D_IDS(&intel_sandybridge_d_info), \ |
||
345 | INTEL_SNB_M_IDS(&intel_sandybridge_m_info), \ |
||
346 | INTEL_IVB_Q_IDS(&intel_ivybridge_q_info), /* must be first IVB */ \ |
||
347 | INTEL_IVB_M_IDS(&intel_ivybridge_m_info), \ |
||
348 | INTEL_IVB_D_IDS(&intel_ivybridge_d_info), \ |
||
349 | INTEL_HSW_D_IDS(&intel_haswell_d_info), \ |
||
350 | INTEL_HSW_M_IDS(&intel_haswell_m_info), \ |
||
351 | INTEL_VLV_M_IDS(&intel_valleyview_m_info), \ |
||
352 | INTEL_VLV_D_IDS(&intel_valleyview_d_info) |
||
353 | |||
2325 | Serge | 354 | static const struct pci_device_id pciidlist[] = { /* aka */ |
4104 | Serge | 355 | INTEL_PCI_IDS, |
2325 | Serge | 356 | {0, 0, 0} |
357 | }; |
||
358 | |||
2326 | Serge | 359 | #define INTEL_PCH_DEVICE_ID_MASK 0xff00 |
360 | #define INTEL_PCH_IBX_DEVICE_ID_TYPE 0x3b00 |
||
361 | #define INTEL_PCH_CPT_DEVICE_ID_TYPE 0x1c00 |
||
362 | #define INTEL_PCH_PPT_DEVICE_ID_TYPE 0x1e00 |
||
3031 | serge | 363 | #define INTEL_PCH_LPT_DEVICE_ID_TYPE 0x8c00 |
2325 | Serge | 364 | |
2342 | Serge | 365 | void intel_detect_pch(struct drm_device *dev) |
2326 | Serge | 366 | { |
367 | struct drm_i915_private *dev_priv = dev->dev_private; |
||
368 | struct pci_dev *pch; |
||
369 | |||
3746 | Serge | 370 | /* In all current cases, num_pipes is equivalent to the PCH_NOP setting |
371 | * (which really amounts to a PCH but no South Display). |
||
372 | */ |
||
373 | if (INTEL_INFO(dev)->num_pipes == 0) { |
||
374 | dev_priv->pch_type = PCH_NOP; |
||
375 | return; |
||
376 | } |
||
377 | |||
2326 | Serge | 378 | /* |
379 | * The reason to probe ISA bridge instead of Dev31:Fun0 is to |
||
380 | * make graphics device passthrough work easy for VMM, that only |
||
381 | * need to expose ISA bridge to let driver know the real hardware |
||
382 | * underneath. This is a requirement from virtualization team. |
||
4104 | Serge | 383 | * |
384 | * In some virtualized environments (e.g. XEN), there is irrelevant |
||
385 | * ISA bridge in the system. To work reliably, we should scan trhough |
||
386 | * all the ISA bridge devices and check for the first match, instead |
||
387 | * of only checking the first one. |
||
2326 | Serge | 388 | */ |
389 | pch = pci_get_class(PCI_CLASS_BRIDGE_ISA << 8, NULL); |
||
4104 | Serge | 390 | while (pch) { |
391 | struct pci_dev *curr = pch; |
||
2326 | Serge | 392 | if (pch->vendor == PCI_VENDOR_ID_INTEL) { |
3243 | Serge | 393 | unsigned short id; |
2326 | Serge | 394 | id = pch->device & INTEL_PCH_DEVICE_ID_MASK; |
3243 | Serge | 395 | dev_priv->pch_id = id; |
2326 | Serge | 396 | |
397 | if (id == INTEL_PCH_IBX_DEVICE_ID_TYPE) { |
||
398 | dev_priv->pch_type = PCH_IBX; |
||
399 | DRM_DEBUG_KMS("Found Ibex Peak PCH\n"); |
||
3243 | Serge | 400 | WARN_ON(!IS_GEN5(dev)); |
2326 | Serge | 401 | } else if (id == INTEL_PCH_CPT_DEVICE_ID_TYPE) { |
402 | dev_priv->pch_type = PCH_CPT; |
||
403 | DRM_DEBUG_KMS("Found CougarPoint PCH\n"); |
||
3243 | Serge | 404 | WARN_ON(!(IS_GEN6(dev) || IS_IVYBRIDGE(dev))); |
2326 | Serge | 405 | } else if (id == INTEL_PCH_PPT_DEVICE_ID_TYPE) { |
406 | /* PantherPoint is CPT compatible */ |
||
407 | dev_priv->pch_type = PCH_CPT; |
||
408 | DRM_DEBUG_KMS("Found PatherPoint PCH\n"); |
||
3243 | Serge | 409 | WARN_ON(!(IS_GEN6(dev) || IS_IVYBRIDGE(dev))); |
3031 | serge | 410 | } else if (id == INTEL_PCH_LPT_DEVICE_ID_TYPE) { |
411 | dev_priv->pch_type = PCH_LPT; |
||
412 | DRM_DEBUG_KMS("Found LynxPoint PCH\n"); |
||
3243 | Serge | 413 | WARN_ON(!IS_HASWELL(dev)); |
3746 | Serge | 414 | WARN_ON(IS_ULT(dev)); |
3243 | Serge | 415 | } else if (id == INTEL_PCH_LPT_LP_DEVICE_ID_TYPE) { |
416 | dev_priv->pch_type = PCH_LPT; |
||
417 | DRM_DEBUG_KMS("Found LynxPoint LP PCH\n"); |
||
418 | WARN_ON(!IS_HASWELL(dev)); |
||
3746 | Serge | 419 | WARN_ON(!IS_ULT(dev)); |
4104 | Serge | 420 | } else { |
421 | goto check_next; |
||
2326 | Serge | 422 | } |
4104 | Serge | 423 | break; |
2326 | Serge | 424 | } |
4104 | Serge | 425 | check_next: |
426 | pch = pci_get_class(PCI_CLASS_BRIDGE_ISA << 8, curr); |
||
427 | // pci_dev_put(curr); |
||
2326 | Serge | 428 | } |
4104 | Serge | 429 | if (!pch) |
430 | DRM_DEBUG_KMS("No PCH found?\n"); |
||
2326 | Serge | 431 | } |
432 | |||
3031 | serge | 433 | bool i915_semaphore_is_enabled(struct drm_device *dev) |
2326 | Serge | 434 | { |
3031 | serge | 435 | if (INTEL_INFO(dev)->gen < 6) |
436 | return 0; |
||
2326 | Serge | 437 | |
3031 | serge | 438 | if (i915_semaphores >= 0) |
439 | return i915_semaphores; |
||
2326 | Serge | 440 | |
3031 | serge | 441 | #ifdef CONFIG_INTEL_IOMMU |
442 | /* Enable semaphores on SNB when IO remapping is off */ |
||
443 | if (INTEL_INFO(dev)->gen == 6 && intel_iommu_gfx_mapped) |
||
444 | return false; |
||
445 | #endif |
||
2326 | Serge | 446 | |
3031 | serge | 447 | return 1; |
2326 | Serge | 448 | } |
449 | |||
4104 | Serge | 450 | #if 0 |
451 | static int i915_drm_freeze(struct drm_device *dev) |
||
452 | { |
||
453 | struct drm_i915_private *dev_priv = dev->dev_private; |
||
454 | struct drm_crtc *crtc; |
||
2342 | Serge | 455 | |
4104 | Serge | 456 | /* ignore lid events during suspend */ |
457 | mutex_lock(&dev_priv->modeset_restore_lock); |
||
458 | dev_priv->modeset_restore = MODESET_SUSPENDED; |
||
459 | mutex_unlock(&dev_priv->modeset_restore_lock); |
||
2342 | Serge | 460 | |
4104 | Serge | 461 | /* We do a lot of poking in a lot of registers, make sure they work |
462 | * properly. */ |
||
463 | hsw_disable_package_c8(dev_priv); |
||
464 | intel_set_power_well(dev, true); |
||
2342 | Serge | 465 | |
4104 | Serge | 466 | drm_kms_helper_poll_disable(dev); |
2342 | Serge | 467 | |
4104 | Serge | 468 | pci_save_state(dev->pdev); |
2325 | Serge | 469 | |
4104 | Serge | 470 | /* If KMS is active, we do the leavevt stuff here */ |
471 | if (drm_core_check_feature(dev, DRIVER_MODESET)) { |
||
472 | int error; |
||
473 | |||
474 | mutex_lock(&dev->struct_mutex); |
||
475 | error = i915_gem_idle(dev); |
||
476 | mutex_unlock(&dev->struct_mutex); |
||
477 | if (error) { |
||
478 | dev_err(&dev->pdev->dev, |
||
479 | "GEM idle failed, resume might fail\n"); |
||
480 | return error; |
||
481 | } |
||
482 | |||
483 | cancel_delayed_work_sync(&dev_priv->rps.delayed_resume_work); |
||
484 | |||
485 | drm_irq_uninstall(dev); |
||
486 | dev_priv->enable_hotplug_processing = false; |
||
487 | /* |
||
488 | * Disable CRTCs directly since we want to preserve sw state |
||
489 | * for _thaw. |
||
490 | */ |
||
491 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) |
||
492 | dev_priv->display.crtc_disable(crtc); |
||
493 | |||
494 | intel_modeset_suspend_hw(dev); |
||
495 | } |
||
496 | |||
497 | i915_save_state(dev); |
||
498 | |||
499 | intel_opregion_fini(dev); |
||
500 | |||
501 | console_lock(); |
||
502 | intel_fbdev_set_suspend(dev, FBINFO_STATE_SUSPENDED); |
||
503 | console_unlock(); |
||
504 | |||
505 | return 0; |
||
506 | } |
||
507 | |||
508 | int i915_suspend(struct drm_device *dev, pm_message_t state) |
||
2325 | Serge | 509 | { |
4104 | Serge | 510 | int error; |
2325 | Serge | 511 | |
4104 | Serge | 512 | if (!dev || !dev->dev_private) { |
513 | DRM_ERROR("dev: %p\n", dev); |
||
514 | DRM_ERROR("DRM not initialized, aborting suspend.\n"); |
||
515 | return -ENODEV; |
||
516 | } |
||
2325 | Serge | 517 | |
4104 | Serge | 518 | if (state.event == PM_EVENT_PRETHAW) |
519 | return 0; |
||
3031 | serge | 520 | |
521 | |||
4104 | Serge | 522 | if (dev->switch_power_state == DRM_SWITCH_POWER_OFF) |
523 | return 0; |
||
2325 | Serge | 524 | |
4104 | Serge | 525 | error = i915_drm_freeze(dev); |
526 | if (error) |
||
527 | return error; |
||
3031 | serge | 528 | |
4104 | Serge | 529 | if (state.event == PM_EVENT_SUSPEND) { |
530 | /* Shut down the device */ |
||
531 | pci_disable_device(dev->pdev); |
||
532 | pci_set_power_state(dev->pdev, PCI_D3hot); |
||
533 | } |
||
3031 | serge | 534 | |
4104 | Serge | 535 | return 0; |
536 | } |
||
2325 | Serge | 537 | |
4104 | Serge | 538 | void intel_console_resume(struct work_struct *work) |
539 | { |
||
540 | struct drm_i915_private *dev_priv = |
||
541 | container_of(work, struct drm_i915_private, |
||
542 | console_resume_work); |
||
543 | struct drm_device *dev = dev_priv->dev; |
||
544 | |||
545 | console_lock(); |
||
546 | intel_fbdev_set_suspend(dev, FBINFO_STATE_RUNNING); |
||
547 | console_unlock(); |
||
2325 | Serge | 548 | } |
549 | |||
4104 | Serge | 550 | static void intel_resume_hotplug(struct drm_device *dev) |
551 | { |
||
552 | struct drm_mode_config *mode_config = &dev->mode_config; |
||
553 | struct intel_encoder *encoder; |
||
3260 | Serge | 554 | |
4104 | Serge | 555 | mutex_lock(&mode_config->mutex); |
556 | DRM_DEBUG_KMS("running encoder hotplug functions\n"); |
||
3260 | Serge | 557 | |
4104 | Serge | 558 | list_for_each_entry(encoder, &mode_config->encoder_list, base.head) |
559 | if (encoder->hot_plug) |
||
560 | encoder->hot_plug(encoder); |
||
561 | |||
562 | mutex_unlock(&mode_config->mutex); |
||
563 | |||
564 | /* Just fire off a uevent and let userspace tell us what to do */ |
||
565 | drm_helper_hpd_irq_event(dev); |
||
566 | } |
||
567 | static int __i915_drm_thaw(struct drm_device *dev) |
||
568 | { |
||
569 | struct drm_i915_private *dev_priv = dev->dev_private; |
||
570 | int error = 0; |
||
571 | |||
572 | i915_restore_state(dev); |
||
573 | intel_opregion_setup(dev); |
||
574 | |||
575 | /* KMS EnterVT equivalent */ |
||
576 | if (drm_core_check_feature(dev, DRIVER_MODESET)) { |
||
577 | intel_init_pch_refclk(dev); |
||
578 | |||
579 | mutex_lock(&dev->struct_mutex); |
||
580 | |||
581 | error = i915_gem_init_hw(dev); |
||
582 | mutex_unlock(&dev->struct_mutex); |
||
583 | |||
584 | /* We need working interrupts for modeset enabling ... */ |
||
585 | drm_irq_install(dev); |
||
586 | |||
587 | intel_modeset_init_hw(dev); |
||
588 | |||
589 | drm_modeset_lock_all(dev); |
||
590 | intel_modeset_setup_hw_state(dev, true); |
||
591 | drm_modeset_unlock_all(dev); |
||
592 | |||
593 | /* |
||
594 | * ... but also need to make sure that hotplug processing |
||
595 | * doesn't cause havoc. Like in the driver load code we don't |
||
596 | * bother with the tiny race here where we might loose hotplug |
||
597 | * notifications. |
||
598 | * */ |
||
599 | intel_hpd_init(dev); |
||
600 | dev_priv->enable_hotplug_processing = true; |
||
601 | /* Config may have changed between suspend and resume */ |
||
602 | intel_resume_hotplug(dev); |
||
603 | } |
||
604 | |||
605 | intel_opregion_init(dev); |
||
606 | |||
607 | /* |
||
608 | * The console lock can be pretty contented on resume due |
||
609 | * to all the printk activity. Try to keep it out of the hot |
||
610 | * path of resume if possible. |
||
611 | */ |
||
612 | if (console_trylock()) { |
||
613 | intel_fbdev_set_suspend(dev, FBINFO_STATE_RUNNING); |
||
614 | console_unlock(); |
||
615 | } else { |
||
616 | schedule_work(&dev_priv->console_resume_work); |
||
617 | } |
||
618 | |||
619 | /* Undo what we did at i915_drm_freeze so the refcount goes back to the |
||
620 | * expected level. */ |
||
621 | hsw_enable_package_c8(dev_priv); |
||
622 | |||
623 | mutex_lock(&dev_priv->modeset_restore_lock); |
||
624 | dev_priv->modeset_restore = MODESET_DONE; |
||
625 | mutex_unlock(&dev_priv->modeset_restore_lock); |
||
626 | return error; |
||
627 | } |
||
628 | |||
629 | static int i915_drm_thaw(struct drm_device *dev) |
||
630 | { |
||
631 | int error = 0; |
||
632 | |||
633 | intel_uncore_sanitize(dev); |
||
634 | |||
635 | if (drm_core_check_feature(dev, DRIVER_MODESET)) { |
||
636 | mutex_lock(&dev->struct_mutex); |
||
637 | i915_gem_restore_gtt_mappings(dev); |
||
638 | mutex_unlock(&dev->struct_mutex); |
||
639 | } |
||
640 | |||
641 | __i915_drm_thaw(dev); |
||
642 | |||
643 | return error; |
||
644 | } |
||
645 | |||
646 | int i915_resume(struct drm_device *dev) |
||
647 | { |
||
648 | struct drm_i915_private *dev_priv = dev->dev_private; |
||
649 | int ret; |
||
650 | |||
651 | if (dev->switch_power_state == DRM_SWITCH_POWER_OFF) |
||
652 | return 0; |
||
653 | |||
654 | if (pci_enable_device(dev->pdev)) |
||
655 | return -EIO; |
||
656 | |||
657 | pci_set_master(dev->pdev); |
||
658 | |||
659 | intel_uncore_sanitize(dev); |
||
660 | |||
661 | /* |
||
662 | * Platforms with opregion should have sane BIOS, older ones (gen3 and |
||
663 | * earlier) need this since the BIOS might clear all our scratch PTEs. |
||
664 | */ |
||
665 | if (drm_core_check_feature(dev, DRIVER_MODESET) && |
||
666 | !dev_priv->opregion.header) { |
||
667 | mutex_lock(&dev->struct_mutex); |
||
668 | i915_gem_restore_gtt_mappings(dev); |
||
669 | mutex_unlock(&dev->struct_mutex); |
||
670 | } |
||
671 | |||
672 | ret = __i915_drm_thaw(dev); |
||
673 | if (ret) |
||
674 | return ret; |
||
675 | |||
676 | drm_kms_helper_poll_enable(dev); |
||
677 | return 0; |
||
678 | } |
||
679 | |||
680 | /** |
||
681 | * i915_reset - reset chip after a hang |
||
682 | * @dev: drm device to reset |
||
683 | * |
||
684 | * Reset the chip. Useful if a hang is detected. Returns zero on successful |
||
685 | * reset or otherwise an error code. |
||
686 | * |
||
687 | * Procedure is fairly simple: |
||
688 | * - reset the chip using the reset reg |
||
689 | * - re-init context state |
||
690 | * - re-init hardware status page |
||
691 | * - re-init ring buffer |
||
692 | * - re-init interrupt state |
||
693 | * - re-init display |
||
694 | */ |
||
695 | int i915_reset(struct drm_device *dev) |
||
696 | { |
||
697 | drm_i915_private_t *dev_priv = dev->dev_private; |
||
698 | bool simulated; |
||
699 | int ret; |
||
700 | |||
701 | if (!i915_try_reset) |
||
702 | return 0; |
||
703 | |||
704 | mutex_lock(&dev->struct_mutex); |
||
705 | |||
706 | i915_gem_reset(dev); |
||
707 | |||
708 | simulated = dev_priv->gpu_error.stop_rings != 0; |
||
709 | |||
710 | if (!simulated && get_seconds() - dev_priv->gpu_error.last_reset < 5) { |
||
711 | DRM_ERROR("GPU hanging too fast, declaring wedged!\n"); |
||
712 | ret = -ENODEV; |
||
713 | } else { |
||
714 | ret = intel_gpu_reset(dev); |
||
715 | |||
716 | /* Also reset the gpu hangman. */ |
||
717 | if (simulated) { |
||
718 | DRM_INFO("Simulated gpu hang, resetting stop_rings\n"); |
||
719 | dev_priv->gpu_error.stop_rings = 0; |
||
720 | if (ret == -ENODEV) { |
||
721 | DRM_ERROR("Reset not implemented, but ignoring " |
||
722 | "error for simulated gpu hangs\n"); |
||
723 | ret = 0; |
||
724 | } |
||
725 | } else |
||
726 | dev_priv->gpu_error.last_reset = get_seconds(); |
||
727 | } |
||
728 | if (ret) { |
||
729 | DRM_ERROR("Failed to reset chip.\n"); |
||
730 | mutex_unlock(&dev->struct_mutex); |
||
731 | return ret; |
||
732 | } |
||
733 | |||
734 | /* Ok, now get things going again... */ |
||
735 | |||
736 | /* |
||
737 | * Everything depends on having the GTT running, so we need to start |
||
738 | * there. Fortunately we don't need to do this unless we reset the |
||
739 | * chip at a PCI level. |
||
740 | * |
||
741 | * Next we need to restore the context, but we don't use those |
||
742 | * yet either... |
||
743 | * |
||
744 | * Ring buffer needs to be re-initialized in the KMS case, or if X |
||
745 | * was running at the time of the reset (i.e. we weren't VT |
||
746 | * switched away). |
||
747 | */ |
||
748 | if (drm_core_check_feature(dev, DRIVER_MODESET) || |
||
749 | !dev_priv->ums.mm_suspended) { |
||
750 | struct intel_ring_buffer *ring; |
||
751 | int i; |
||
752 | |||
753 | dev_priv->ums.mm_suspended = 0; |
||
754 | |||
755 | i915_gem_init_swizzling(dev); |
||
756 | |||
757 | for_each_ring(ring, dev_priv, i) |
||
758 | ring->init(ring); |
||
759 | |||
760 | i915_gem_context_init(dev); |
||
761 | if (dev_priv->mm.aliasing_ppgtt) { |
||
762 | ret = dev_priv->mm.aliasing_ppgtt->enable(dev); |
||
763 | if (ret) |
||
764 | i915_gem_cleanup_aliasing_ppgtt(dev); |
||
765 | } |
||
766 | |||
767 | /* |
||
768 | * It would make sense to re-init all the other hw state, at |
||
769 | * least the rps/rc6/emon init done within modeset_init_hw. For |
||
770 | * some unknown reason, this blows up my ilk, so don't. |
||
771 | */ |
||
772 | |||
773 | mutex_unlock(&dev->struct_mutex); |
||
774 | |||
775 | drm_irq_uninstall(dev); |
||
776 | drm_irq_install(dev); |
||
777 | intel_hpd_init(dev); |
||
778 | } else { |
||
779 | mutex_unlock(&dev->struct_mutex); |
||
780 | } |
||
781 | |||
782 | return 0; |
||
783 | } |
||
784 | |||
785 | static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) |
||
786 | { |
||
787 | struct intel_device_info *intel_info = |
||
788 | (struct intel_device_info *) ent->driver_data; |
||
789 | |||
790 | /* Only bind to function 0 of the device. Early generations |
||
791 | * used function 1 as a placeholder for multi-head. This causes |
||
792 | * us confusion instead, especially on the systems where both |
||
793 | * functions have the same PCI-ID! |
||
794 | */ |
||
795 | if (PCI_FUNC(pdev->devfn)) |
||
796 | return -ENODEV; |
||
797 | |||
798 | /* We've managed to ship a kms-enabled ddx that shipped with an XvMC |
||
799 | * implementation for gen3 (and only gen3) that used legacy drm maps |
||
800 | * (gasp!) to share buffers between X and the client. Hence we need to |
||
801 | * keep around the fake agp stuff for gen3, even when kms is enabled. */ |
||
802 | if (intel_info->gen != 3) { |
||
803 | driver.driver_features &= |
||
804 | ~(DRIVER_USE_AGP | DRIVER_REQUIRE_AGP); |
||
805 | } else if (!intel_agp_enabled) { |
||
806 | DRM_ERROR("drm/i915 can't work without intel_agp module!\n"); |
||
807 | return -ENODEV; |
||
808 | } |
||
809 | |||
810 | return drm_get_pci_dev(pdev, ent, &driver); |
||
811 | } |
||
812 | |||
813 | static void |
||
814 | i915_pci_remove(struct pci_dev *pdev) |
||
815 | { |
||
816 | struct drm_device *dev = pci_get_drvdata(pdev); |
||
817 | |||
818 | drm_put_dev(dev); |
||
819 | } |
||
820 | |||
821 | static int i915_pm_suspend(struct device *dev) |
||
822 | { |
||
823 | struct pci_dev *pdev = to_pci_dev(dev); |
||
824 | struct drm_device *drm_dev = pci_get_drvdata(pdev); |
||
825 | int error; |
||
826 | |||
827 | if (!drm_dev || !drm_dev->dev_private) { |
||
828 | dev_err(dev, "DRM not initialized, aborting suspend.\n"); |
||
829 | return -ENODEV; |
||
830 | } |
||
831 | |||
832 | if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF) |
||
833 | return 0; |
||
834 | |||
835 | error = i915_drm_freeze(drm_dev); |
||
836 | if (error) |
||
837 | return error; |
||
838 | |||
839 | pci_disable_device(pdev); |
||
840 | pci_set_power_state(pdev, PCI_D3hot); |
||
841 | |||
842 | return 0; |
||
843 | } |
||
844 | |||
845 | static int i915_pm_resume(struct device *dev) |
||
846 | { |
||
847 | struct pci_dev *pdev = to_pci_dev(dev); |
||
848 | struct drm_device *drm_dev = pci_get_drvdata(pdev); |
||
849 | |||
850 | return i915_resume(drm_dev); |
||
851 | } |
||
852 | |||
853 | static int i915_pm_freeze(struct device *dev) |
||
854 | { |
||
855 | struct pci_dev *pdev = to_pci_dev(dev); |
||
856 | struct drm_device *drm_dev = pci_get_drvdata(pdev); |
||
857 | |||
858 | if (!drm_dev || !drm_dev->dev_private) { |
||
859 | dev_err(dev, "DRM not initialized, aborting suspend.\n"); |
||
860 | return -ENODEV; |
||
861 | } |
||
862 | |||
863 | return i915_drm_freeze(drm_dev); |
||
864 | } |
||
865 | |||
866 | static int i915_pm_thaw(struct device *dev) |
||
867 | { |
||
868 | struct pci_dev *pdev = to_pci_dev(dev); |
||
869 | struct drm_device *drm_dev = pci_get_drvdata(pdev); |
||
870 | |||
871 | return i915_drm_thaw(drm_dev); |
||
872 | } |
||
873 | |||
874 | static int i915_pm_poweroff(struct device *dev) |
||
875 | { |
||
876 | struct pci_dev *pdev = to_pci_dev(dev); |
||
877 | struct drm_device *drm_dev = pci_get_drvdata(pdev); |
||
878 | |||
879 | return i915_drm_freeze(drm_dev); |
||
880 | } |
||
881 | |||
882 | #endif |
||
883 | |||
3260 | Serge | 884 | static struct drm_driver driver = { |
885 | /* Don't use MTRRs here; the Xserver or userspace app should |
||
886 | * deal with them for Intel hardware. |
||
887 | */ |
||
3482 | Serge | 888 | .driver_features = |
4104 | Serge | 889 | DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | |
890 | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_GEM | DRIVER_PRIME | |
||
891 | DRIVER_RENDER, |
||
892 | .load = i915_driver_load, |
||
3260 | Serge | 893 | // .unload = i915_driver_unload, |
3263 | Serge | 894 | .open = i915_driver_open, |
3260 | Serge | 895 | // .lastclose = i915_driver_lastclose, |
896 | // .preclose = i915_driver_preclose, |
||
897 | // .postclose = i915_driver_postclose, |
||
898 | |||
899 | /* Used in place of i915_pm_ops for non-DRIVER_MODESET */ |
||
900 | // .suspend = i915_suspend, |
||
901 | // .resume = i915_resume, |
||
902 | |||
903 | // .device_is_agp = i915_driver_device_is_agp, |
||
904 | // .master_create = i915_master_create, |
||
905 | // .master_destroy = i915_master_destroy, |
||
4104 | Serge | 906 | #if defined(CONFIG_DEBUG_FS) |
907 | .debugfs_init = i915_debugfs_init, |
||
908 | .debugfs_cleanup = i915_debugfs_cleanup, |
||
909 | #endif |
||
3260 | Serge | 910 | .gem_init_object = i915_gem_init_object, |
911 | .gem_free_object = i915_gem_free_object, |
||
912 | |||
913 | // .prime_handle_to_fd = drm_gem_prime_handle_to_fd, |
||
914 | // .prime_fd_to_handle = drm_gem_prime_fd_to_handle, |
||
915 | // .gem_prime_export = i915_gem_prime_export, |
||
916 | // .gem_prime_import = i915_gem_prime_import, |
||
917 | |||
918 | // .dumb_create = i915_gem_dumb_create, |
||
919 | // .dumb_map_offset = i915_gem_mmap_gtt, |
||
920 | // .dumb_destroy = i915_gem_dumb_destroy, |
||
921 | // .ioctls = i915_ioctls, |
||
922 | // .fops = &i915_driver_fops, |
||
923 | // .name = DRIVER_NAME, |
||
924 | // .desc = DRIVER_DESC, |
||
925 | // .date = DRIVER_DATE, |
||
926 | // .major = DRIVER_MAJOR, |
||
927 | // .minor = DRIVER_MINOR, |
||
928 | // .patchlevel = DRIVER_PATCHLEVEL, |
||
929 | }; |
||
930 | |||
931 | |||
3243 | Serge | 932 | |
3255 | Serge | 933 | |
4104 | Serge | 934 | int i915_init(void) |
935 | { |
||
936 | static pci_dev_t device; |
||
937 | const struct pci_device_id *ent; |
||
938 | int err; |
||
2325 | Serge | 939 | |
4104 | Serge | 940 | ent = find_pci_device(&device, pciidlist); |
941 | if( unlikely(ent == NULL) ) |
||
942 | { |
||
943 | dbgprintf("device not found\n"); |
||
944 | return -ENODEV; |
||
945 | }; |
||
2325 | Serge | 946 | |
4104 | Serge | 947 | drm_core_init(); |
3255 | Serge | 948 | |
4104 | Serge | 949 | DRM_INFO("device %x:%x\n", device.pci_dev.vendor, |
950 | device.pci_dev.device); |
||
951 | /* |
||
952 | if (intel_info->gen != 3) { |
||
2325 | Serge | 953 | |
4104 | Serge | 954 | } else if (init_agp() != 0) { |
955 | DRM_ERROR("drm/i915 can't work without intel_agp module!\n"); |
||
956 | return -ENODEV; |
||
3263 | Serge | 957 | } |
4104 | Serge | 958 | */ |
959 | err = drm_get_pci_dev(&device.pci_dev, ent, &driver); |
||
3263 | Serge | 960 | |
4104 | Serge | 961 | return err; |
962 | } |
||
2325 | Serge | 963 | |
2330 | Serge | 964 | |
3031 | serge | 965 | /* We give fast paths for the really cool registers */ |
966 | #define NEEDS_FORCE_WAKE(dev_priv, reg) \ |
||
967 | ((HAS_FORCE_WAKE((dev_priv)->dev)) && \ |
||
968 | ((reg) < 0x40000) && \ |
||
969 | ((reg) != FORCEWAKE)) |
||
2325 | Serge | 970 | |
3031 | serge | 971 | static bool IS_DISPLAYREG(u32 reg) |
972 | { |
||
973 | /* |
||
974 | * This should make it easier to transition modules over to the |
||
975 | * new register block scheme, since we can do it incrementally. |
||
976 | */ |
||
977 | if (reg >= VLV_DISPLAY_BASE) |
||
978 | return false; |
||
979 | |||
980 | if (reg >= RENDER_RING_BASE && |
||
981 | reg < RENDER_RING_BASE + 0xff) |
||
982 | return false; |
||
983 | if (reg >= GEN6_BSD_RING_BASE && |
||
984 | reg < GEN6_BSD_RING_BASE + 0xff) |
||
985 | return false; |
||
986 | if (reg >= BLT_RING_BASE && |
||
987 | reg < BLT_RING_BASE + 0xff) |
||
988 | return false; |
||
989 | |||
990 | if (reg == PGTBL_ER) |
||
991 | return false; |
||
992 | |||
993 | if (reg >= IPEIR_I965 && |
||
994 | reg < HWSTAM) |
||
995 | return false; |
||
996 | |||
997 | if (reg == MI_MODE) |
||
998 | return false; |
||
999 | |||
1000 | if (reg == GFX_MODE_GEN7) |
||
1001 | return false; |
||
1002 | |||
1003 | if (reg == RENDER_HWS_PGA_GEN7 || |
||
1004 | reg == BSD_HWS_PGA_GEN7 || |
||
1005 | reg == BLT_HWS_PGA_GEN7) |
||
1006 | return false; |
||
1007 | |||
1008 | if (reg == GEN6_BSD_SLEEP_PSMI_CONTROL || |
||
1009 | reg == GEN6_BSD_RNCID) |
||
1010 | return false; |
||
1011 | |||
1012 | if (reg == GEN6_BLITTER_ECOSKPD) |
||
1013 | return false; |
||
1014 | |||
1015 | if (reg >= 0x4000c && |
||
1016 | reg <= 0x4002c) |
||
1017 | return false; |
||
1018 | |||
1019 | if (reg >= 0x4f000 && |
||
1020 | reg <= 0x4f08f) |
||
1021 | return false; |
||
1022 | |||
1023 | if (reg >= 0x4f100 && |
||
1024 | reg <= 0x4f11f) |
||
1025 | return false; |
||
1026 | |||
1027 | if (reg >= VLV_MASTER_IER && |
||
1028 | reg <= GEN6_PMIER) |
||
1029 | return false; |
||
1030 | |||
1031 | if (reg >= FENCE_REG_SANDYBRIDGE_0 && |
||
1032 | reg < (FENCE_REG_SANDYBRIDGE_0 + (16*8))) |
||
1033 | return false; |
||
1034 | |||
1035 | if (reg >= VLV_IIR_RW && |
||
1036 | reg <= VLV_ISR) |
||
1037 | return false; |
||
1038 | |||
1039 | if (reg == FORCEWAKE_VLV || |
||
1040 | reg == FORCEWAKE_ACK_VLV) |
||
1041 | return false; |
||
1042 | |||
1043 | if (reg == GEN6_GDRST) |
||
1044 | return false; |
||
1045 | |||
3243 | Serge | 1046 | switch (reg) { |
1047 | case _3D_CHICKEN3: |
||
1048 | case IVB_CHICKEN3: |
||
1049 | case GEN7_COMMON_SLICE_CHICKEN1: |
||
1050 | case GEN7_L3CNTLREG1: |
||
1051 | case GEN7_L3_CHICKEN_MODE_REGISTER: |
||
1052 | case GEN7_ROW_CHICKEN2: |
||
1053 | case GEN7_L3SQCREG4: |
||
1054 | case GEN7_SQ_CHICKEN_MBCUNIT_CONFIG: |
||
1055 | case GEN7_HALF_SLICE_CHICKEN1: |
||
1056 | case GEN6_MBCTL: |
||
1057 | case GEN6_UCGCTL2: |
||
1058 | return false; |
||
1059 | default: |
||
1060 | break; |
||
1061 | } |
||
1062 | |||
3031 | serge | 1063 | return true; |
1064 | } |
||
1065 | |||
3746 | Serge | 1066 | /* We give fast paths for the really cool registers */ |
1067 | #define NEEDS_FORCE_WAKE(dev_priv, reg) \ |
||
1068 | ((HAS_FORCE_WAKE((dev_priv)->dev)) && \ |
||
1069 | ((reg) < 0x40000) && \ |
||
1070 | ((reg) != FORCEWAKE)) |
||
3243 | Serge | 1071 | static void |
1072 | ilk_dummy_write(struct drm_i915_private *dev_priv) |
||
1073 | { |
||
4104 | Serge | 1074 | /* WaIssueDummyWriteToWakeupFromRC6:ilk Issue a dummy write to wake up |
1075 | * the chip from rc6 before touching it for real. MI_MODE is masked, |
||
1076 | * hence harmless to write 0 into. */ |
||
3243 | Serge | 1077 | I915_WRITE_NOTRACE(MI_MODE, 0); |
1078 | } |
||
1079 | |||
3746 | Serge | 1080 | static void |
1081 | hsw_unclaimed_reg_clear(struct drm_i915_private *dev_priv, u32 reg) |
||
1082 | { |
||
4104 | Serge | 1083 | if (HAS_FPGA_DBG_UNCLAIMED(dev_priv->dev) && |
3746 | Serge | 1084 | (I915_READ_NOTRACE(FPGA_DBG) & FPGA_DBG_RM_NOCLAIM)) { |
1085 | DRM_ERROR("Unknown unclaimed register before writing to %x\n", |
||
1086 | reg); |
||
1087 | I915_WRITE_NOTRACE(FPGA_DBG, FPGA_DBG_RM_NOCLAIM); |
||
1088 | } |
||
1089 | } |
||
1090 | |||
1091 | static void |
||
1092 | hsw_unclaimed_reg_check(struct drm_i915_private *dev_priv, u32 reg) |
||
1093 | { |
||
4104 | Serge | 1094 | if (HAS_FPGA_DBG_UNCLAIMED(dev_priv->dev) && |
3746 | Serge | 1095 | (I915_READ_NOTRACE(FPGA_DBG) & FPGA_DBG_RM_NOCLAIM)) { |
1096 | DRM_ERROR("Unclaimed write to %x\n", reg); |
||
1097 | I915_WRITE_NOTRACE(FPGA_DBG, FPGA_DBG_RM_NOCLAIM); |
||
1098 | } |
||
1099 | }>=>>=>=>=>=>>>>>>>>><>><> |
||
1100 |