i915_drv.c 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112
  1. /* i915_drv.c -- i830,i845,i855,i865,i915 driver -*- linux-c -*-
  2. */
  3. /*
  4. *
  5. * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
  6. * All Rights Reserved.
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a
  9. * copy of this software and associated documentation files (the
  10. * "Software"), to deal in the Software without restriction, including
  11. * without limitation the rights to use, copy, modify, merge, publish,
  12. * distribute, sub license, and/or sell copies of the Software, and to
  13. * permit persons to whom the Software is furnished to do so, subject to
  14. * the following conditions:
  15. *
  16. * The above copyright notice and this permission notice (including the
  17. * next paragraph) shall be included in all copies or substantial portions
  18. * of the Software.
  19. *
  20. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  21. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  23. * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
  24. * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  25. * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  26. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27. *
  28. */
  29. #include <linux/device.h>
  30. #include <drm/drmP.h>
  31. #include <drm/i915_drm.h>
  32. #include "i915_drv.h"
  33. #include "i915_trace.h"
  34. #include "intel_drv.h"
  35. #include <linux/console.h>
  36. #include <linux/module.h>
  37. #include <drm/drm_crtc_helper.h>
  38. static int i915_modeset __read_mostly = -1;
  39. module_param_named(modeset, i915_modeset, int, 0400);
  40. MODULE_PARM_DESC(modeset,
  41. "Use kernel modesetting [KMS] (0=DRM_I915_KMS from .config, "
  42. "1=on, -1=force vga console preference [default])");
  43. unsigned int i915_fbpercrtc __always_unused = 0;
  44. module_param_named(fbpercrtc, i915_fbpercrtc, int, 0400);
  45. int i915_panel_ignore_lid __read_mostly = 1;
  46. module_param_named(panel_ignore_lid, i915_panel_ignore_lid, int, 0600);
  47. MODULE_PARM_DESC(panel_ignore_lid,
  48. "Override lid status (0=autodetect, 1=autodetect disabled [default], "
  49. "-1=force lid closed, -2=force lid open)");
  50. unsigned int i915_powersave __read_mostly = 1;
  51. module_param_named(powersave, i915_powersave, int, 0600);
  52. MODULE_PARM_DESC(powersave,
  53. "Enable powersavings, fbc, downclocking, etc. (default: true)");
  54. int i915_semaphores __read_mostly = -1;
  55. module_param_named(semaphores, i915_semaphores, int, 0600);
  56. MODULE_PARM_DESC(semaphores,
  57. "Use semaphores for inter-ring sync (default: -1 (use per-chip defaults))");
  58. int i915_enable_rc6 __read_mostly = -1;
  59. module_param_named(i915_enable_rc6, i915_enable_rc6, int, 0400);
  60. MODULE_PARM_DESC(i915_enable_rc6,
  61. "Enable power-saving render C-state 6. "
  62. "Different stages can be selected via bitmask values "
  63. "(0 = disable; 1 = enable rc6; 2 = enable deep rc6; 4 = enable deepest rc6). "
  64. "For example, 3 would enable rc6 and deep rc6, and 7 would enable everything. "
  65. "default: -1 (use per-chip default)");
  66. int i915_enable_fbc __read_mostly = -1;
  67. module_param_named(i915_enable_fbc, i915_enable_fbc, int, 0600);
  68. MODULE_PARM_DESC(i915_enable_fbc,
  69. "Enable frame buffer compression for power savings "
  70. "(default: -1 (use per-chip default))");
  71. unsigned int i915_lvds_downclock __read_mostly = 0;
  72. module_param_named(lvds_downclock, i915_lvds_downclock, int, 0400);
  73. MODULE_PARM_DESC(lvds_downclock,
  74. "Use panel (LVDS/eDP) downclocking for power savings "
  75. "(default: false)");
  76. int i915_lvds_channel_mode __read_mostly;
  77. module_param_named(lvds_channel_mode, i915_lvds_channel_mode, int, 0600);
  78. MODULE_PARM_DESC(lvds_channel_mode,
  79. "Specify LVDS channel mode "
  80. "(0=probe BIOS [default], 1=single-channel, 2=dual-channel)");
  81. int i915_panel_use_ssc __read_mostly = -1;
  82. module_param_named(lvds_use_ssc, i915_panel_use_ssc, int, 0600);
  83. MODULE_PARM_DESC(lvds_use_ssc,
  84. "Use Spread Spectrum Clock with panels [LVDS/eDP] "
  85. "(default: auto from VBT)");
  86. int i915_vbt_sdvo_panel_type __read_mostly = -1;
  87. module_param_named(vbt_sdvo_panel_type, i915_vbt_sdvo_panel_type, int, 0600);
  88. MODULE_PARM_DESC(vbt_sdvo_panel_type,
  89. "Override/Ignore selection of SDVO panel mode in the VBT "
  90. "(-2=ignore, -1=auto [default], index in VBT BIOS table)");
  91. static bool i915_try_reset __read_mostly = true;
  92. module_param_named(reset, i915_try_reset, bool, 0600);
  93. MODULE_PARM_DESC(reset, "Attempt GPU resets (default: true)");
  94. bool i915_enable_hangcheck __read_mostly = true;
  95. module_param_named(enable_hangcheck, i915_enable_hangcheck, bool, 0644);
  96. MODULE_PARM_DESC(enable_hangcheck,
  97. "Periodically check GPU activity for detecting hangs. "
  98. "WARNING: Disabling this can cause system wide hangs. "
  99. "(default: true)");
  100. int i915_enable_ppgtt __read_mostly = -1;
  101. module_param_named(i915_enable_ppgtt, i915_enable_ppgtt, int, 0600);
  102. MODULE_PARM_DESC(i915_enable_ppgtt,
  103. "Enable PPGTT (default: true)");
  104. int i915_enable_psr __read_mostly = 0;
  105. module_param_named(enable_psr, i915_enable_psr, int, 0600);
  106. MODULE_PARM_DESC(enable_psr, "Enable PSR (default: false)");
  107. unsigned int i915_preliminary_hw_support __read_mostly = IS_ENABLED(CONFIG_DRM_I915_PRELIMINARY_HW_SUPPORT);
  108. module_param_named(preliminary_hw_support, i915_preliminary_hw_support, int, 0600);
  109. MODULE_PARM_DESC(preliminary_hw_support,
  110. "Enable preliminary hardware support.");
  111. int i915_disable_power_well __read_mostly = 1;
  112. module_param_named(disable_power_well, i915_disable_power_well, int, 0600);
  113. MODULE_PARM_DESC(disable_power_well,
  114. "Disable the power well when possible (default: true)");
  115. int i915_enable_ips __read_mostly = 1;
  116. module_param_named(enable_ips, i915_enable_ips, int, 0600);
  117. MODULE_PARM_DESC(enable_ips, "Enable IPS (default: true)");
  118. bool i915_fastboot __read_mostly = 0;
  119. module_param_named(fastboot, i915_fastboot, bool, 0600);
  120. MODULE_PARM_DESC(fastboot, "Try to skip unnecessary mode sets at boot time "
  121. "(default: false)");
  122. int i915_enable_pc8 __read_mostly = 0;
  123. module_param_named(enable_pc8, i915_enable_pc8, int, 0600);
  124. MODULE_PARM_DESC(enable_pc8, "Enable support for low power package C states (PC8+) (default: false)");
  125. bool i915_prefault_disable __read_mostly;
  126. module_param_named(prefault_disable, i915_prefault_disable, bool, 0600);
  127. MODULE_PARM_DESC(prefault_disable,
  128. "Disable page prefaulting for pread/pwrite/reloc (default:false). For developers only.");
  129. static struct drm_driver driver;
  130. extern int intel_agp_enabled;
  131. #define INTEL_VGA_DEVICE(id, info) { \
  132. .class = PCI_BASE_CLASS_DISPLAY << 16, \
  133. .class_mask = 0xff0000, \
  134. .vendor = 0x8086, \
  135. .device = id, \
  136. .subvendor = PCI_ANY_ID, \
  137. .subdevice = PCI_ANY_ID, \
  138. .driver_data = (unsigned long) info }
  139. #define INTEL_QUANTA_VGA_DEVICE(info) { \
  140. .class = PCI_BASE_CLASS_DISPLAY << 16, \
  141. .class_mask = 0xff0000, \
  142. .vendor = 0x8086, \
  143. .device = 0x16a, \
  144. .subvendor = 0x152d, \
  145. .subdevice = 0x8990, \
  146. .driver_data = (unsigned long) info }
  147. static const struct intel_device_info intel_i830_info = {
  148. .gen = 2, .is_mobile = 1, .cursor_needs_physical = 1, .num_pipes = 2,
  149. .has_overlay = 1, .overlay_needs_physical = 1,
  150. };
  151. static const struct intel_device_info intel_845g_info = {
  152. .gen = 2, .num_pipes = 1,
  153. .has_overlay = 1, .overlay_needs_physical = 1,
  154. };
  155. static const struct intel_device_info intel_i85x_info = {
  156. .gen = 2, .is_i85x = 1, .is_mobile = 1, .num_pipes = 2,
  157. .cursor_needs_physical = 1,
  158. .has_overlay = 1, .overlay_needs_physical = 1,
  159. };
  160. static const struct intel_device_info intel_i865g_info = {
  161. .gen = 2, .num_pipes = 1,
  162. .has_overlay = 1, .overlay_needs_physical = 1,
  163. };
  164. static const struct intel_device_info intel_i915g_info = {
  165. .gen = 3, .is_i915g = 1, .cursor_needs_physical = 1, .num_pipes = 2,
  166. .has_overlay = 1, .overlay_needs_physical = 1,
  167. };
  168. static const struct intel_device_info intel_i915gm_info = {
  169. .gen = 3, .is_mobile = 1, .num_pipes = 2,
  170. .cursor_needs_physical = 1,
  171. .has_overlay = 1, .overlay_needs_physical = 1,
  172. .supports_tv = 1,
  173. };
  174. static const struct intel_device_info intel_i945g_info = {
  175. .gen = 3, .has_hotplug = 1, .cursor_needs_physical = 1, .num_pipes = 2,
  176. .has_overlay = 1, .overlay_needs_physical = 1,
  177. };
  178. static const struct intel_device_info intel_i945gm_info = {
  179. .gen = 3, .is_i945gm = 1, .is_mobile = 1, .num_pipes = 2,
  180. .has_hotplug = 1, .cursor_needs_physical = 1,
  181. .has_overlay = 1, .overlay_needs_physical = 1,
  182. .supports_tv = 1,
  183. };
  184. static const struct intel_device_info intel_i965g_info = {
  185. .gen = 4, .is_broadwater = 1, .num_pipes = 2,
  186. .has_hotplug = 1,
  187. .has_overlay = 1,
  188. };
  189. static const struct intel_device_info intel_i965gm_info = {
  190. .gen = 4, .is_crestline = 1, .num_pipes = 2,
  191. .is_mobile = 1, .has_fbc = 1, .has_hotplug = 1,
  192. .has_overlay = 1,
  193. .supports_tv = 1,
  194. };
  195. static const struct intel_device_info intel_g33_info = {
  196. .gen = 3, .is_g33 = 1, .num_pipes = 2,
  197. .need_gfx_hws = 1, .has_hotplug = 1,
  198. .has_overlay = 1,
  199. };
  200. static const struct intel_device_info intel_g45_info = {
  201. .gen = 4, .is_g4x = 1, .need_gfx_hws = 1, .num_pipes = 2,
  202. .has_pipe_cxsr = 1, .has_hotplug = 1,
  203. .has_bsd_ring = 1,
  204. };
  205. static const struct intel_device_info intel_gm45_info = {
  206. .gen = 4, .is_g4x = 1, .num_pipes = 2,
  207. .is_mobile = 1, .need_gfx_hws = 1, .has_fbc = 1,
  208. .has_pipe_cxsr = 1, .has_hotplug = 1,
  209. .supports_tv = 1,
  210. .has_bsd_ring = 1,
  211. };
  212. static const struct intel_device_info intel_pineview_info = {
  213. .gen = 3, .is_g33 = 1, .is_pineview = 1, .is_mobile = 1, .num_pipes = 2,
  214. .need_gfx_hws = 1, .has_hotplug = 1,
  215. .has_overlay = 1,
  216. };
  217. static const struct intel_device_info intel_ironlake_d_info = {
  218. .gen = 5, .num_pipes = 2,
  219. .need_gfx_hws = 1, .has_hotplug = 1,
  220. .has_bsd_ring = 1,
  221. };
  222. static const struct intel_device_info intel_ironlake_m_info = {
  223. .gen = 5, .is_mobile = 1, .num_pipes = 2,
  224. .need_gfx_hws = 1, .has_hotplug = 1,
  225. .has_fbc = 1,
  226. .has_bsd_ring = 1,
  227. };
  228. static const struct intel_device_info intel_sandybridge_d_info = {
  229. .gen = 6, .num_pipes = 2,
  230. .need_gfx_hws = 1, .has_hotplug = 1,
  231. .has_bsd_ring = 1,
  232. .has_blt_ring = 1,
  233. .has_llc = 1,
  234. .has_force_wake = 1,
  235. };
  236. static const struct intel_device_info intel_sandybridge_m_info = {
  237. .gen = 6, .is_mobile = 1, .num_pipes = 2,
  238. .need_gfx_hws = 1, .has_hotplug = 1,
  239. .has_fbc = 1,
  240. .has_bsd_ring = 1,
  241. .has_blt_ring = 1,
  242. .has_llc = 1,
  243. .has_force_wake = 1,
  244. };
  245. #define GEN7_FEATURES \
  246. .gen = 7, .num_pipes = 3, \
  247. .need_gfx_hws = 1, .has_hotplug = 1, \
  248. .has_bsd_ring = 1, \
  249. .has_blt_ring = 1, \
  250. .has_llc = 1, \
  251. .has_force_wake = 1
  252. static const struct intel_device_info intel_ivybridge_d_info = {
  253. GEN7_FEATURES,
  254. .is_ivybridge = 1,
  255. };
  256. static const struct intel_device_info intel_ivybridge_m_info = {
  257. GEN7_FEATURES,
  258. .is_ivybridge = 1,
  259. .is_mobile = 1,
  260. .has_fbc = 1,
  261. };
  262. static const struct intel_device_info intel_ivybridge_q_info = {
  263. GEN7_FEATURES,
  264. .is_ivybridge = 1,
  265. .num_pipes = 0, /* legal, last one wins */
  266. };
  267. static const struct intel_device_info intel_valleyview_m_info = {
  268. GEN7_FEATURES,
  269. .is_mobile = 1,
  270. .num_pipes = 2,
  271. .is_valleyview = 1,
  272. .display_mmio_offset = VLV_DISPLAY_BASE,
  273. .has_llc = 0, /* legal, last one wins */
  274. };
  275. static const struct intel_device_info intel_valleyview_d_info = {
  276. GEN7_FEATURES,
  277. .num_pipes = 2,
  278. .is_valleyview = 1,
  279. .display_mmio_offset = VLV_DISPLAY_BASE,
  280. .has_llc = 0, /* legal, last one wins */
  281. };
  282. static const struct intel_device_info intel_haswell_d_info = {
  283. GEN7_FEATURES,
  284. .is_haswell = 1,
  285. .has_ddi = 1,
  286. .has_fpga_dbg = 1,
  287. .has_vebox_ring = 1,
  288. };
  289. static const struct intel_device_info intel_haswell_m_info = {
  290. GEN7_FEATURES,
  291. .is_haswell = 1,
  292. .is_mobile = 1,
  293. .has_ddi = 1,
  294. .has_fpga_dbg = 1,
  295. .has_fbc = 1,
  296. .has_vebox_ring = 1,
  297. };
  298. static const struct pci_device_id pciidlist[] = { /* aka */
  299. INTEL_VGA_DEVICE(0x3577, &intel_i830_info), /* I830_M */
  300. INTEL_VGA_DEVICE(0x2562, &intel_845g_info), /* 845_G */
  301. INTEL_VGA_DEVICE(0x3582, &intel_i85x_info), /* I855_GM */
  302. INTEL_VGA_DEVICE(0x358e, &intel_i85x_info),
  303. INTEL_VGA_DEVICE(0x2572, &intel_i865g_info), /* I865_G */
  304. INTEL_VGA_DEVICE(0x2582, &intel_i915g_info), /* I915_G */
  305. INTEL_VGA_DEVICE(0x258a, &intel_i915g_info), /* E7221_G */
  306. INTEL_VGA_DEVICE(0x2592, &intel_i915gm_info), /* I915_GM */
  307. INTEL_VGA_DEVICE(0x2772, &intel_i945g_info), /* I945_G */
  308. INTEL_VGA_DEVICE(0x27a2, &intel_i945gm_info), /* I945_GM */
  309. INTEL_VGA_DEVICE(0x27ae, &intel_i945gm_info), /* I945_GME */
  310. INTEL_VGA_DEVICE(0x2972, &intel_i965g_info), /* I946_GZ */
  311. INTEL_VGA_DEVICE(0x2982, &intel_i965g_info), /* G35_G */
  312. INTEL_VGA_DEVICE(0x2992, &intel_i965g_info), /* I965_Q */
  313. INTEL_VGA_DEVICE(0x29a2, &intel_i965g_info), /* I965_G */
  314. INTEL_VGA_DEVICE(0x29b2, &intel_g33_info), /* Q35_G */
  315. INTEL_VGA_DEVICE(0x29c2, &intel_g33_info), /* G33_G */
  316. INTEL_VGA_DEVICE(0x29d2, &intel_g33_info), /* Q33_G */
  317. INTEL_VGA_DEVICE(0x2a02, &intel_i965gm_info), /* I965_GM */
  318. INTEL_VGA_DEVICE(0x2a12, &intel_i965gm_info), /* I965_GME */
  319. INTEL_VGA_DEVICE(0x2a42, &intel_gm45_info), /* GM45_G */
  320. INTEL_VGA_DEVICE(0x2e02, &intel_g45_info), /* IGD_E_G */
  321. INTEL_VGA_DEVICE(0x2e12, &intel_g45_info), /* Q45_G */
  322. INTEL_VGA_DEVICE(0x2e22, &intel_g45_info), /* G45_G */
  323. INTEL_VGA_DEVICE(0x2e32, &intel_g45_info), /* G41_G */
  324. INTEL_VGA_DEVICE(0x2e42, &intel_g45_info), /* B43_G */
  325. INTEL_VGA_DEVICE(0x2e92, &intel_g45_info), /* B43_G.1 */
  326. INTEL_VGA_DEVICE(0xa001, &intel_pineview_info),
  327. INTEL_VGA_DEVICE(0xa011, &intel_pineview_info),
  328. INTEL_VGA_DEVICE(0x0042, &intel_ironlake_d_info),
  329. INTEL_VGA_DEVICE(0x0046, &intel_ironlake_m_info),
  330. INTEL_VGA_DEVICE(0x0102, &intel_sandybridge_d_info),
  331. INTEL_VGA_DEVICE(0x0112, &intel_sandybridge_d_info),
  332. INTEL_VGA_DEVICE(0x0122, &intel_sandybridge_d_info),
  333. INTEL_VGA_DEVICE(0x0106, &intel_sandybridge_m_info),
  334. INTEL_VGA_DEVICE(0x0116, &intel_sandybridge_m_info),
  335. INTEL_VGA_DEVICE(0x0126, &intel_sandybridge_m_info),
  336. INTEL_VGA_DEVICE(0x010A, &intel_sandybridge_d_info),
  337. INTEL_VGA_DEVICE(0x0156, &intel_ivybridge_m_info), /* GT1 mobile */
  338. INTEL_VGA_DEVICE(0x0166, &intel_ivybridge_m_info), /* GT2 mobile */
  339. INTEL_VGA_DEVICE(0x0152, &intel_ivybridge_d_info), /* GT1 desktop */
  340. INTEL_VGA_DEVICE(0x0162, &intel_ivybridge_d_info), /* GT2 desktop */
  341. INTEL_VGA_DEVICE(0x015a, &intel_ivybridge_d_info), /* GT1 server */
  342. INTEL_QUANTA_VGA_DEVICE(&intel_ivybridge_q_info), /* Quanta transcode */
  343. INTEL_VGA_DEVICE(0x016a, &intel_ivybridge_d_info), /* GT2 server */
  344. INTEL_VGA_DEVICE(0x0402, &intel_haswell_d_info), /* GT1 desktop */
  345. INTEL_VGA_DEVICE(0x0412, &intel_haswell_d_info), /* GT2 desktop */
  346. INTEL_VGA_DEVICE(0x0422, &intel_haswell_d_info), /* GT3 desktop */
  347. INTEL_VGA_DEVICE(0x040a, &intel_haswell_d_info), /* GT1 server */
  348. INTEL_VGA_DEVICE(0x041a, &intel_haswell_d_info), /* GT2 server */
  349. INTEL_VGA_DEVICE(0x042a, &intel_haswell_d_info), /* GT3 server */
  350. INTEL_VGA_DEVICE(0x0406, &intel_haswell_m_info), /* GT1 mobile */
  351. INTEL_VGA_DEVICE(0x0416, &intel_haswell_m_info), /* GT2 mobile */
  352. INTEL_VGA_DEVICE(0x0426, &intel_haswell_m_info), /* GT2 mobile */
  353. INTEL_VGA_DEVICE(0x040B, &intel_haswell_d_info), /* GT1 reserved */
  354. INTEL_VGA_DEVICE(0x041B, &intel_haswell_d_info), /* GT2 reserved */
  355. INTEL_VGA_DEVICE(0x042B, &intel_haswell_d_info), /* GT3 reserved */
  356. INTEL_VGA_DEVICE(0x040E, &intel_haswell_d_info), /* GT1 reserved */
  357. INTEL_VGA_DEVICE(0x041E, &intel_haswell_d_info), /* GT2 reserved */
  358. INTEL_VGA_DEVICE(0x042E, &intel_haswell_d_info), /* GT3 reserved */
  359. INTEL_VGA_DEVICE(0x0C02, &intel_haswell_d_info), /* SDV GT1 desktop */
  360. INTEL_VGA_DEVICE(0x0C12, &intel_haswell_d_info), /* SDV GT2 desktop */
  361. INTEL_VGA_DEVICE(0x0C22, &intel_haswell_d_info), /* SDV GT3 desktop */
  362. INTEL_VGA_DEVICE(0x0C0A, &intel_haswell_d_info), /* SDV GT1 server */
  363. INTEL_VGA_DEVICE(0x0C1A, &intel_haswell_d_info), /* SDV GT2 server */
  364. INTEL_VGA_DEVICE(0x0C2A, &intel_haswell_d_info), /* SDV GT3 server */
  365. INTEL_VGA_DEVICE(0x0C06, &intel_haswell_m_info), /* SDV GT1 mobile */
  366. INTEL_VGA_DEVICE(0x0C16, &intel_haswell_m_info), /* SDV GT2 mobile */
  367. INTEL_VGA_DEVICE(0x0C26, &intel_haswell_m_info), /* SDV GT3 mobile */
  368. INTEL_VGA_DEVICE(0x0C0B, &intel_haswell_d_info), /* SDV GT1 reserved */
  369. INTEL_VGA_DEVICE(0x0C1B, &intel_haswell_d_info), /* SDV GT2 reserved */
  370. INTEL_VGA_DEVICE(0x0C2B, &intel_haswell_d_info), /* SDV GT3 reserved */
  371. INTEL_VGA_DEVICE(0x0C0E, &intel_haswell_d_info), /* SDV GT1 reserved */
  372. INTEL_VGA_DEVICE(0x0C1E, &intel_haswell_d_info), /* SDV GT2 reserved */
  373. INTEL_VGA_DEVICE(0x0C2E, &intel_haswell_d_info), /* SDV GT3 reserved */
  374. INTEL_VGA_DEVICE(0x0A02, &intel_haswell_d_info), /* ULT GT1 desktop */
  375. INTEL_VGA_DEVICE(0x0A12, &intel_haswell_d_info), /* ULT GT2 desktop */
  376. INTEL_VGA_DEVICE(0x0A22, &intel_haswell_d_info), /* ULT GT3 desktop */
  377. INTEL_VGA_DEVICE(0x0A0A, &intel_haswell_d_info), /* ULT GT1 server */
  378. INTEL_VGA_DEVICE(0x0A1A, &intel_haswell_d_info), /* ULT GT2 server */
  379. INTEL_VGA_DEVICE(0x0A2A, &intel_haswell_d_info), /* ULT GT3 server */
  380. INTEL_VGA_DEVICE(0x0A06, &intel_haswell_m_info), /* ULT GT1 mobile */
  381. INTEL_VGA_DEVICE(0x0A16, &intel_haswell_m_info), /* ULT GT2 mobile */
  382. INTEL_VGA_DEVICE(0x0A26, &intel_haswell_m_info), /* ULT GT3 mobile */
  383. INTEL_VGA_DEVICE(0x0A0B, &intel_haswell_d_info), /* ULT GT1 reserved */
  384. INTEL_VGA_DEVICE(0x0A1B, &intel_haswell_d_info), /* ULT GT2 reserved */
  385. INTEL_VGA_DEVICE(0x0A2B, &intel_haswell_d_info), /* ULT GT3 reserved */
  386. INTEL_VGA_DEVICE(0x0A0E, &intel_haswell_m_info), /* ULT GT1 reserved */
  387. INTEL_VGA_DEVICE(0x0A1E, &intel_haswell_m_info), /* ULT GT2 reserved */
  388. INTEL_VGA_DEVICE(0x0A2E, &intel_haswell_m_info), /* ULT GT3 reserved */
  389. INTEL_VGA_DEVICE(0x0D02, &intel_haswell_d_info), /* CRW GT1 desktop */
  390. INTEL_VGA_DEVICE(0x0D12, &intel_haswell_d_info), /* CRW GT2 desktop */
  391. INTEL_VGA_DEVICE(0x0D22, &intel_haswell_d_info), /* CRW GT3 desktop */
  392. INTEL_VGA_DEVICE(0x0D0A, &intel_haswell_d_info), /* CRW GT1 server */
  393. INTEL_VGA_DEVICE(0x0D1A, &intel_haswell_d_info), /* CRW GT2 server */
  394. INTEL_VGA_DEVICE(0x0D2A, &intel_haswell_d_info), /* CRW GT3 server */
  395. INTEL_VGA_DEVICE(0x0D06, &intel_haswell_m_info), /* CRW GT1 mobile */
  396. INTEL_VGA_DEVICE(0x0D16, &intel_haswell_m_info), /* CRW GT2 mobile */
  397. INTEL_VGA_DEVICE(0x0D26, &intel_haswell_m_info), /* CRW GT3 mobile */
  398. INTEL_VGA_DEVICE(0x0D0B, &intel_haswell_d_info), /* CRW GT1 reserved */
  399. INTEL_VGA_DEVICE(0x0D1B, &intel_haswell_d_info), /* CRW GT2 reserved */
  400. INTEL_VGA_DEVICE(0x0D2B, &intel_haswell_d_info), /* CRW GT3 reserved */
  401. INTEL_VGA_DEVICE(0x0D0E, &intel_haswell_d_info), /* CRW GT1 reserved */
  402. INTEL_VGA_DEVICE(0x0D1E, &intel_haswell_d_info), /* CRW GT2 reserved */
  403. INTEL_VGA_DEVICE(0x0D2E, &intel_haswell_d_info), /* CRW GT3 reserved */
  404. INTEL_VGA_DEVICE(0x0f30, &intel_valleyview_m_info),
  405. INTEL_VGA_DEVICE(0x0f31, &intel_valleyview_m_info),
  406. INTEL_VGA_DEVICE(0x0f32, &intel_valleyview_m_info),
  407. INTEL_VGA_DEVICE(0x0f33, &intel_valleyview_m_info),
  408. INTEL_VGA_DEVICE(0x0157, &intel_valleyview_m_info),
  409. INTEL_VGA_DEVICE(0x0155, &intel_valleyview_d_info),
  410. {0, 0, 0}
  411. };
  412. #if defined(CONFIG_DRM_I915_KMS)
  413. MODULE_DEVICE_TABLE(pci, pciidlist);
  414. #endif
  415. void intel_detect_pch(struct drm_device *dev)
  416. {
  417. struct drm_i915_private *dev_priv = dev->dev_private;
  418. struct pci_dev *pch;
  419. /* In all current cases, num_pipes is equivalent to the PCH_NOP setting
  420. * (which really amounts to a PCH but no South Display).
  421. */
  422. if (INTEL_INFO(dev)->num_pipes == 0) {
  423. dev_priv->pch_type = PCH_NOP;
  424. return;
  425. }
  426. /*
  427. * The reason to probe ISA bridge instead of Dev31:Fun0 is to
  428. * make graphics device passthrough work easy for VMM, that only
  429. * need to expose ISA bridge to let driver know the real hardware
  430. * underneath. This is a requirement from virtualization team.
  431. *
  432. * In some virtualized environments (e.g. XEN), there is irrelevant
  433. * ISA bridge in the system. To work reliably, we should scan trhough
  434. * all the ISA bridge devices and check for the first match, instead
  435. * of only checking the first one.
  436. */
  437. pch = pci_get_class(PCI_CLASS_BRIDGE_ISA << 8, NULL);
  438. while (pch) {
  439. struct pci_dev *curr = pch;
  440. if (pch->vendor == PCI_VENDOR_ID_INTEL) {
  441. unsigned short id;
  442. id = pch->device & INTEL_PCH_DEVICE_ID_MASK;
  443. dev_priv->pch_id = id;
  444. if (id == INTEL_PCH_IBX_DEVICE_ID_TYPE) {
  445. dev_priv->pch_type = PCH_IBX;
  446. DRM_DEBUG_KMS("Found Ibex Peak PCH\n");
  447. WARN_ON(!IS_GEN5(dev));
  448. } else if (id == INTEL_PCH_CPT_DEVICE_ID_TYPE) {
  449. dev_priv->pch_type = PCH_CPT;
  450. DRM_DEBUG_KMS("Found CougarPoint PCH\n");
  451. WARN_ON(!(IS_GEN6(dev) || IS_IVYBRIDGE(dev)));
  452. } else if (id == INTEL_PCH_PPT_DEVICE_ID_TYPE) {
  453. /* PantherPoint is CPT compatible */
  454. dev_priv->pch_type = PCH_CPT;
  455. DRM_DEBUG_KMS("Found PatherPoint PCH\n");
  456. WARN_ON(!(IS_GEN6(dev) || IS_IVYBRIDGE(dev)));
  457. } else if (id == INTEL_PCH_LPT_DEVICE_ID_TYPE) {
  458. dev_priv->pch_type = PCH_LPT;
  459. DRM_DEBUG_KMS("Found LynxPoint PCH\n");
  460. WARN_ON(!IS_HASWELL(dev));
  461. WARN_ON(IS_ULT(dev));
  462. } else if (id == INTEL_PCH_LPT_LP_DEVICE_ID_TYPE) {
  463. dev_priv->pch_type = PCH_LPT;
  464. DRM_DEBUG_KMS("Found LynxPoint LP PCH\n");
  465. WARN_ON(!IS_HASWELL(dev));
  466. WARN_ON(!IS_ULT(dev));
  467. } else {
  468. goto check_next;
  469. }
  470. pci_dev_put(pch);
  471. break;
  472. }
  473. check_next:
  474. pch = pci_get_class(PCI_CLASS_BRIDGE_ISA << 8, curr);
  475. pci_dev_put(curr);
  476. }
  477. if (!pch)
  478. DRM_DEBUG_KMS("No PCH found?\n");
  479. }
  480. bool i915_semaphore_is_enabled(struct drm_device *dev)
  481. {
  482. if (INTEL_INFO(dev)->gen < 6)
  483. return 0;
  484. if (i915_semaphores >= 0)
  485. return i915_semaphores;
  486. #ifdef CONFIG_INTEL_IOMMU
  487. /* Enable semaphores on SNB when IO remapping is off */
  488. if (INTEL_INFO(dev)->gen == 6 && intel_iommu_gfx_mapped)
  489. return false;
  490. #endif
  491. return 1;
  492. }
  493. static int i915_drm_freeze(struct drm_device *dev)
  494. {
  495. struct drm_i915_private *dev_priv = dev->dev_private;
  496. struct drm_crtc *crtc;
  497. /* ignore lid events during suspend */
  498. mutex_lock(&dev_priv->modeset_restore_lock);
  499. dev_priv->modeset_restore = MODESET_SUSPENDED;
  500. mutex_unlock(&dev_priv->modeset_restore_lock);
  501. /* We do a lot of poking in a lot of registers, make sure they work
  502. * properly. */
  503. hsw_disable_package_c8(dev_priv);
  504. intel_set_power_well(dev, true);
  505. drm_kms_helper_poll_disable(dev);
  506. pci_save_state(dev->pdev);
  507. /* If KMS is active, we do the leavevt stuff here */
  508. if (drm_core_check_feature(dev, DRIVER_MODESET)) {
  509. int error;
  510. mutex_lock(&dev->struct_mutex);
  511. error = i915_gem_idle(dev);
  512. mutex_unlock(&dev->struct_mutex);
  513. if (error) {
  514. dev_err(&dev->pdev->dev,
  515. "GEM idle failed, resume might fail\n");
  516. return error;
  517. }
  518. cancel_delayed_work_sync(&dev_priv->rps.delayed_resume_work);
  519. drm_irq_uninstall(dev);
  520. dev_priv->enable_hotplug_processing = false;
  521. /*
  522. * Disable CRTCs directly since we want to preserve sw state
  523. * for _thaw.
  524. */
  525. list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
  526. dev_priv->display.crtc_disable(crtc);
  527. intel_modeset_suspend_hw(dev);
  528. }
  529. i915_save_state(dev);
  530. intel_opregion_fini(dev);
  531. console_lock();
  532. intel_fbdev_set_suspend(dev, FBINFO_STATE_SUSPENDED);
  533. console_unlock();
  534. return 0;
  535. }
  536. int i915_suspend(struct drm_device *dev, pm_message_t state)
  537. {
  538. int error;
  539. if (!dev || !dev->dev_private) {
  540. DRM_ERROR("dev: %p\n", dev);
  541. DRM_ERROR("DRM not initialized, aborting suspend.\n");
  542. return -ENODEV;
  543. }
  544. if (state.event == PM_EVENT_PRETHAW)
  545. return 0;
  546. if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
  547. return 0;
  548. error = i915_drm_freeze(dev);
  549. if (error)
  550. return error;
  551. if (state.event == PM_EVENT_SUSPEND) {
  552. /* Shut down the device */
  553. pci_disable_device(dev->pdev);
  554. pci_set_power_state(dev->pdev, PCI_D3hot);
  555. }
  556. return 0;
  557. }
  558. void intel_console_resume(struct work_struct *work)
  559. {
  560. struct drm_i915_private *dev_priv =
  561. container_of(work, struct drm_i915_private,
  562. console_resume_work);
  563. struct drm_device *dev = dev_priv->dev;
  564. console_lock();
  565. intel_fbdev_set_suspend(dev, FBINFO_STATE_RUNNING);
  566. console_unlock();
  567. }
  568. static void intel_resume_hotplug(struct drm_device *dev)
  569. {
  570. struct drm_mode_config *mode_config = &dev->mode_config;
  571. struct intel_encoder *encoder;
  572. mutex_lock(&mode_config->mutex);
  573. DRM_DEBUG_KMS("running encoder hotplug functions\n");
  574. list_for_each_entry(encoder, &mode_config->encoder_list, base.head)
  575. if (encoder->hot_plug)
  576. encoder->hot_plug(encoder);
  577. mutex_unlock(&mode_config->mutex);
  578. /* Just fire off a uevent and let userspace tell us what to do */
  579. drm_helper_hpd_irq_event(dev);
  580. }
  581. static int __i915_drm_thaw(struct drm_device *dev)
  582. {
  583. struct drm_i915_private *dev_priv = dev->dev_private;
  584. int error = 0;
  585. i915_restore_state(dev);
  586. intel_opregion_setup(dev);
  587. /* KMS EnterVT equivalent */
  588. if (drm_core_check_feature(dev, DRIVER_MODESET)) {
  589. intel_init_pch_refclk(dev);
  590. mutex_lock(&dev->struct_mutex);
  591. error = i915_gem_init_hw(dev);
  592. mutex_unlock(&dev->struct_mutex);
  593. /* We need working interrupts for modeset enabling ... */
  594. drm_irq_install(dev);
  595. intel_modeset_init_hw(dev);
  596. drm_modeset_lock_all(dev);
  597. intel_modeset_setup_hw_state(dev, true);
  598. drm_modeset_unlock_all(dev);
  599. /*
  600. * ... but also need to make sure that hotplug processing
  601. * doesn't cause havoc. Like in the driver load code we don't
  602. * bother with the tiny race here where we might loose hotplug
  603. * notifications.
  604. * */
  605. intel_hpd_init(dev);
  606. dev_priv->enable_hotplug_processing = true;
  607. /* Config may have changed between suspend and resume */
  608. intel_resume_hotplug(dev);
  609. }
  610. intel_opregion_init(dev);
  611. /*
  612. * The console lock can be pretty contented on resume due
  613. * to all the printk activity. Try to keep it out of the hot
  614. * path of resume if possible.
  615. */
  616. if (console_trylock()) {
  617. intel_fbdev_set_suspend(dev, FBINFO_STATE_RUNNING);
  618. console_unlock();
  619. } else {
  620. schedule_work(&dev_priv->console_resume_work);
  621. }
  622. /* Undo what we did at i915_drm_freeze so the refcount goes back to the
  623. * expected level. */
  624. hsw_enable_package_c8(dev_priv);
  625. mutex_lock(&dev_priv->modeset_restore_lock);
  626. dev_priv->modeset_restore = MODESET_DONE;
  627. mutex_unlock(&dev_priv->modeset_restore_lock);
  628. return error;
  629. }
  630. static int i915_drm_thaw(struct drm_device *dev)
  631. {
  632. int error = 0;
  633. intel_uncore_sanitize(dev);
  634. if (drm_core_check_feature(dev, DRIVER_MODESET)) {
  635. mutex_lock(&dev->struct_mutex);
  636. i915_gem_restore_gtt_mappings(dev);
  637. mutex_unlock(&dev->struct_mutex);
  638. }
  639. __i915_drm_thaw(dev);
  640. return error;
  641. }
  642. int i915_resume(struct drm_device *dev)
  643. {
  644. struct drm_i915_private *dev_priv = dev->dev_private;
  645. int ret;
  646. if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
  647. return 0;
  648. if (pci_enable_device(dev->pdev))
  649. return -EIO;
  650. pci_set_master(dev->pdev);
  651. intel_uncore_sanitize(dev);
  652. /*
  653. * Platforms with opregion should have sane BIOS, older ones (gen3 and
  654. * earlier) need this since the BIOS might clear all our scratch PTEs.
  655. */
  656. if (drm_core_check_feature(dev, DRIVER_MODESET) &&
  657. !dev_priv->opregion.header) {
  658. mutex_lock(&dev->struct_mutex);
  659. i915_gem_restore_gtt_mappings(dev);
  660. mutex_unlock(&dev->struct_mutex);
  661. }
  662. ret = __i915_drm_thaw(dev);
  663. if (ret)
  664. return ret;
  665. drm_kms_helper_poll_enable(dev);
  666. return 0;
  667. }
  668. /**
  669. * i915_reset - reset chip after a hang
  670. * @dev: drm device to reset
  671. *
  672. * Reset the chip. Useful if a hang is detected. Returns zero on successful
  673. * reset or otherwise an error code.
  674. *
  675. * Procedure is fairly simple:
  676. * - reset the chip using the reset reg
  677. * - re-init context state
  678. * - re-init hardware status page
  679. * - re-init ring buffer
  680. * - re-init interrupt state
  681. * - re-init display
  682. */
  683. int i915_reset(struct drm_device *dev)
  684. {
  685. drm_i915_private_t *dev_priv = dev->dev_private;
  686. bool simulated;
  687. int ret;
  688. if (!i915_try_reset)
  689. return 0;
  690. mutex_lock(&dev->struct_mutex);
  691. i915_gem_reset(dev);
  692. simulated = dev_priv->gpu_error.stop_rings != 0;
  693. if (!simulated && get_seconds() - dev_priv->gpu_error.last_reset < 5) {
  694. DRM_ERROR("GPU hanging too fast, declaring wedged!\n");
  695. ret = -ENODEV;
  696. } else {
  697. ret = intel_gpu_reset(dev);
  698. /* Also reset the gpu hangman. */
  699. if (simulated) {
  700. DRM_INFO("Simulated gpu hang, resetting stop_rings\n");
  701. dev_priv->gpu_error.stop_rings = 0;
  702. if (ret == -ENODEV) {
  703. DRM_ERROR("Reset not implemented, but ignoring "
  704. "error for simulated gpu hangs\n");
  705. ret = 0;
  706. }
  707. } else
  708. dev_priv->gpu_error.last_reset = get_seconds();
  709. }
  710. if (ret) {
  711. DRM_ERROR("Failed to reset chip.\n");
  712. mutex_unlock(&dev->struct_mutex);
  713. return ret;
  714. }
  715. /* Ok, now get things going again... */
  716. /*
  717. * Everything depends on having the GTT running, so we need to start
  718. * there. Fortunately we don't need to do this unless we reset the
  719. * chip at a PCI level.
  720. *
  721. * Next we need to restore the context, but we don't use those
  722. * yet either...
  723. *
  724. * Ring buffer needs to be re-initialized in the KMS case, or if X
  725. * was running at the time of the reset (i.e. we weren't VT
  726. * switched away).
  727. */
  728. if (drm_core_check_feature(dev, DRIVER_MODESET) ||
  729. !dev_priv->ums.mm_suspended) {
  730. struct intel_ring_buffer *ring;
  731. int i;
  732. dev_priv->ums.mm_suspended = 0;
  733. i915_gem_init_swizzling(dev);
  734. for_each_ring(ring, dev_priv, i)
  735. ring->init(ring);
  736. i915_gem_context_init(dev);
  737. if (dev_priv->mm.aliasing_ppgtt) {
  738. ret = dev_priv->mm.aliasing_ppgtt->enable(dev);
  739. if (ret)
  740. i915_gem_cleanup_aliasing_ppgtt(dev);
  741. }
  742. /*
  743. * It would make sense to re-init all the other hw state, at
  744. * least the rps/rc6/emon init done within modeset_init_hw. For
  745. * some unknown reason, this blows up my ilk, so don't.
  746. */
  747. mutex_unlock(&dev->struct_mutex);
  748. drm_irq_uninstall(dev);
  749. drm_irq_install(dev);
  750. intel_hpd_init(dev);
  751. } else {
  752. mutex_unlock(&dev->struct_mutex);
  753. }
  754. return 0;
  755. }
  756. static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
  757. {
  758. struct intel_device_info *intel_info =
  759. (struct intel_device_info *) ent->driver_data;
  760. /* Only bind to function 0 of the device. Early generations
  761. * used function 1 as a placeholder for multi-head. This causes
  762. * us confusion instead, especially on the systems where both
  763. * functions have the same PCI-ID!
  764. */
  765. if (PCI_FUNC(pdev->devfn))
  766. return -ENODEV;
  767. /* We've managed to ship a kms-enabled ddx that shipped with an XvMC
  768. * implementation for gen3 (and only gen3) that used legacy drm maps
  769. * (gasp!) to share buffers between X and the client. Hence we need to
  770. * keep around the fake agp stuff for gen3, even when kms is enabled. */
  771. if (intel_info->gen != 3) {
  772. driver.driver_features &=
  773. ~(DRIVER_USE_AGP | DRIVER_REQUIRE_AGP);
  774. } else if (!intel_agp_enabled) {
  775. DRM_ERROR("drm/i915 can't work without intel_agp module!\n");
  776. return -ENODEV;
  777. }
  778. return drm_get_pci_dev(pdev, ent, &driver);
  779. }
  780. static void
  781. i915_pci_remove(struct pci_dev *pdev)
  782. {
  783. struct drm_device *dev = pci_get_drvdata(pdev);
  784. drm_put_dev(dev);
  785. }
  786. static int i915_pm_suspend(struct device *dev)
  787. {
  788. struct pci_dev *pdev = to_pci_dev(dev);
  789. struct drm_device *drm_dev = pci_get_drvdata(pdev);
  790. int error;
  791. if (!drm_dev || !drm_dev->dev_private) {
  792. dev_err(dev, "DRM not initialized, aborting suspend.\n");
  793. return -ENODEV;
  794. }
  795. if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF)
  796. return 0;
  797. error = i915_drm_freeze(drm_dev);
  798. if (error)
  799. return error;
  800. pci_disable_device(pdev);
  801. pci_set_power_state(pdev, PCI_D3hot);
  802. return 0;
  803. }
  804. static int i915_pm_resume(struct device *dev)
  805. {
  806. struct pci_dev *pdev = to_pci_dev(dev);
  807. struct drm_device *drm_dev = pci_get_drvdata(pdev);
  808. return i915_resume(drm_dev);
  809. }
  810. static int i915_pm_freeze(struct device *dev)
  811. {
  812. struct pci_dev *pdev = to_pci_dev(dev);
  813. struct drm_device *drm_dev = pci_get_drvdata(pdev);
  814. if (!drm_dev || !drm_dev->dev_private) {
  815. dev_err(dev, "DRM not initialized, aborting suspend.\n");
  816. return -ENODEV;
  817. }
  818. return i915_drm_freeze(drm_dev);
  819. }
  820. static int i915_pm_thaw(struct device *dev)
  821. {
  822. struct pci_dev *pdev = to_pci_dev(dev);
  823. struct drm_device *drm_dev = pci_get_drvdata(pdev);
  824. return i915_drm_thaw(drm_dev);
  825. }
  826. static int i915_pm_poweroff(struct device *dev)
  827. {
  828. struct pci_dev *pdev = to_pci_dev(dev);
  829. struct drm_device *drm_dev = pci_get_drvdata(pdev);
  830. return i915_drm_freeze(drm_dev);
  831. }
  832. static const struct dev_pm_ops i915_pm_ops = {
  833. .suspend = i915_pm_suspend,
  834. .resume = i915_pm_resume,
  835. .freeze = i915_pm_freeze,
  836. .thaw = i915_pm_thaw,
  837. .poweroff = i915_pm_poweroff,
  838. .restore = i915_pm_resume,
  839. };
  840. static const struct vm_operations_struct i915_gem_vm_ops = {
  841. .fault = i915_gem_fault,
  842. .open = drm_gem_vm_open,
  843. .close = drm_gem_vm_close,
  844. };
  845. static const struct file_operations i915_driver_fops = {
  846. .owner = THIS_MODULE,
  847. .open = drm_open,
  848. .release = drm_release,
  849. .unlocked_ioctl = drm_ioctl,
  850. .mmap = drm_gem_mmap,
  851. .poll = drm_poll,
  852. .fasync = drm_fasync,
  853. .read = drm_read,
  854. #ifdef CONFIG_COMPAT
  855. .compat_ioctl = i915_compat_ioctl,
  856. #endif
  857. .llseek = noop_llseek,
  858. };
  859. static struct drm_driver driver = {
  860. /* Don't use MTRRs here; the Xserver or userspace app should
  861. * deal with them for Intel hardware.
  862. */
  863. .driver_features =
  864. DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | /* DRIVER_USE_MTRR |*/
  865. DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_GEM | DRIVER_PRIME,
  866. .load = i915_driver_load,
  867. .unload = i915_driver_unload,
  868. .open = i915_driver_open,
  869. .lastclose = i915_driver_lastclose,
  870. .preclose = i915_driver_preclose,
  871. .postclose = i915_driver_postclose,
  872. /* Used in place of i915_pm_ops for non-DRIVER_MODESET */
  873. .suspend = i915_suspend,
  874. .resume = i915_resume,
  875. .device_is_agp = i915_driver_device_is_agp,
  876. .master_create = i915_master_create,
  877. .master_destroy = i915_master_destroy,
  878. #if defined(CONFIG_DEBUG_FS)
  879. .debugfs_init = i915_debugfs_init,
  880. .debugfs_cleanup = i915_debugfs_cleanup,
  881. #endif
  882. .gem_init_object = i915_gem_init_object,
  883. .gem_free_object = i915_gem_free_object,
  884. .gem_vm_ops = &i915_gem_vm_ops,
  885. .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
  886. .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
  887. .gem_prime_export = i915_gem_prime_export,
  888. .gem_prime_import = i915_gem_prime_import,
  889. .dumb_create = i915_gem_dumb_create,
  890. .dumb_map_offset = i915_gem_mmap_gtt,
  891. .dumb_destroy = i915_gem_dumb_destroy,
  892. .ioctls = i915_ioctls,
  893. .fops = &i915_driver_fops,
  894. .name = DRIVER_NAME,
  895. .desc = DRIVER_DESC,
  896. .date = DRIVER_DATE,
  897. .major = DRIVER_MAJOR,
  898. .minor = DRIVER_MINOR,
  899. .patchlevel = DRIVER_PATCHLEVEL,
  900. };
  901. static struct pci_driver i915_pci_driver = {
  902. .name = DRIVER_NAME,
  903. .id_table = pciidlist,
  904. .probe = i915_pci_probe,
  905. .remove = i915_pci_remove,
  906. .driver.pm = &i915_pm_ops,
  907. };
  908. static int __init i915_init(void)
  909. {
  910. driver.num_ioctls = i915_max_ioctl;
  911. /*
  912. * If CONFIG_DRM_I915_KMS is set, default to KMS unless
  913. * explicitly disabled with the module pararmeter.
  914. *
  915. * Otherwise, just follow the parameter (defaulting to off).
  916. *
  917. * Allow optional vga_text_mode_force boot option to override
  918. * the default behavior.
  919. */
  920. #if defined(CONFIG_DRM_I915_KMS)
  921. if (i915_modeset != 0)
  922. driver.driver_features |= DRIVER_MODESET;
  923. #endif
  924. if (i915_modeset == 1)
  925. driver.driver_features |= DRIVER_MODESET;
  926. #ifdef CONFIG_VGA_CONSOLE
  927. if (vgacon_text_force() && i915_modeset == -1)
  928. driver.driver_features &= ~DRIVER_MODESET;
  929. #endif
  930. if (!(driver.driver_features & DRIVER_MODESET))
  931. driver.get_vblank_timestamp = NULL;
  932. return drm_pci_init(&driver, &i915_pci_driver);
  933. }
  934. static void __exit i915_exit(void)
  935. {
  936. drm_pci_exit(&driver, &i915_pci_driver);
  937. }
  938. module_init(i915_init);
  939. module_exit(i915_exit);
  940. MODULE_AUTHOR(DRIVER_AUTHOR);
  941. MODULE_DESCRIPTION(DRIVER_DESC);
  942. MODULE_LICENSE("GPL and additional rights");