Wed Jul 24 03:20:52 2013 UTC ()
Omit Linux framebuffer stuff from i915_drv.c.


(riastradh)
diff -r1.1.1.1.2.7 -r1.1.1.1.2.8 src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.c

cvs diff -r1.1.1.1.2.7 -r1.1.1.1.2.8 src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.c (switch to unified diff)

--- src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.c 2013/07/24 03:20:37 1.1.1.1.2.7
+++ src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.c 2013/07/24 03:20:52 1.1.1.1.2.8
@@ -1,1394 +1,1400 @@ @@ -1,1394 +1,1400 @@
1/* i915_drv.c -- i830,i845,i855,i865,i915 driver -*- linux-c -*- 1/* i915_drv.c -- i830,i845,i855,i865,i915 driver -*- linux-c -*-
2 */ 2 */
3/* 3/*
4 * 4 *
5 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. 5 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * All Rights Reserved. 6 * All Rights Reserved.
7 * 7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a 8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the 9 * copy of this software and associated documentation files (the
10 * "Software"), to deal in the Software without restriction, including 10 * "Software"), to deal in the Software without restriction, including
11 * without limitation the rights to use, copy, modify, merge, publish, 11 * without limitation the rights to use, copy, modify, merge, publish,
12 * distribute, sub license, and/or sell copies of the Software, and to 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 13 * permit persons to whom the Software is furnished to do so, subject to
14 * the following conditions: 14 * the following conditions:
15 * 15 *
16 * The above copyright notice and this permission notice (including the 16 * The above copyright notice and this permission notice (including the
17 * next paragraph) shall be included in all copies or substantial portions 17 * next paragraph) shall be included in all copies or substantial portions
18 * of the Software. 18 * of the Software.
19 * 19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 22 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
23 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR 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, 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 25 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 * 27 *
28 */ 28 */
29 29
30#include <linux/device.h> 30#include <linux/device.h>
31#include <linux/moduleparam.h> 31#include <linux/moduleparam.h>
32#include <linux/time.h> 32#include <linux/time.h>
33#include <drm/drmP.h> 33#include <drm/drmP.h>
34#include <drm/i915_drm.h> 34#include <drm/i915_drm.h>
35#include "i915_drv.h" 35#include "i915_drv.h"
36#include "i915_trace.h" 36#include "i915_trace.h"
37#include "intel_drv.h" 37#include "intel_drv.h"
38 38
39#include <linux/console.h> 39#include <linux/console.h>
40#include <linux/module.h> 40#include <linux/module.h>
41#include <drm/drm_crtc_helper.h> 41#include <drm/drm_crtc_helper.h>
42 42
43static int i915_modeset __read_mostly = -1; 43static int i915_modeset __read_mostly = -1;
44module_param_named(modeset, i915_modeset, int, 0400); 44module_param_named(modeset, i915_modeset, int, 0400);
45MODULE_PARM_DESC(modeset, 45MODULE_PARM_DESC(modeset,
46 "Use kernel modesetting [KMS] (0=DRM_I915_KMS from .config, " 46 "Use kernel modesetting [KMS] (0=DRM_I915_KMS from .config, "
47 "1=on, -1=force vga console preference [default])"); 47 "1=on, -1=force vga console preference [default])");
48 48
49unsigned int i915_fbpercrtc __always_unused = 0; 49unsigned int i915_fbpercrtc __always_unused = 0;
50module_param_named(fbpercrtc, i915_fbpercrtc, int, 0400); 50module_param_named(fbpercrtc, i915_fbpercrtc, int, 0400);
51 51
52int i915_panel_ignore_lid __read_mostly = 1; 52int i915_panel_ignore_lid __read_mostly = 1;
53module_param_named(panel_ignore_lid, i915_panel_ignore_lid, int, 0600); 53module_param_named(panel_ignore_lid, i915_panel_ignore_lid, int, 0600);
54MODULE_PARM_DESC(panel_ignore_lid, 54MODULE_PARM_DESC(panel_ignore_lid,
55 "Override lid status (0=autodetect, 1=autodetect disabled [default], " 55 "Override lid status (0=autodetect, 1=autodetect disabled [default], "
56 "-1=force lid closed, -2=force lid open)"); 56 "-1=force lid closed, -2=force lid open)");
57 57
58unsigned int i915_powersave __read_mostly = 1; 58unsigned int i915_powersave __read_mostly = 1;
59module_param_named(powersave, i915_powersave, int, 0600); 59module_param_named(powersave, i915_powersave, int, 0600);
60MODULE_PARM_DESC(powersave, 60MODULE_PARM_DESC(powersave,
61 "Enable powersavings, fbc, downclocking, etc. (default: true)"); 61 "Enable powersavings, fbc, downclocking, etc. (default: true)");
62 62
63int i915_semaphores __read_mostly = -1; 63int i915_semaphores __read_mostly = -1;
64module_param_named(semaphores, i915_semaphores, int, 0600); 64module_param_named(semaphores, i915_semaphores, int, 0600);
65MODULE_PARM_DESC(semaphores, 65MODULE_PARM_DESC(semaphores,
66 "Use semaphores for inter-ring sync (default: -1 (use per-chip defaults))"); 66 "Use semaphores for inter-ring sync (default: -1 (use per-chip defaults))");
67 67
68int i915_enable_rc6 __read_mostly = -1; 68int i915_enable_rc6 __read_mostly = -1;
69module_param_named(i915_enable_rc6, i915_enable_rc6, int, 0400); 69module_param_named(i915_enable_rc6, i915_enable_rc6, int, 0400);
70MODULE_PARM_DESC(i915_enable_rc6, 70MODULE_PARM_DESC(i915_enable_rc6,
71 "Enable power-saving render C-state 6. " 71 "Enable power-saving render C-state 6. "
72 "Different stages can be selected via bitmask values " 72 "Different stages can be selected via bitmask values "
73 "(0 = disable; 1 = enable rc6; 2 = enable deep rc6; 4 = enable deepest rc6). " 73 "(0 = disable; 1 = enable rc6; 2 = enable deep rc6; 4 = enable deepest rc6). "
74 "For example, 3 would enable rc6 and deep rc6, and 7 would enable everything. " 74 "For example, 3 would enable rc6 and deep rc6, and 7 would enable everything. "
75 "default: -1 (use per-chip default)"); 75 "default: -1 (use per-chip default)");
76 76
77int i915_enable_fbc __read_mostly = -1; 77int i915_enable_fbc __read_mostly = -1;
78module_param_named(i915_enable_fbc, i915_enable_fbc, int, 0600); 78module_param_named(i915_enable_fbc, i915_enable_fbc, int, 0600);
79MODULE_PARM_DESC(i915_enable_fbc, 79MODULE_PARM_DESC(i915_enable_fbc,
80 "Enable frame buffer compression for power savings " 80 "Enable frame buffer compression for power savings "
81 "(default: -1 (use per-chip default))"); 81 "(default: -1 (use per-chip default))");
82 82
83unsigned int i915_lvds_downclock __read_mostly = 0; 83unsigned int i915_lvds_downclock __read_mostly = 0;
84module_param_named(lvds_downclock, i915_lvds_downclock, int, 0400); 84module_param_named(lvds_downclock, i915_lvds_downclock, int, 0400);
85MODULE_PARM_DESC(lvds_downclock, 85MODULE_PARM_DESC(lvds_downclock,
86 "Use panel (LVDS/eDP) downclocking for power savings " 86 "Use panel (LVDS/eDP) downclocking for power savings "
87 "(default: false)"); 87 "(default: false)");
88 88
89int i915_lvds_channel_mode __read_mostly; 89int i915_lvds_channel_mode __read_mostly;
90module_param_named(lvds_channel_mode, i915_lvds_channel_mode, int, 0600); 90module_param_named(lvds_channel_mode, i915_lvds_channel_mode, int, 0600);
91MODULE_PARM_DESC(lvds_channel_mode, 91MODULE_PARM_DESC(lvds_channel_mode,
92 "Specify LVDS channel mode " 92 "Specify LVDS channel mode "
93 "(0=probe BIOS [default], 1=single-channel, 2=dual-channel)"); 93 "(0=probe BIOS [default], 1=single-channel, 2=dual-channel)");
94 94
95int i915_panel_use_ssc __read_mostly = -1; 95int i915_panel_use_ssc __read_mostly = -1;
96module_param_named(lvds_use_ssc, i915_panel_use_ssc, int, 0600); 96module_param_named(lvds_use_ssc, i915_panel_use_ssc, int, 0600);
97MODULE_PARM_DESC(lvds_use_ssc, 97MODULE_PARM_DESC(lvds_use_ssc,
98 "Use Spread Spectrum Clock with panels [LVDS/eDP] " 98 "Use Spread Spectrum Clock with panels [LVDS/eDP] "
99 "(default: auto from VBT)"); 99 "(default: auto from VBT)");
100 100
101int i915_vbt_sdvo_panel_type __read_mostly = -1; 101int i915_vbt_sdvo_panel_type __read_mostly = -1;
102module_param_named(vbt_sdvo_panel_type, i915_vbt_sdvo_panel_type, int, 0600); 102module_param_named(vbt_sdvo_panel_type, i915_vbt_sdvo_panel_type, int, 0600);
103MODULE_PARM_DESC(vbt_sdvo_panel_type, 103MODULE_PARM_DESC(vbt_sdvo_panel_type,
104 "Override/Ignore selection of SDVO panel mode in the VBT " 104 "Override/Ignore selection of SDVO panel mode in the VBT "
105 "(-2=ignore, -1=auto [default], index in VBT BIOS table)"); 105 "(-2=ignore, -1=auto [default], index in VBT BIOS table)");
106 106
107static bool i915_try_reset __read_mostly = true; 107static bool i915_try_reset __read_mostly = true;
108module_param_named(reset, i915_try_reset, bool, 0600); 108module_param_named(reset, i915_try_reset, bool, 0600);
109MODULE_PARM_DESC(reset, "Attempt GPU resets (default: true)"); 109MODULE_PARM_DESC(reset, "Attempt GPU resets (default: true)");
110 110
111bool i915_enable_hangcheck __read_mostly = true; 111bool i915_enable_hangcheck __read_mostly = true;
112module_param_named(enable_hangcheck, i915_enable_hangcheck, bool, 0644); 112module_param_named(enable_hangcheck, i915_enable_hangcheck, bool, 0644);
113MODULE_PARM_DESC(enable_hangcheck, 113MODULE_PARM_DESC(enable_hangcheck,
114 "Periodically check GPU activity for detecting hangs. " 114 "Periodically check GPU activity for detecting hangs. "
115 "WARNING: Disabling this can cause system wide hangs. " 115 "WARNING: Disabling this can cause system wide hangs. "
116 "(default: true)"); 116 "(default: true)");
117 117
118int i915_enable_ppgtt __read_mostly = -1; 118int i915_enable_ppgtt __read_mostly = -1;
119module_param_named(i915_enable_ppgtt, i915_enable_ppgtt, int, 0600); 119module_param_named(i915_enable_ppgtt, i915_enable_ppgtt, int, 0600);
120MODULE_PARM_DESC(i915_enable_ppgtt, 120MODULE_PARM_DESC(i915_enable_ppgtt,
121 "Enable PPGTT (default: true)"); 121 "Enable PPGTT (default: true)");
122 122
123unsigned int i915_preliminary_hw_support __read_mostly = 0; 123unsigned int i915_preliminary_hw_support __read_mostly = 0;
124module_param_named(preliminary_hw_support, i915_preliminary_hw_support, int, 0600); 124module_param_named(preliminary_hw_support, i915_preliminary_hw_support, int, 0600);
125MODULE_PARM_DESC(preliminary_hw_support, 125MODULE_PARM_DESC(preliminary_hw_support,
126 "Enable preliminary hardware support. " 126 "Enable preliminary hardware support. "
127 "Enable Haswell and ValleyView Support. " 127 "Enable Haswell and ValleyView Support. "
128 "(default: false)"); 128 "(default: false)");
129 129
130static struct drm_driver driver; 130static struct drm_driver driver;
131extern int intel_agp_enabled; 131extern int intel_agp_enabled;
132 132
133#define INTEL_VGA_DEVICE(id, info) { \ 133#define INTEL_VGA_DEVICE(id, info) { \
134 .class = PCI_BASE_CLASS_DISPLAY << 16, \ 134 .class = PCI_BASE_CLASS_DISPLAY << 16, \
135 .class_mask = 0xff0000, \ 135 .class_mask = 0xff0000, \
136 .vendor = 0x8086, \ 136 .vendor = 0x8086, \
137 .device = id, \ 137 .device = id, \
138 .subvendor = PCI_ANY_ID, \ 138 .subvendor = PCI_ANY_ID, \
139 .subdevice = PCI_ANY_ID, \ 139 .subdevice = PCI_ANY_ID, \
140 .driver_data = (unsigned long) info } 140 .driver_data = (unsigned long) info }
141 141
142static const struct intel_device_info intel_i830_info = { 142static const struct intel_device_info intel_i830_info = {
143 .gen = 2, .is_mobile = 1, .cursor_needs_physical = 1, 143 .gen = 2, .is_mobile = 1, .cursor_needs_physical = 1,
144 .has_overlay = 1, .overlay_needs_physical = 1, 144 .has_overlay = 1, .overlay_needs_physical = 1,
145}; 145};
146 146
147static const struct intel_device_info intel_845g_info = { 147static const struct intel_device_info intel_845g_info = {
148 .gen = 2, 148 .gen = 2,
149 .has_overlay = 1, .overlay_needs_physical = 1, 149 .has_overlay = 1, .overlay_needs_physical = 1,
150}; 150};
151 151
152static const struct intel_device_info intel_i85x_info = { 152static const struct intel_device_info intel_i85x_info = {
153 .gen = 2, .is_i85x = 1, .is_mobile = 1, 153 .gen = 2, .is_i85x = 1, .is_mobile = 1,
154 .cursor_needs_physical = 1, 154 .cursor_needs_physical = 1,
155 .has_overlay = 1, .overlay_needs_physical = 1, 155 .has_overlay = 1, .overlay_needs_physical = 1,
156}; 156};
157 157
158static const struct intel_device_info intel_i865g_info = { 158static const struct intel_device_info intel_i865g_info = {
159 .gen = 2, 159 .gen = 2,
160 .has_overlay = 1, .overlay_needs_physical = 1, 160 .has_overlay = 1, .overlay_needs_physical = 1,
161}; 161};
162 162
163static const struct intel_device_info intel_i915g_info = { 163static const struct intel_device_info intel_i915g_info = {
164 .gen = 3, .is_i915g = 1, .cursor_needs_physical = 1, 164 .gen = 3, .is_i915g = 1, .cursor_needs_physical = 1,
165 .has_overlay = 1, .overlay_needs_physical = 1, 165 .has_overlay = 1, .overlay_needs_physical = 1,
166}; 166};
167static const struct intel_device_info intel_i915gm_info = { 167static const struct intel_device_info intel_i915gm_info = {
168 .gen = 3, .is_mobile = 1, 168 .gen = 3, .is_mobile = 1,
169 .cursor_needs_physical = 1, 169 .cursor_needs_physical = 1,
170 .has_overlay = 1, .overlay_needs_physical = 1, 170 .has_overlay = 1, .overlay_needs_physical = 1,
171 .supports_tv = 1, 171 .supports_tv = 1,
172}; 172};
173static const struct intel_device_info intel_i945g_info = { 173static const struct intel_device_info intel_i945g_info = {
174 .gen = 3, .has_hotplug = 1, .cursor_needs_physical = 1, 174 .gen = 3, .has_hotplug = 1, .cursor_needs_physical = 1,
175 .has_overlay = 1, .overlay_needs_physical = 1, 175 .has_overlay = 1, .overlay_needs_physical = 1,
176}; 176};
177static const struct intel_device_info intel_i945gm_info = { 177static const struct intel_device_info intel_i945gm_info = {
178 .gen = 3, .is_i945gm = 1, .is_mobile = 1, 178 .gen = 3, .is_i945gm = 1, .is_mobile = 1,
179 .has_hotplug = 1, .cursor_needs_physical = 1, 179 .has_hotplug = 1, .cursor_needs_physical = 1,
180 .has_overlay = 1, .overlay_needs_physical = 1, 180 .has_overlay = 1, .overlay_needs_physical = 1,
181 .supports_tv = 1, 181 .supports_tv = 1,
182}; 182};
183 183
184static const struct intel_device_info intel_i965g_info = { 184static const struct intel_device_info intel_i965g_info = {
185 .gen = 4, .is_broadwater = 1, 185 .gen = 4, .is_broadwater = 1,
186 .has_hotplug = 1, 186 .has_hotplug = 1,
187 .has_overlay = 1, 187 .has_overlay = 1,
188}; 188};
189 189
190static const struct intel_device_info intel_i965gm_info = { 190static const struct intel_device_info intel_i965gm_info = {
191 .gen = 4, .is_crestline = 1, 191 .gen = 4, .is_crestline = 1,
192 .is_mobile = 1, .has_fbc = 1, .has_hotplug = 1, 192 .is_mobile = 1, .has_fbc = 1, .has_hotplug = 1,
193 .has_overlay = 1, 193 .has_overlay = 1,
194 .supports_tv = 1, 194 .supports_tv = 1,
195}; 195};
196 196
197static const struct intel_device_info intel_g33_info = { 197static const struct intel_device_info intel_g33_info = {
198 .gen = 3, .is_g33 = 1, 198 .gen = 3, .is_g33 = 1,
199 .need_gfx_hws = 1, .has_hotplug = 1, 199 .need_gfx_hws = 1, .has_hotplug = 1,
200 .has_overlay = 1, 200 .has_overlay = 1,
201}; 201};
202 202
203static const struct intel_device_info intel_g45_info = { 203static const struct intel_device_info intel_g45_info = {
204 .gen = 4, .is_g4x = 1, .need_gfx_hws = 1, 204 .gen = 4, .is_g4x = 1, .need_gfx_hws = 1,
205 .has_pipe_cxsr = 1, .has_hotplug = 1, 205 .has_pipe_cxsr = 1, .has_hotplug = 1,
206 .has_bsd_ring = 1, 206 .has_bsd_ring = 1,
207}; 207};
208 208
209static const struct intel_device_info intel_gm45_info = { 209static const struct intel_device_info intel_gm45_info = {
210 .gen = 4, .is_g4x = 1, 210 .gen = 4, .is_g4x = 1,
211 .is_mobile = 1, .need_gfx_hws = 1, .has_fbc = 1, 211 .is_mobile = 1, .need_gfx_hws = 1, .has_fbc = 1,
212 .has_pipe_cxsr = 1, .has_hotplug = 1, 212 .has_pipe_cxsr = 1, .has_hotplug = 1,
213 .supports_tv = 1, 213 .supports_tv = 1,
214 .has_bsd_ring = 1, 214 .has_bsd_ring = 1,
215}; 215};
216 216
217static const struct intel_device_info intel_pineview_info = { 217static const struct intel_device_info intel_pineview_info = {
218 .gen = 3, .is_g33 = 1, .is_pineview = 1, .is_mobile = 1, 218 .gen = 3, .is_g33 = 1, .is_pineview = 1, .is_mobile = 1,
219 .need_gfx_hws = 1, .has_hotplug = 1, 219 .need_gfx_hws = 1, .has_hotplug = 1,
220 .has_overlay = 1, 220 .has_overlay = 1,
221}; 221};
222 222
223static const struct intel_device_info intel_ironlake_d_info = { 223static const struct intel_device_info intel_ironlake_d_info = {
224 .gen = 5, 224 .gen = 5,
225 .need_gfx_hws = 1, .has_hotplug = 1, 225 .need_gfx_hws = 1, .has_hotplug = 1,
226 .has_bsd_ring = 1, 226 .has_bsd_ring = 1,
227}; 227};
228 228
229static const struct intel_device_info intel_ironlake_m_info = { 229static const struct intel_device_info intel_ironlake_m_info = {
230 .gen = 5, .is_mobile = 1, 230 .gen = 5, .is_mobile = 1,
231 .need_gfx_hws = 1, .has_hotplug = 1, 231 .need_gfx_hws = 1, .has_hotplug = 1,
232 .has_fbc = 1, 232 .has_fbc = 1,
233 .has_bsd_ring = 1, 233 .has_bsd_ring = 1,
234}; 234};
235 235
236static const struct intel_device_info intel_sandybridge_d_info = { 236static const struct intel_device_info intel_sandybridge_d_info = {
237 .gen = 6, 237 .gen = 6,
238 .need_gfx_hws = 1, .has_hotplug = 1, 238 .need_gfx_hws = 1, .has_hotplug = 1,
239 .has_bsd_ring = 1, 239 .has_bsd_ring = 1,
240 .has_blt_ring = 1, 240 .has_blt_ring = 1,
241 .has_llc = 1, 241 .has_llc = 1,
242 .has_force_wake = 1, 242 .has_force_wake = 1,
243}; 243};
244 244
245static const struct intel_device_info intel_sandybridge_m_info = { 245static const struct intel_device_info intel_sandybridge_m_info = {
246 .gen = 6, .is_mobile = 1, 246 .gen = 6, .is_mobile = 1,
247 .need_gfx_hws = 1, .has_hotplug = 1, 247 .need_gfx_hws = 1, .has_hotplug = 1,
248 .has_fbc = 1, 248 .has_fbc = 1,
249 .has_bsd_ring = 1, 249 .has_bsd_ring = 1,
250 .has_blt_ring = 1, 250 .has_blt_ring = 1,
251 .has_llc = 1, 251 .has_llc = 1,
252 .has_force_wake = 1, 252 .has_force_wake = 1,
253}; 253};
254 254
255static const struct intel_device_info intel_ivybridge_d_info = { 255static const struct intel_device_info intel_ivybridge_d_info = {
256 .is_ivybridge = 1, .gen = 7, 256 .is_ivybridge = 1, .gen = 7,
257 .need_gfx_hws = 1, .has_hotplug = 1, 257 .need_gfx_hws = 1, .has_hotplug = 1,
258 .has_bsd_ring = 1, 258 .has_bsd_ring = 1,
259 .has_blt_ring = 1, 259 .has_blt_ring = 1,
260 .has_llc = 1, 260 .has_llc = 1,
261 .has_force_wake = 1, 261 .has_force_wake = 1,
262}; 262};
263 263
264static const struct intel_device_info intel_ivybridge_m_info = { 264static const struct intel_device_info intel_ivybridge_m_info = {
265 .is_ivybridge = 1, .gen = 7, .is_mobile = 1, 265 .is_ivybridge = 1, .gen = 7, .is_mobile = 1,
266 .need_gfx_hws = 1, .has_hotplug = 1, 266 .need_gfx_hws = 1, .has_hotplug = 1,
267 .has_fbc = 0, /* FBC is not enabled on Ivybridge mobile yet */ 267 .has_fbc = 0, /* FBC is not enabled on Ivybridge mobile yet */
268 .has_bsd_ring = 1, 268 .has_bsd_ring = 1,
269 .has_blt_ring = 1, 269 .has_blt_ring = 1,
270 .has_llc = 1, 270 .has_llc = 1,
271 .has_force_wake = 1, 271 .has_force_wake = 1,
272}; 272};
273 273
274static const struct intel_device_info intel_valleyview_m_info = { 274static const struct intel_device_info intel_valleyview_m_info = {
275 .gen = 7, .is_mobile = 1, 275 .gen = 7, .is_mobile = 1,
276 .need_gfx_hws = 1, .has_hotplug = 1, 276 .need_gfx_hws = 1, .has_hotplug = 1,
277 .has_fbc = 0, 277 .has_fbc = 0,
278 .has_bsd_ring = 1, 278 .has_bsd_ring = 1,
279 .has_blt_ring = 1, 279 .has_blt_ring = 1,
280 .is_valleyview = 1, 280 .is_valleyview = 1,
281}; 281};
282 282
283static const struct intel_device_info intel_valleyview_d_info = { 283static const struct intel_device_info intel_valleyview_d_info = {
284 .gen = 7, 284 .gen = 7,
285 .need_gfx_hws = 1, .has_hotplug = 1, 285 .need_gfx_hws = 1, .has_hotplug = 1,
286 .has_fbc = 0, 286 .has_fbc = 0,
287 .has_bsd_ring = 1, 287 .has_bsd_ring = 1,
288 .has_blt_ring = 1, 288 .has_blt_ring = 1,
289 .is_valleyview = 1, 289 .is_valleyview = 1,
290}; 290};
291 291
292static const struct intel_device_info intel_haswell_d_info = { 292static const struct intel_device_info intel_haswell_d_info = {
293 .is_haswell = 1, .gen = 7, 293 .is_haswell = 1, .gen = 7,
294 .need_gfx_hws = 1, .has_hotplug = 1, 294 .need_gfx_hws = 1, .has_hotplug = 1,
295 .has_bsd_ring = 1, 295 .has_bsd_ring = 1,
296 .has_blt_ring = 1, 296 .has_blt_ring = 1,
297 .has_llc = 1, 297 .has_llc = 1,
298 .has_force_wake = 1, 298 .has_force_wake = 1,
299}; 299};
300 300
301static const struct intel_device_info intel_haswell_m_info = { 301static const struct intel_device_info intel_haswell_m_info = {
302 .is_haswell = 1, .gen = 7, .is_mobile = 1, 302 .is_haswell = 1, .gen = 7, .is_mobile = 1,
303 .need_gfx_hws = 1, .has_hotplug = 1, 303 .need_gfx_hws = 1, .has_hotplug = 1,
304 .has_bsd_ring = 1, 304 .has_bsd_ring = 1,
305 .has_blt_ring = 1, 305 .has_blt_ring = 1,
306 .has_llc = 1, 306 .has_llc = 1,
307 .has_force_wake = 1, 307 .has_force_wake = 1,
308}; 308};
309 309
310static const struct pci_device_id pciidlist[] = { /* aka */ 310static const struct pci_device_id pciidlist[] = { /* aka */
311 INTEL_VGA_DEVICE(0x3577, &intel_i830_info), /* I830_M */ 311 INTEL_VGA_DEVICE(0x3577, &intel_i830_info), /* I830_M */
312 INTEL_VGA_DEVICE(0x2562, &intel_845g_info), /* 845_G */ 312 INTEL_VGA_DEVICE(0x2562, &intel_845g_info), /* 845_G */
313 INTEL_VGA_DEVICE(0x3582, &intel_i85x_info), /* I855_GM */ 313 INTEL_VGA_DEVICE(0x3582, &intel_i85x_info), /* I855_GM */
314 INTEL_VGA_DEVICE(0x358e, &intel_i85x_info), 314 INTEL_VGA_DEVICE(0x358e, &intel_i85x_info),
315 INTEL_VGA_DEVICE(0x2572, &intel_i865g_info), /* I865_G */ 315 INTEL_VGA_DEVICE(0x2572, &intel_i865g_info), /* I865_G */
316 INTEL_VGA_DEVICE(0x2582, &intel_i915g_info), /* I915_G */ 316 INTEL_VGA_DEVICE(0x2582, &intel_i915g_info), /* I915_G */
317 INTEL_VGA_DEVICE(0x258a, &intel_i915g_info), /* E7221_G */ 317 INTEL_VGA_DEVICE(0x258a, &intel_i915g_info), /* E7221_G */
318 INTEL_VGA_DEVICE(0x2592, &intel_i915gm_info), /* I915_GM */ 318 INTEL_VGA_DEVICE(0x2592, &intel_i915gm_info), /* I915_GM */
319 INTEL_VGA_DEVICE(0x2772, &intel_i945g_info), /* I945_G */ 319 INTEL_VGA_DEVICE(0x2772, &intel_i945g_info), /* I945_G */
320 INTEL_VGA_DEVICE(0x27a2, &intel_i945gm_info), /* I945_GM */ 320 INTEL_VGA_DEVICE(0x27a2, &intel_i945gm_info), /* I945_GM */
321 INTEL_VGA_DEVICE(0x27ae, &intel_i945gm_info), /* I945_GME */ 321 INTEL_VGA_DEVICE(0x27ae, &intel_i945gm_info), /* I945_GME */
322 INTEL_VGA_DEVICE(0x2972, &intel_i965g_info), /* I946_GZ */ 322 INTEL_VGA_DEVICE(0x2972, &intel_i965g_info), /* I946_GZ */
323 INTEL_VGA_DEVICE(0x2982, &intel_i965g_info), /* G35_G */ 323 INTEL_VGA_DEVICE(0x2982, &intel_i965g_info), /* G35_G */
324 INTEL_VGA_DEVICE(0x2992, &intel_i965g_info), /* I965_Q */ 324 INTEL_VGA_DEVICE(0x2992, &intel_i965g_info), /* I965_Q */
325 INTEL_VGA_DEVICE(0x29a2, &intel_i965g_info), /* I965_G */ 325 INTEL_VGA_DEVICE(0x29a2, &intel_i965g_info), /* I965_G */
326 INTEL_VGA_DEVICE(0x29b2, &intel_g33_info), /* Q35_G */ 326 INTEL_VGA_DEVICE(0x29b2, &intel_g33_info), /* Q35_G */
327 INTEL_VGA_DEVICE(0x29c2, &intel_g33_info), /* G33_G */ 327 INTEL_VGA_DEVICE(0x29c2, &intel_g33_info), /* G33_G */
328 INTEL_VGA_DEVICE(0x29d2, &intel_g33_info), /* Q33_G */ 328 INTEL_VGA_DEVICE(0x29d2, &intel_g33_info), /* Q33_G */
329 INTEL_VGA_DEVICE(0x2a02, &intel_i965gm_info), /* I965_GM */ 329 INTEL_VGA_DEVICE(0x2a02, &intel_i965gm_info), /* I965_GM */
330 INTEL_VGA_DEVICE(0x2a12, &intel_i965gm_info), /* I965_GME */ 330 INTEL_VGA_DEVICE(0x2a12, &intel_i965gm_info), /* I965_GME */
331 INTEL_VGA_DEVICE(0x2a42, &intel_gm45_info), /* GM45_G */ 331 INTEL_VGA_DEVICE(0x2a42, &intel_gm45_info), /* GM45_G */
332 INTEL_VGA_DEVICE(0x2e02, &intel_g45_info), /* IGD_E_G */ 332 INTEL_VGA_DEVICE(0x2e02, &intel_g45_info), /* IGD_E_G */
333 INTEL_VGA_DEVICE(0x2e12, &intel_g45_info), /* Q45_G */ 333 INTEL_VGA_DEVICE(0x2e12, &intel_g45_info), /* Q45_G */
334 INTEL_VGA_DEVICE(0x2e22, &intel_g45_info), /* G45_G */ 334 INTEL_VGA_DEVICE(0x2e22, &intel_g45_info), /* G45_G */
335 INTEL_VGA_DEVICE(0x2e32, &intel_g45_info), /* G41_G */ 335 INTEL_VGA_DEVICE(0x2e32, &intel_g45_info), /* G41_G */
336 INTEL_VGA_DEVICE(0x2e42, &intel_g45_info), /* B43_G */ 336 INTEL_VGA_DEVICE(0x2e42, &intel_g45_info), /* B43_G */
337 INTEL_VGA_DEVICE(0x2e92, &intel_g45_info), /* B43_G.1 */ 337 INTEL_VGA_DEVICE(0x2e92, &intel_g45_info), /* B43_G.1 */
338 INTEL_VGA_DEVICE(0xa001, &intel_pineview_info), 338 INTEL_VGA_DEVICE(0xa001, &intel_pineview_info),
339 INTEL_VGA_DEVICE(0xa011, &intel_pineview_info), 339 INTEL_VGA_DEVICE(0xa011, &intel_pineview_info),
340 INTEL_VGA_DEVICE(0x0042, &intel_ironlake_d_info), 340 INTEL_VGA_DEVICE(0x0042, &intel_ironlake_d_info),
341 INTEL_VGA_DEVICE(0x0046, &intel_ironlake_m_info), 341 INTEL_VGA_DEVICE(0x0046, &intel_ironlake_m_info),
342 INTEL_VGA_DEVICE(0x0102, &intel_sandybridge_d_info), 342 INTEL_VGA_DEVICE(0x0102, &intel_sandybridge_d_info),
343 INTEL_VGA_DEVICE(0x0112, &intel_sandybridge_d_info), 343 INTEL_VGA_DEVICE(0x0112, &intel_sandybridge_d_info),
344 INTEL_VGA_DEVICE(0x0122, &intel_sandybridge_d_info), 344 INTEL_VGA_DEVICE(0x0122, &intel_sandybridge_d_info),
345 INTEL_VGA_DEVICE(0x0106, &intel_sandybridge_m_info), 345 INTEL_VGA_DEVICE(0x0106, &intel_sandybridge_m_info),
346 INTEL_VGA_DEVICE(0x0116, &intel_sandybridge_m_info), 346 INTEL_VGA_DEVICE(0x0116, &intel_sandybridge_m_info),
347 INTEL_VGA_DEVICE(0x0126, &intel_sandybridge_m_info), 347 INTEL_VGA_DEVICE(0x0126, &intel_sandybridge_m_info),
348 INTEL_VGA_DEVICE(0x010A, &intel_sandybridge_d_info), 348 INTEL_VGA_DEVICE(0x010A, &intel_sandybridge_d_info),
349 INTEL_VGA_DEVICE(0x0156, &intel_ivybridge_m_info), /* GT1 mobile */ 349 INTEL_VGA_DEVICE(0x0156, &intel_ivybridge_m_info), /* GT1 mobile */
350 INTEL_VGA_DEVICE(0x0166, &intel_ivybridge_m_info), /* GT2 mobile */ 350 INTEL_VGA_DEVICE(0x0166, &intel_ivybridge_m_info), /* GT2 mobile */
351 INTEL_VGA_DEVICE(0x0152, &intel_ivybridge_d_info), /* GT1 desktop */ 351 INTEL_VGA_DEVICE(0x0152, &intel_ivybridge_d_info), /* GT1 desktop */
352 INTEL_VGA_DEVICE(0x0162, &intel_ivybridge_d_info), /* GT2 desktop */ 352 INTEL_VGA_DEVICE(0x0162, &intel_ivybridge_d_info), /* GT2 desktop */
353 INTEL_VGA_DEVICE(0x015a, &intel_ivybridge_d_info), /* GT1 server */ 353 INTEL_VGA_DEVICE(0x015a, &intel_ivybridge_d_info), /* GT1 server */
354 INTEL_VGA_DEVICE(0x016a, &intel_ivybridge_d_info), /* GT2 server */ 354 INTEL_VGA_DEVICE(0x016a, &intel_ivybridge_d_info), /* GT2 server */
355 INTEL_VGA_DEVICE(0x0402, &intel_haswell_d_info), /* GT1 desktop */ 355 INTEL_VGA_DEVICE(0x0402, &intel_haswell_d_info), /* GT1 desktop */
356 INTEL_VGA_DEVICE(0x0412, &intel_haswell_d_info), /* GT2 desktop */ 356 INTEL_VGA_DEVICE(0x0412, &intel_haswell_d_info), /* GT2 desktop */
357 INTEL_VGA_DEVICE(0x0422, &intel_haswell_d_info), /* GT2 desktop */ 357 INTEL_VGA_DEVICE(0x0422, &intel_haswell_d_info), /* GT2 desktop */
358 INTEL_VGA_DEVICE(0x040a, &intel_haswell_d_info), /* GT1 server */ 358 INTEL_VGA_DEVICE(0x040a, &intel_haswell_d_info), /* GT1 server */
359 INTEL_VGA_DEVICE(0x041a, &intel_haswell_d_info), /* GT2 server */ 359 INTEL_VGA_DEVICE(0x041a, &intel_haswell_d_info), /* GT2 server */
360 INTEL_VGA_DEVICE(0x042a, &intel_haswell_d_info), /* GT2 server */ 360 INTEL_VGA_DEVICE(0x042a, &intel_haswell_d_info), /* GT2 server */
361 INTEL_VGA_DEVICE(0x0406, &intel_haswell_m_info), /* GT1 mobile */ 361 INTEL_VGA_DEVICE(0x0406, &intel_haswell_m_info), /* GT1 mobile */
362 INTEL_VGA_DEVICE(0x0416, &intel_haswell_m_info), /* GT2 mobile */ 362 INTEL_VGA_DEVICE(0x0416, &intel_haswell_m_info), /* GT2 mobile */
363 INTEL_VGA_DEVICE(0x0426, &intel_haswell_m_info), /* GT2 mobile */ 363 INTEL_VGA_DEVICE(0x0426, &intel_haswell_m_info), /* GT2 mobile */
364 INTEL_VGA_DEVICE(0x0C02, &intel_haswell_d_info), /* SDV GT1 desktop */ 364 INTEL_VGA_DEVICE(0x0C02, &intel_haswell_d_info), /* SDV GT1 desktop */
365 INTEL_VGA_DEVICE(0x0C12, &intel_haswell_d_info), /* SDV GT2 desktop */ 365 INTEL_VGA_DEVICE(0x0C12, &intel_haswell_d_info), /* SDV GT2 desktop */
366 INTEL_VGA_DEVICE(0x0C22, &intel_haswell_d_info), /* SDV GT2 desktop */ 366 INTEL_VGA_DEVICE(0x0C22, &intel_haswell_d_info), /* SDV GT2 desktop */
367 INTEL_VGA_DEVICE(0x0C0A, &intel_haswell_d_info), /* SDV GT1 server */ 367 INTEL_VGA_DEVICE(0x0C0A, &intel_haswell_d_info), /* SDV GT1 server */
368 INTEL_VGA_DEVICE(0x0C1A, &intel_haswell_d_info), /* SDV GT2 server */ 368 INTEL_VGA_DEVICE(0x0C1A, &intel_haswell_d_info), /* SDV GT2 server */
369 INTEL_VGA_DEVICE(0x0C2A, &intel_haswell_d_info), /* SDV GT2 server */ 369 INTEL_VGA_DEVICE(0x0C2A, &intel_haswell_d_info), /* SDV GT2 server */
370 INTEL_VGA_DEVICE(0x0C06, &intel_haswell_m_info), /* SDV GT1 mobile */ 370 INTEL_VGA_DEVICE(0x0C06, &intel_haswell_m_info), /* SDV GT1 mobile */
371 INTEL_VGA_DEVICE(0x0C16, &intel_haswell_m_info), /* SDV GT2 mobile */ 371 INTEL_VGA_DEVICE(0x0C16, &intel_haswell_m_info), /* SDV GT2 mobile */
372 INTEL_VGA_DEVICE(0x0C26, &intel_haswell_m_info), /* SDV GT2 mobile */ 372 INTEL_VGA_DEVICE(0x0C26, &intel_haswell_m_info), /* SDV GT2 mobile */
373 INTEL_VGA_DEVICE(0x0A02, &intel_haswell_d_info), /* ULT GT1 desktop */ 373 INTEL_VGA_DEVICE(0x0A02, &intel_haswell_d_info), /* ULT GT1 desktop */
374 INTEL_VGA_DEVICE(0x0A12, &intel_haswell_d_info), /* ULT GT2 desktop */ 374 INTEL_VGA_DEVICE(0x0A12, &intel_haswell_d_info), /* ULT GT2 desktop */
375 INTEL_VGA_DEVICE(0x0A22, &intel_haswell_d_info), /* ULT GT2 desktop */ 375 INTEL_VGA_DEVICE(0x0A22, &intel_haswell_d_info), /* ULT GT2 desktop */
376 INTEL_VGA_DEVICE(0x0A0A, &intel_haswell_d_info), /* ULT GT1 server */ 376 INTEL_VGA_DEVICE(0x0A0A, &intel_haswell_d_info), /* ULT GT1 server */
377 INTEL_VGA_DEVICE(0x0A1A, &intel_haswell_d_info), /* ULT GT2 server */ 377 INTEL_VGA_DEVICE(0x0A1A, &intel_haswell_d_info), /* ULT GT2 server */
378 INTEL_VGA_DEVICE(0x0A2A, &intel_haswell_d_info), /* ULT GT2 server */ 378 INTEL_VGA_DEVICE(0x0A2A, &intel_haswell_d_info), /* ULT GT2 server */
379 INTEL_VGA_DEVICE(0x0A06, &intel_haswell_m_info), /* ULT GT1 mobile */ 379 INTEL_VGA_DEVICE(0x0A06, &intel_haswell_m_info), /* ULT GT1 mobile */
380 INTEL_VGA_DEVICE(0x0A16, &intel_haswell_m_info), /* ULT GT2 mobile */ 380 INTEL_VGA_DEVICE(0x0A16, &intel_haswell_m_info), /* ULT GT2 mobile */
381 INTEL_VGA_DEVICE(0x0A26, &intel_haswell_m_info), /* ULT GT2 mobile */ 381 INTEL_VGA_DEVICE(0x0A26, &intel_haswell_m_info), /* ULT GT2 mobile */
382 INTEL_VGA_DEVICE(0x0D12, &intel_haswell_d_info), /* CRW GT1 desktop */ 382 INTEL_VGA_DEVICE(0x0D12, &intel_haswell_d_info), /* CRW GT1 desktop */
383 INTEL_VGA_DEVICE(0x0D22, &intel_haswell_d_info), /* CRW GT2 desktop */ 383 INTEL_VGA_DEVICE(0x0D22, &intel_haswell_d_info), /* CRW GT2 desktop */
384 INTEL_VGA_DEVICE(0x0D32, &intel_haswell_d_info), /* CRW GT2 desktop */ 384 INTEL_VGA_DEVICE(0x0D32, &intel_haswell_d_info), /* CRW GT2 desktop */
385 INTEL_VGA_DEVICE(0x0D1A, &intel_haswell_d_info), /* CRW GT1 server */ 385 INTEL_VGA_DEVICE(0x0D1A, &intel_haswell_d_info), /* CRW GT1 server */
386 INTEL_VGA_DEVICE(0x0D2A, &intel_haswell_d_info), /* CRW GT2 server */ 386 INTEL_VGA_DEVICE(0x0D2A, &intel_haswell_d_info), /* CRW GT2 server */
387 INTEL_VGA_DEVICE(0x0D3A, &intel_haswell_d_info), /* CRW GT2 server */ 387 INTEL_VGA_DEVICE(0x0D3A, &intel_haswell_d_info), /* CRW GT2 server */
388 INTEL_VGA_DEVICE(0x0D16, &intel_haswell_m_info), /* CRW GT1 mobile */ 388 INTEL_VGA_DEVICE(0x0D16, &intel_haswell_m_info), /* CRW GT1 mobile */
389 INTEL_VGA_DEVICE(0x0D26, &intel_haswell_m_info), /* CRW GT2 mobile */ 389 INTEL_VGA_DEVICE(0x0D26, &intel_haswell_m_info), /* CRW GT2 mobile */
390 INTEL_VGA_DEVICE(0x0D36, &intel_haswell_m_info), /* CRW GT2 mobile */ 390 INTEL_VGA_DEVICE(0x0D36, &intel_haswell_m_info), /* CRW GT2 mobile */
391 INTEL_VGA_DEVICE(0x0f30, &intel_valleyview_m_info), 391 INTEL_VGA_DEVICE(0x0f30, &intel_valleyview_m_info),
392 INTEL_VGA_DEVICE(0x0157, &intel_valleyview_m_info), 392 INTEL_VGA_DEVICE(0x0157, &intel_valleyview_m_info),
393 INTEL_VGA_DEVICE(0x0155, &intel_valleyview_d_info), 393 INTEL_VGA_DEVICE(0x0155, &intel_valleyview_d_info),
394#ifdef __NetBSD__ 394#ifdef __NetBSD__
395 {0, 0, 0, 0, 0, 0, 0} 395 {0, 0, 0, 0, 0, 0, 0}
396#else 396#else
397 {0, 0, 0} 397 {0, 0, 0}
398#endif 398#endif
399}; 399};
400 400
401#if defined(CONFIG_DRM_I915_KMS) 401#if defined(CONFIG_DRM_I915_KMS)
402MODULE_DEVICE_TABLE(pci, pciidlist); 402MODULE_DEVICE_TABLE(pci, pciidlist);
403#endif 403#endif
404 404
405void intel_detect_pch(struct drm_device *dev) 405void intel_detect_pch(struct drm_device *dev)
406{ 406{
407 struct drm_i915_private *dev_priv = dev->dev_private; 407 struct drm_i915_private *dev_priv = dev->dev_private;
408 struct pci_dev *pch; 408 struct pci_dev *pch;
409 409
410 /* 410 /*
411 * The reason to probe ISA bridge instead of Dev31:Fun0 is to 411 * The reason to probe ISA bridge instead of Dev31:Fun0 is to
412 * make graphics device passthrough work easy for VMM, that only 412 * make graphics device passthrough work easy for VMM, that only
413 * need to expose ISA bridge to let driver know the real hardware 413 * need to expose ISA bridge to let driver know the real hardware
414 * underneath. This is a requirement from virtualization team. 414 * underneath. This is a requirement from virtualization team.
415 */ 415 */
416 pch = pci_get_class(PCI_CLASS_BRIDGE_ISA << 8, NULL); 416 pch = pci_get_class(PCI_CLASS_BRIDGE_ISA << 8, NULL);
417 if (pch) { 417 if (pch) {
418 if (pch->vendor == PCI_VENDOR_ID_INTEL) { 418 if (pch->vendor == PCI_VENDOR_ID_INTEL) {
419 unsigned short id; 419 unsigned short id;
420 id = pch->device & INTEL_PCH_DEVICE_ID_MASK; 420 id = pch->device & INTEL_PCH_DEVICE_ID_MASK;
421 dev_priv->pch_id = id; 421 dev_priv->pch_id = id;
422 422
423 if (id == INTEL_PCH_IBX_DEVICE_ID_TYPE) { 423 if (id == INTEL_PCH_IBX_DEVICE_ID_TYPE) {
424 dev_priv->pch_type = PCH_IBX; 424 dev_priv->pch_type = PCH_IBX;
425 dev_priv->num_pch_pll = 2; 425 dev_priv->num_pch_pll = 2;
426 DRM_DEBUG_KMS("Found Ibex Peak PCH\n"); 426 DRM_DEBUG_KMS("Found Ibex Peak PCH\n");
427 WARN_ON(!IS_GEN5(dev)); 427 WARN_ON(!IS_GEN5(dev));
428 } else if (id == INTEL_PCH_CPT_DEVICE_ID_TYPE) { 428 } else if (id == INTEL_PCH_CPT_DEVICE_ID_TYPE) {
429 dev_priv->pch_type = PCH_CPT; 429 dev_priv->pch_type = PCH_CPT;
430 dev_priv->num_pch_pll = 2; 430 dev_priv->num_pch_pll = 2;
431 DRM_DEBUG_KMS("Found CougarPoint PCH\n"); 431 DRM_DEBUG_KMS("Found CougarPoint PCH\n");
432 WARN_ON(!(IS_GEN6(dev) || IS_IVYBRIDGE(dev))); 432 WARN_ON(!(IS_GEN6(dev) || IS_IVYBRIDGE(dev)));
433 } else if (id == INTEL_PCH_PPT_DEVICE_ID_TYPE) { 433 } else if (id == INTEL_PCH_PPT_DEVICE_ID_TYPE) {
434 /* PantherPoint is CPT compatible */ 434 /* PantherPoint is CPT compatible */
435 dev_priv->pch_type = PCH_CPT; 435 dev_priv->pch_type = PCH_CPT;
436 dev_priv->num_pch_pll = 2; 436 dev_priv->num_pch_pll = 2;
437 DRM_DEBUG_KMS("Found PatherPoint PCH\n"); 437 DRM_DEBUG_KMS("Found PatherPoint PCH\n");
438 WARN_ON(!(IS_GEN6(dev) || IS_IVYBRIDGE(dev))); 438 WARN_ON(!(IS_GEN6(dev) || IS_IVYBRIDGE(dev)));
439 } else if (id == INTEL_PCH_LPT_DEVICE_ID_TYPE) { 439 } else if (id == INTEL_PCH_LPT_DEVICE_ID_TYPE) {
440 dev_priv->pch_type = PCH_LPT; 440 dev_priv->pch_type = PCH_LPT;
441 dev_priv->num_pch_pll = 0; 441 dev_priv->num_pch_pll = 0;
442 DRM_DEBUG_KMS("Found LynxPoint PCH\n"); 442 DRM_DEBUG_KMS("Found LynxPoint PCH\n");
443 WARN_ON(!IS_HASWELL(dev)); 443 WARN_ON(!IS_HASWELL(dev));
444 } else if (id == INTEL_PCH_LPT_LP_DEVICE_ID_TYPE) { 444 } else if (id == INTEL_PCH_LPT_LP_DEVICE_ID_TYPE) {
445 dev_priv->pch_type = PCH_LPT; 445 dev_priv->pch_type = PCH_LPT;
446 dev_priv->num_pch_pll = 0; 446 dev_priv->num_pch_pll = 0;
447 DRM_DEBUG_KMS("Found LynxPoint LP PCH\n"); 447 DRM_DEBUG_KMS("Found LynxPoint LP PCH\n");
448 WARN_ON(!IS_HASWELL(dev)); 448 WARN_ON(!IS_HASWELL(dev));
449 } 449 }
450 BUG_ON(dev_priv->num_pch_pll > I915_NUM_PLLS); 450 BUG_ON(dev_priv->num_pch_pll > I915_NUM_PLLS);
451 } 451 }
452 pci_dev_put(pch); 452 pci_dev_put(pch);
453 } 453 }
454} 454}
455 455
456bool i915_semaphore_is_enabled(struct drm_device *dev) 456bool i915_semaphore_is_enabled(struct drm_device *dev)
457{ 457{
458 if (INTEL_INFO(dev)->gen < 6) 458 if (INTEL_INFO(dev)->gen < 6)
459 return 0; 459 return 0;
460 460
461 if (i915_semaphores >= 0) 461 if (i915_semaphores >= 0)
462 return i915_semaphores; 462 return i915_semaphores;
463 463
464#ifdef CONFIG_INTEL_IOMMU 464#ifdef CONFIG_INTEL_IOMMU
465 /* Enable semaphores on SNB when IO remapping is off */ 465 /* Enable semaphores on SNB when IO remapping is off */
466 if (INTEL_INFO(dev)->gen == 6 && intel_iommu_gfx_mapped) 466 if (INTEL_INFO(dev)->gen == 6 && intel_iommu_gfx_mapped)
467 return false; 467 return false;
468#endif 468#endif
469 469
470 return 1; 470 return 1;
471} 471}
472 472
473static int i915_drm_freeze(struct drm_device *dev) 473static int i915_drm_freeze(struct drm_device *dev)
474{ 474{
475 struct drm_i915_private *dev_priv = dev->dev_private; 475 struct drm_i915_private *dev_priv = dev->dev_private;
476 476
477 drm_kms_helper_poll_disable(dev); 477 drm_kms_helper_poll_disable(dev);
478 478
479#ifndef __NetBSD__ /* pmf handles this for us. */ 479#ifndef __NetBSD__ /* pmf handles this for us. */
480 pci_save_state(dev->pdev); 480 pci_save_state(dev->pdev);
481#endif 481#endif
482 482
483 /* If KMS is active, we do the leavevt stuff here */ 483 /* If KMS is active, we do the leavevt stuff here */
484 if (drm_core_check_feature(dev, DRIVER_MODESET)) { 484 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
485 int error = i915_gem_idle(dev); 485 int error = i915_gem_idle(dev);
486 if (error) { 486 if (error) {
487#ifdef __NetBSD__ 487#ifdef __NetBSD__
488 dev_err(pci_dev_dev(dev->pdev), 488 dev_err(pci_dev_dev(dev->pdev),
489 "GEM idle failed, resume might fail\n"); 489 "GEM idle failed, resume might fail\n");
490#else 490#else
491 dev_err(&dev->pdev->dev, 491 dev_err(&dev->pdev->dev,
492 "GEM idle failed, resume might fail\n"); 492 "GEM idle failed, resume might fail\n");
493#endif 493#endif
494 return error; 494 return error;
495 } 495 }
496 496
497 cancel_delayed_work_sync(&dev_priv->rps.delayed_resume_work); 497 cancel_delayed_work_sync(&dev_priv->rps.delayed_resume_work);
498 498
499 intel_modeset_disable(dev); 499 intel_modeset_disable(dev);
500 500
501 drm_irq_uninstall(dev); 501 drm_irq_uninstall(dev);
502 } 502 }
503 503
504 i915_save_state(dev); 504 i915_save_state(dev);
505 505
506 intel_opregion_fini(dev); 506 intel_opregion_fini(dev);
507 507
508 /* Modeset on resume, not lid events */ 508 /* Modeset on resume, not lid events */
509 dev_priv->modeset_on_lid = 0; 509 dev_priv->modeset_on_lid = 0;
510 510
 511#ifndef __NetBSD__ /* XXX fb */
511 console_lock(); 512 console_lock();
512 intel_fbdev_set_suspend(dev, 1); 513 intel_fbdev_set_suspend(dev, 1);
513 console_unlock(); 514 console_unlock();
 515#endif
514 516
515 return 0; 517 return 0;
516} 518}
517 519
518int i915_suspend(struct drm_device *dev, pm_message_t state) 520int i915_suspend(struct drm_device *dev, pm_message_t state)
519{ 521{
520 int error; 522 int error;
521 523
522 if (!dev || !dev->dev_private) { 524 if (!dev || !dev->dev_private) {
523 DRM_ERROR("dev: %p\n", dev); 525 DRM_ERROR("dev: %p\n", dev);
524 DRM_ERROR("DRM not initialized, aborting suspend.\n"); 526 DRM_ERROR("DRM not initialized, aborting suspend.\n");
525 return -ENODEV; 527 return -ENODEV;
526 } 528 }
527 529
528 if (state.event == PM_EVENT_PRETHAW) 530 if (state.event == PM_EVENT_PRETHAW)
529 return 0; 531 return 0;
530 532
531 533
532 if (dev->switch_power_state == DRM_SWITCH_POWER_OFF) 534 if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
533 return 0; 535 return 0;
534 536
535 error = i915_drm_freeze(dev); 537 error = i915_drm_freeze(dev);
536 if (error) 538 if (error)
537 return error; 539 return error;
538 540
539 if (state.event == PM_EVENT_SUSPEND) { 541 if (state.event == PM_EVENT_SUSPEND) {
540 /* Shut down the device */ 542 /* Shut down the device */
541 pci_disable_device(dev->pdev); 543 pci_disable_device(dev->pdev);
542 pci_set_power_state(dev->pdev, PCI_D3hot); 544 pci_set_power_state(dev->pdev, PCI_D3hot);
543 } 545 }
544 546
545 return 0; 547 return 0;
546} 548}
547 549
 550#ifndef __NetBSD__ /* XXX fb */
