i915_pci.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798
  1. /*
  2. * Copyright © 2016 Intel Corporation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice (including the next
  12. * paragraph) shall be included in all copies or substantial portions of the
  13. * Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  21. * IN THE SOFTWARE.
  22. *
  23. */
  24. #include <linux/console.h>
  25. #include <linux/vgaarb.h>
  26. #include <linux/vga_switcheroo.h>
  27. #include "i915_drv.h"
  28. #include "i915_selftest.h"
  29. #define PLATFORM(x) .platform = (x), .platform_mask = BIT(x)
  30. #define GEN(x) .gen = (x), .gen_mask = BIT((x) - 1)
  31. #define GEN_DEFAULT_PIPEOFFSETS \
  32. .pipe_offsets = { PIPE_A_OFFSET, PIPE_B_OFFSET, \
  33. PIPE_C_OFFSET, PIPE_EDP_OFFSET }, \
  34. .trans_offsets = { TRANSCODER_A_OFFSET, TRANSCODER_B_OFFSET, \
  35. TRANSCODER_C_OFFSET, TRANSCODER_EDP_OFFSET }, \
  36. .palette_offsets = { PALETTE_A_OFFSET, PALETTE_B_OFFSET }
  37. #define GEN_CHV_PIPEOFFSETS \
  38. .pipe_offsets = { PIPE_A_OFFSET, PIPE_B_OFFSET, \
  39. CHV_PIPE_C_OFFSET }, \
  40. .trans_offsets = { TRANSCODER_A_OFFSET, TRANSCODER_B_OFFSET, \
  41. CHV_TRANSCODER_C_OFFSET, }, \
  42. .palette_offsets = { PALETTE_A_OFFSET, PALETTE_B_OFFSET, \
  43. CHV_PALETTE_C_OFFSET }
  44. #define CURSOR_OFFSETS \
  45. .cursor_offsets = { CURSOR_A_OFFSET, CURSOR_B_OFFSET, CHV_CURSOR_C_OFFSET }
  46. #define IVB_CURSOR_OFFSETS \
  47. .cursor_offsets = { CURSOR_A_OFFSET, IVB_CURSOR_B_OFFSET, IVB_CURSOR_C_OFFSET }
  48. #define BDW_COLORS \
  49. .color = { .degamma_lut_size = 512, .gamma_lut_size = 512 }
  50. #define CHV_COLORS \
  51. .color = { .degamma_lut_size = 65, .gamma_lut_size = 257 }
  52. #define GLK_COLORS \
  53. .color = { .degamma_lut_size = 0, .gamma_lut_size = 1024 }
  54. /* Keep in gen based order, and chronological order within a gen */
  55. #define GEN_DEFAULT_PAGE_SIZES \
  56. .page_sizes = I915_GTT_PAGE_SIZE_4K
  57. #define GEN2_FEATURES \
  58. GEN(2), \
  59. .num_pipes = 1, \
  60. .has_overlay = 1, .overlay_needs_physical = 1, \
  61. .has_gmch_display = 1, \
  62. .hws_needs_physical = 1, \
  63. .unfenced_needs_alignment = 1, \
  64. .ring_mask = RENDER_RING, \
  65. .has_snoop = true, \
  66. .has_coherent_ggtt = false, \
  67. GEN_DEFAULT_PIPEOFFSETS, \
  68. GEN_DEFAULT_PAGE_SIZES, \
  69. CURSOR_OFFSETS
  70. static const struct intel_device_info intel_i830_info = {
  71. GEN2_FEATURES,
  72. PLATFORM(INTEL_I830),
  73. .is_mobile = 1, .cursor_needs_physical = 1,
  74. .num_pipes = 2, /* legal, last one wins */
  75. };
  76. static const struct intel_device_info intel_i845g_info = {
  77. GEN2_FEATURES,
  78. PLATFORM(INTEL_I845G),
  79. };
  80. static const struct intel_device_info intel_i85x_info = {
  81. GEN2_FEATURES,
  82. PLATFORM(INTEL_I85X),
  83. .is_mobile = 1,
  84. .num_pipes = 2, /* legal, last one wins */
  85. .cursor_needs_physical = 1,
  86. .has_fbc = 1,
  87. };
  88. static const struct intel_device_info intel_i865g_info = {
  89. GEN2_FEATURES,
  90. PLATFORM(INTEL_I865G),
  91. };
  92. #define GEN3_FEATURES \
  93. GEN(3), \
  94. .num_pipes = 2, \
  95. .has_gmch_display = 1, \
  96. .ring_mask = RENDER_RING, \
  97. .has_snoop = true, \
  98. .has_coherent_ggtt = true, \
  99. GEN_DEFAULT_PIPEOFFSETS, \
  100. GEN_DEFAULT_PAGE_SIZES, \
  101. CURSOR_OFFSETS
  102. static const struct intel_device_info intel_i915g_info = {
  103. GEN3_FEATURES,
  104. PLATFORM(INTEL_I915G),
  105. .has_coherent_ggtt = false,
  106. .cursor_needs_physical = 1,
  107. .has_overlay = 1, .overlay_needs_physical = 1,
  108. .hws_needs_physical = 1,
  109. .unfenced_needs_alignment = 1,
  110. };
  111. static const struct intel_device_info intel_i915gm_info = {
  112. GEN3_FEATURES,
  113. PLATFORM(INTEL_I915GM),
  114. .is_mobile = 1,
  115. .cursor_needs_physical = 1,
  116. .has_overlay = 1, .overlay_needs_physical = 1,
  117. .supports_tv = 1,
  118. .has_fbc = 1,
  119. .hws_needs_physical = 1,
  120. .unfenced_needs_alignment = 1,
  121. };
  122. static const struct intel_device_info intel_i945g_info = {
  123. GEN3_FEATURES,
  124. PLATFORM(INTEL_I945G),
  125. .has_hotplug = 1, .cursor_needs_physical = 1,
  126. .has_overlay = 1, .overlay_needs_physical = 1,
  127. .hws_needs_physical = 1,
  128. .unfenced_needs_alignment = 1,
  129. };
  130. static const struct intel_device_info intel_i945gm_info = {
  131. GEN3_FEATURES,
  132. PLATFORM(INTEL_I945GM),
  133. .is_mobile = 1,
  134. .has_hotplug = 1, .cursor_needs_physical = 1,
  135. .has_overlay = 1, .overlay_needs_physical = 1,
  136. .supports_tv = 1,
  137. .has_fbc = 1,
  138. .hws_needs_physical = 1,
  139. .unfenced_needs_alignment = 1,
  140. };
  141. static const struct intel_device_info intel_g33_info = {
  142. GEN3_FEATURES,
  143. PLATFORM(INTEL_G33),
  144. .has_hotplug = 1,
  145. .has_overlay = 1,
  146. };
  147. static const struct intel_device_info intel_pineview_info = {
  148. GEN3_FEATURES,
  149. PLATFORM(INTEL_PINEVIEW),
  150. .is_mobile = 1,
  151. .has_hotplug = 1,
  152. .has_overlay = 1,
  153. };
  154. #define GEN4_FEATURES \
  155. GEN(4), \
  156. .num_pipes = 2, \
  157. .has_hotplug = 1, \
  158. .has_gmch_display = 1, \
  159. .ring_mask = RENDER_RING, \
  160. .has_snoop = true, \
  161. .has_coherent_ggtt = true, \
  162. GEN_DEFAULT_PIPEOFFSETS, \
  163. GEN_DEFAULT_PAGE_SIZES, \
  164. CURSOR_OFFSETS
  165. static const struct intel_device_info intel_i965g_info = {
  166. GEN4_FEATURES,
  167. PLATFORM(INTEL_I965G),
  168. .has_overlay = 1,
  169. .hws_needs_physical = 1,
  170. .has_snoop = false,
  171. };
  172. static const struct intel_device_info intel_i965gm_info = {
  173. GEN4_FEATURES,
  174. PLATFORM(INTEL_I965GM),
  175. .is_mobile = 1, .has_fbc = 1,
  176. .has_overlay = 1,
  177. .supports_tv = 1,
  178. .hws_needs_physical = 1,
  179. .has_snoop = false,
  180. };
  181. static const struct intel_device_info intel_g45_info = {
  182. GEN4_FEATURES,
  183. PLATFORM(INTEL_G45),
  184. .ring_mask = RENDER_RING | BSD_RING,
  185. };
  186. static const struct intel_device_info intel_gm45_info = {
  187. GEN4_FEATURES,
  188. PLATFORM(INTEL_GM45),
  189. .is_mobile = 1, .has_fbc = 1,
  190. .supports_tv = 1,
  191. .ring_mask = RENDER_RING | BSD_RING,
  192. };
  193. #define GEN5_FEATURES \
  194. GEN(5), \
  195. .num_pipes = 2, \
  196. .has_hotplug = 1, \
  197. .ring_mask = RENDER_RING | BSD_RING, \
  198. .has_snoop = true, \
  199. .has_coherent_ggtt = true, \
  200. /* ilk does support rc6, but we do not implement [power] contexts */ \
  201. .has_rc6 = 0, \
  202. GEN_DEFAULT_PIPEOFFSETS, \
  203. GEN_DEFAULT_PAGE_SIZES, \
  204. CURSOR_OFFSETS
  205. static const struct intel_device_info intel_ironlake_d_info = {
  206. GEN5_FEATURES,
  207. PLATFORM(INTEL_IRONLAKE),
  208. };
  209. static const struct intel_device_info intel_ironlake_m_info = {
  210. GEN5_FEATURES,
  211. PLATFORM(INTEL_IRONLAKE),
  212. .is_mobile = 1, .has_fbc = 1,
  213. };
  214. #define GEN6_FEATURES \
  215. GEN(6), \
  216. .num_pipes = 2, \
  217. .has_hotplug = 1, \
  218. .has_fbc = 1, \
  219. .ring_mask = RENDER_RING | BSD_RING | BLT_RING, \
  220. .has_coherent_ggtt = true, \
  221. .has_llc = 1, \
  222. .has_rc6 = 1, \
  223. .has_rc6p = 1, \
  224. .has_aliasing_ppgtt = 1, \
  225. GEN_DEFAULT_PIPEOFFSETS, \
  226. GEN_DEFAULT_PAGE_SIZES, \
  227. CURSOR_OFFSETS
  228. #define SNB_D_PLATFORM \
  229. GEN6_FEATURES, \
  230. PLATFORM(INTEL_SANDYBRIDGE)
  231. static const struct intel_device_info intel_sandybridge_d_gt1_info = {
  232. SNB_D_PLATFORM,
  233. .gt = 1,
  234. };
  235. static const struct intel_device_info intel_sandybridge_d_gt2_info = {
  236. SNB_D_PLATFORM,
  237. .gt = 2,
  238. };
  239. #define SNB_M_PLATFORM \
  240. GEN6_FEATURES, \
  241. PLATFORM(INTEL_SANDYBRIDGE), \
  242. .is_mobile = 1
  243. static const struct intel_device_info intel_sandybridge_m_gt1_info = {
  244. SNB_M_PLATFORM,
  245. .gt = 1,
  246. };
  247. static const struct intel_device_info intel_sandybridge_m_gt2_info = {
  248. SNB_M_PLATFORM,
  249. .gt = 2,
  250. };
  251. #define GEN7_FEATURES \
  252. GEN(7), \
  253. .num_pipes = 3, \
  254. .has_hotplug = 1, \
  255. .has_fbc = 1, \
  256. .ring_mask = RENDER_RING | BSD_RING | BLT_RING, \
  257. .has_coherent_ggtt = true, \
  258. .has_llc = 1, \
  259. .has_rc6 = 1, \
  260. .has_rc6p = 1, \
  261. .has_aliasing_ppgtt = 1, \
  262. .has_full_ppgtt = 1, \
  263. GEN_DEFAULT_PIPEOFFSETS, \
  264. GEN_DEFAULT_PAGE_SIZES, \
  265. IVB_CURSOR_OFFSETS
  266. #define IVB_D_PLATFORM \
  267. GEN7_FEATURES, \
  268. PLATFORM(INTEL_IVYBRIDGE), \
  269. .has_l3_dpf = 1
  270. static const struct intel_device_info intel_ivybridge_d_gt1_info = {
  271. IVB_D_PLATFORM,
  272. .gt = 1,
  273. };
  274. static const struct intel_device_info intel_ivybridge_d_gt2_info = {
  275. IVB_D_PLATFORM,
  276. .gt = 2,
  277. };
  278. #define IVB_M_PLATFORM \
  279. GEN7_FEATURES, \
  280. PLATFORM(INTEL_IVYBRIDGE), \
  281. .is_mobile = 1, \
  282. .has_l3_dpf = 1
  283. static const struct intel_device_info intel_ivybridge_m_gt1_info = {
  284. IVB_M_PLATFORM,
  285. .gt = 1,
  286. };
  287. static const struct intel_device_info intel_ivybridge_m_gt2_info = {
  288. IVB_M_PLATFORM,
  289. .gt = 2,
  290. };
  291. static const struct intel_device_info intel_ivybridge_q_info = {
  292. GEN7_FEATURES,
  293. PLATFORM(INTEL_IVYBRIDGE),
  294. .gt = 2,
  295. .num_pipes = 0, /* legal, last one wins */
  296. .has_l3_dpf = 1,
  297. };
  298. static const struct intel_device_info intel_valleyview_info = {
  299. PLATFORM(INTEL_VALLEYVIEW),
  300. GEN(7),
  301. .is_lp = 1,
  302. .num_pipes = 2,
  303. .has_runtime_pm = 1,
  304. .has_rc6 = 1,
  305. .has_gmch_display = 1,
  306. .has_hotplug = 1,
  307. .has_aliasing_ppgtt = 1,
  308. .has_full_ppgtt = 1,
  309. .has_snoop = true,
  310. .has_coherent_ggtt = false,
  311. .ring_mask = RENDER_RING | BSD_RING | BLT_RING,
  312. .display_mmio_offset = VLV_DISPLAY_BASE,
  313. GEN_DEFAULT_PAGE_SIZES,
  314. GEN_DEFAULT_PIPEOFFSETS,
  315. CURSOR_OFFSETS
  316. };
  317. #define G75_FEATURES \
  318. GEN7_FEATURES, \
  319. .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING, \
  320. .has_ddi = 1, \
  321. .has_fpga_dbg = 1, \
  322. .has_psr = 1, \
  323. .has_resource_streamer = 1, \
  324. .has_dp_mst = 1, \
  325. .has_rc6p = 0 /* RC6p removed-by HSW */, \
  326. .has_runtime_pm = 1
  327. #define HSW_PLATFORM \
  328. G75_FEATURES, \
  329. PLATFORM(INTEL_HASWELL), \
  330. .has_l3_dpf = 1
  331. static const struct intel_device_info intel_haswell_gt1_info = {
  332. HSW_PLATFORM,
  333. .gt = 1,
  334. };
  335. static const struct intel_device_info intel_haswell_gt2_info = {
  336. HSW_PLATFORM,
  337. .gt = 2,
  338. };
  339. static const struct intel_device_info intel_haswell_gt3_info = {
  340. HSW_PLATFORM,
  341. .gt = 3,
  342. };
  343. #define GEN8_FEATURES \
  344. G75_FEATURES, \
  345. GEN(8), \
  346. BDW_COLORS, \
  347. .page_sizes = I915_GTT_PAGE_SIZE_4K | \
  348. I915_GTT_PAGE_SIZE_2M, \
  349. .has_logical_ring_contexts = 1, \
  350. .has_full_48bit_ppgtt = 1, \
  351. .has_64bit_reloc = 1, \
  352. .has_reset_engine = 1
  353. #define BDW_PLATFORM \
  354. GEN8_FEATURES, \
  355. PLATFORM(INTEL_BROADWELL)
  356. static const struct intel_device_info intel_broadwell_gt1_info = {
  357. BDW_PLATFORM,
  358. .gt = 1,
  359. };
  360. static const struct intel_device_info intel_broadwell_gt2_info = {
  361. BDW_PLATFORM,
  362. .gt = 2,
  363. };
  364. static const struct intel_device_info intel_broadwell_rsvd_info = {
  365. BDW_PLATFORM,
  366. .gt = 3,
  367. /* According to the device ID those devices are GT3, they were
  368. * previously treated as not GT3, keep it like that.
  369. */
  370. };
  371. static const struct intel_device_info intel_broadwell_gt3_info = {
  372. BDW_PLATFORM,
  373. .gt = 3,
  374. .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
  375. };
  376. static const struct intel_device_info intel_cherryview_info = {
  377. PLATFORM(INTEL_CHERRYVIEW),
  378. GEN(8),
  379. .num_pipes = 3,
  380. .has_hotplug = 1,
  381. .is_lp = 1,
  382. .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING,
  383. .has_64bit_reloc = 1,
  384. .has_runtime_pm = 1,
  385. .has_resource_streamer = 1,
  386. .has_rc6 = 1,
  387. .has_logical_ring_contexts = 1,
  388. .has_gmch_display = 1,
  389. .has_aliasing_ppgtt = 1,
  390. .has_full_ppgtt = 1,
  391. .has_reset_engine = 1,
  392. .has_snoop = true,
  393. .has_coherent_ggtt = false,
  394. .display_mmio_offset = VLV_DISPLAY_BASE,
  395. GEN_DEFAULT_PAGE_SIZES,
  396. GEN_CHV_PIPEOFFSETS,
  397. CURSOR_OFFSETS,
  398. CHV_COLORS,
  399. };
  400. #define GEN9_DEFAULT_PAGE_SIZES \
  401. .page_sizes = I915_GTT_PAGE_SIZE_4K | \
  402. I915_GTT_PAGE_SIZE_64K | \
  403. I915_GTT_PAGE_SIZE_2M
  404. #define GEN9_FEATURES \
  405. GEN8_FEATURES, \
  406. GEN(9), \
  407. GEN9_DEFAULT_PAGE_SIZES, \
  408. .has_logical_ring_preemption = 1, \
  409. .has_csr = 1, \
  410. .has_guc = 1, \
  411. .has_ipc = 1, \
  412. .ddb_size = 896
  413. #define SKL_PLATFORM \
  414. GEN9_FEATURES, \
  415. PLATFORM(INTEL_SKYLAKE)
  416. static const struct intel_device_info intel_skylake_gt1_info = {
  417. SKL_PLATFORM,
  418. .gt = 1,
  419. };
  420. static const struct intel_device_info intel_skylake_gt2_info = {
  421. SKL_PLATFORM,
  422. .gt = 2,
  423. };
  424. #define SKL_GT3_PLUS_PLATFORM \
  425. SKL_PLATFORM, \
  426. .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING
  427. static const struct intel_device_info intel_skylake_gt3_info = {
  428. SKL_GT3_PLUS_PLATFORM,
  429. .gt = 3,
  430. };
  431. static const struct intel_device_info intel_skylake_gt4_info = {
  432. SKL_GT3_PLUS_PLATFORM,
  433. .gt = 4,
  434. };
  435. #define GEN9_LP_FEATURES \
  436. GEN(9), \
  437. .is_lp = 1, \
  438. .has_hotplug = 1, \
  439. .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING, \
  440. .num_pipes = 3, \
  441. .has_64bit_reloc = 1, \
  442. .has_ddi = 1, \
  443. .has_fpga_dbg = 1, \
  444. .has_fbc = 1, \
  445. .has_psr = 1, \
  446. .has_runtime_pm = 1, \
  447. .has_pooled_eu = 0, \
  448. .has_csr = 1, \
  449. .has_resource_streamer = 1, \
  450. .has_rc6 = 1, \
  451. .has_dp_mst = 1, \
  452. .has_logical_ring_contexts = 1, \
  453. .has_logical_ring_preemption = 1, \
  454. .has_guc = 1, \
  455. .has_aliasing_ppgtt = 1, \
  456. .has_full_ppgtt = 1, \
  457. .has_full_48bit_ppgtt = 1, \
  458. .has_reset_engine = 1, \
  459. .has_snoop = true, \
  460. .has_coherent_ggtt = false, \
  461. .has_ipc = 1, \
  462. GEN9_DEFAULT_PAGE_SIZES, \
  463. GEN_DEFAULT_PIPEOFFSETS, \
  464. IVB_CURSOR_OFFSETS, \
  465. BDW_COLORS
  466. static const struct intel_device_info intel_broxton_info = {
  467. GEN9_LP_FEATURES,
  468. PLATFORM(INTEL_BROXTON),
  469. .ddb_size = 512,
  470. };
  471. static const struct intel_device_info intel_geminilake_info = {
  472. GEN9_LP_FEATURES,
  473. PLATFORM(INTEL_GEMINILAKE),
  474. .ddb_size = 1024,
  475. GLK_COLORS,
  476. };
  477. #define KBL_PLATFORM \
  478. GEN9_FEATURES, \
  479. PLATFORM(INTEL_KABYLAKE)
  480. static const struct intel_device_info intel_kabylake_gt1_info = {
  481. KBL_PLATFORM,
  482. .gt = 1,
  483. };
  484. static const struct intel_device_info intel_kabylake_gt2_info = {
  485. KBL_PLATFORM,
  486. .gt = 2,
  487. };
  488. static const struct intel_device_info intel_kabylake_gt3_info = {
  489. KBL_PLATFORM,
  490. .gt = 3,
  491. .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
  492. };
  493. #define CFL_PLATFORM \
  494. GEN9_FEATURES, \
  495. PLATFORM(INTEL_COFFEELAKE)
  496. static const struct intel_device_info intel_coffeelake_gt1_info = {
  497. CFL_PLATFORM,
  498. .gt = 1,
  499. };
  500. static const struct intel_device_info intel_coffeelake_gt2_info = {
  501. CFL_PLATFORM,
  502. .gt = 2,
  503. };
  504. static const struct intel_device_info intel_coffeelake_gt3_info = {
  505. CFL_PLATFORM,
  506. .gt = 3,
  507. .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
  508. };
  509. #define GEN10_FEATURES \
  510. GEN9_FEATURES, \
  511. GEN(10), \
  512. .ddb_size = 1024, \
  513. GLK_COLORS
  514. static const struct intel_device_info intel_cannonlake_info = {
  515. GEN10_FEATURES,
  516. PLATFORM(INTEL_CANNONLAKE),
  517. .gt = 2,
  518. };
  519. #define GEN11_FEATURES \
  520. GEN10_FEATURES, \
  521. GEN(11), \
  522. .ddb_size = 2048, \
  523. .has_csr = 0, \
  524. .has_logical_ring_elsq = 1
  525. static const struct intel_device_info intel_icelake_11_info = {
  526. GEN11_FEATURES,
  527. PLATFORM(INTEL_ICELAKE),
  528. .is_alpha_support = 1,
  529. .has_resource_streamer = 0,
  530. .ring_mask = RENDER_RING | BLT_RING | VEBOX_RING | BSD_RING | BSD3_RING,
  531. };
  532. #undef GEN
  533. #undef PLATFORM
  534. /*
  535. * Make sure any device matches here are from most specific to most
  536. * general. For example, since the Quanta match is based on the subsystem
  537. * and subvendor IDs, we need it to come before the more general IVB
  538. * PCI ID matches, otherwise we'll use the wrong info struct above.
  539. */
  540. static const struct pci_device_id pciidlist[] = {
  541. INTEL_I830_IDS(&intel_i830_info),
  542. INTEL_I845G_IDS(&intel_i845g_info),
  543. INTEL_I85X_IDS(&intel_i85x_info),
  544. INTEL_I865G_IDS(&intel_i865g_info),
  545. INTEL_I915G_IDS(&intel_i915g_info),
  546. INTEL_I915GM_IDS(&intel_i915gm_info),
  547. INTEL_I945G_IDS(&intel_i945g_info),
  548. INTEL_I945GM_IDS(&intel_i945gm_info),
  549. INTEL_I965G_IDS(&intel_i965g_info),
  550. INTEL_G33_IDS(&intel_g33_info),
  551. INTEL_I965GM_IDS(&intel_i965gm_info),
  552. INTEL_GM45_IDS(&intel_gm45_info),
  553. INTEL_G45_IDS(&intel_g45_info),
  554. INTEL_PINEVIEW_IDS(&intel_pineview_info),
  555. INTEL_IRONLAKE_D_IDS(&intel_ironlake_d_info),
  556. INTEL_IRONLAKE_M_IDS(&intel_ironlake_m_info),
  557. INTEL_SNB_D_GT1_IDS(&intel_sandybridge_d_gt1_info),
  558. INTEL_SNB_D_GT2_IDS(&intel_sandybridge_d_gt2_info),
  559. INTEL_SNB_M_GT1_IDS(&intel_sandybridge_m_gt1_info),
  560. INTEL_SNB_M_GT2_IDS(&intel_sandybridge_m_gt2_info),
  561. INTEL_IVB_Q_IDS(&intel_ivybridge_q_info), /* must be first IVB */
  562. INTEL_IVB_M_GT1_IDS(&intel_ivybridge_m_gt1_info),
  563. INTEL_IVB_M_GT2_IDS(&intel_ivybridge_m_gt2_info),
  564. INTEL_IVB_D_GT1_IDS(&intel_ivybridge_d_gt1_info),
  565. INTEL_IVB_D_GT2_IDS(&intel_ivybridge_d_gt2_info),
  566. INTEL_HSW_GT1_IDS(&intel_haswell_gt1_info),
  567. INTEL_HSW_GT2_IDS(&intel_haswell_gt2_info),
  568. INTEL_HSW_GT3_IDS(&intel_haswell_gt3_info),
  569. INTEL_VLV_IDS(&intel_valleyview_info),
  570. INTEL_BDW_GT1_IDS(&intel_broadwell_gt1_info),
  571. INTEL_BDW_GT2_IDS(&intel_broadwell_gt2_info),
  572. INTEL_BDW_GT3_IDS(&intel_broadwell_gt3_info),
  573. INTEL_BDW_RSVD_IDS(&intel_broadwell_rsvd_info),
  574. INTEL_CHV_IDS(&intel_cherryview_info),
  575. INTEL_SKL_GT1_IDS(&intel_skylake_gt1_info),
  576. INTEL_SKL_GT2_IDS(&intel_skylake_gt2_info),
  577. INTEL_SKL_GT3_IDS(&intel_skylake_gt3_info),
  578. INTEL_SKL_GT4_IDS(&intel_skylake_gt4_info),
  579. INTEL_BXT_IDS(&intel_broxton_info),
  580. INTEL_GLK_IDS(&intel_geminilake_info),
  581. INTEL_KBL_GT1_IDS(&intel_kabylake_gt1_info),
  582. INTEL_KBL_GT2_IDS(&intel_kabylake_gt2_info),
  583. INTEL_KBL_GT3_IDS(&intel_kabylake_gt3_info),
  584. INTEL_KBL_GT4_IDS(&intel_kabylake_gt3_info),
  585. INTEL_AML_GT2_IDS(&intel_kabylake_gt2_info),
  586. INTEL_CFL_S_GT1_IDS(&intel_coffeelake_gt1_info),
  587. INTEL_CFL_S_GT2_IDS(&intel_coffeelake_gt2_info),
  588. INTEL_CFL_H_GT2_IDS(&intel_coffeelake_gt2_info),
  589. INTEL_CFL_U_GT2_IDS(&intel_coffeelake_gt2_info),
  590. INTEL_CFL_U_GT3_IDS(&intel_coffeelake_gt3_info),
  591. INTEL_WHL_U_GT1_IDS(&intel_coffeelake_gt1_info),
  592. INTEL_WHL_U_GT2_IDS(&intel_coffeelake_gt2_info),
  593. INTEL_WHL_U_GT3_IDS(&intel_coffeelake_gt3_info),
  594. INTEL_CNL_IDS(&intel_cannonlake_info),
  595. INTEL_ICL_11_IDS(&intel_icelake_11_info),
  596. {0, 0, 0}
  597. };
  598. MODULE_DEVICE_TABLE(pci, pciidlist);
  599. static void i915_pci_remove(struct pci_dev *pdev)
  600. {
  601. struct drm_device *dev;
  602. dev = pci_get_drvdata(pdev);
  603. if (!dev) /* driver load aborted, nothing to cleanup */
  604. return;
  605. i915_driver_unload(dev);
  606. drm_dev_put(dev);
  607. pci_set_drvdata(pdev, NULL);
  608. }
  609. static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
  610. {
  611. struct intel_device_info *intel_info =
  612. (struct intel_device_info *) ent->driver_data;
  613. int err;
  614. if (IS_ALPHA_SUPPORT(intel_info) && !i915_modparams.alpha_support) {
  615. DRM_INFO("The driver support for your hardware in this kernel version is alpha quality\n"
  616. "See CONFIG_DRM_I915_ALPHA_SUPPORT or i915.alpha_support module parameter\n"
  617. "to enable support in this kernel version, or check for kernel updates.\n");
  618. return -ENODEV;
  619. }
  620. /* Only bind to function 0 of the device. Early generations
  621. * used function 1 as a placeholder for multi-head. This causes
  622. * us confusion instead, especially on the systems where both
  623. * functions have the same PCI-ID!
  624. */
  625. if (PCI_FUNC(pdev->devfn))
  626. return -ENODEV;
  627. /*
  628. * apple-gmux is needed on dual GPU MacBook Pro
  629. * to probe the panel if we're the inactive GPU.
  630. */
  631. if (vga_switcheroo_client_probe_defer(pdev))
  632. return -EPROBE_DEFER;
  633. err = i915_driver_load(pdev, ent);
  634. if (err)
  635. return err;
  636. if (i915_inject_load_failure()) {
  637. i915_pci_remove(pdev);
  638. return -ENODEV;
  639. }
  640. err = i915_live_selftests(pdev);
  641. if (err) {
  642. i915_pci_remove(pdev);
  643. return err > 0 ? -ENOTTY : err;
  644. }
  645. return 0;
  646. }
  647. static struct pci_driver i915_pci_driver = {
  648. .name = DRIVER_NAME,
  649. .id_table = pciidlist,
  650. .probe = i915_pci_probe,
  651. .remove = i915_pci_remove,
  652. .driver.pm = &i915_pm_ops,
  653. };
  654. static int __init i915_init(void)
  655. {
  656. bool use_kms = true;
  657. int err;
  658. err = i915_mock_selftests();
  659. if (err)
  660. return err > 0 ? 0 : err;
  661. /*
  662. * Enable KMS by default, unless explicitly overriden by
  663. * either the i915.modeset prarameter or by the
  664. * vga_text_mode_force boot option.
  665. */
  666. if (i915_modparams.modeset == 0)
  667. use_kms = false;
  668. if (vgacon_text_force() && i915_modparams.modeset == -1)
  669. use_kms = false;
  670. if (!use_kms) {
  671. /* Silently fail loading to not upset userspace. */
  672. DRM_DEBUG_DRIVER("KMS disabled.\n");
  673. return 0;
  674. }
  675. return pci_register_driver(&i915_pci_driver);
  676. }
  677. static void __exit i915_exit(void)
  678. {
  679. if (!i915_pci_driver.driver.owner)
  680. return;
  681. pci_unregister_driver(&i915_pci_driver);
  682. }
  683. module_init(i915_init);
  684. module_exit(i915_exit);
  685. MODULE_AUTHOR("Tungsten Graphics, Inc.");
  686. MODULE_AUTHOR("Intel Corporation");
  687. MODULE_DESCRIPTION(DRIVER_DESC);
  688. MODULE_LICENSE("GPL and additional rights");