Wed Jul 24 03:21:07 2013 UTC ()
Omit more stuff that pmf does for us in i915_drv.c.


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

cvs diff -r1.1.1.1.2.8 -r1.1.1.1.2.9 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:52 1.1.1.1.2.8
+++ src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.c 2013/07/24 03:21:07 1.1.1.1.2.9
@@ -1,1400 +1,1406 @@ @@ -1,1400 +1,1406 @@
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#ifndef __NetBSD__ /* XXX fb */
512 console_lock(); 512 console_lock();
513 intel_fbdev_set_suspend(dev, 1); 513 intel_fbdev_set_suspend(dev, 1);
514 console_unlock(); 514 console_unlock();
515#endif 515#endif
516 516
517 return 0; 517 return 0;
518} 518}
519 519
520int i915_suspend(struct drm_device *dev, pm_message_t state) 520int i915_suspend(struct drm_device *dev, pm_message_t state)
521{ 521{
522 int error; 522 int error;
523 523
524 if (!dev || !dev->dev_private) { 524 if (!dev || !dev->dev_private) {
525 DRM_ERROR("dev: %p\n", dev); 525 DRM_ERROR("dev: %p\n", dev);
526 DRM_ERROR("DRM not initialized, aborting suspend.\n"); 526 DRM_ERROR("DRM not initialized, aborting suspend.\n");
527 return -ENODEV; 527 return -ENODEV;
528 } 528 }
529 529
530 if (state.event == PM_EVENT_PRETHAW) 530 if (state.event == PM_EVENT_PRETHAW)
531 return 0; 531 return 0;
532 532
533 533
534 if (dev->switch_power_state == DRM_SWITCH_POWER_OFF) 534 if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
535 return 0; 535 return 0;
536 536
537 error = i915_drm_freeze(dev); 537 error = i915_drm_freeze(dev);
538 if (error) 538 if (error)
539 return error; 539 return error;
540 540
 541#ifndef __NetBSD__ /* pmf handles this for us. */
541 if (state.event == PM_EVENT_SUSPEND) { 542 if (state.event == PM_EVENT_SUSPEND) {
542 /* Shut down the device */ 543 /* Shut down the device */
543 pci_disable_device(dev->pdev); 544 pci_disable_device(dev->pdev);
544 pci_set_power_state(dev->pdev, PCI_D3hot); 545 pci_set_power_state(dev->pdev, PCI_D3hot);
545 } 546 }
 547#endif
546 548
547 return 0; 549 return 0;
548} 550}
549 551
550#ifndef __NetBSD__ /* XXX fb */ 552#ifndef __NetBSD__ /* XXX fb */
551void intel_console_resume(struct work_struct *work) 553void intel_console_resume(struct work_struct *work)
552{ 554{
553 struct drm_i915_private *dev_priv = 555 struct drm_i915_private *dev_priv =
554 container_of(work, struct drm_i915_private, 556 container_of(work, struct drm_i915_private,
555 console_resume_work); 557 console_resume_work);
556 struct drm_device *dev = dev_priv->dev; 558 struct drm_device *dev = dev_priv->dev;
557 559
558 console_lock(); 560 console_lock();
559 intel_fbdev_set_suspend(dev, 0); 561 intel_fbdev_set_suspend(dev, 0);
560 console_unlock(); 562 console_unlock();
561} 563}
562#endif 564#endif
563 565
564static int __i915_drm_thaw(struct drm_device *dev) 566static int __i915_drm_thaw(struct drm_device *dev)
565{ 567{
566 struct drm_i915_private *dev_priv = dev->dev_private; 568 struct drm_i915_private *dev_priv = dev->dev_private;
567 int error = 0; 569 int error = 0;
568 570
569 i915_restore_state(dev); 571 i915_restore_state(dev);
570 intel_opregion_setup(dev); 572 intel_opregion_setup(dev);
571 573
572 /* KMS EnterVT equivalent */ 574 /* KMS EnterVT equivalent */
573 if (drm_core_check_feature(dev, DRIVER_MODESET)) { 575 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
574 intel_init_pch_refclk(dev); 576 intel_init_pch_refclk(dev);
575 577
576 mutex_lock(&dev->struct_mutex); 578 mutex_lock(&dev->struct_mutex);
577 dev_priv->mm.suspended = 0; 579 dev_priv->mm.suspended = 0;
578 580
579 error = i915_gem_init_hw(dev); 581 error = i915_gem_init_hw(dev);
580 mutex_unlock(&dev->struct_mutex); 582 mutex_unlock(&dev->struct_mutex);
581 583
582 intel_modeset_init_hw(dev); 584 intel_modeset_init_hw(dev);
583 intel_modeset_setup_hw_state(dev, false); 585 intel_modeset_setup_hw_state(dev, false);
584 drm_irq_install(dev); 586 drm_irq_install(dev);
585 } 587 }
586 588
587 intel_opregion_init(dev); 589 intel_opregion_init(dev);
588 590
589 dev_priv->modeset_on_lid = 0; 591 dev_priv->modeset_on_lid = 0;
590 592
591#ifndef __NetBSD__ /* XXX fb */ 593#ifndef __NetBSD__ /* XXX fb */
592 /* 594 /*
593 * The console lock can be pretty contented on resume due 595 * The console lock can be pretty contented on resume due
594 * to all the printk activity. Try to keep it out of the hot 596 * to all the printk activity. Try to keep it out of the hot
595 * path of resume if possible. 597 * path of resume if possible.
596 */ 598 */
597 if (console_trylock()) { 599 if (console_trylock()) {
598 intel_fbdev_set_suspend(dev, 0); 600 intel_fbdev_set_suspend(dev, 0);
599 console_unlock(); 601 console_unlock();
600 } else { 602 } else {
601 schedule_work(&dev_priv->console_resume_work); 603 schedule_work(&dev_priv->console_resume_work);
602 } 604 }
603#endif 605#endif
604 606
605 return error; 607 return error;
606} 608}
607 609
608static int i915_drm_thaw(struct drm_device *dev) 610static int i915_drm_thaw(struct drm_device *dev)
609{ 611{
610 int error = 0; 612 int error = 0;
611 613
612 intel_gt_reset(dev); 614 intel_gt_reset(dev);
613 615
614 if (drm_core_check_feature(dev, DRIVER_MODESET)) { 616 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
615 mutex_lock(&dev->struct_mutex); 617 mutex_lock(&dev->struct_mutex);
616 i915_gem_restore_gtt_mappings(dev); 618 i915_gem_restore_gtt_mappings(dev);
617 mutex_unlock(&dev->struct_mutex); 619 mutex_unlock(&dev->struct_mutex);
618 } 620 }
619 621
620 __i915_drm_thaw(dev); 622 __i915_drm_thaw(dev);
621 623
622 return error; 624 return error;
623} 625}
624 626
625int i915_resume(struct drm_device *dev) 627int i915_resume(struct drm_device *dev)
626{ 628{
627 struct drm_i915_private *dev_priv = dev->dev_private; 629 struct drm_i915_private *dev_priv = dev->dev_private;
628 int ret; 630 int ret;
629 631
630 if (dev->switch_power_state == DRM_SWITCH_POWER_OFF) 632 if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
631 return 0; 633 return 0;
632 634
 635#ifndef __NetBSD__ /* pmf handles this for us. */
633 if (pci_enable_device(dev->pdev)) 636 if (pci_enable_device(dev->pdev))
634 return -EIO; 637 return -EIO;
 638#endif
635 639
636 pci_set_master(dev->pdev); 640 pci_set_master(dev->pdev);
637 641
638 intel_gt_reset(dev); 642 intel_gt_reset(dev);
639 643
640 /* 644 /*
641 * Platforms with opregion should have sane BIOS, older ones (gen3 and 645 * Platforms with opregion should have sane BIOS, older ones (gen3 and
642 * earlier) need this since the BIOS might clear all our scratch PTEs. 646 * earlier) need this since the BIOS might clear all our scratch PTEs.
643 */ 647 */
644 if (drm_core_check_feature(dev, DRIVER_MODESET) && 648 if (drm_core_check_feature(dev, DRIVER_MODESET) &&
645 !dev_priv->opregion.header) { 649 !dev_priv->opregion.header) {
646 mutex_lock(&dev->struct_mutex); 650 mutex_lock(&dev->struct_mutex);
647 i915_gem_restore_gtt_mappings(dev); 651 i915_gem_restore_gtt_mappings(dev);
648 mutex_unlock(&dev->struct_mutex); 652 mutex_unlock(&dev->struct_mutex);
649 } 653 }
650 654
651 ret = __i915_drm_thaw(dev); 655 ret = __i915_drm_thaw(dev);
652 if (ret) 656 if (ret)
653 return ret; 657 return ret;
654 658
655 drm_kms_helper_poll_enable(dev); 659 drm_kms_helper_poll_enable(dev);
656 return 0; 660 return 0;
657} 661}
658 662
659static int i8xx_do_reset(struct drm_device *dev) 663static int i8xx_do_reset(struct drm_device *dev)
660{ 664{
661 struct drm_i915_private *dev_priv = dev->dev_private; 665 struct drm_i915_private *dev_priv = dev->dev_private;
662 666
663 if (IS_I85X(dev)) 667 if (IS_I85X(dev))
664 return -ENODEV; 668 return -ENODEV;
665 669
666 I915_WRITE(D_STATE, I915_READ(D_STATE) | DSTATE_GFX_RESET_I830); 670 I915_WRITE(D_STATE, I915_READ(D_STATE) | DSTATE_GFX_RESET_I830);
667 POSTING_READ(D_STATE); 671 POSTING_READ(D_STATE);
668 672
669 if (IS_I830(dev) || IS_845G(dev)) { 673 if (IS_I830(dev) || IS_845G(dev)) {
670 I915_WRITE(DEBUG_RESET_I830, 674 I915_WRITE(DEBUG_RESET_I830,
671 DEBUG_RESET_DISPLAY | 675 DEBUG_RESET_DISPLAY |
672 DEBUG_RESET_RENDER | 676 DEBUG_RESET_RENDER |
673 DEBUG_RESET_FULL); 677 DEBUG_RESET_FULL);
674 POSTING_READ(DEBUG_RESET_I830); 678 POSTING_READ(DEBUG_RESET_I830);
675 msleep(1); 679 msleep(1);
676 680
677 I915_WRITE(DEBUG_RESET_I830, 0); 681 I915_WRITE(DEBUG_RESET_I830, 0);
678 POSTING_READ(DEBUG_RESET_I830); 682 POSTING_READ(DEBUG_RESET_I830);
679 } 683 }
680 684
681 msleep(1); 685 msleep(1);
682 686
683 I915_WRITE(D_STATE, I915_READ(D_STATE) & ~DSTATE_GFX_RESET_I830); 687 I915_WRITE(D_STATE, I915_READ(D_STATE) & ~DSTATE_GFX_RESET_I830);
684 POSTING_READ(D_STATE); 688 POSTING_READ(D_STATE);
685 689
686 return 0; 690 return 0;
687} 691}
688 692
689static int i965_reset_complete(struct drm_device *dev) 693static int i965_reset_complete(struct drm_device *dev)
690{ 694{
691 u8 gdrst; 695 u8 gdrst;
692 pci_read_config_byte(dev->pdev, I965_GDRST, &gdrst); 696 pci_read_config_byte(dev->pdev, I965_GDRST, &gdrst);
693 return (gdrst & GRDOM_RESET_ENABLE) == 0; 697 return (gdrst & GRDOM_RESET_ENABLE) == 0;
694} 698}
695 699
696static int i965_do_reset(struct drm_device *dev) 700static int i965_do_reset(struct drm_device *dev)
697{ 701{
698 int ret; 702 int ret;
699 u8 gdrst; 703 u8 gdrst;
700 704
701 /* 705 /*
702 * Set the domains we want to reset (GRDOM/bits 2 and 3) as 706 * Set the domains we want to reset (GRDOM/bits 2 and 3) as
703 * well as the reset bit (GR/bit 0). Setting the GR bit 707 * well as the reset bit (GR/bit 0). Setting the GR bit
704 * triggers the reset; when done, the hardware will clear it. 708 * triggers the reset; when done, the hardware will clear it.
705 */ 709 */
706 pci_read_config_byte(dev->pdev, I965_GDRST, &gdrst); 710 pci_read_config_byte(dev->pdev, I965_GDRST, &gdrst);
707 pci_write_config_byte(dev->pdev, I965_GDRST, 711 pci_write_config_byte(dev->pdev, I965_GDRST,
708 gdrst | GRDOM_RENDER | 712 gdrst | GRDOM_RENDER |
709 GRDOM_RESET_ENABLE); 713 GRDOM_RESET_ENABLE);
710 ret = wait_for(i965_reset_complete(dev), 500); 714 ret = wait_for(i965_reset_complete(dev), 500);
711 if (ret) 715 if (ret)
712 return ret; 716 return ret;
713 717
714 /* We can't reset render&media without also resetting display ... */ 718 /* We can't reset render&media without also resetting display ... */
715 pci_read_config_byte(dev->pdev, I965_GDRST, &gdrst); 719 pci_read_config_byte(dev->pdev, I965_GDRST, &gdrst);
716 pci_write_config_byte(dev->pdev, I965_GDRST, 720 pci_write_config_byte(dev->pdev, I965_GDRST,
717 gdrst | GRDOM_MEDIA | 721 gdrst | GRDOM_MEDIA |
718 GRDOM_RESET_ENABLE); 722 GRDOM_RESET_ENABLE);
719 723
720 return wait_for(i965_reset_complete(dev), 500); 724 return wait_for(i965_reset_complete(dev), 500);
721} 725}
722 726
723static int ironlake_do_reset(struct drm_device *dev) 727static int ironlake_do_reset(struct drm_device *dev)
724{ 728{
725 struct drm_i915_private *dev_priv = dev->dev_private; 729 struct drm_i915_private *dev_priv = dev->dev_private;
726 u32 gdrst; 730 u32 gdrst;
727 int ret; 731 int ret;
728 732
729 gdrst = I915_READ(MCHBAR_MIRROR_BASE + ILK_GDSR); 733 gdrst = I915_READ(MCHBAR_MIRROR_BASE + ILK_GDSR);
730 I915_WRITE(MCHBAR_MIRROR_BASE + ILK_GDSR, 734 I915_WRITE(MCHBAR_MIRROR_BASE + ILK_GDSR,
731 gdrst | GRDOM_RENDER | GRDOM_RESET_ENABLE); 735 gdrst | GRDOM_RENDER | GRDOM_RESET_ENABLE);
732 ret = wait_for(I915_READ(MCHBAR_MIRROR_BASE + ILK_GDSR) & 0x1, 500); 736 ret = wait_for(I915_READ(MCHBAR_MIRROR_BASE + ILK_GDSR) & 0x1, 500);
733 if (ret) 737 if (ret)
734 return ret; 738 return ret;
735 739
736 /* We can't reset render&media without also resetting display ... */ 740 /* We can't reset render&media without also resetting display ... */
737 gdrst = I915_READ(MCHBAR_MIRROR_BASE + ILK_GDSR); 741 gdrst = I915_READ(MCHBAR_MIRROR_BASE + ILK_GDSR);
738 I915_WRITE(MCHBAR_MIRROR_BASE + ILK_GDSR, 742 I915_WRITE(MCHBAR_MIRROR_BASE + ILK_GDSR,
739 gdrst | GRDOM_MEDIA | GRDOM_RESET_ENABLE); 743 gdrst | GRDOM_MEDIA | GRDOM_RESET_ENABLE);
740 return wait_for(I915_READ(MCHBAR_MIRROR_BASE + ILK_GDSR) & 0x1, 500); 744 return wait_for(I915_READ(MCHBAR_MIRROR_BASE + ILK_GDSR) & 0x1, 500);
741} 745}
742 746
743static int gen6_do_reset(struct drm_device *dev) 747static int gen6_do_reset(struct drm_device *dev)
744{ 748{
745 struct drm_i915_private *dev_priv = dev->dev_private; 749 struct drm_i915_private *dev_priv = dev->dev_private;
746 int ret; 750 int ret;
747 unsigned long irqflags; 751 unsigned long irqflags;
748 752
749 /* Hold gt_lock across reset to prevent any register access 753 /* Hold gt_lock across reset to prevent any register access
750 * with forcewake not set correctly 754 * with forcewake not set correctly
751 */ 755 */
752 spin_lock_irqsave(&dev_priv->gt_lock, irqflags); 756 spin_lock_irqsave(&dev_priv->gt_lock, irqflags);
753 757
754 /* Reset the chip */ 758 /* Reset the chip */
755 759
756 /* GEN6_GDRST is not in the gt power well, no need to check 760 /* GEN6_GDRST is not in the gt power well, no need to check
757 * for fifo space for the write or forcewake the chip for 761 * for fifo space for the write or forcewake the chip for
758 * the read 762 * the read
759 */ 763 */
760 I915_WRITE_NOTRACE(GEN6_GDRST, GEN6_GRDOM_FULL); 764 I915_WRITE_NOTRACE(GEN6_GDRST, GEN6_GRDOM_FULL);
761 765
762 /* Spin waiting for the device to ack the reset request */ 766 /* Spin waiting for the device to ack the reset request */
763 ret = wait_for((I915_READ_NOTRACE(GEN6_GDRST) & GEN6_GRDOM_FULL) == 0, 500); 767 ret = wait_for((I915_READ_NOTRACE(GEN6_GDRST) & GEN6_GRDOM_FULL) == 0, 500);
764 768
765 /* If reset with a user forcewake, try to restore, otherwise turn it off */ 769 /* If reset with a user forcewake, try to restore, otherwise turn it off */
766 if (dev_priv->forcewake_count) 770 if (dev_priv->forcewake_count)
767 dev_priv->gt.force_wake_get(dev_priv); 771 dev_priv->gt.force_wake_get(dev_priv);
768 else 772 else
769 dev_priv->gt.force_wake_put(dev_priv); 773 dev_priv->gt.force_wake_put(dev_priv);
770 774
771 /* Restore fifo count */ 775 /* Restore fifo count */
772 dev_priv->gt_fifo_count = I915_READ_NOTRACE(GT_FIFO_FREE_ENTRIES); 776 dev_priv->gt_fifo_count = I915_READ_NOTRACE(GT_FIFO_FREE_ENTRIES);
773 777
774 spin_unlock_irqrestore(&dev_priv->gt_lock, irqflags); 778 spin_unlock_irqrestore(&dev_priv->gt_lock, irqflags);
775 return ret; 779 return ret;
776} 780}
777 781
778int intel_gpu_reset(struct drm_device *dev) 782int intel_gpu_reset(struct drm_device *dev)
779{ 783{
780 struct drm_i915_private *dev_priv = dev->dev_private; 784 struct drm_i915_private *dev_priv = dev->dev_private;
781 int ret = -ENODEV; 785 int ret = -ENODEV;
782 786
783 switch (INTEL_INFO(dev)->gen) { 787 switch (INTEL_INFO(dev)->gen) {
784 case 7: 788 case 7:
785 case 6: 789 case 6:
786 ret = gen6_do_reset(dev); 790 ret = gen6_do_reset(dev);
787 break; 791 break;
788 case 5: 792 case 5:
789 ret = ironlake_do_reset(dev); 793 ret = ironlake_do_reset(dev);
790 break; 794 break;
791 case 4: 795 case 4:
792 ret = i965_do_reset(dev); 796 ret = i965_do_reset(dev);
793 break; 797 break;
794 case 2: 798 case 2:
795 ret = i8xx_do_reset(dev); 799 ret = i8xx_do_reset(dev);
796 break; 800 break;
797 } 801 }
798 802
799 /* Also reset the gpu hangman. */ 803 /* Also reset the gpu hangman. */
800 if (dev_priv->stop_rings) { 804 if (dev_priv->stop_rings) {
801 DRM_DEBUG("Simulated gpu hang, resetting stop_rings\n"); 805 DRM_DEBUG("Simulated gpu hang, resetting stop_rings\n");
802 dev_priv->stop_rings = 0; 806 dev_priv->stop_rings = 0;
803 if (ret == -ENODEV) { 807 if (ret == -ENODEV) {
804 DRM_ERROR("Reset not implemented, but ignoring " 808 DRM_ERROR("Reset not implemented, but ignoring "
805 "error for simulated gpu hangs\n"); 809 "error for simulated gpu hangs\n");
806 ret = 0; 810 ret = 0;
807 } 811 }
808 } 812 }
809 813
810 return ret; 814 return ret;
811} 815}
812 816
813/** 817/**
814 * i915_reset - reset chip after a hang 818 * i915_reset - reset chip after a hang
815 * @dev: drm device to reset 819 * @dev: drm device to reset
816 * 820 *
817 * Reset the chip. Useful if a hang is detected. Returns zero on successful 821 * Reset the chip. Useful if a hang is detected. Returns zero on successful
818 * reset or otherwise an error code. 822 * reset or otherwise an error code.
819 * 823 *
820 * Procedure is fairly simple: 824 * Procedure is fairly simple:
821 * - reset the chip using the reset reg 825 * - reset the chip using the reset reg
822 * - re-init context state 826 * - re-init context state
823 * - re-init hardware status page 827 * - re-init hardware status page
824 * - re-init ring buffer 828 * - re-init ring buffer
825 * - re-init interrupt state 829 * - re-init interrupt state
826 * - re-init display 830 * - re-init display
827 */ 831 */
828int i915_reset(struct drm_device *dev) 832int i915_reset(struct drm_device *dev)
829{ 833{
830 drm_i915_private_t *dev_priv = dev->dev_private; 834 drm_i915_private_t *dev_priv = dev->dev_private;
831 int ret; 835 int ret;
832 836
833 if (!i915_try_reset) 837 if (!i915_try_reset)
834 return 0; 838 return 0;
835 839
836 mutex_lock(&dev->struct_mutex); 840 mutex_lock(&dev->struct_mutex);
837 841
838 i915_gem_reset(dev); 842 i915_gem_reset(dev);
839 843
840 ret = -ENODEV; 844 ret = -ENODEV;
841 if (get_seconds() - dev_priv->last_gpu_reset < 5) 845 if (get_seconds() - dev_priv->last_gpu_reset < 5)
842 DRM_ERROR("GPU hanging too fast, declaring wedged!\n"); 846 DRM_ERROR("GPU hanging too fast, declaring wedged!\n");
843 else 847 else
844 ret = intel_gpu_reset(dev); 848 ret = intel_gpu_reset(dev);
845 849
846 dev_priv->last_gpu_reset = get_seconds(); 850 dev_priv->last_gpu_reset = get_seconds();
847 if (ret) { 851 if (ret) {
848 DRM_ERROR("Failed to reset chip.\n"); 852 DRM_ERROR("Failed to reset chip.\n");
849 mutex_unlock(&dev->struct_mutex); 853 mutex_unlock(&dev->struct_mutex);
850 return ret; 854 return ret;
851 } 855 }
852 856
853 /* Ok, now get things going again... */ 857 /* Ok, now get things going again... */
854 858
855 /* 859 /*
856 * Everything depends on having the GTT running, so we need to start 860 * Everything depends on having the GTT running, so we need to start
857 * there. Fortunately we don't need to do this unless we reset the 861 * there. Fortunately we don't need to do this unless we reset the
858 * chip at a PCI level. 862 * chip at a PCI level.
859 * 863 *
860 * Next we need to restore the context, but we don't use those 864 * Next we need to restore the context, but we don't use those
861 * yet either... 865 * yet either...
862 * 866 *
863 * Ring buffer needs to be re-initialized in the KMS case, or if X 867 * Ring buffer needs to be re-initialized in the KMS case, or if X
864 * was running at the time of the reset (i.e. we weren't VT 868 * was running at the time of the reset (i.e. we weren't VT
865 * switched away). 869 * switched away).
866 */ 870 */
867 if (drm_core_check_feature(dev, DRIVER_MODESET) || 871 if (drm_core_check_feature(dev, DRIVER_MODESET) ||
868 !dev_priv->mm.suspended) { 872 !dev_priv->mm.suspended) {
869 struct intel_ring_buffer *ring; 873 struct intel_ring_buffer *ring;
870 int i; 874 int i;
871 875
872 dev_priv->mm.suspended = 0; 876 dev_priv->mm.suspended = 0;
873 877
874 i915_gem_init_swizzling(dev); 878 i915_gem_init_swizzling(dev);
875 879
876 for_each_ring(ring, dev_priv, i) 880 for_each_ring(ring, dev_priv, i)
877 ring->init(ring); 881 ring->init(ring);
878 882
879 i915_gem_context_init(dev); 883 i915_gem_context_init(dev);
880 i915_gem_init_ppgtt(dev); 884 i915_gem_init_ppgtt(dev);
881 885
882 /* 886 /*
883 * It would make sense to re-init all the other hw state, at 887 * It would make sense to re-init all the other hw state, at
884 * least the rps/rc6/emon init done within modeset_init_hw. For 888 * least the rps/rc6/emon init done within modeset_init_hw. For
885 * some unknown reason, this blows up my ilk, so don't. 889 * some unknown reason, this blows up my ilk, so don't.
886 */ 890 */
887 891
888 mutex_unlock(&dev->struct_mutex); 892 mutex_unlock(&dev->struct_mutex);
889 893
890 drm_irq_uninstall(dev); 894 drm_irq_uninstall(dev);
891 drm_irq_install(dev); 895 drm_irq_install(dev);
892 } else { 896 } else {
893 mutex_unlock(&dev->struct_mutex); 897 mutex_unlock(&dev->struct_mutex);
894 } 898 }
895 899
896 return 0; 900 return 0;
897} 901}
898 902
899static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 903static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
900{ 904{
901 struct intel_device_info *intel_info = 905 struct intel_device_info *intel_info =
902 (struct intel_device_info *) ent->driver_data; 906 (struct intel_device_info *) ent->driver_data;
903 907
904 if (intel_info->is_valleyview) 908 if (intel_info->is_valleyview)
905 if(!i915_preliminary_hw_support) { 909 if(!i915_preliminary_hw_support) {
906 DRM_ERROR("Preliminary hardware support disabled\n"); 910 DRM_ERROR("Preliminary hardware support disabled\n");
907 return -ENODEV; 911 return -ENODEV;
908 } 912 }
909 913
910 /* Only bind to function 0 of the device. Early generations 914 /* Only bind to function 0 of the device. Early generations
911 * used function 1 as a placeholder for multi-head. This causes 915 * used function 1 as a placeholder for multi-head. This causes
912 * us confusion instead, especially on the systems where both 916 * us confusion instead, especially on the systems where both
913 * functions have the same PCI-ID! 917 * functions have the same PCI-ID!
914 */ 918 */
915 if (PCI_FUNC(pdev->devfn)) 919 if (PCI_FUNC(pdev->devfn))
916 return -ENODEV; 920 return -ENODEV;
917 921
918 /* We've managed to ship a kms-enabled ddx that shipped with an XvMC 922 /* We've managed to ship a kms-enabled ddx that shipped with an XvMC
919 * implementation for gen3 (and only gen3) that used legacy drm maps 923 * implementation for gen3 (and only gen3) that used legacy drm maps
920 * (gasp!) to share buffers between X and the client. Hence we need to 924 * (gasp!) to share buffers between X and the client. Hence we need to
921 * keep around the fake agp stuff for gen3, even when kms is enabled. */ 925 * keep around the fake agp stuff for gen3, even when kms is enabled. */
922 if (intel_info->gen != 3) { 926 if (intel_info->gen != 3) {
923 driver.driver_features &= 927 driver.driver_features &=
924 ~(DRIVER_USE_AGP | DRIVER_REQUIRE_AGP); 928 ~(DRIVER_USE_AGP | DRIVER_REQUIRE_AGP);
925 } else if (!intel_agp_enabled) { 929 } else if (!intel_agp_enabled) {
926 DRM_ERROR("drm/i915 can't work without intel_agp module!\n"); 930 DRM_ERROR("drm/i915 can't work without intel_agp module!\n");
927 return -ENODEV; 931 return -ENODEV;
928 } 932 }
929 933
930 return drm_get_pci_dev(pdev, ent, &driver); 934 return drm_get_pci_dev(pdev, ent, &driver);
931} 935}
932 936
933static void 937static void
934i915_pci_remove(struct pci_dev *pdev) 938i915_pci_remove(struct pci_dev *pdev)
935{ 939{
936 struct drm_device *dev = pci_get_drvdata(pdev); 940 struct drm_device *dev = pci_get_drvdata(pdev);
937 941
938 drm_put_dev(dev); 942 drm_put_dev(dev);
939} 943}
940 944
941static int i915_pm_suspend(struct device *dev) 945static int i915_pm_suspend(struct device *dev)
942{ 946{
943 struct pci_dev *pdev = to_pci_dev(dev); 947 struct pci_dev *pdev = to_pci_dev(dev);
944 struct drm_device *drm_dev = pci_get_drvdata(pdev); 948 struct drm_device *drm_dev = pci_get_drvdata(pdev);
945 int error; 949 int error;
946 950
947 if (!drm_dev || !drm_dev->dev_private) { 951 if (!drm_dev || !drm_dev->dev_private) {
948 dev_err(dev, "DRM not initialized, aborting suspend.\n"); 952 dev_err(dev, "DRM not initialized, aborting suspend.\n");
949 return -ENODEV; 953 return -ENODEV;
950 } 954 }
951 955
952 if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF) 956 if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF)
953 return 0; 957 return 0;
954 958
955 error = i915_drm_freeze(drm_dev); 959 error = i915_drm_freeze(drm_dev);
956 if (error) 960 if (error)
957 return error; 961 return error;
958 962
 963#ifndef __NetBSD__ /* pmf handles this for us. */