548void intel_console_resume(struct work_struct *work) 551void intel_console_resume(struct work_struct *work)
549{ 552{
550 struct drm_i915_private *dev_priv = 553 struct drm_i915_private *dev_priv =
551 container_of(work, struct drm_i915_private, 554 container_of(work, struct drm_i915_private,
552 console_resume_work); 555 console_resume_work);
553 struct drm_device *dev = dev_priv->dev; 556 struct drm_device *dev = dev_priv->dev;
554 557
555 console_lock(); 558 console_lock();
556 intel_fbdev_set_suspend(dev, 0); 559 intel_fbdev_set_suspend(dev, 0);
557 console_unlock(); 560 console_unlock();
558} 561}
 562#endif
559 563
560static int __i915_drm_thaw(struct drm_device *dev) 564static int __i915_drm_thaw(struct drm_device *dev)
561{ 565{
562 struct drm_i915_private *dev_priv = dev->dev_private; 566 struct drm_i915_private *dev_priv = dev->dev_private;
563 int error = 0; 567 int error = 0;
564 568
565 i915_restore_state(dev); 569 i915_restore_state(dev);
566 intel_opregion_setup(dev); 570 intel_opregion_setup(dev);
567 571
568 /* KMS EnterVT equivalent */ 572 /* KMS EnterVT equivalent */
569 if (drm_core_check_feature(dev, DRIVER_MODESET)) { 573 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
570 intel_init_pch_refclk(dev); 574 intel_init_pch_refclk(dev);
571 575
572 mutex_lock(&dev->struct_mutex); 576 mutex_lock(&dev->struct_mutex);
573 dev_priv->mm.suspended = 0; 577 dev_priv->mm.suspended = 0;
574 578
575 error = i915_gem_init_hw(dev); 579 error = i915_gem_init_hw(dev);
576 mutex_unlock(&dev->struct_mutex); 580 mutex_unlock(&dev->struct_mutex);
577 581
578 intel_modeset_init_hw(dev); 582 intel_modeset_init_hw(dev);
579 intel_modeset_setup_hw_state(dev, false); 583 intel_modeset_setup_hw_state(dev, false);
580 drm_irq_install(dev); 584 drm_irq_install(dev);
581 } 585 }
582 586
583 intel_opregion_init(dev); 587 intel_opregion_init(dev);
584 588
585 dev_priv->modeset_on_lid = 0; 589 dev_priv->modeset_on_lid = 0;
586 590
 591#ifndef __NetBSD__ /* XXX fb */
587 /* 592 /*
588 * The console lock can be pretty contented on resume due 593 * The console lock can be pretty contented on resume due
589 * to all the printk activity. Try to keep it out of the hot 594 * to all the printk activity. Try to keep it out of the hot
590 * path of resume if possible. 595 * path of resume if possible.
591 */ 596 */
592 if (console_trylock()) { 597 if (console_trylock()) {
593 intel_fbdev_set_suspend(dev, 0); 598 intel_fbdev_set_suspend(dev, 0);
594 console_unlock(); 599 console_unlock();
595 } else { 600 } else {
596 schedule_work(&dev_priv->console_resume_work); 601 schedule_work(&dev_priv->console_resume_work);
597 } 602 }
 603#endif
598 604
599 return error; 605 return error;
600} 606}
601 607
602static int i915_drm_thaw(struct drm_device *dev) 608static int i915_drm_thaw(struct drm_device *dev)
603{ 609{
604 int error = 0; 610 int error = 0;
605 611
606 intel_gt_reset(dev); 612 intel_gt_reset(dev);
607 613
608 if (drm_core_check_feature(dev, DRIVER_MODESET)) { 614 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
609 mutex_lock(&dev->struct_mutex); 615 mutex_lock(&dev->struct_mutex);
610 i915_gem_restore_gtt_mappings(dev); 616 i915_gem_restore_gtt_mappings(dev);
611 mutex_unlock(&dev->struct_mutex); 617 mutex_unlock(&dev->struct_mutex);
612 } 618 }
613 619
614 __i915_drm_thaw(dev); 620 __i915_drm_thaw(dev);
615 621
616 return error; 622 return error;
617} 623}
618 624
619int i915_resume(struct drm_device *dev) 625int i915_resume(struct drm_device *dev)
620{ 626{
621 struct drm_i915_private *dev_priv = dev->dev_private; 627 struct drm_i915_private *dev_priv = dev->dev_private;
622 int ret; 628 int ret;
623 629
624 if (dev->switch_power_state == DRM_SWITCH_POWER_OFF) 630 if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
625 return 0; 631 return 0;
626 632
627 if (pci_enable_device(dev->pdev)) 633 if (pci_enable_device(dev->pdev))
628 return -EIO; 634 return -EIO;
629 635
630 pci_set_master(dev->pdev); 636 pci_set_master(dev->pdev);
631 637
632 intel_gt_reset(dev); 638 intel_gt_reset(dev);
633 639
634 /* 640 /*
635 * Platforms with opregion should have sane BIOS, older ones (gen3 and 641 * Platforms with opregion should have sane BIOS, older ones (gen3 and
636 * earlier) need this since the BIOS might clear all our scratch PTEs. 642 * earlier) need this since the BIOS might clear all our scratch PTEs.
637 */ 643 */
638 if (drm_core_check_feature(dev, DRIVER_MODESET) && 644 if (drm_core_check_feature(dev, DRIVER_MODESET) &&
639 !dev_priv->opregion.header) { 645 !dev_priv->opregion.header) {
640 mutex_lock(&dev->struct_mutex); 646 mutex_lock(&dev->struct_mutex);
641 i915_gem_restore_gtt_mappings(dev); 647 i915_gem_restore_gtt_mappings(dev);
642 mutex_unlock(&dev->struct_mutex); 648 mutex_unlock(&dev->struct_mutex);
643 } 649 }
644 650
645 ret = __i915_drm_thaw(dev); 651 ret = __i915_drm_thaw(dev);
646 if (ret) 652 if (ret)
647 return ret; 653 return ret;
648 654
649 drm_kms_helper_poll_enable(dev); 655 drm_kms_helper_poll_enable(dev);
650 return 0; 656 return 0;
651} 657}
652 658
653static int i8xx_do_reset(struct drm_device *dev) 659static int i8xx_do_reset(struct drm_device *dev)
654{ 660{
655 struct drm_i915_private *dev_priv = dev->dev_private; 661 struct drm_i915_private *dev_priv = dev->dev_private;
656 662
657 if (IS_I85X(dev)) 663 if (IS_I85X(dev))
658 return -ENODEV; 664 return -ENODEV;
659 665
660 I915_WRITE(D_STATE, I915_READ(D_STATE) | DSTATE_GFX_RESET_I830); 666 I915_WRITE(D_STATE, I915_READ(D_STATE) | DSTATE_GFX_RESET_I830);
661 POSTING_READ(D_STATE); 667 POSTING_READ(D_STATE);
662 668
663 if (IS_I830(dev) || IS_845G(dev)) { 669 if (IS_I830(dev) || IS_845G(dev)) {
664 I915_WRITE(DEBUG_RESET_I830, 670 I915_WRITE(DEBUG_RESET_I830,
665 DEBUG_RESET_DISPLAY | 671 DEBUG_RESET_DISPLAY |
666 DEBUG_RESET_RENDER | 672 DEBUG_RESET_RENDER |
667 DEBUG_RESET_FULL); 673 DEBUG_RESET_FULL);
668 POSTING_READ(DEBUG_RESET_I830); 674 POSTING_READ(DEBUG_RESET_I830);
669 msleep(1); 675 msleep(1);
670 676
671 I915_WRITE(DEBUG_RESET_I830, 0); 677 I915_WRITE(DEBUG_RESET_I830, 0);
672 POSTING_READ(DEBUG_RESET_I830); 678 POSTING_READ(DEBUG_RESET_I830);
673 } 679 }
674 680
675 msleep(1); 681 msleep(1);
676 682
677 I915_WRITE(D_STATE, I915_READ(D_STATE) & ~DSTATE_GFX_RESET_I830); 683 I915_WRITE(D_STATE, I915_READ(D_STATE) & ~DSTATE_GFX_RESET_I830);
678 POSTING_READ(D_STATE); 684 POSTING_READ(D_STATE);
679 685
680 return 0; 686 return 0;
681} 687}
682 688
683static int i965_reset_complete(struct drm_device *dev) 689static int i965_reset_complete(struct drm_device *dev)
684{ 690{
685 u8 gdrst; 691 u8 gdrst;
686 pci_read_config_byte(dev->pdev, I965_GDRST, &gdrst); 692 pci_read_config_byte(dev->pdev, I965_GDRST, &gdrst);
687 return (gdrst & GRDOM_RESET_ENABLE) == 0; 693 return (gdrst & GRDOM_RESET_ENABLE) == 0;
688} 694}
689 695
690static int i965_do_reset(struct drm_device *dev) 696static int i965_do_reset(struct drm_device *dev)
691{ 697{
692 int ret; 698 int ret;
693 u8 gdrst; 699 u8 gdrst;
694 700
695 /* 701 /*
696 * Set the domains we want to reset (GRDOM/bits 2 and 3) as 702 * Set the domains we want to reset (GRDOM/bits 2 and 3) as
697 * well as the reset bit (GR/bit 0). Setting the GR bit 703 * well as the reset bit (GR/bit 0). Setting the GR bit
698 * triggers the reset; when done, the hardware will clear it. 704 * triggers the reset; when done, the hardware will clear it.
699 */ 705 */
700 pci_read_config_byte(dev->pdev, I965_GDRST, &gdrst); 706 pci_read_config_byte(dev->pdev, I965_GDRST, &gdrst);
701 pci_write_config_byte(dev->pdev, I965_GDRST, 707 pci_write_config_byte(dev->pdev, I965_GDRST,
702 gdrst | GRDOM_RENDER | 708 gdrst | GRDOM_RENDER |
703 GRDOM_RESET_ENABLE); 709 GRDOM_RESET_ENABLE);
704 ret = wait_for(i965_reset_complete(dev), 500); 710 ret = wait_for(i965_reset_complete(dev), 500);
705 if (ret) 711 if (ret)
706 return ret; 712 return ret;
707 713
708 /* We can't reset render&media without also resetting display ... */ 714 /* We can't reset render&media without also resetting display ... */
709 pci_read_config_byte(dev->pdev, I965_GDRST, &gdrst); 715 pci_read_config_byte(dev->pdev, I965_GDRST, &gdrst);
710 pci_write_config_byte(dev->pdev, I965_GDRST, 716 pci_write_config_byte(dev->pdev, I965_GDRST,
711 gdrst | GRDOM_MEDIA | 717 gdrst | GRDOM_MEDIA |
712 GRDOM_RESET_ENABLE); 718 GRDOM_RESET_ENABLE);
713 719
714 return wait_for(i965_reset_complete(dev), 500); 720 return wait_for(i965_reset_complete(dev), 500);
715} 721}
716 722
717static int ironlake_do_reset(struct drm_device *dev) 723static int ironlake_do_reset(struct drm_device *dev)
718{ 724{
719 struct drm_i915_private *dev_priv = dev->dev_private; 725 struct drm_i915_private *dev_priv = dev->dev_private;
720 u32 gdrst; 726 u32 gdrst;
721 int ret; 727 int ret;
722 728
723 gdrst = I915_READ(MCHBAR_MIRROR_BASE + ILK_GDSR); 729 gdrst = I915_READ(MCHBAR_MIRROR_BASE + ILK_GDSR);
724 I915_WRITE(MCHBAR_MIRROR_BASE + ILK_GDSR, 730 I915_WRITE(MCHBAR_MIRROR_BASE + ILK_GDSR,
725 gdrst | GRDOM_RENDER | GRDOM_RESET_ENABLE); 731 gdrst | GRDOM_RENDER | GRDOM_RESET_ENABLE);
726 ret = wait_for(I915_READ(MCHBAR_MIRROR_BASE + ILK_GDSR) & 0x1, 500); 732 ret = wait_for(I915_READ(MCHBAR_MIRROR_BASE + ILK_GDSR) & 0x1, 500);
727 if (ret) 733 if (ret)
728 return ret; 734 return ret;
729 735
730 /* We can't reset render&media without also resetting display ... */ 736 /* We can't reset render&media without also resetting display ... */
731 gdrst = I915_READ(MCHBAR_MIRROR_BASE + ILK_GDSR); 737 gdrst = I915_READ(MCHBAR_MIRROR_BASE + ILK_GDSR);
732 I915_WRITE(MCHBAR_MIRROR_BASE + ILK_GDSR, 738 I915_WRITE(MCHBAR_MIRROR_BASE + ILK_GDSR,
733 gdrst | GRDOM_MEDIA | GRDOM_RESET_ENABLE); 739 gdrst | GRDOM_MEDIA | GRDOM_RESET_ENABLE);
734 return wait_for(I915_READ(MCHBAR_MIRROR_BASE + ILK_GDSR) & 0x1, 500); 740 return wait_for(I915_READ(MCHBAR_MIRROR_BASE + ILK_GDSR) & 0x1, 500);
735} 741}
736 742
737static int gen6_do_reset(struct drm_device *dev) 743static int gen6_do_reset(struct drm_device *dev)
738{ 744{
739 struct drm_i915_private *dev_priv = dev->dev_private; 745 struct drm_i915_private *dev_priv = dev->dev_private;
740 int ret; 746 int ret;
741 unsigned long irqflags; 747 unsigned long irqflags;
742 748
743 /* Hold gt_lock across reset to prevent any register access 749 /* Hold gt_lock across reset to prevent any register access
744 * with forcewake not set correctly 750 * with forcewake not set correctly
745 */ 751 */
746 spin_lock_irqsave(&dev_priv->gt_lock, irqflags); 752 spin_lock_irqsave(&dev_priv->gt_lock, irqflags);
747 753
748 /* Reset the chip */ 754 /* Reset the chip */
749 755
750 /* GEN6_GDRST is not in the gt power well, no need to check 756 /* GEN6_GDRST is not in the gt power well, no need to check
751 * for fifo space for the write or forcewake the chip for 757 * for fifo space for the write or forcewake the chip for
752 * the read 758 * the read
753 */ 759 */
754 I915_WRITE_NOTRACE(GEN6_GDRST, GEN6_GRDOM_FULL); 760 I915_WRITE_NOTRACE(GEN6_GDRST, GEN6_GRDOM_FULL);
755 761
756 /* Spin waiting for the device to ack the reset request */ 762 /* Spin waiting for the device to ack the reset request */
757 ret = wait_for((I915_READ_NOTRACE(GEN6_GDRST) & GEN6_GRDOM_FULL) == 0, 500); 763 ret = wait_for((I915_READ_NOTRACE(GEN6_GDRST) & GEN6_GRDOM_FULL) == 0, 500);
758 764
759 /* If reset with a user forcewake, try to restore, otherwise turn it off */ 765 /* If reset with a user forcewake, try to restore, otherwise turn it off */
760 if (dev_priv->forcewake_count) 766 if (dev_priv->forcewake_count)
761 dev_priv->gt.force_wake_get(dev_priv); 767 dev_priv->gt.force_wake_get(dev_priv);
762 else 768 else
763 dev_priv->gt.force_wake_put(dev_priv); 769 dev_priv->gt.force_wake_put(dev_priv);
764 770
765 /* Restore fifo count */ 771 /* Restore fifo count */
766 dev_priv->gt_fifo_count = I915_READ_NOTRACE(GT_FIFO_FREE_ENTRIES); 772 dev_priv->gt_fifo_count = I915_READ_NOTRACE(GT_FIFO_FREE_ENTRIES);
767 773
768 spin_unlock_irqrestore(&dev_priv->gt_lock, irqflags); 774 spin_unlock_irqrestore(&dev_priv->gt_lock, irqflags);
769 return ret; 775 return ret;
770} 776}
771 777
772int intel_gpu_reset(struct drm_device *dev) 778int intel_gpu_reset(struct drm_device *dev)
773{ 779{
774 struct drm_i915_private *dev_priv = dev->dev_private; 780 struct drm_i915_private *dev_priv = dev->dev_private;
775 int ret = -ENODEV; 781 int ret = -ENODEV;
776 782
777 switch (INTEL_INFO(dev)->gen) { 783 switch (INTEL_INFO(dev)->gen) {
778 case 7: 784 case 7:
779 case 6: 785 case 6:
780 ret = gen6_do_reset(dev); 786 ret = gen6_do_reset(dev);
781 break; 787 break;
782 case 5: 788 case 5:
783 ret = ironlake_do_reset(dev); 789 ret = ironlake_do_reset(dev);
784 break; 790 break;
785 case 4: 791 case 4:
786 ret = i965_do_reset(dev); 792 ret = i965_do_reset(dev);
787 break; 793 break;
788 case 2: 794 case 2:
789 ret = i8xx_do_reset(dev); 795 ret = i8xx_do_reset(dev);
790 break; 796 break;
791 } 797 }
792 798
793 /* Also reset the gpu hangman. */ 799 /* Also reset the gpu hangman. */
794 if (dev_priv->stop_rings) { 800 if (dev_priv->stop_rings) {
795 DRM_DEBUG("Simulated gpu hang, resetting stop_rings\n"); 801 DRM_DEBUG("Simulated gpu hang, resetting stop_rings\n");
796 dev_priv->stop_rings = 0; 802 dev_priv->stop_rings = 0;
797 if (ret == -ENODEV) { 803 if (ret == -ENODEV) {
798 DRM_ERROR("Reset not implemented, but ignoring " 804 DRM_ERROR("Reset not implemented, but ignoring "
799 "error for simulated gpu hangs\n"); 805 "error for simulated gpu hangs\n");
800 ret = 0; 806 ret = 0;
801 } 807 }
802 } 808 }
803 809
804 return ret; 810 return ret;
805} 811}
806 812
807/** 813/**
808 * i915_reset - reset chip after a hang 814 * i915_reset - reset chip after a hang
809 * @dev: drm device to reset 815 * @dev: drm device to reset
810 * 816 *
811 * Reset the chip. Useful if a hang is detected. Returns zero on successful 817 * Reset the chip. Useful if a hang is detected. Returns zero on successful
812 * reset or otherwise an error code. 818 * reset or otherwise an error code.
813 * 819 *
814 * Procedure is fairly simple: 820 * Procedure is fairly simple:
815 * - reset the chip using the reset reg 821 * - reset the chip using the reset reg
816 * - re-init context state 822 * - re-init context state
817 * - re-init hardware status page 823 * - re-init hardware status page
818 * - re-init ring buffer 824 * - re-init ring buffer
819 * - re-init interrupt state 825 * - re-init interrupt state
820 * - re-init display 826 * - re-init display
821 */ 827 */
822int i915_reset(struct drm_device *dev) 828int i915_reset(struct drm_device *dev)
823{ 829{
824 drm_i915_private_t *dev_priv = dev->dev_private; 830 drm_i915_private_t *dev_priv = dev->dev_private;
825 int ret; 831 int ret;
826 832
827 if (!i915_try_reset) 833 if (!i915_try_reset)
828 return 0; 834 return 0;
829 835
830 mutex_lock(&dev->struct_mutex); 836 mutex_lock(&dev->struct_mutex);
831 837
832 i915_gem_reset(dev); 838 i915_gem_reset(dev);
833 839
834 ret = -ENODEV; 840 ret = -ENODEV;
835 if (get_seconds() - dev_priv->last_gpu_reset < 5) 841 if (get_seconds() - dev_priv->last_gpu_reset < 5)
836 DRM_ERROR("GPU hanging too fast, declaring wedged!\n"); 842 DRM_ERROR("GPU hanging too fast, declaring wedged!\n");
837 else 843 else
838 ret = intel_gpu_reset(dev); 844 ret = intel_gpu_reset(dev);
839 845
840 dev_priv->last_gpu_reset = get_seconds(); 846 dev_priv->last_gpu_reset = get_seconds();
841 if (ret) { 847 if (ret) {
842 DRM_ERROR("Failed to reset chip.\n"); 848 DRM_ERROR("Failed to reset chip.\n");
843 mutex_unlock(&dev->struct_mutex); 849 mutex_unlock(&dev->struct_mutex);
844 return ret; 850 return ret;
845 } 851 }
846 852
847 /* Ok, now get things going again... */ 853 /* Ok, now get things going again... */
848 854
849 /* 855 /*
850 * Everything depends on having the GTT running, so we need to start 856 * Everything depends on having the GTT running, so we need to start
851 * there. Fortunately we don't need to do this unless we reset the 857 * there. Fortunately we don't need to do this unless we reset the
852 * chip at a PCI level. 858 * chip at a PCI level.
853 * 859 *
854 * Next we need to restore the context, but we don't use those 860 * Next we need to restore the context, but we don't use those
855 * yet either... 861 * yet either...
856 * 862 *
857 * Ring buffer needs to be re-initialized in the KMS case, or if X 863 * Ring buffer needs to be re-initialized in the KMS case, or if X
858 * was running at the time of the reset (i.e. we weren't VT 864 * was running at the time of the reset (i.e. we weren't VT
859 * switched away). 865 * switched away).
860 */ 866 */
861 if (drm_core_check_feature(dev, DRIVER_MODESET) || 867 if (drm_core_check_feature(dev, DRIVER_MODESET) ||
862 !dev_priv->mm.suspended) { 868 !dev_priv->mm.suspended) {
863 struct intel_ring_buffer *ring; 869 struct intel_ring_buffer *ring;
864 int i; 870 int i;
865 871
866 dev_priv->mm.suspended = 0; 872 dev_priv->mm.suspended = 0;
867 873
868 i915_gem_init_swizzling(dev); 874 i915_gem_init_swizzling(dev);
869 875
870 for_each_ring(ring, dev_priv, i) 876 for_each_ring(ring, dev_priv, i)
871 ring->init(ring); 877 ring->init(ring);
872 878
873 i915_gem_context_init(dev); 879 i915_gem_context_init(dev);
874 i915_gem_init_ppgtt(dev); 880 i915_gem_init_ppgtt(dev);
875 881
876 /* 882 /*
877 * It would make sense to re-init all the other hw state, at 883 * It would make sense to re-init all the other hw state, at
878 * least the rps/rc6/emon init done within modeset_init_hw. For 884 * least the rps/rc6/emon init done within modeset_init_hw. For
879 * some unknown reason, this blows up my ilk, so don't. 885 * some unknown reason, this blows up my ilk, so don't.
880 */ 886 */
881 887
882 mutex_unlock(&dev->struct_mutex); 888 mutex_unlock(&dev->struct_mutex);
883 889
884 drm_irq_uninstall(dev); 890 drm_irq_uninstall(dev);
885 drm_irq_install(dev); 891 drm_irq_install(dev);
886 } else { 892 } else {
887 mutex_unlock(&dev->struct_mutex); 893 mutex_unlock(&dev->struct_mutex);
888 } 894 }
889 895
890 return 0; 896 return 0;
891} 897}
892 898
893static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 899static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
894{ 900{
895 struct intel_device_info *intel_info = 901 struct intel_device_info *intel_info =
896 (struct intel_device_info *) ent->driver_data; 902 (struct intel_device_info *) ent->driver_data;
897 903
898 if (intel_info->is_valleyview) 904 if (intel_info->is_valleyview)
899 if(!i915_preliminary_hw_support) { 905 if(!i915_preliminary_hw_support) {
900 DRM_ERROR("Preliminary hardware support disabled\n"); 906 DRM_ERROR("Preliminary hardware support disabled\n");
901 return -ENODEV; 907 return -ENODEV;
902 } 908 }
903 909
904 /* Only bind to function 0 of the device. Early generations 910 /* Only bind to function 0 of the device. Early generations
905 * used function 1 as a placeholder for multi-head. This causes 911 * used function 1 as a placeholder for multi-head. This causes
906 * us confusion instead, especially on the systems where both 912 * us confusion instead, especially on the systems where both
907 * functions have the same PCI-ID! 913 * functions have the same PCI-ID!
908 */ 914 */
909 if (PCI_FUNC(pdev->devfn)) 915 if (PCI_FUNC(pdev->devfn))
910 return -ENODEV; 916 return -ENODEV;
911 917
912 /* We've managed to ship a kms-enabled ddx that shipped with an XvMC 918 /* We've managed to ship a kms-enabled ddx that shipped with an XvMC
913 * implementation for gen3 (and only gen3) that used legacy drm maps 919 * implementation for gen3 (and only gen3) that used legacy drm maps
914 * (gasp!) to share buffers between X and the client. Hence we need to 920 * (gasp!) to share buffers between X and the client. Hence we need to
915 * keep around the fake agp stuff for gen3, even when kms is enabled. */ 921 * keep around the fake agp stuff for gen3, even when kms is enabled. */
916 if (intel_info->gen != 3) { 922 if (intel_info->gen != 3) {
917 driver.driver_features &= 923 driver.driver_features &=
918 ~(DRIVER_USE_AGP | DRIVER_REQUIRE_AGP); 924 ~(DRIVER_USE_AGP | DRIVER_REQUIRE_AGP);
919 } else if (!intel_agp_enabled) { 925 } else if (!intel_agp_enabled) {
920 DRM_ERROR("drm/i915 can't work without intel_agp module!\n"); 926 DRM_ERROR("drm/i915 can't work without intel_agp module!\n");
921 return -ENODEV; 927 return -ENODEV;
922 } 928 }
923 929
924 return drm_get_pci_dev(pdev, ent, &driver); 930 return drm_get_pci_dev(pdev, ent, &driver);
925} 931}
926 932
927static void 933static void
928i915_pci_remove(struct pci_dev *pdev) 934i915_pci_remove(struct pci_dev *pdev)
929{ 935{
930 struct drm_device *dev = pci_get_drvdata(pdev); 936 struct drm_device *dev = pci_get_drvdata(pdev);
931 937
932 drm_put_dev(dev); 938 drm_put_dev(dev);
933} 939}
934 940
935static int i915_pm_suspend(struct device *dev) 941static int i915_pm_suspend(struct device *dev)
936{ 942{
937 struct pci_dev *pdev = to_pci_dev(dev); 943 struct pci_dev *pdev = to_pci_dev(dev);
938 struct drm_device *drm_dev = pci_get_drvdata(pdev); 944 struct drm_device *drm_dev = pci_get_drvdata(pdev);
939 int error; 945 int error;
940 946
941 if (!drm_dev || !drm_dev->dev_private) { 947 if (!drm_dev || !drm_dev->dev_private) {
942 dev_err(dev, "DRM not initialized, aborting suspend.\n"); 948 dev_err(dev, "DRM not initialized, aborting suspend.\n");
943 return -ENODEV; 949 return -ENODEV;
944 } 950 }
945 951
946 if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF) 952 if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF)
947 return 0; 953 return 0;
948 954
949 error = i915_drm_freeze(drm_dev); 955 error = i915_drm_freeze(drm_dev);
950 if (error) 956 if (error)
951 return error; 957 return error;
952 958
953 pci_disable_device(pdev); 959 pci_disable_device(pdev);
954 pci_set_power_state(pdev, PCI_D3hot); 960 pci_set_power_state(pdev, PCI_D3hot);
955 961
956 return 0; 962 return 0;
957} 963}
958 964
959static int i915_pm_resume(struct device *dev) 965static int i915_pm_resume(struct device *dev)
960{ 966{
961 struct pci_dev *pdev = to_pci_dev(dev); 967 struct pci_dev *pdev = to_pci_dev(dev);
962 struct drm_device *drm_dev = pci_get_drvdata(pdev); 968 struct drm_device *drm_dev = pci_get_drvdata(pdev);
963 969
964 return i915_resume(drm_dev); 970 return i915_resume(drm_dev);
965} 971}
966 972
967static int i915_pm_freeze(struct device *dev) 973static int i915_pm_freeze(struct device *dev)
968{ 974{
969 struct pci_dev *pdev = to_pci_dev(dev); 975 struct pci_dev *pdev = to_pci_dev(dev);
970 struct drm_device *drm_dev = pci_get_drvdata(pdev); 976 struct drm_device *drm_dev = pci_get_drvdata(pdev);
971 977
972 if (!drm_dev || !drm_dev->dev_private) { 978 if (!drm_dev || !drm_dev->dev_private) {
973 dev_err(dev, "DRM not initialized, aborting suspend.\n"); 979 dev_err(dev, "DRM not initialized, aborting suspend.\n");
974 return -ENODEV; 980 return -ENODEV;
975 } 981 }
976 982
977 return i915_drm_freeze(drm_dev); 983 return i915_drm_freeze(drm_dev);
978} 984}
979 985
980static int i915_pm_thaw(struct device *dev) 986static int i915_pm_thaw(struct device *dev)
981{ 987{
982 struct pci_dev *pdev = to_pci_dev(dev); 988 struct pci_dev *pdev = to_pci_dev(dev);
983 struct drm_device *drm_dev = pci_get_drvdata(pdev); 989 struct drm_device *drm_dev = pci_get_drvdata(pdev);
984 990
985 return i915_drm_thaw(drm_dev); 991 return i915_drm_thaw(drm_dev);
986} 992}
987 993
988static int i915_pm_poweroff(struct device *dev) 994static int i915_pm_poweroff(struct device *dev)
989{ 995{
990 struct pci_dev *pdev = to_pci_dev(dev); 996 struct pci_dev *pdev = to_pci_dev(dev);
991 struct drm_device *drm_dev = pci_get_drvdata(pdev); 997 struct drm_device *drm_dev = pci_get_drvdata(pdev);
992 998
993 return i915_drm_freeze(drm_dev); 999 return i915_drm_freeze(drm_dev);
994} 1000}
995 1001
996static const struct dev_pm_ops i915_pm_ops = { 1002static const struct dev_pm_ops i915_pm_ops = {
997 .suspend = i915_pm_suspend, 1003 .suspend = i915_pm_suspend,
998 .resume = i915_pm_resume, 1004 .resume = i915_pm_resume,
999 .freeze = i915_pm_freeze, 1005 .freeze = i915_pm_freeze,
1000 .thaw = i915_pm_thaw, 1006 .thaw = i915_pm_thaw,
1001 .poweroff = i915_pm_poweroff, 1007 .poweroff = i915_pm_poweroff,
1002 .restore = i915_pm_resume, 1008 .restore = i915_pm_resume,
1003}; 1009};
1004 1010
1005static const struct vm_operations_struct i915_gem_vm_ops = { 1011static const struct vm_operations_struct i915_gem_vm_ops = {
1006 .fault = i915_gem_fault, 1012 .fault = i915_gem_fault,
1007 .open = drm_gem_vm_open, 1013 .open = drm_gem_vm_open,
1008 .close = drm_gem_vm_close, 1014 .close = drm_gem_vm_close,
1009}; 1015};
1010 1016
1011static const struct file_operations i915_driver_fops = { 1017static const struct file_operations i915_driver_fops = {
1012 .owner = THIS_MODULE, 1018 .owner = THIS_MODULE,
1013 .open = drm_open, 1019 .open = drm_open,
1014 .release = drm_release, 1020 .release = drm_release,
1015 .unlocked_ioctl = drm_ioctl, 1021 .unlocked_ioctl = drm_ioctl,
1016 .mmap = drm_gem_mmap, 1022 .mmap = drm_gem_mmap,
1017 .poll = drm_poll, 1023 .poll = drm_poll,
1018 .fasync = drm_fasync, 1024 .fasync = drm_fasync,
1019 .read = drm_read, 1025 .read = drm_read,
1020#ifdef CONFIG_COMPAT 1026#ifdef CONFIG_COMPAT
1021 .compat_ioctl = i915_compat_ioctl, 1027 .compat_ioctl = i915_compat_ioctl,
1022#endif 1028#endif
1023 .llseek = noop_llseek, 1029 .llseek = noop_llseek,
1024}; 1030};
1025 1031
1026static struct drm_driver driver = { 1032static struct drm_driver driver = {
1027 /* Don't use MTRRs here; the Xserver or userspace app should 1033 /* Don't use MTRRs here; the Xserver or userspace app should
1028 * deal with them for Intel hardware. 1034 * deal with them for Intel hardware.
1029 */ 1035 */
1030 .driver_features = 1036 .driver_features =
1031 DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | /* DRIVER_USE_MTRR |*/ 1037 DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | /* DRIVER_USE_MTRR |*/
1032 DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_GEM | DRIVER_PRIME, 1038 DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_GEM | DRIVER_PRIME,
1033 .load = i915_driver_load, 1039 .load = i915_driver_load,
1034 .unload = i915_driver_unload, 1040 .unload = i915_driver_unload,
1035 .open = i915_driver_open, 1041 .open = i915_driver_open,
1036 .lastclose = i915_driver_lastclose, 1042 .lastclose = i915_driver_lastclose,
1037 .preclose = i915_driver_preclose, 1043 .preclose = i915_driver_preclose,
1038 .postclose = i915_driver_postclose, 1044 .postclose = i915_driver_postclose,
1039 1045
1040 /* Used in place of i915_pm_ops for non-DRIVER_MODESET */ 1046 /* Used in place of i915_pm_ops for non-DRIVER_MODESET */
1041 .suspend = i915_suspend, 1047 .suspend = i915_suspend,
1042 .resume = i915_resume, 1048 .resume = i915_resume,
1043 1049
1044 .device_is_agp = i915_driver_device_is_agp, 1050 .device_is_agp = i915_driver_device_is_agp,
1045 .master_create = i915_master_create, 1051 .master_create = i915_master_create,
1046 .master_destroy = i915_master_destroy, 1052 .master_destroy = i915_master_destroy,
1047#if defined(CONFIG_DEBUG_FS) 1053#if defined(CONFIG_DEBUG_FS)
1048 .debugfs_init = i915_debugfs_init, 1054 .debugfs_init = i915_debugfs_init,
1049 .debugfs_cleanup = i915_debugfs_cleanup, 1055 .debugfs_cleanup = i915_debugfs_cleanup,
1050#endif 1056#endif
1051 .gem_init_object = i915_gem_init_object, 1057 .gem_init_object = i915_gem_init_object,
1052 .gem_free_object = i915_gem_free_object, 1058 .gem_free_object = i915_gem_free_object,
1053 .gem_vm_ops = &i915_gem_vm_ops, 1059 .gem_vm_ops = &i915_gem_vm_ops,
1054 1060
1055 .prime_handle_to_fd = drm_gem_prime_handle_to_fd, 1061 .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
1056 .prime_fd_to_handle = drm_gem_prime_fd_to_handle, 1062 .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
1057 .gem_prime_export = i915_gem_prime_export, 1063 .gem_prime_export = i915_gem_prime_export,
1058 .gem_prime_import = i915_gem_prime_import, 1064 .gem_prime_import = i915_gem_prime_import,
1059 1065
1060 .dumb_create = i915_gem_dumb_create, 1066 .dumb_create = i915_gem_dumb_create,
1061 .dumb_map_offset = i915_gem_mmap_gtt, 1067 .dumb_map_offset = i915_gem_mmap_gtt,
1062 .dumb_destroy = i915_gem_dumb_destroy, 1068 .dumb_destroy = i915_gem_dumb_destroy,
1063 .ioctls = i915_ioctls, 1069 .ioctls = i915_ioctls,
1064 .fops = &i915_driver_fops, 1070 .fops = &i915_driver_fops,
1065 .name = DRIVER_NAME, 1071 .name = DRIVER_NAME,
1066 .desc = DRIVER_DESC, 1072 .desc = DRIVER_DESC,
1067 .date = DRIVER_DATE, 1073 .date = DRIVER_DATE,
1068 .major = DRIVER_MAJOR, 1074 .major = DRIVER_MAJOR,
1069 .minor = DRIVER_MINOR, 1075 .minor = DRIVER_MINOR,
1070 .patchlevel = DRIVER_PATCHLEVEL, 1076 .patchlevel = DRIVER_PATCHLEVEL,
1071}; 1077};
1072 1078
1073static struct pci_driver i915_pci_driver = { 1079static struct pci_driver i915_pci_driver = {
1074 .name = DRIVER_NAME, 1080 .name = DRIVER_NAME,
1075 .id_table = pciidlist, 1081 .id_table = pciidlist,
1076 .probe = i915_pci_probe, 1082 .probe = i915_pci_probe,
1077 .remove = i915_pci_remove, 1083 .remove = i915_pci_remove,
1078 .driver.pm = &i915_pm_ops, 1084 .driver.pm = &i915_pm_ops,
1079}; 1085};
1080 1086
1081static int __init i915_init(void) 1087static int __init i915_init(void)
1082{ 1088{
1083 driver.num_ioctls = i915_max_ioctl; 1089 driver.num_ioctls = i915_max_ioctl;
1084 1090
1085 /* 1091 /*
1086 * If CONFIG_DRM_I915_KMS is set, default to KMS unless 1092 * If CONFIG_DRM_I915_KMS is set, default to KMS unless
1087 * explicitly disabled with the module pararmeter. 1093 * explicitly disabled with the module pararmeter.
1088 * 1094 *
1089 * Otherwise, just follow the parameter (defaulting to off). 1095 * Otherwise, just follow the parameter (defaulting to off).
1090 * 1096 *
1091 * Allow optional vga_text_mode_force boot option to override 1097 * Allow optional vga_text_mode_force boot option to override
1092 * the default behavior. 1098 * the default behavior.
1093 */ 1099 */
1094#if defined(CONFIG_DRM_I915_KMS) 1100#if defined(CONFIG_DRM_I915_KMS)
1095 if (i915_modeset != 0) 1101 if (i915_modeset != 0)
1096 driver.driver_features |= DRIVER_MODESET; 1102 driver.driver_features |= DRIVER_MODESET;
1097#endif 1103#endif
1098 if (i915_modeset == 1) 1104 if (i915_modeset == 1)
1099 driver.driver_features |= DRIVER_MODESET; 1105 driver.driver_features |= DRIVER_MODESET;
1100 1106
1101#ifdef CONFIG_VGA_CONSOLE 1107#ifdef CONFIG_VGA_CONSOLE
1102 if (vgacon_text_force() && i915_modeset == -1) 1108 if (vgacon_text_force() && i915_modeset == -1)
1103 driver.driver_features &= ~DRIVER_MODESET; 1109 driver.driver_features &= ~DRIVER_MODESET;
1104#endif 1110#endif
1105 1111
1106 if (!(driver.driver_features & DRIVER_MODESET)) 1112 if (!(driver.driver_features & DRIVER_MODESET))
1107 driver.get_vblank_timestamp = NULL; 1113 driver.get_vblank_timestamp = NULL;
1108 1114
1109 return drm_pci_init(&driver, &i915_pci_driver); 1115 return drm_pci_init(&driver, &i915_pci_driver);
1110} 1116}
1111 1117
1112static void __exit i915_exit(void) 1118static void __exit i915_exit(void)
1113{ 1119{
1114 drm_pci_exit(&driver, &i915_pci_driver); 1120 drm_pci_exit(&driver, &i915_pci_driver);
1115} 1121}
1116 1122
1117module_init(i915_init); 1123module_init(i915_init);
1118module_exit(i915_exit); 1124module_exit(i915_exit);
1119 1125
1120MODULE_AUTHOR(DRIVER_AUTHOR); 1126MODULE_AUTHOR(DRIVER_AUTHOR);
1121MODULE_DESCRIPTION(DRIVER_DESC); 1127MODULE_DESCRIPTION(DRIVER_DESC);
1122MODULE_LICENSE("GPL and additional rights"); 1128MODULE_LICENSE("GPL and additional rights");
1123 1129
1124/* We give fast paths for the really cool registers */ 1130/* We give fast paths for the really cool registers */
1125#define NEEDS_FORCE_WAKE(dev_priv, reg) \ 1131#define NEEDS_FORCE_WAKE(dev_priv, reg) \
1126 ((HAS_FORCE_WAKE((dev_priv)->dev)) && \ 1132 ((HAS_FORCE_WAKE((dev_priv)->dev)) && \
1127 ((reg) < 0x40000) && \ 1133 ((reg) < 0x40000) && \
1128 ((reg) != FORCEWAKE)) 1134 ((reg) != FORCEWAKE))
1129 1135
1130static bool IS_DISPLAYREG(u32 reg) 1136static bool IS_DISPLAYREG(u32 reg)
1131{ 1137{
1132 /* 1138 /*
1133 * This should make it easier to transition modules over to the 1139 * This should make it easier to transition modules over to the
1134 * new register block scheme, since we can do it incrementally. 1140 * new register block scheme, since we can do it incrementally.
1135 */ 1141 */
1136 if (reg >= VLV_DISPLAY_BASE) 1142 if (reg >= VLV_DISPLAY_BASE)
1137 return false; 1143 return false;
1138 1144
1139 if (reg >= RENDER_RING_BASE && 1145 if (reg >= RENDER_RING_BASE &&
1140 reg < RENDER_RING_BASE + 0xff) 1146 reg < RENDER_RING_BASE + 0xff)
1141 return false; 1147 return false;
1142 if (reg >= GEN6_BSD_RING_BASE && 1148 if (reg >= GEN6_BSD_RING_BASE &&
1143 reg < GEN6_BSD_RING_BASE + 0xff) 1149 reg < GEN6_BSD_RING_BASE + 0xff)
1144 return false; 1150 return false;
1145 if (reg >= BLT_RING_BASE && 1151 if (reg >= BLT_RING_BASE &&
1146 reg < BLT_RING_BASE + 0xff) 1152 reg < BLT_RING_BASE + 0xff)
1147 return false; 1153 return false;
1148 1154
1149 if (reg == PGTBL_ER) 1155 if (reg == PGTBL_ER)
1150 return false; 1156 return false;
1151 1157
1152 if (reg >= IPEIR_I965 && 1158 if (reg >= IPEIR_I965 &&
1153 reg < HWSTAM) 1159 reg < HWSTAM)
1154 return false; 1160 return false;
1155 1161
1156 if (reg == MI_MODE) 1162 if (reg == MI_MODE)
1157 return false; 1163 return false;
1158 1164
1159 if (reg == GFX_MODE_GEN7) 1165 if (reg == GFX_MODE_GEN7)
1160 return false; 1166 return false;
1161 1167
1162 if (reg == RENDER_HWS_PGA_GEN7 || 1168 if (reg == RENDER_HWS_PGA_GEN7 ||
1163 reg == BSD_HWS_PGA_GEN7 || 1169 reg == BSD_HWS_PGA_GEN7 ||
1164 reg == BLT_HWS_PGA_GEN7) 1170 reg == BLT_HWS_PGA_GEN7)
1165 return false; 1171 return false;
1166 1172
1167 if (reg == GEN6_BSD_SLEEP_PSMI_CONTROL || 1173 if (reg == GEN6_BSD_SLEEP_PSMI_CONTROL ||
1168 reg == GEN6_BSD_RNCID) 1174 reg == GEN6_BSD_RNCID)
1169 return false; 1175 return false;
1170 1176
1171 if (reg == GEN6_BLITTER_ECOSKPD) 1177 if (reg == GEN6_BLITTER_ECOSKPD)
1172 return false; 1178 return false;
1173 1179
1174 if (reg >= 0x4000c && 1180 if (reg >= 0x4000c &&
1175 reg <= 0x4002c) 1181 reg <= 0x4002c)
1176 return false; 1182 return false;
1177 1183
1178 if (reg >= 0x4f000 && 1184 if (reg >= 0x4f000 &&
1179 reg <= 0x4f08f) 1185 reg <= 0x4f08f)
1180 return false; 1186 return false;
1181 1187
1182 if (reg >= 0x4f100 && 1188 if (reg >= 0x4f100 &&
1183 reg <= 0x4f11f) 1189 reg <= 0x4f11f)
1184 return false; 1190 return false;
1185 1191
1186 if (reg >= VLV_MASTER_IER && 1192 if (reg >= VLV_MASTER_IER &&
1187 reg <= GEN6_PMIER) 1193 reg <= GEN6_PMIER)
1188 return false; 1194 return false;
1189 1195
1190 if (reg >= FENCE_REG_SANDYBRIDGE_0 && 1196 if (reg >= FENCE_REG_SANDYBRIDGE_0 &&
1191 reg < (FENCE_REG_SANDYBRIDGE_0 + (16*8))) 1197 reg < (FENCE_REG_SANDYBRIDGE_0 + (16*8)))
1192 return false; 1198 return false;
1193 1199
1194 if (reg >= VLV_IIR_RW && 1200 if (reg >= VLV_IIR_RW &&
1195 reg <= VLV_ISR) 1201 reg <= VLV_ISR)
1196 return false; 1202 return false;
1197 1203
1198 if (reg == FORCEWAKE_VLV || 1204 if (reg == FORCEWAKE_VLV ||
1199 reg == FORCEWAKE_ACK_VLV) 1205 reg == FORCEWAKE_ACK_VLV)
1200 return false; 1206 return false;
1201 1207
1202 if (reg == GEN6_GDRST) 1208 if (reg == GEN6_GDRST)
1203 return false; 1209 return false;
1204 1210
1205 switch (reg) { 1211 switch (reg) {
1206 case _3D_CHICKEN3: 1212 case _3D_CHICKEN3:
1207 case IVB_CHICKEN3: 1213 case IVB_CHICKEN3:
1208 case GEN7_COMMON_SLICE_CHICKEN1: 1214 case GEN7_COMMON_SLICE_CHICKEN1:
1209 case GEN7_L3CNTLREG1: 1215 case GEN7_L3CNTLREG1:
1210 case GEN7_L3_CHICKEN_MODE_REGISTER: 1216 case GEN7_L3_CHICKEN_MODE_REGISTER:
1211 case GEN7_ROW_CHICKEN2: 1217 case GEN7_ROW_CHICKEN2:
1212 case GEN7_L3SQCREG4: 1218 case GEN7_L3SQCREG4:
1213 case GEN7_SQ_CHICKEN_MBCUNIT_CONFIG: 1219 case GEN7_SQ_CHICKEN_MBCUNIT_CONFIG:
1214 case GEN7_HALF_SLICE_CHICKEN1: 1220 case GEN7_HALF_SLICE_CHICKEN1:
1215 case GEN6_MBCTL: 1221 case GEN6_MBCTL:
1216 case GEN6_UCGCTL2: 1222 case GEN6_UCGCTL2:
1217 return false; 1223 return false;
1218 default: 1224 default:
1219 break; 1225 break;
1220 } 1226 }
1221 1227
1222 return true; 1228 return true;
1223} 1229}
1224 1230
1225static void 1231static void
1226ilk_dummy_write(struct drm_i915_private *dev_priv) 1232ilk_dummy_write(struct drm_i915_private *dev_priv)
1227{ 1233{
1228 /* WaIssueDummyWriteToWakeupFromRC6: Issue a dummy write to wake up the 1234 /* WaIssueDummyWriteToWakeupFromRC6: Issue a dummy write to wake up the
1229 * chip from rc6 before touching it for real. MI_MODE is masked, hence 1235 * chip from rc6 before touching it for real. MI_MODE is masked, hence
1230 * harmless to write 0 into. */ 1236 * harmless to write 0 into. */
1231 I915_WRITE_NOTRACE(MI_MODE, 0); 1237 I915_WRITE_NOTRACE(MI_MODE, 0);
1232} 1238}
1233 1239
1234#ifdef __NetBSD__ 1240#ifdef __NetBSD__
1235#define __i915_read(x, y) \ 1241#define __i915_read(x, y) \
1236u##x i915_read##x(struct drm_i915_private *dev_priv, u32 reg) { \ 1242u##x i915_read##x(struct drm_i915_private *dev_priv, u32 reg) { \
1237 u##x val = 0; \ 1243 u##x val = 0; \
1238 if (IS_GEN5(dev_priv->dev)) \ 1244 if (IS_GEN5(dev_priv->dev)) \
1239 ilk_dummy_write(dev_priv); \ 1245 ilk_dummy_write(dev_priv); \
1240 if (NEEDS_FORCE_WAKE((dev_priv), (reg))) { \ 1246 if (NEEDS_FORCE_WAKE((dev_priv), (reg))) { \
1241 unsigned long irqflags; \ 1247 unsigned long irqflags; \
1242 spin_lock_irqsave(&dev_priv->gt_lock, irqflags); \ 1248 spin_lock_irqsave(&dev_priv->gt_lock, irqflags); \
1243 if (dev_priv->forcewake_count == 0) \ 1249 if (dev_priv->forcewake_count == 0) \
1244 dev_priv->gt.force_wake_get(dev_priv); \ 1250 dev_priv->gt.force_wake_get(dev_priv); \
1245 val = DRM_READ##x(dev_priv->regs_map, reg); \ 1251 val = DRM_READ##x(dev_priv->regs_map, reg); \
1246 if (dev_priv->forcewake_count == 0) \ 1252 if (dev_priv->forcewake_count == 0) \
1247 dev_priv->gt.force_wake_put(dev_priv); \ 1253 dev_priv->gt.force_wake_put(dev_priv); \
1248 spin_unlock_irqrestore(&dev_priv->gt_lock, irqflags); \ 1254 spin_unlock_irqrestore(&dev_priv->gt_lock, irqflags); \
1249 } else if (IS_VALLEYVIEW(dev_priv->dev) && IS_DISPLAYREG(reg)) { \ 1255 } else if (IS_VALLEYVIEW(dev_priv->dev) && IS_DISPLAYREG(reg)) { \
1250 val = DRM_READ##x(dev_priv->regs_map, reg + 0x180000); \ 1256 val = DRM_READ##x(dev_priv->regs_map, reg + 0x180000); \
1251 } else { \ 1257 } else { \
1252 val = DRM_READ##x(dev_priv->regs_map, reg); \ 1258 val = DRM_READ##x(dev_priv->regs_map, reg); \
1253 } \ 1259 } \
1254 trace_i915_reg_rw(false, reg, val, sizeof(val)); \ 1260 trace_i915_reg_rw(false, reg, val, sizeof(val)); \
1255 return val; \ 1261 return val; \
1256} 1262}
1257#else 1263#else
1258#define __i915_read(x, y) \ 1264#define __i915_read(x, y) \
1259u##x i915_read##x(struct drm_i915_private *dev_priv, u32 reg) { \ 1265u##x i915_read##x(struct drm_i915_private *dev_priv, u32 reg) { \
1260 u##x val = 0; \ 1266 u##x val = 0; \
1261 if (IS_GEN5(dev_priv->dev)) \ 1267 if (IS_GEN5(dev_priv->dev)) \
1262 ilk_dummy_write(dev_priv); \ 1268 ilk_dummy_write(dev_priv); \
1263 if (NEEDS_FORCE_WAKE((dev_priv), (reg))) { \ 1269 if (NEEDS_FORCE_WAKE((dev_priv), (reg))) { \
1264 unsigned long irqflags; \ 1270 unsigned long irqflags; \
1265 spin_lock_irqsave(&dev_priv->gt_lock, irqflags); \ 1271 spin_lock_irqsave(&dev_priv->gt_lock, irqflags); \
1266 if (dev_priv->forcewake_count == 0) \ 1272 if (dev_priv->forcewake_count == 0) \
1267 dev_priv->gt.force_wake_get(dev_priv); \ 1273 dev_priv->gt.force_wake_get(dev_priv); \
1268 val = read##y(dev_priv->regs + reg); \ 1274 val = read##y(dev_priv->regs + reg); \
1269 if (dev_priv->forcewake_count == 0) \ 1275 if (dev_priv->forcewake_count == 0) \
1270 dev_priv->gt.force_wake_put(dev_priv); \ 1276 dev_priv->gt.force_wake_put(dev_priv); \
1271 spin_unlock_irqrestore(&dev_priv->gt_lock, irqflags); \ 1277 spin_unlock_irqrestore(&dev_priv->gt_lock, irqflags); \
1272 } else if (IS_VALLEYVIEW(dev_priv->dev) && IS_DISPLAYREG(reg)) { \ 1278 } else if (IS_VALLEYVIEW(dev_priv->dev) && IS_DISPLAYREG(reg)) { \
1273 val = read##y(dev_priv->regs + reg + 0x180000); \ 1279 val = read##y(dev_priv->regs + reg + 0x180000); \
1274 } else { \ 1280 } else { \
1275 val = read##y(dev_priv->regs + reg); \ 1281 val = read##y(dev_priv->regs + reg); \
1276 } \ 1282 } \
1277 trace_i915_reg_rw(false, reg, val, sizeof(val)); \ 1283 trace_i915_reg_rw(false, reg, val, sizeof(val)); \
1278 return val; \ 1284 return val; \
1279} 1285}
1280#endif 1286#endif
1281 1287
1282__i915_read(8, b) 1288__i915_read(8, b)
1283__i915_read(16, w) 1289__i915_read(16, w)
1284__i915_read(32, l) 1290__i915_read(32, l)
1285__i915_read(64, q) 1291__i915_read(64, q)
1286#undef __i915_read 1292#undef __i915_read
1287 1293
1288#ifdef __NetBSD__ 1294#ifdef __NetBSD__
1289#define __i915_write(x, y) \ 1295#define __i915_write(x, y) \
1290void i915_write##x(struct drm_i915_private *dev_priv, u32 reg, u##x val) { \ 1296void i915_write##x(struct drm_i915_private *dev_priv, u32 reg, u##x val) { \
1291 u32 __fifo_ret = 0; \ 1297 u32 __fifo_ret = 0; \
1292 trace_i915_reg_rw(true, reg, val, sizeof(val)); \ 1298 trace_i915_reg_rw(true, reg, val, sizeof(val)); \
1293 if (NEEDS_FORCE_WAKE((dev_priv), (reg))) { \ 1299 if (NEEDS_FORCE_WAKE((dev_priv), (reg))) { \
1294 __fifo_ret = __gen6_gt_wait_for_fifo(dev_priv); \ 1300 __fifo_ret = __gen6_gt_wait_for_fifo(dev_priv); \
1295 } \ 1301 } \
1296 if (IS_GEN5(dev_priv->dev)) \ 1302 if (IS_GEN5(dev_priv->dev)) \
1297 ilk_dummy_write(dev_priv); \ 1303 ilk_dummy_write(dev_priv); \
1298 if (IS_HASWELL(dev_priv->dev) && (I915_READ_NOTRACE(GEN7_ERR_INT) & ERR_INT_MMIO_UNCLAIMED)) { \ 1304 if (IS_HASWELL(dev_priv->dev) && (I915_READ_NOTRACE(GEN7_ERR_INT) & ERR_INT_MMIO_UNCLAIMED)) { \
1299 DRM_ERROR("Unknown unclaimed register before writing to %x\n", reg); \ 1305 DRM_ERROR("Unknown unclaimed register before writing to %x\n", reg); \
1300 I915_WRITE_NOTRACE(GEN7_ERR_INT, ERR_INT_MMIO_UNCLAIMED); \ 1306 I915_WRITE_NOTRACE(GEN7_ERR_INT, ERR_INT_MMIO_UNCLAIMED); \
1301 } \ 1307 } \
1302 if (IS_VALLEYVIEW(dev_priv->dev) && IS_DISPLAYREG(reg)) { \ 1308 if (IS_VALLEYVIEW(dev_priv->dev) && IS_DISPLAYREG(reg)) { \
1303 DRM_WRITE##x(dev_priv->regs_map, reg + 0x180000, val); \ 1309 DRM_WRITE##x(dev_priv->regs_map, reg + 0x180000, val); \
1304 } else { \ 1310 } else { \
1305 DRM_WRITE##x(dev_priv->regs_map, reg, val); \ 1311 DRM_WRITE##x(dev_priv->regs_map, reg, val); \
1306 } \ 1312 } \
1307 if (unlikely(__fifo_ret)) { \ 1313 if (unlikely(__fifo_ret)) { \
1308 gen6_gt_check_fifodbg(dev_priv); \ 1314 gen6_gt_check_fifodbg(dev_priv); \
1309 } \ 1315 } \
1310 if (IS_HASWELL(dev_priv->dev) && (I915_READ_NOTRACE(GEN7_ERR_INT) & ERR_INT_MMIO_UNCLAIMED)) { \ 1316 if (IS_HASWELL(dev_priv->dev) && (I915_READ_NOTRACE(GEN7_ERR_INT) & ERR_INT_MMIO_UNCLAIMED)) { \
1311 DRM_ERROR("Unclaimed write to %x\n", reg); \ 1317 DRM_ERROR("Unclaimed write to %x\n", reg); \
1312 DRM_WRITE32(dev_priv->regs_map, GEN7_ERR_INT, ERR_INT_MMIO_UNCLAIMED); \ 1318 DRM_WRITE32(dev_priv->regs_map, GEN7_ERR_INT, ERR_INT_MMIO_UNCLAIMED); \
1313 } \ 1319 } \
1314} 1320}
1315#else 1321#else
1316#define __i915_write(x, y) \ 1322#define __i915_write(x, y) \
1317void i915_write##x(struct drm_i915_private *dev_priv, u32 reg, u##x val) { \ 1323void i915_write##x(struct drm_i915_private *dev_priv, u32 reg, u##x val) { \
1318 u32 __fifo_ret = 0; \ 1324 u32 __fifo_ret = 0; \
1319 trace_i915_reg_rw(true, reg, val, sizeof(val)); \ 1325 trace_i915_reg_rw(true, reg, val, sizeof(val)); \
1320 if (NEEDS_FORCE_WAKE((dev_priv), (reg))) { \ 1326 if (NEEDS_FORCE_WAKE((dev_priv), (reg))) { \
1321 __fifo_ret = __gen6_gt_wait_for_fifo(dev_priv); \ 1327 __fifo_ret = __gen6_gt_wait_for_fifo(dev_priv); \
1322 } \ 1328 } \
1323 if (IS_GEN5(dev_priv->dev)) \ 1329 if (IS_GEN5(dev_priv->dev)) \
1324 ilk_dummy_write(dev_priv); \ 1330 ilk_dummy_write(dev_priv); \
1325 if (IS_HASWELL(dev_priv->dev) && (I915_READ_NOTRACE(GEN7_ERR_INT) & ERR_INT_MMIO_UNCLAIMED)) { \ 1331 if (IS_HASWELL(dev_priv->dev) && (I915_READ_NOTRACE(GEN7_ERR_INT) & ERR_INT_MMIO_UNCLAIMED)) { \
1326 DRM_ERROR("Unknown unclaimed register before writing to %x\n", reg); \ 1332 DRM_ERROR("Unknown unclaimed register before writing to %x\n", reg); \
1327 I915_WRITE_NOTRACE(GEN7_ERR_INT, ERR_INT_MMIO_UNCLAIMED); \ 1333 I915_WRITE_NOTRACE(GEN7_ERR_INT, ERR_INT_MMIO_UNCLAIMED); \
1328 } \ 1334 } \
1329 if (IS_VALLEYVIEW(dev_priv->dev) && IS_DISPLAYREG(reg)) { \ 1335 if (IS_VALLEYVIEW(dev_priv->dev) && IS_DISPLAYREG(reg)) { \
1330 write##y(val, dev_priv->regs + reg + 0x180000); \ 1336 write##y(val, dev_priv->regs + reg + 0x180000); \
1331 } else { \ 1337 } else { \
1332 write##y(val, dev_priv->regs + reg); \ 1338 write##y(val, dev_priv->regs + reg); \
1333 } \ 1339 } \
1334 if (unlikely(__fifo_ret)) { \ 1340 if (unlikely(__fifo_ret)) { \
1335 gen6_gt_check_fifodbg(dev_priv); \ 1341 gen6_gt_check_fifodbg(dev_priv); \
1336 } \ 1342 } \
1337 if (IS_HASWELL(dev_priv->dev) && (I915_READ_NOTRACE(GEN7_ERR_INT) & ERR_INT_MMIO_UNCLAIMED)) { \ 1343 if (IS_HASWELL(dev_priv->dev) && (I915_READ_NOTRACE(GEN7_ERR_INT) & ERR_INT_MMIO_UNCLAIMED)) { \
1338 DRM_ERROR("Unclaimed write to %x\n", reg); \ 1344 DRM_ERROR("Unclaimed write to %x\n", reg); \
1339 writel(ERR_INT_MMIO_UNCLAIMED, dev_priv->regs + GEN7_ERR_INT); \ 1345 writel(ERR_INT_MMIO_UNCLAIMED, dev_priv->regs + GEN7_ERR_INT); \
1340 } \ 1346 } \
1341} 1347}
1342#endif 1348#endif
1343 1349
1344__i915_write(8, b) 1350__i915_write(8, b)
1345__i915_write(16, w) 1351__i915_write(16, w)
1346__i915_write(32, l) 1352__i915_write(32, l)
1347__i915_write(64, q) 1353__i915_write(64, q)
1348#undef __i915_write 1354#undef __i915_write
1349 1355
1350static const struct register_whitelist { 1356static const struct register_whitelist {
1351 uint64_t offset; 1357 uint64_t offset;
1352 uint32_t size; 1358 uint32_t size;
1353 uint32_t gen_bitmask; /* support gens, 0x10 for 4, 0x30 for 4 and 5, etc. */ 1359 uint32_t gen_bitmask; /* support gens, 0x10 for 4, 0x30 for 4 and 5, etc. */
1354} whitelist[] = { 1360} whitelist[] = {
1355 { RING_TIMESTAMP(RENDER_RING_BASE), 8, 0xF0 }, 1361 { RING_TIMESTAMP(RENDER_RING_BASE), 8, 0xF0 },
1356}; 1362};
1357 1363
1358int i915_reg_read_ioctl(struct drm_device *dev, 1364int i915_reg_read_ioctl(struct drm_device *dev,
1359 void *data, struct drm_file *file) 1365 void *data, struct drm_file *file)
1360{ 1366{
1361 struct drm_i915_private *dev_priv = dev->dev_private; 1367 struct drm_i915_private *dev_priv = dev->dev_private;
1362 struct drm_i915_reg_read *reg = data; 1368 struct drm_i915_reg_read *reg = data;
1363 struct register_whitelist const *entry = whitelist; 1369 struct register_whitelist const *entry = whitelist;
1364 int i; 1370 int i;
1365 1371
1366 for (i = 0; i < ARRAY_SIZE(whitelist); i++, entry++) { 1372 for (i = 0; i < ARRAY_SIZE(whitelist); i++, entry++) {
1367 if (entry->offset == reg->offset && 1373 if (entry->offset == reg->offset &&
1368 (1 << INTEL_INFO(dev)->gen & entry->gen_bitmask)) 1374 (1 << INTEL_INFO(dev)->gen & entry->gen_bitmask))
1369 break; 1375 break;
1370 } 1376 }
1371 1377
1372 if (i == ARRAY_SIZE(whitelist)) 1378 if (i == ARRAY_SIZE(whitelist))
1373 return -EINVAL; 1379 return -EINVAL;
1374 1380
1375 switch (entry->size) { 1381 switch (entry->size) {
1376 case 8: 1382 case 8:
1377 reg->val = I915_READ64(reg->offset); 1383 reg->val = I915_READ64(reg->offset);
1378 break; 1384 break;
1379 case 4: 1385 case 4:
1380 reg->val = I915_READ(reg->offset); 1386 reg->val = I915_READ(reg->offset);
1381 break; 1387 break;
1382 case 2: 1388 case 2:
1383 reg->val = I915_READ16(reg->offset); 1389 reg->val = I915_READ16(reg->offset);
1384 break; 1390 break;
1385 case 1: 1391 case 1:
1386 reg->val = I915_READ8(reg->offset); 1392 reg->val = I915_READ8(reg->offset);
1387 break; 1393 break;
1388 default: 1394 default:
1389 WARN_ON(1); 1395 WARN_ON(1);
1390 return -EINVAL; 1396 return -EINVAL;
1391 } 1397 }
1392 1398
1393 return 0; 1399 return 0;
1394} 1400}