959 pci_disable_device(pdev); 964 pci_disable_device(pdev);
960 pci_set_power_state(pdev, PCI_D3hot); 965 pci_set_power_state(pdev, PCI_D3hot);
 966#endif
961 967
962 return 0; 968 return 0;
963} 969}
964 970
965static int i915_pm_resume(struct device *dev) 971static int i915_pm_resume(struct device *dev)
966{ 972{
967 struct pci_dev *pdev = to_pci_dev(dev); 973 struct pci_dev *pdev = to_pci_dev(dev);
968 struct drm_device *drm_dev = pci_get_drvdata(pdev); 974 struct drm_device *drm_dev = pci_get_drvdata(pdev);
969 975
970 return i915_resume(drm_dev); 976 return i915_resume(drm_dev);
971} 977}
972 978
973static int i915_pm_freeze(struct device *dev) 979static int i915_pm_freeze(struct device *dev)
974{ 980{
975 struct pci_dev *pdev = to_pci_dev(dev); 981 struct pci_dev *pdev = to_pci_dev(dev);
976 struct drm_device *drm_dev = pci_get_drvdata(pdev); 982 struct drm_device *drm_dev = pci_get_drvdata(pdev);
977 983
978 if (!drm_dev || !drm_dev->dev_private) { 984 if (!drm_dev || !drm_dev->dev_private) {
979 dev_err(dev, "DRM not initialized, aborting suspend.\n"); 985 dev_err(dev, "DRM not initialized, aborting suspend.\n");
980 return -ENODEV; 986 return -ENODEV;
981 } 987 }
982 988
983 return i915_drm_freeze(drm_dev); 989 return i915_drm_freeze(drm_dev);
984} 990}
985 991
986static int i915_pm_thaw(struct device *dev) 992static int i915_pm_thaw(struct device *dev)
987{ 993{
988 struct pci_dev *pdev = to_pci_dev(dev); 994 struct pci_dev *pdev = to_pci_dev(dev);
989 struct drm_device *drm_dev = pci_get_drvdata(pdev); 995 struct drm_device *drm_dev = pci_get_drvdata(pdev);
990 996
991 return i915_drm_thaw(drm_dev); 997 return i915_drm_thaw(drm_dev);
992} 998}
993 999
994static int i915_pm_poweroff(struct device *dev) 1000static int i915_pm_poweroff(struct device *dev)
995{ 1001{
996 struct pci_dev *pdev = to_pci_dev(dev); 1002 struct pci_dev *pdev = to_pci_dev(dev);
997 struct drm_device *drm_dev = pci_get_drvdata(pdev); 1003 struct drm_device *drm_dev = pci_get_drvdata(pdev);
998 1004
999 return i915_drm_freeze(drm_dev); 1005 return i915_drm_freeze(drm_dev);
1000} 1006}
1001 1007
1002static const struct dev_pm_ops i915_pm_ops = { 1008static const struct dev_pm_ops i915_pm_ops = {
1003 .suspend = i915_pm_suspend, 1009 .suspend = i915_pm_suspend,
1004 .resume = i915_pm_resume, 1010 .resume = i915_pm_resume,
1005 .freeze = i915_pm_freeze, 1011 .freeze = i915_pm_freeze,
1006 .thaw = i915_pm_thaw, 1012 .thaw = i915_pm_thaw,
1007 .poweroff = i915_pm_poweroff, 1013 .poweroff = i915_pm_poweroff,
1008 .restore = i915_pm_resume, 1014 .restore = i915_pm_resume,
1009}; 1015};
1010 1016
1011static const struct vm_operations_struct i915_gem_vm_ops = { 1017static const struct vm_operations_struct i915_gem_vm_ops = {
1012 .fault = i915_gem_fault, 1018 .fault = i915_gem_fault,
1013 .open = drm_gem_vm_open, 1019 .open = drm_gem_vm_open,
1014 .close = drm_gem_vm_close, 1020 .close = drm_gem_vm_close,
1015}; 1021};
1016 1022
1017static const struct file_operations i915_driver_fops = { 1023static const struct file_operations i915_driver_fops = {
1018 .owner = THIS_MODULE, 1024 .owner = THIS_MODULE,
1019 .open = drm_open, 1025 .open = drm_open,
1020 .release = drm_release, 1026 .release = drm_release,
1021 .unlocked_ioctl = drm_ioctl, 1027 .unlocked_ioctl = drm_ioctl,
1022 .mmap = drm_gem_mmap, 1028 .mmap = drm_gem_mmap,
1023 .poll = drm_poll, 1029 .poll = drm_poll,
1024 .fasync = drm_fasync, 1030 .fasync = drm_fasync,
1025 .read = drm_read, 1031 .read = drm_read,
1026#ifdef CONFIG_COMPAT 1032#ifdef CONFIG_COMPAT
1027 .compat_ioctl = i915_compat_ioctl, 1033 .compat_ioctl = i915_compat_ioctl,
1028#endif 1034#endif
1029 .llseek = noop_llseek, 1035 .llseek = noop_llseek,
1030}; 1036};
1031 1037
1032static struct drm_driver driver = { 1038static struct drm_driver driver = {
1033 /* Don't use MTRRs here; the Xserver or userspace app should 1039 /* Don't use MTRRs here; the Xserver or userspace app should
1034 * deal with them for Intel hardware. 1040 * deal with them for Intel hardware.
1035 */ 1041 */
1036 .driver_features = 1042 .driver_features =
1037 DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | /* DRIVER_USE_MTRR |*/ 1043 DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | /* DRIVER_USE_MTRR |*/
1038 DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_GEM | DRIVER_PRIME, 1044 DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_GEM | DRIVER_PRIME,
1039 .load = i915_driver_load, 1045 .load = i915_driver_load,
1040 .unload = i915_driver_unload, 1046 .unload = i915_driver_unload,
1041 .open = i915_driver_open, 1047 .open = i915_driver_open,
1042 .lastclose = i915_driver_lastclose, 1048 .lastclose = i915_driver_lastclose,
1043 .preclose = i915_driver_preclose, 1049 .preclose = i915_driver_preclose,
1044 .postclose = i915_driver_postclose, 1050 .postclose = i915_driver_postclose,
1045 1051
1046 /* Used in place of i915_pm_ops for non-DRIVER_MODESET */ 1052 /* Used in place of i915_pm_ops for non-DRIVER_MODESET */
1047 .suspend = i915_suspend, 1053 .suspend = i915_suspend,
1048 .resume = i915_resume, 1054 .resume = i915_resume,
1049 1055
1050 .device_is_agp = i915_driver_device_is_agp, 1056 .device_is_agp = i915_driver_device_is_agp,
1051 .master_create = i915_master_create, 1057 .master_create = i915_master_create,
1052 .master_destroy = i915_master_destroy, 1058 .master_destroy = i915_master_destroy,
1053#if defined(CONFIG_DEBUG_FS) 1059#if defined(CONFIG_DEBUG_FS)
1054 .debugfs_init = i915_debugfs_init, 1060 .debugfs_init = i915_debugfs_init,
1055 .debugfs_cleanup = i915_debugfs_cleanup, 1061 .debugfs_cleanup = i915_debugfs_cleanup,
1056#endif 1062#endif
1057 .gem_init_object = i915_gem_init_object, 1063 .gem_init_object = i915_gem_init_object,
1058 .gem_free_object = i915_gem_free_object, 1064 .gem_free_object = i915_gem_free_object,
1059 .gem_vm_ops = &i915_gem_vm_ops, 1065 .gem_vm_ops = &i915_gem_vm_ops,
1060 1066
1061 .prime_handle_to_fd = drm_gem_prime_handle_to_fd, 1067 .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
1062 .prime_fd_to_handle = drm_gem_prime_fd_to_handle, 1068 .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
1063 .gem_prime_export = i915_gem_prime_export, 1069 .gem_prime_export = i915_gem_prime_export,
1064 .gem_prime_import = i915_gem_prime_import, 1070 .gem_prime_import = i915_gem_prime_import,
1065 1071
1066 .dumb_create = i915_gem_dumb_create, 1072 .dumb_create = i915_gem_dumb_create,
1067 .dumb_map_offset = i915_gem_mmap_gtt, 1073 .dumb_map_offset = i915_gem_mmap_gtt,
1068 .dumb_destroy = i915_gem_dumb_destroy, 1074 .dumb_destroy = i915_gem_dumb_destroy,
1069 .ioctls = i915_ioctls, 1075 .ioctls = i915_ioctls,
1070 .fops = &i915_driver_fops, 1076 .fops = &i915_driver_fops,
1071 .name = DRIVER_NAME, 1077 .name = DRIVER_NAME,
1072 .desc = DRIVER_DESC, 1078 .desc = DRIVER_DESC,
1073 .date = DRIVER_DATE, 1079 .date = DRIVER_DATE,
1074 .major = DRIVER_MAJOR, 1080 .major = DRIVER_MAJOR,
1075 .minor = DRIVER_MINOR, 1081 .minor = DRIVER_MINOR,
1076 .patchlevel = DRIVER_PATCHLEVEL, 1082 .patchlevel = DRIVER_PATCHLEVEL,
1077}; 1083};
1078 1084
1079static struct pci_driver i915_pci_driver = { 1085static struct pci_driver i915_pci_driver = {
1080 .name = DRIVER_NAME, 1086 .name = DRIVER_NAME,
1081 .id_table = pciidlist, 1087 .id_table = pciidlist,
1082 .probe = i915_pci_probe, 1088 .probe = i915_pci_probe,
1083 .remove = i915_pci_remove, 1089 .remove = i915_pci_remove,
1084 .driver.pm = &i915_pm_ops, 1090 .driver.pm = &i915_pm_ops,
1085}; 1091};
1086 1092
1087static int __init i915_init(void) 1093static int __init i915_init(void)
1088{ 1094{
1089 driver.num_ioctls = i915_max_ioctl; 1095 driver.num_ioctls = i915_max_ioctl;
1090 1096
1091 /* 1097 /*
1092 * If CONFIG_DRM_I915_KMS is set, default to KMS unless 1098 * If CONFIG_DRM_I915_KMS is set, default to KMS unless
1093 * explicitly disabled with the module pararmeter. 1099 * explicitly disabled with the module pararmeter.
1094 * 1100 *
1095 * Otherwise, just follow the parameter (defaulting to off). 1101 * Otherwise, just follow the parameter (defaulting to off).
1096 * 1102 *
1097 * Allow optional vga_text_mode_force boot option to override 1103 * Allow optional vga_text_mode_force boot option to override
1098 * the default behavior. 1104 * the default behavior.
1099 */ 1105 */
1100#if defined(CONFIG_DRM_I915_KMS) 1106#if defined(CONFIG_DRM_I915_KMS)
1101 if (i915_modeset != 0) 1107 if (i915_modeset != 0)
1102 driver.driver_features |= DRIVER_MODESET; 1108 driver.driver_features |= DRIVER_MODESET;
1103#endif 1109#endif
1104 if (i915_modeset == 1) 1110 if (i915_modeset == 1)
1105 driver.driver_features |= DRIVER_MODESET; 1111 driver.driver_features |= DRIVER_MODESET;
1106 1112
1107#ifdef CONFIG_VGA_CONSOLE 1113#ifdef CONFIG_VGA_CONSOLE
1108 if (vgacon_text_force() && i915_modeset == -1) 1114 if (vgacon_text_force() && i915_modeset == -1)
1109 driver.driver_features &= ~DRIVER_MODESET; 1115 driver.driver_features &= ~DRIVER_MODESET;
1110#endif 1116#endif
1111 1117
1112 if (!(driver.driver_features & DRIVER_MODESET)) 1118 if (!(driver.driver_features & DRIVER_MODESET))
1113 driver.get_vblank_timestamp = NULL; 1119 driver.get_vblank_timestamp = NULL;
1114 1120
1115 return drm_pci_init(&driver, &i915_pci_driver); 1121 return drm_pci_init(&driver, &i915_pci_driver);
1116} 1122}
1117 1123
1118static void __exit i915_exit(void) 1124static void __exit i915_exit(void)
1119{ 1125{
1120 drm_pci_exit(&driver, &i915_pci_driver); 1126 drm_pci_exit(&driver, &i915_pci_driver);
1121} 1127}
1122 1128
1123module_init(i915_init); 1129module_init(i915_init);
1124module_exit(i915_exit); 1130module_exit(i915_exit);
1125 1131
1126MODULE_AUTHOR(DRIVER_AUTHOR); 1132MODULE_AUTHOR(DRIVER_AUTHOR);
1127MODULE_DESCRIPTION(DRIVER_DESC); 1133MODULE_DESCRIPTION(DRIVER_DESC);
1128MODULE_LICENSE("GPL and additional rights"); 1134MODULE_LICENSE("GPL and additional rights");
1129 1135
1130/* We give fast paths for the really cool registers */ 1136/* We give fast paths for the really cool registers */
1131#define NEEDS_FORCE_WAKE(dev_priv, reg) \ 1137#define NEEDS_FORCE_WAKE(dev_priv, reg) \
1132 ((HAS_FORCE_WAKE((dev_priv)->dev)) && \ 1138 ((HAS_FORCE_WAKE((dev_priv)->dev)) && \
1133 ((reg) < 0x40000) && \ 1139 ((reg) < 0x40000) && \
1134 ((reg) != FORCEWAKE)) 1140 ((reg) != FORCEWAKE))
1135 1141
1136static bool IS_DISPLAYREG(u32 reg) 1142static bool IS_DISPLAYREG(u32 reg)
1137{ 1143{
1138 /* 1144 /*
1139 * This should make it easier to transition modules over to the 1145 * This should make it easier to transition modules over to the
1140 * new register block scheme, since we can do it incrementally. 1146 * new register block scheme, since we can do it incrementally.
1141 */ 1147 */
1142 if (reg >= VLV_DISPLAY_BASE) 1148 if (reg >= VLV_DISPLAY_BASE)
1143 return false; 1149 return false;
1144 1150
1145 if (reg >= RENDER_RING_BASE && 1151 if (reg >= RENDER_RING_BASE &&
1146 reg < RENDER_RING_BASE + 0xff) 1152 reg < RENDER_RING_BASE + 0xff)
1147 return false; 1153 return false;
1148 if (reg >= GEN6_BSD_RING_BASE && 1154 if (reg >= GEN6_BSD_RING_BASE &&
1149 reg < GEN6_BSD_RING_BASE + 0xff) 1155 reg < GEN6_BSD_RING_BASE + 0xff)
1150 return false; 1156 return false;
1151 if (reg >= BLT_RING_BASE && 1157 if (reg >= BLT_RING_BASE &&
1152 reg < BLT_RING_BASE + 0xff) 1158 reg < BLT_RING_BASE + 0xff)
1153 return false; 1159 return false;
1154 1160
1155 if (reg == PGTBL_ER) 1161 if (reg == PGTBL_ER)
1156 return false; 1162 return false;
1157 1163
1158 if (reg >= IPEIR_I965 && 1164 if (reg >= IPEIR_I965 &&
1159 reg < HWSTAM) 1165 reg < HWSTAM)
1160 return false; 1166 return false;
1161 1167
1162 if (reg == MI_MODE) 1168 if (reg == MI_MODE)
1163 return false; 1169 return false;
1164 1170
1165 if (reg == GFX_MODE_GEN7) 1171 if (reg == GFX_MODE_GEN7)
1166 return false; 1172 return false;
1167 1173
1168 if (reg == RENDER_HWS_PGA_GEN7 || 1174 if (reg == RENDER_HWS_PGA_GEN7 ||
1169 reg == BSD_HWS_PGA_GEN7 || 1175 reg == BSD_HWS_PGA_GEN7 ||
1170 reg == BLT_HWS_PGA_GEN7) 1176 reg == BLT_HWS_PGA_GEN7)
1171 return false; 1177 return false;
1172 1178
1173 if (reg == GEN6_BSD_SLEEP_PSMI_CONTROL || 1179 if (reg == GEN6_BSD_SLEEP_PSMI_CONTROL ||
1174 reg == GEN6_BSD_RNCID) 1180 reg == GEN6_BSD_RNCID)
1175 return false; 1181 return false;
1176 1182
1177 if (reg == GEN6_BLITTER_ECOSKPD) 1183 if (reg == GEN6_BLITTER_ECOSKPD)
1178 return false; 1184 return false;
1179 1185
1180 if (reg >= 0x4000c && 1186 if (reg >= 0x4000c &&
1181 reg <= 0x4002c) 1187 reg <= 0x4002c)
1182 return false; 1188 return false;
1183 1189
1184 if (reg >= 0x4f000 && 1190 if (reg >= 0x4f000 &&
1185 reg <= 0x4f08f) 1191 reg <= 0x4f08f)
1186 return false; 1192 return false;
1187 1193
1188 if (reg >= 0x4f100 && 1194 if (reg >= 0x4f100 &&
1189 reg <= 0x4f11f) 1195 reg <= 0x4f11f)
1190 return false; 1196 return false;
1191 1197
1192 if (reg >= VLV_MASTER_IER && 1198 if (reg >= VLV_MASTER_IER &&
1193 reg <= GEN6_PMIER) 1199 reg <= GEN6_PMIER)
1194 return false; 1200 return false;
1195 1201
1196 if (reg >= FENCE_REG_SANDYBRIDGE_0 && 1202 if (reg >= FENCE_REG_SANDYBRIDGE_0 &&
1197 reg < (FENCE_REG_SANDYBRIDGE_0 + (16*8))) 1203 reg < (FENCE_REG_SANDYBRIDGE_0 + (16*8)))
1198 return false; 1204 return false;
1199 1205
1200 if (reg >= VLV_IIR_RW && 1206 if (reg >= VLV_IIR_RW &&
1201 reg <= VLV_ISR) 1207 reg <= VLV_ISR)
1202 return false; 1208 return false;
1203 1209
1204 if (reg == FORCEWAKE_VLV || 1210 if (reg == FORCEWAKE_VLV ||
1205 reg == FORCEWAKE_ACK_VLV) 1211 reg == FORCEWAKE_ACK_VLV)
1206 return false; 1212 return false;
1207 1213
1208 if (reg == GEN6_GDRST) 1214 if (reg == GEN6_GDRST)
1209 return false; 1215 return false;
1210 1216
1211 switch (reg) { 1217 switch (reg) {
1212 case _3D_CHICKEN3: 1218 case _3D_CHICKEN3:
1213 case IVB_CHICKEN3: 1219 case IVB_CHICKEN3:
1214 case GEN7_COMMON_SLICE_CHICKEN1: 1220 case GEN7_COMMON_SLICE_CHICKEN1:
1215 case GEN7_L3CNTLREG1: 1221 case GEN7_L3CNTLREG1:
1216 case GEN7_L3_CHICKEN_MODE_REGISTER: 1222 case GEN7_L3_CHICKEN_MODE_REGISTER:
1217 case GEN7_ROW_CHICKEN2: 1223 case GEN7_ROW_CHICKEN2:
1218 case GEN7_L3SQCREG4: 1224 case GEN7_L3SQCREG4:
1219 case GEN7_SQ_CHICKEN_MBCUNIT_CONFIG: 1225 case GEN7_SQ_CHICKEN_MBCUNIT_CONFIG:
1220 case GEN7_HALF_SLICE_CHICKEN1: 1226 case GEN7_HALF_SLICE_CHICKEN1:
1221 case GEN6_MBCTL: 1227 case GEN6_MBCTL:
1222 case GEN6_UCGCTL2: 1228 case GEN6_UCGCTL2:
1223 return false; 1229 return false;
1224 default: 1230 default:
1225 break; 1231 break;
1226 } 1232 }
1227 1233
1228 return true; 1234 return true;
1229} 1235}
1230 1236
1231static void 1237static void
1232ilk_dummy_write(struct drm_i915_private *dev_priv) 1238ilk_dummy_write(struct drm_i915_private *dev_priv)
1233{ 1239{
1234 /* WaIssueDummyWriteToWakeupFromRC6: Issue a dummy write to wake up the 1240 /* WaIssueDummyWriteToWakeupFromRC6: Issue a dummy write to wake up the
1235 * chip from rc6 before touching it for real. MI_MODE is masked, hence 1241 * chip from rc6 before touching it for real. MI_MODE is masked, hence
1236 * harmless to write 0 into. */ 1242 * harmless to write 0 into. */
1237 I915_WRITE_NOTRACE(MI_MODE, 0); 1243 I915_WRITE_NOTRACE(MI_MODE, 0);
1238} 1244}
1239 1245
1240#ifdef __NetBSD__ 1246#ifdef __NetBSD__
1241#define __i915_read(x, y) \ 1247#define __i915_read(x, y) \
1242u##x i915_read##x(struct drm_i915_private *dev_priv, u32 reg) { \ 1248u##x i915_read##x(struct drm_i915_private *dev_priv, u32 reg) { \
1243 u##x val = 0; \ 1249 u##x val = 0; \
1244 if (IS_GEN5(dev_priv->dev)) \ 1250 if (IS_GEN5(dev_priv->dev)) \
1245 ilk_dummy_write(dev_priv); \ 1251 ilk_dummy_write(dev_priv); \
1246 if (NEEDS_FORCE_WAKE((dev_priv), (reg))) { \ 1252 if (NEEDS_FORCE_WAKE((dev_priv), (reg))) { \
1247 unsigned long irqflags; \ 1253 unsigned long irqflags; \
1248 spin_lock_irqsave(&dev_priv->gt_lock, irqflags); \ 1254 spin_lock_irqsave(&dev_priv->gt_lock, irqflags); \
1249 if (dev_priv->forcewake_count == 0) \ 1255 if (dev_priv->forcewake_count == 0) \
1250 dev_priv->gt.force_wake_get(dev_priv); \ 1256 dev_priv->gt.force_wake_get(dev_priv); \
1251 val = DRM_READ##x(dev_priv->regs_map, reg); \ 1257 val = DRM_READ##x(dev_priv->regs_map, reg); \
1252 if (dev_priv->forcewake_count == 0) \ 1258 if (dev_priv->forcewake_count == 0) \
1253 dev_priv->gt.force_wake_put(dev_priv); \ 1259 dev_priv->gt.force_wake_put(dev_priv); \
1254 spin_unlock_irqrestore(&dev_priv->gt_lock, irqflags); \ 1260 spin_unlock_irqrestore(&dev_priv->gt_lock, irqflags); \
1255 } else if (IS_VALLEYVIEW(dev_priv->dev) && IS_DISPLAYREG(reg)) { \ 1261 } else if (IS_VALLEYVIEW(dev_priv->dev) && IS_DISPLAYREG(reg)) { \
1256 val = DRM_READ##x(dev_priv->regs_map, reg + 0x180000); \ 1262 val = DRM_READ##x(dev_priv->regs_map, reg + 0x180000); \
1257 } else { \ 1263 } else { \
1258 val = DRM_READ##x(dev_priv->regs_map, reg); \ 1264 val = DRM_READ##x(dev_priv->regs_map, reg); \
1259 } \ 1265 } \
1260 trace_i915_reg_rw(false, reg, val, sizeof(val)); \ 1266 trace_i915_reg_rw(false, reg, val, sizeof(val)); \
1261 return val; \ 1267 return val; \
1262} 1268}
1263#else 1269#else
1264#define __i915_read(x, y) \ 1270#define __i915_read(x, y) \
1265u##x i915_read##x(struct drm_i915_private *dev_priv, u32 reg) { \ 1271u##x i915_read##x(struct drm_i915_private *dev_priv, u32 reg) { \
1266 u##x val = 0; \ 1272 u##x val = 0; \
1267 if (IS_GEN5(dev_priv->dev)) \ 1273 if (IS_GEN5(dev_priv->dev)) \
1268 ilk_dummy_write(dev_priv); \ 1274 ilk_dummy_write(dev_priv); \
1269 if (NEEDS_FORCE_WAKE((dev_priv), (reg))) { \ 1275 if (NEEDS_FORCE_WAKE((dev_priv), (reg))) { \
1270 unsigned long irqflags; \ 1276 unsigned long irqflags; \
1271 spin_lock_irqsave(&dev_priv->gt_lock, irqflags); \ 1277 spin_lock_irqsave(&dev_priv->gt_lock, irqflags); \
1272 if (dev_priv->forcewake_count == 0) \ 1278 if (dev_priv->forcewake_count == 0) \
1273 dev_priv->gt.force_wake_get(dev_priv); \ 1279 dev_priv->gt.force_wake_get(dev_priv); \
1274 val = read##y(dev_priv->regs + reg); \ 1280 val = read##y(dev_priv->regs + reg); \
1275 if (dev_priv->forcewake_count == 0) \ 1281 if (dev_priv->forcewake_count == 0) \
1276 dev_priv->gt.force_wake_put(dev_priv); \ 1282 dev_priv->gt.force_wake_put(dev_priv); \
1277 spin_unlock_irqrestore(&dev_priv->gt_lock, irqflags); \ 1283 spin_unlock_irqrestore(&dev_priv->gt_lock, irqflags); \
1278 } else if (IS_VALLEYVIEW(dev_priv->dev) && IS_DISPLAYREG(reg)) { \ 1284 } else if (IS_VALLEYVIEW(dev_priv->dev) && IS_DISPLAYREG(reg)) { \
1279 val = read##y(dev_priv->regs + reg + 0x180000); \ 1285 val = read##y(dev_priv->regs + reg + 0x180000); \
1280 } else { \ 1286 } else { \
1281 val = read##y(dev_priv->regs + reg); \ 1287 val = read##y(dev_priv->regs + reg); \
1282 } \ 1288 } \
1283 trace_i915_reg_rw(false, reg, val, sizeof(val)); \ 1289 trace_i915_reg_rw(false, reg, val, sizeof(val)); \
1284 return val; \ 1290 return val; \
1285} 1291}
1286#endif 1292#endif
1287 1293
1288__i915_read(8, b) 1294__i915_read(8, b)
1289__i915_read(16, w) 1295__i915_read(16, w)
1290__i915_read(32, l) 1296__i915_read(32, l)
1291__i915_read(64, q) 1297__i915_read(64, q)
1292#undef __i915_read 1298#undef __i915_read
1293 1299
1294#ifdef __NetBSD__ 1300#ifdef __NetBSD__
1295#define __i915_write(x, y) \ 1301#define __i915_write(x, y) \
1296void i915_write##x(struct drm_i915_private *dev_priv, u32 reg, u##x val) { \ 1302void i915_write##x(struct drm_i915_private *dev_priv, u32 reg, u##x val) { \
1297 u32 __fifo_ret = 0; \ 1303 u32 __fifo_ret = 0; \
1298 trace_i915_reg_rw(true, reg, val, sizeof(val)); \ 1304 trace_i915_reg_rw(true, reg, val, sizeof(val)); \
1299 if (NEEDS_FORCE_WAKE((dev_priv), (reg))) { \ 1305 if (NEEDS_FORCE_WAKE((dev_priv), (reg))) { \
1300 __fifo_ret = __gen6_gt_wait_for_fifo(dev_priv); \ 1306 __fifo_ret = __gen6_gt_wait_for_fifo(dev_priv); \
1301 } \ 1307 } \
1302 if (IS_GEN5(dev_priv->dev)) \ 1308 if (IS_GEN5(dev_priv->dev)) \
1303 ilk_dummy_write(dev_priv); \ 1309 ilk_dummy_write(dev_priv); \
1304 if (IS_HASWELL(dev_priv->dev) && (I915_READ_NOTRACE(GEN7_ERR_INT) & ERR_INT_MMIO_UNCLAIMED)) { \ 1310 if (IS_HASWELL(dev_priv->dev) && (I915_READ_NOTRACE(GEN7_ERR_INT) & ERR_INT_MMIO_UNCLAIMED)) { \
1305 DRM_ERROR("Unknown unclaimed register before writing to %x\n", reg); \ 1311 DRM_ERROR("Unknown unclaimed register before writing to %x\n", reg); \
1306 I915_WRITE_NOTRACE(GEN7_ERR_INT, ERR_INT_MMIO_UNCLAIMED); \ 1312 I915_WRITE_NOTRACE(GEN7_ERR_INT, ERR_INT_MMIO_UNCLAIMED); \
1307 } \ 1313 } \
1308 if (IS_VALLEYVIEW(dev_priv->dev) && IS_DISPLAYREG(reg)) { \ 1314 if (IS_VALLEYVIEW(dev_priv->dev) && IS_DISPLAYREG(reg)) { \
1309 DRM_WRITE##x(dev_priv->regs_map, reg + 0x180000, val); \ 1315 DRM_WRITE##x(dev_priv->regs_map, reg + 0x180000, val); \
1310 } else { \ 1316 } else { \
1311 DRM_WRITE##x(dev_priv->regs_map, reg, val); \ 1317 DRM_WRITE##x(dev_priv->regs_map, reg, val); \
1312 } \ 1318 } \
1313 if (unlikely(__fifo_ret)) { \ 1319 if (unlikely(__fifo_ret)) { \
1314 gen6_gt_check_fifodbg(dev_priv); \ 1320 gen6_gt_check_fifodbg(dev_priv); \
1315 } \ 1321 } \
1316 if (IS_HASWELL(dev_priv->dev) && (I915_READ_NOTRACE(GEN7_ERR_INT) & ERR_INT_MMIO_UNCLAIMED)) { \ 1322 if (IS_HASWELL(dev_priv->dev) && (I915_READ_NOTRACE(GEN7_ERR_INT) & ERR_INT_MMIO_UNCLAIMED)) { \
1317 DRM_ERROR("Unclaimed write to %x\n", reg); \ 1323 DRM_ERROR("Unclaimed write to %x\n", reg); \
1318 DRM_WRITE32(dev_priv->regs_map, GEN7_ERR_INT, ERR_INT_MMIO_UNCLAIMED); \ 1324 DRM_WRITE32(dev_priv->regs_map, GEN7_ERR_INT, ERR_INT_MMIO_UNCLAIMED); \
1319 } \ 1325 } \
1320} 1326}
1321#else 1327#else
1322#define __i915_write(x, y) \ 1328#define __i915_write(x, y) \
1323void i915_write##x(struct drm_i915_private *dev_priv, u32 reg, u##x val) { \ 1329void i915_write##x(struct drm_i915_private *dev_priv, u32 reg, u##x val) { \
1324 u32 __fifo_ret = 0; \ 1330 u32 __fifo_ret = 0; \
1325 trace_i915_reg_rw(true, reg, val, sizeof(val)); \ 1331 trace_i915_reg_rw(true, reg, val, sizeof(val)); \
1326 if (NEEDS_FORCE_WAKE((dev_priv), (reg))) { \ 1332 if (NEEDS_FORCE_WAKE((dev_priv), (reg))) { \
1327 __fifo_ret = __gen6_gt_wait_for_fifo(dev_priv); \ 1333 __fifo_ret = __gen6_gt_wait_for_fifo(dev_priv); \
1328 } \ 1334 } \
1329 if (IS_GEN5(dev_priv->dev)) \ 1335 if (IS_GEN5(dev_priv->dev)) \
1330 ilk_dummy_write(dev_priv); \ 1336 ilk_dummy_write(dev_priv); \
1331 if (IS_HASWELL(dev_priv->dev) && (I915_READ_NOTRACE(GEN7_ERR_INT) & ERR_INT_MMIO_UNCLAIMED)) { \ 1337 if (IS_HASWELL(dev_priv->dev) && (I915_READ_NOTRACE(GEN7_ERR_INT) & ERR_INT_MMIO_UNCLAIMED)) { \
1332 DRM_ERROR("Unknown unclaimed register before writing to %x\n", reg); \ 1338 DRM_ERROR("Unknown unclaimed register before writing to %x\n", reg); \
1333 I915_WRITE_NOTRACE(GEN7_ERR_INT, ERR_INT_MMIO_UNCLAIMED); \ 1339 I915_WRITE_NOTRACE(GEN7_ERR_INT, ERR_INT_MMIO_UNCLAIMED); \
1334 } \ 1340 } \
1335 if (IS_VALLEYVIEW(dev_priv->dev) && IS_DISPLAYREG(reg)) { \ 1341 if (IS_VALLEYVIEW(dev_priv->dev) && IS_DISPLAYREG(reg)) { \
1336 write##y(val, dev_priv->regs + reg + 0x180000); \ 1342 write##y(val, dev_priv->regs + reg + 0x180000); \
1337 } else { \ 1343 } else { \
1338 write##y(val, dev_priv->regs + reg); \ 1344 write##y(val, dev_priv->regs + reg); \
1339 } \ 1345 } \
1340 if (unlikely(__fifo_ret)) { \ 1346 if (unlikely(__fifo_ret)) { \
1341 gen6_gt_check_fifodbg(dev_priv); \ 1347 gen6_gt_check_fifodbg(dev_priv); \
1342 } \ 1348 } \
1343 if (IS_HASWELL(dev_priv->dev) && (I915_READ_NOTRACE(GEN7_ERR_INT) & ERR_INT_MMIO_UNCLAIMED)) { \ 1349 if (IS_HASWELL(dev_priv->dev) && (I915_READ_NOTRACE(GEN7_ERR_INT) & ERR_INT_MMIO_UNCLAIMED)) { \
1344 DRM_ERROR("Unclaimed write to %x\n", reg); \ 1350 DRM_ERROR("Unclaimed write to %x\n", reg); \
1345 writel(ERR_INT_MMIO_UNCLAIMED, dev_priv->regs + GEN7_ERR_INT); \ 1351 writel(ERR_INT_MMIO_UNCLAIMED, dev_priv->regs + GEN7_ERR_INT); \
1346 } \ 1352 } \
1347} 1353}
1348#endif 1354#endif
1349 1355
1350__i915_write(8, b) 1356__i915_write(8, b)
1351__i915_write(16, w) 1357__i915_write(16, w)
1352__i915_write(32, l) 1358__i915_write(32, l)
1353__i915_write(64, q) 1359__i915_write(64, q)
1354#undef __i915_write 1360#undef __i915_write
1355 1361
1356static const struct register_whitelist { 1362static const struct register_whitelist {
1357 uint64_t offset; 1363 uint64_t offset;
1358 uint32_t size; 1364 uint32_t size;
1359 uint32_t gen_bitmask; /* support gens, 0x10 for 4, 0x30 for 4 and 5, etc. */ 1365 uint32_t gen_bitmask; /* support gens, 0x10 for 4, 0x30 for 4 and 5, etc. */
1360} whitelist[] = { 1366} whitelist[] = {
1361 { RING_TIMESTAMP(RENDER_RING_BASE), 8, 0xF0 }, 1367 { RING_TIMESTAMP(RENDER_RING_BASE), 8, 0xF0 },
1362}; 1368};
1363 1369
1364int i915_reg_read_ioctl(struct drm_device *dev, 1370int i915_reg_read_ioctl(struct drm_device *dev,
1365 void *data, struct drm_file *file) 1371 void *data, struct drm_file *file)
1366{ 1372{
1367 struct drm_i915_private *dev_priv = dev->dev_private; 1373 struct drm_i915_private *dev_priv = dev->dev_private;
1368 struct drm_i915_reg_read *reg = data; 1374 struct drm_i915_reg_read *reg = data;
1369 struct register_whitelist const *entry = whitelist; 1375 struct register_whitelist const *entry = whitelist;
1370 int i; 1376 int i;
1371 1377
1372 for (i = 0; i < ARRAY_SIZE(whitelist); i++, entry++) { 1378 for (i = 0; i < ARRAY_SIZE(whitelist); i++, entry++) {
1373 if (entry->offset == reg->offset && 1379 if (entry->offset == reg->offset &&
1374 (1 << INTEL_INFO(dev)->gen & entry->gen_bitmask)) 1380 (1 << INTEL_INFO(dev)->gen & entry->gen_bitmask))
1375 break; 1381 break;
1376 } 1382 }
1377 1383
1378 if (i == ARRAY_SIZE(whitelist)) 1384 if (i == ARRAY_SIZE(whitelist))
1379 return -EINVAL; 1385 return -EINVAL;
1380 1386
1381 switch (entry->size) { 1387 switch (entry->size) {
1382 case 8: 1388 case 8:
1383 reg->val = I915_READ64(reg->offset); 1389 reg->val = I915_READ64(reg->offset);
1384 break; 1390 break;
1385 case 4: 1391 case 4:
1386 reg->val = I915_READ(reg->offset); 1392 reg->val = I915_READ(reg->offset);
1387 break; 1393 break;
1388 case 2: 1394 case 2:
1389 reg->val = I915_READ16(reg->offset); 1395 reg->val = I915_READ16(reg->offset);
1390 break; 1396 break;
1391 case 1: 1397 case 1:
1392 reg->val = I915_READ8(reg->offset); 1398 reg->val = I915_READ8(reg->offset);
1393 break; 1399 break;
1394 default: 1400 default:
1395 WARN_ON(1); 1401 WARN_ON(1);
1396 return -EINVAL; 1402 return -EINVAL;
1397 } 1403 }
1398 1404
1399 return 0; 1405 return 0;
1400} 1406}