i915_pci.c 26 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042
  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 <drm/drm_color_mgmt.h>
  25. #include <drm/drm_drv.h>
  26. #include <drm/intel/pciids.h>
  27. #include "display/intel_display_driver.h"
  28. #include "gt/intel_gt_regs.h"
  29. #include "gt/intel_sa_media.h"
  30. #include "gem/i915_gem_object_types.h"
  31. #include "i915_driver.h"
  32. #include "i915_drv.h"
  33. #include "i915_pci.h"
  34. #include "i915_reg.h"
  35. #include "intel_pci_config.h"
  36. __diag_push();
  37. __diag_ignore_all("-Woverride-init", "Allow field initialization overrides for device info");
  38. #define PLATFORM(x) .platform = (x)
  39. #define GEN(x) \
  40. .__runtime.graphics.ip.ver = (x), \
  41. .__runtime.media.ip.ver = (x)
  42. #define LEGACY_CACHELEVEL \
  43. .cachelevel_to_pat = { \
  44. [I915_CACHE_NONE] = 0, \
  45. [I915_CACHE_LLC] = 1, \
  46. [I915_CACHE_L3_LLC] = 2, \
  47. [I915_CACHE_WT] = 3, \
  48. }
  49. #define TGL_CACHELEVEL \
  50. .cachelevel_to_pat = { \
  51. [I915_CACHE_NONE] = 3, \
  52. [I915_CACHE_LLC] = 0, \
  53. [I915_CACHE_L3_LLC] = 0, \
  54. [I915_CACHE_WT] = 2, \
  55. }
  56. #define MTL_CACHELEVEL \
  57. .cachelevel_to_pat = { \
  58. [I915_CACHE_NONE] = 2, \
  59. [I915_CACHE_LLC] = 3, \
  60. [I915_CACHE_L3_LLC] = 3, \
  61. [I915_CACHE_WT] = 1, \
  62. }
  63. /* Keep in gen based order, and chronological order within a gen */
  64. #define GEN_DEFAULT_PAGE_SIZES \
  65. .__runtime.page_sizes = I915_GTT_PAGE_SIZE_4K
  66. #define GEN_DEFAULT_REGIONS \
  67. .memory_regions = BIT(INTEL_REGION_SMEM) | BIT(INTEL_REGION_STOLEN_SMEM)
  68. #define I830_FEATURES \
  69. GEN(2), \
  70. .is_mobile = 1, \
  71. .gpu_reset_clobbers_display = true, \
  72. .has_3d_pipeline = 1, \
  73. .hws_needs_physical = 1, \
  74. .unfenced_needs_alignment = 1, \
  75. .platform_engine_mask = BIT(RCS0), \
  76. .has_snoop = true, \
  77. .has_coherent_ggtt = false, \
  78. .dma_mask_size = 32, \
  79. .max_pat_index = 3, \
  80. GEN_DEFAULT_PAGE_SIZES, \
  81. GEN_DEFAULT_REGIONS, \
  82. LEGACY_CACHELEVEL
  83. #define I845_FEATURES \
  84. GEN(2), \
  85. .has_3d_pipeline = 1, \
  86. .gpu_reset_clobbers_display = true, \
  87. .hws_needs_physical = 1, \
  88. .unfenced_needs_alignment = 1, \
  89. .platform_engine_mask = BIT(RCS0), \
  90. .has_snoop = true, \
  91. .has_coherent_ggtt = false, \
  92. .dma_mask_size = 32, \
  93. .max_pat_index = 3, \
  94. GEN_DEFAULT_PAGE_SIZES, \
  95. GEN_DEFAULT_REGIONS, \
  96. LEGACY_CACHELEVEL
  97. static const struct intel_device_info i830_info = {
  98. I830_FEATURES,
  99. PLATFORM(INTEL_I830),
  100. };
  101. static const struct intel_device_info i845g_info = {
  102. I845_FEATURES,
  103. PLATFORM(INTEL_I845G),
  104. };
  105. static const struct intel_device_info i85x_info = {
  106. I830_FEATURES,
  107. PLATFORM(INTEL_I85X),
  108. };
  109. static const struct intel_device_info i865g_info = {
  110. I845_FEATURES,
  111. PLATFORM(INTEL_I865G),
  112. };
  113. #define GEN3_FEATURES \
  114. GEN(3), \
  115. .gpu_reset_clobbers_display = true, \
  116. .platform_engine_mask = BIT(RCS0), \
  117. .has_3d_pipeline = 1, \
  118. .has_snoop = true, \
  119. .has_coherent_ggtt = true, \
  120. .dma_mask_size = 32, \
  121. .max_pat_index = 3, \
  122. GEN_DEFAULT_PAGE_SIZES, \
  123. GEN_DEFAULT_REGIONS, \
  124. LEGACY_CACHELEVEL
  125. static const struct intel_device_info i915g_info = {
  126. GEN3_FEATURES,
  127. PLATFORM(INTEL_I915G),
  128. .has_coherent_ggtt = false,
  129. .hws_needs_physical = 1,
  130. .unfenced_needs_alignment = 1,
  131. };
  132. static const struct intel_device_info i915gm_info = {
  133. GEN3_FEATURES,
  134. PLATFORM(INTEL_I915GM),
  135. .is_mobile = 1,
  136. .hws_needs_physical = 1,
  137. .unfenced_needs_alignment = 1,
  138. };
  139. static const struct intel_device_info i945g_info = {
  140. GEN3_FEATURES,
  141. PLATFORM(INTEL_I945G),
  142. .hws_needs_physical = 1,
  143. .unfenced_needs_alignment = 1,
  144. };
  145. static const struct intel_device_info i945gm_info = {
  146. GEN3_FEATURES,
  147. PLATFORM(INTEL_I945GM),
  148. .is_mobile = 1,
  149. .hws_needs_physical = 1,
  150. .unfenced_needs_alignment = 1,
  151. };
  152. static const struct intel_device_info g33_info = {
  153. GEN3_FEATURES,
  154. PLATFORM(INTEL_G33),
  155. .dma_mask_size = 36,
  156. };
  157. static const struct intel_device_info pnv_g_info = {
  158. GEN3_FEATURES,
  159. PLATFORM(INTEL_PINEVIEW),
  160. .dma_mask_size = 36,
  161. };
  162. static const struct intel_device_info pnv_m_info = {
  163. GEN3_FEATURES,
  164. PLATFORM(INTEL_PINEVIEW),
  165. .is_mobile = 1,
  166. .dma_mask_size = 36,
  167. };
  168. #define GEN4_FEATURES \
  169. GEN(4), \
  170. .gpu_reset_clobbers_display = true, \
  171. .platform_engine_mask = BIT(RCS0), \
  172. .has_3d_pipeline = 1, \
  173. .has_snoop = true, \
  174. .has_coherent_ggtt = true, \
  175. .dma_mask_size = 36, \
  176. .max_pat_index = 3, \
  177. GEN_DEFAULT_PAGE_SIZES, \
  178. GEN_DEFAULT_REGIONS, \
  179. LEGACY_CACHELEVEL
  180. static const struct intel_device_info i965g_info = {
  181. GEN4_FEATURES,
  182. PLATFORM(INTEL_I965G),
  183. .hws_needs_physical = 1,
  184. .has_snoop = false,
  185. };
  186. static const struct intel_device_info i965gm_info = {
  187. GEN4_FEATURES,
  188. PLATFORM(INTEL_I965GM),
  189. .is_mobile = 1,
  190. .hws_needs_physical = 1,
  191. .has_snoop = false,
  192. };
  193. static const struct intel_device_info g45_info = {
  194. GEN4_FEATURES,
  195. PLATFORM(INTEL_G45),
  196. .platform_engine_mask = BIT(RCS0) | BIT(VCS0),
  197. .gpu_reset_clobbers_display = false,
  198. };
  199. static const struct intel_device_info gm45_info = {
  200. GEN4_FEATURES,
  201. PLATFORM(INTEL_GM45),
  202. .is_mobile = 1,
  203. .platform_engine_mask = BIT(RCS0) | BIT(VCS0),
  204. .gpu_reset_clobbers_display = false,
  205. };
  206. #define GEN5_FEATURES \
  207. GEN(5), \
  208. .platform_engine_mask = BIT(RCS0) | BIT(VCS0), \
  209. .has_3d_pipeline = 1, \
  210. .has_snoop = true, \
  211. .has_coherent_ggtt = true, \
  212. /* ilk does support rc6, but we do not implement [power] contexts */ \
  213. .has_rc6 = 0, \
  214. .dma_mask_size = 36, \
  215. .max_pat_index = 3, \
  216. GEN_DEFAULT_PAGE_SIZES, \
  217. GEN_DEFAULT_REGIONS, \
  218. LEGACY_CACHELEVEL
  219. static const struct intel_device_info ilk_d_info = {
  220. GEN5_FEATURES,
  221. PLATFORM(INTEL_IRONLAKE),
  222. };
  223. static const struct intel_device_info ilk_m_info = {
  224. GEN5_FEATURES,
  225. PLATFORM(INTEL_IRONLAKE),
  226. .is_mobile = 1,
  227. .has_rps = true,
  228. };
  229. #define GEN6_FEATURES \
  230. GEN(6), \
  231. .platform_engine_mask = BIT(RCS0) | BIT(VCS0) | BIT(BCS0), \
  232. .has_3d_pipeline = 1, \
  233. .has_coherent_ggtt = true, \
  234. .has_llc = 1, \
  235. .has_rc6 = 1, \
  236. /* snb does support rc6p, but enabling it causes various issues */ \
  237. .has_rc6p = 0, \
  238. .has_rps = true, \
  239. .dma_mask_size = 40, \
  240. .max_pat_index = 3, \
  241. .__runtime.ppgtt_type = INTEL_PPGTT_ALIASING, \
  242. .__runtime.ppgtt_size = 31, \
  243. GEN_DEFAULT_PAGE_SIZES, \
  244. GEN_DEFAULT_REGIONS, \
  245. LEGACY_CACHELEVEL
  246. #define SNB_D_PLATFORM \
  247. GEN6_FEATURES, \
  248. PLATFORM(INTEL_SANDYBRIDGE)
  249. static const struct intel_device_info snb_d_gt1_info = {
  250. SNB_D_PLATFORM,
  251. .gt = 1,
  252. };
  253. static const struct intel_device_info snb_d_gt2_info = {
  254. SNB_D_PLATFORM,
  255. .gt = 2,
  256. };
  257. #define SNB_M_PLATFORM \
  258. GEN6_FEATURES, \
  259. PLATFORM(INTEL_SANDYBRIDGE), \
  260. .is_mobile = 1
  261. static const struct intel_device_info snb_m_gt1_info = {
  262. SNB_M_PLATFORM,
  263. .gt = 1,
  264. };
  265. static const struct intel_device_info snb_m_gt2_info = {
  266. SNB_M_PLATFORM,
  267. .gt = 2,
  268. };
  269. #define GEN7_FEATURES \
  270. GEN(7), \
  271. .platform_engine_mask = BIT(RCS0) | BIT(VCS0) | BIT(BCS0), \
  272. .has_3d_pipeline = 1, \
  273. .has_coherent_ggtt = true, \
  274. .has_llc = 1, \
  275. .has_rc6 = 1, \
  276. .has_rc6p = 1, \
  277. .has_reset_engine = true, \
  278. .has_rps = true, \
  279. .dma_mask_size = 40, \
  280. .max_pat_index = 3, \
  281. .__runtime.ppgtt_type = INTEL_PPGTT_ALIASING, \
  282. .__runtime.ppgtt_size = 31, \
  283. GEN_DEFAULT_PAGE_SIZES, \
  284. GEN_DEFAULT_REGIONS, \
  285. LEGACY_CACHELEVEL
  286. #define IVB_D_PLATFORM \
  287. GEN7_FEATURES, \
  288. PLATFORM(INTEL_IVYBRIDGE), \
  289. .has_l3_dpf = 1
  290. static const struct intel_device_info ivb_d_gt1_info = {
  291. IVB_D_PLATFORM,
  292. .gt = 1,
  293. };
  294. static const struct intel_device_info ivb_d_gt2_info = {
  295. IVB_D_PLATFORM,
  296. .gt = 2,
  297. };
  298. #define IVB_M_PLATFORM \
  299. GEN7_FEATURES, \
  300. PLATFORM(INTEL_IVYBRIDGE), \
  301. .is_mobile = 1, \
  302. .has_l3_dpf = 1
  303. static const struct intel_device_info ivb_m_gt1_info = {
  304. IVB_M_PLATFORM,
  305. .gt = 1,
  306. };
  307. static const struct intel_device_info ivb_m_gt2_info = {
  308. IVB_M_PLATFORM,
  309. .gt = 2,
  310. };
  311. static const struct intel_device_info ivb_q_info = {
  312. GEN7_FEATURES,
  313. PLATFORM(INTEL_IVYBRIDGE),
  314. .gt = 2,
  315. .has_l3_dpf = 1,
  316. };
  317. static const struct intel_device_info vlv_info = {
  318. PLATFORM(INTEL_VALLEYVIEW),
  319. GEN(7),
  320. .has_runtime_pm = 1,
  321. .has_rc6 = 1,
  322. .has_reset_engine = true,
  323. .has_rps = true,
  324. .dma_mask_size = 40,
  325. .max_pat_index = 3,
  326. .__runtime.ppgtt_type = INTEL_PPGTT_ALIASING,
  327. .__runtime.ppgtt_size = 31,
  328. .has_snoop = true,
  329. .has_coherent_ggtt = false,
  330. .platform_engine_mask = BIT(RCS0) | BIT(VCS0) | BIT(BCS0),
  331. GEN_DEFAULT_PAGE_SIZES,
  332. GEN_DEFAULT_REGIONS,
  333. LEGACY_CACHELEVEL,
  334. };
  335. #define G75_FEATURES \
  336. GEN7_FEATURES, \
  337. .platform_engine_mask = BIT(RCS0) | BIT(VCS0) | BIT(BCS0) | BIT(VECS0), \
  338. .has_rc6p = 0 /* RC6p removed-by HSW */, \
  339. .has_runtime_pm = 1
  340. #define HSW_PLATFORM \
  341. G75_FEATURES, \
  342. PLATFORM(INTEL_HASWELL), \
  343. .has_l3_dpf = 1
  344. static const struct intel_device_info hsw_gt1_info = {
  345. HSW_PLATFORM,
  346. .gt = 1,
  347. };
  348. static const struct intel_device_info hsw_gt2_info = {
  349. HSW_PLATFORM,
  350. .gt = 2,
  351. };
  352. static const struct intel_device_info hsw_gt3_info = {
  353. HSW_PLATFORM,
  354. .gt = 3,
  355. };
  356. #define GEN8_FEATURES \
  357. G75_FEATURES, \
  358. GEN(8), \
  359. .has_logical_ring_contexts = 1, \
  360. .dma_mask_size = 39, \
  361. .__runtime.ppgtt_type = INTEL_PPGTT_FULL, \
  362. .__runtime.ppgtt_size = 48, \
  363. .has_64bit_reloc = 1
  364. #define BDW_PLATFORM \
  365. GEN8_FEATURES, \
  366. PLATFORM(INTEL_BROADWELL)
  367. static const struct intel_device_info bdw_gt1_info = {
  368. BDW_PLATFORM,
  369. .gt = 1,
  370. };
  371. static const struct intel_device_info bdw_gt2_info = {
  372. BDW_PLATFORM,
  373. .gt = 2,
  374. };
  375. static const struct intel_device_info bdw_rsvd_info = {
  376. BDW_PLATFORM,
  377. .gt = 3,
  378. /* According to the device ID those devices are GT3, they were
  379. * previously treated as not GT3, keep it like that.
  380. */
  381. };
  382. static const struct intel_device_info bdw_gt3_info = {
  383. BDW_PLATFORM,
  384. .gt = 3,
  385. .platform_engine_mask =
  386. BIT(RCS0) | BIT(VCS0) | BIT(BCS0) | BIT(VECS0) | BIT(VCS1),
  387. };
  388. static const struct intel_device_info chv_info = {
  389. PLATFORM(INTEL_CHERRYVIEW),
  390. GEN(8),
  391. .platform_engine_mask = BIT(RCS0) | BIT(VCS0) | BIT(BCS0) | BIT(VECS0),
  392. .has_64bit_reloc = 1,
  393. .has_runtime_pm = 1,
  394. .has_rc6 = 1,
  395. .has_rps = true,
  396. .has_logical_ring_contexts = 1,
  397. .dma_mask_size = 39,
  398. .max_pat_index = 3,
  399. .__runtime.ppgtt_type = INTEL_PPGTT_FULL,
  400. .__runtime.ppgtt_size = 32,
  401. .has_reset_engine = 1,
  402. .has_snoop = true,
  403. .has_coherent_ggtt = false,
  404. GEN_DEFAULT_PAGE_SIZES,
  405. GEN_DEFAULT_REGIONS,
  406. LEGACY_CACHELEVEL,
  407. };
  408. #define GEN9_DEFAULT_PAGE_SIZES \
  409. .__runtime.page_sizes = I915_GTT_PAGE_SIZE_4K | \
  410. I915_GTT_PAGE_SIZE_64K
  411. #define GEN9_FEATURES \
  412. GEN8_FEATURES, \
  413. GEN(9), \
  414. GEN9_DEFAULT_PAGE_SIZES, \
  415. .has_gt_uc = 1
  416. #define SKL_PLATFORM \
  417. GEN9_FEATURES, \
  418. PLATFORM(INTEL_SKYLAKE)
  419. static const struct intel_device_info skl_gt1_info = {
  420. SKL_PLATFORM,
  421. .gt = 1,
  422. };
  423. static const struct intel_device_info skl_gt2_info = {
  424. SKL_PLATFORM,
  425. .gt = 2,
  426. };
  427. #define SKL_GT3_PLUS_PLATFORM \
  428. SKL_PLATFORM, \
  429. .platform_engine_mask = \
  430. BIT(RCS0) | BIT(VCS0) | BIT(BCS0) | BIT(VECS0) | BIT(VCS1)
  431. static const struct intel_device_info skl_gt3_info = {
  432. SKL_GT3_PLUS_PLATFORM,
  433. .gt = 3,
  434. };
  435. static const struct intel_device_info skl_gt4_info = {
  436. SKL_GT3_PLUS_PLATFORM,
  437. .gt = 4,
  438. };
  439. #define GEN9_LP_FEATURES \
  440. GEN(9), \
  441. .platform_engine_mask = BIT(RCS0) | BIT(VCS0) | BIT(BCS0) | BIT(VECS0), \
  442. .has_3d_pipeline = 1, \
  443. .has_64bit_reloc = 1, \
  444. .has_runtime_pm = 1, \
  445. .has_rc6 = 1, \
  446. .has_rps = true, \
  447. .has_logical_ring_contexts = 1, \
  448. .has_gt_uc = 1, \
  449. .dma_mask_size = 39, \
  450. .__runtime.ppgtt_type = INTEL_PPGTT_FULL, \
  451. .__runtime.ppgtt_size = 48, \
  452. .has_reset_engine = 1, \
  453. .has_snoop = true, \
  454. .has_coherent_ggtt = false, \
  455. .max_pat_index = 3, \
  456. GEN9_DEFAULT_PAGE_SIZES, \
  457. GEN_DEFAULT_REGIONS, \
  458. LEGACY_CACHELEVEL
  459. static const struct intel_device_info bxt_info = {
  460. GEN9_LP_FEATURES,
  461. PLATFORM(INTEL_BROXTON),
  462. };
  463. static const struct intel_device_info glk_info = {
  464. GEN9_LP_FEATURES,
  465. PLATFORM(INTEL_GEMINILAKE),
  466. };
  467. #define KBL_PLATFORM \
  468. GEN9_FEATURES, \
  469. PLATFORM(INTEL_KABYLAKE)
  470. static const struct intel_device_info kbl_gt1_info = {
  471. KBL_PLATFORM,
  472. .gt = 1,
  473. };
  474. static const struct intel_device_info kbl_gt2_info = {
  475. KBL_PLATFORM,
  476. .gt = 2,
  477. };
  478. static const struct intel_device_info kbl_gt3_info = {
  479. KBL_PLATFORM,
  480. .gt = 3,
  481. .platform_engine_mask =
  482. BIT(RCS0) | BIT(VCS0) | BIT(BCS0) | BIT(VECS0) | BIT(VCS1),
  483. };
  484. #define CFL_PLATFORM \
  485. GEN9_FEATURES, \
  486. PLATFORM(INTEL_COFFEELAKE)
  487. static const struct intel_device_info cfl_gt1_info = {
  488. CFL_PLATFORM,
  489. .gt = 1,
  490. };
  491. static const struct intel_device_info cfl_gt2_info = {
  492. CFL_PLATFORM,
  493. .gt = 2,
  494. };
  495. static const struct intel_device_info cfl_gt3_info = {
  496. CFL_PLATFORM,
  497. .gt = 3,
  498. .platform_engine_mask =
  499. BIT(RCS0) | BIT(VCS0) | BIT(BCS0) | BIT(VECS0) | BIT(VCS1),
  500. };
  501. #define CML_PLATFORM \
  502. GEN9_FEATURES, \
  503. PLATFORM(INTEL_COMETLAKE)
  504. static const struct intel_device_info cml_gt1_info = {
  505. CML_PLATFORM,
  506. .gt = 1,
  507. };
  508. static const struct intel_device_info cml_gt2_info = {
  509. CML_PLATFORM,
  510. .gt = 2,
  511. };
  512. #define GEN11_DEFAULT_PAGE_SIZES \
  513. .__runtime.page_sizes = I915_GTT_PAGE_SIZE_4K | \
  514. I915_GTT_PAGE_SIZE_64K | \
  515. I915_GTT_PAGE_SIZE_2M
  516. #define GEN11_FEATURES \
  517. GEN9_FEATURES, \
  518. GEN11_DEFAULT_PAGE_SIZES, \
  519. GEN(11), \
  520. .has_coherent_ggtt = false, \
  521. .has_logical_ring_elsq = 1
  522. static const struct intel_device_info icl_info = {
  523. GEN11_FEATURES,
  524. PLATFORM(INTEL_ICELAKE),
  525. .platform_engine_mask =
  526. BIT(RCS0) | BIT(BCS0) | BIT(VECS0) | BIT(VCS0) | BIT(VCS2),
  527. };
  528. static const struct intel_device_info ehl_info = {
  529. GEN11_FEATURES,
  530. PLATFORM(INTEL_ELKHARTLAKE),
  531. .platform_engine_mask = BIT(RCS0) | BIT(BCS0) | BIT(VCS0) | BIT(VECS0),
  532. .__runtime.ppgtt_size = 36,
  533. };
  534. static const struct intel_device_info jsl_info = {
  535. GEN11_FEATURES,
  536. PLATFORM(INTEL_JASPERLAKE),
  537. .platform_engine_mask = BIT(RCS0) | BIT(BCS0) | BIT(VCS0) | BIT(VECS0),
  538. .__runtime.ppgtt_size = 36,
  539. };
  540. #define GEN12_FEATURES \
  541. GEN11_FEATURES, \
  542. GEN(12), \
  543. TGL_CACHELEVEL, \
  544. .has_global_mocs = 1, \
  545. .has_pxp = 1, \
  546. .max_pat_index = 3
  547. static const struct intel_device_info tgl_info = {
  548. GEN12_FEATURES,
  549. PLATFORM(INTEL_TIGERLAKE),
  550. .platform_engine_mask =
  551. BIT(RCS0) | BIT(BCS0) | BIT(VECS0) | BIT(VCS0) | BIT(VCS2),
  552. };
  553. static const struct intel_device_info rkl_info = {
  554. GEN12_FEATURES,
  555. PLATFORM(INTEL_ROCKETLAKE),
  556. .platform_engine_mask =
  557. BIT(RCS0) | BIT(BCS0) | BIT(VECS0) | BIT(VCS0),
  558. };
  559. #define DGFX_FEATURES \
  560. .memory_regions = BIT(INTEL_REGION_SMEM) | BIT(INTEL_REGION_LMEM_0) | BIT(INTEL_REGION_STOLEN_LMEM), \
  561. .has_llc = 0, \
  562. .has_pxp = 0, \
  563. .has_snoop = 1, \
  564. .is_dgfx = 1, \
  565. .has_heci_gscfi = 1
  566. static const struct intel_device_info dg1_info = {
  567. GEN12_FEATURES,
  568. DGFX_FEATURES,
  569. .__runtime.graphics.ip.rel = 10,
  570. PLATFORM(INTEL_DG1),
  571. .platform_engine_mask =
  572. BIT(RCS0) | BIT(BCS0) | BIT(VECS0) |
  573. BIT(VCS0) | BIT(VCS2),
  574. /* Wa_16011227922 */
  575. .__runtime.ppgtt_size = 47,
  576. };
  577. static const struct intel_device_info adl_s_info = {
  578. GEN12_FEATURES,
  579. PLATFORM(INTEL_ALDERLAKE_S),
  580. .platform_engine_mask =
  581. BIT(RCS0) | BIT(BCS0) | BIT(VECS0) | BIT(VCS0) | BIT(VCS2),
  582. .dma_mask_size = 39,
  583. };
  584. static const struct intel_device_info adl_p_info = {
  585. GEN12_FEATURES,
  586. PLATFORM(INTEL_ALDERLAKE_P),
  587. .platform_engine_mask =
  588. BIT(RCS0) | BIT(BCS0) | BIT(VECS0) | BIT(VCS0) | BIT(VCS2),
  589. .__runtime.ppgtt_size = 48,
  590. .dma_mask_size = 39,
  591. };
  592. #undef GEN
  593. #define XE_HP_PAGE_SIZES \
  594. .__runtime.page_sizes = I915_GTT_PAGE_SIZE_4K | \
  595. I915_GTT_PAGE_SIZE_64K | \
  596. I915_GTT_PAGE_SIZE_2M
  597. #define XE_HP_FEATURES \
  598. XE_HP_PAGE_SIZES, \
  599. TGL_CACHELEVEL, \
  600. .dma_mask_size = 46, \
  601. .has_3d_pipeline = 1, \
  602. .has_64bit_reloc = 1, \
  603. .has_flat_ccs = 1, \
  604. .has_global_mocs = 1, \
  605. .has_gt_uc = 1, \
  606. .has_llc = 1, \
  607. .has_logical_ring_contexts = 1, \
  608. .has_logical_ring_elsq = 1, \
  609. .has_mslice_steering = 1, \
  610. .has_oa_bpc_reporting = 1, \
  611. .has_oa_slice_contrib_limits = 1, \
  612. .has_oam = 1, \
  613. .has_rc6 = 1, \
  614. .has_reset_engine = 1, \
  615. .has_rps = 1, \
  616. .has_runtime_pm = 1, \
  617. .max_pat_index = 3, \
  618. .__runtime.ppgtt_size = 48, \
  619. .__runtime.ppgtt_type = INTEL_PPGTT_FULL
  620. #define DG2_FEATURES \
  621. XE_HP_FEATURES, \
  622. DGFX_FEATURES, \
  623. .__runtime.graphics.ip.ver = 12, \
  624. .__runtime.graphics.ip.rel = 55, \
  625. .__runtime.media.ip.ver = 12, \
  626. .__runtime.media.ip.rel = 55, \
  627. PLATFORM(INTEL_DG2), \
  628. .has_64k_pages = 1, \
  629. .has_guc_deprivilege = 1, \
  630. .has_heci_pxp = 1, \
  631. .has_media_ratio_mode = 1, \
  632. .platform_engine_mask = \
  633. BIT(RCS0) | BIT(BCS0) | \
  634. BIT(VECS0) | BIT(VECS1) | \
  635. BIT(VCS0) | BIT(VCS2) | \
  636. BIT(CCS0) | BIT(CCS1) | BIT(CCS2) | BIT(CCS3)
  637. static const struct intel_device_info dg2_info = {
  638. DG2_FEATURES,
  639. };
  640. static const struct intel_device_info ats_m_info = {
  641. DG2_FEATURES,
  642. .require_force_probe = 1,
  643. .tuning_thread_rr_after_dep = 1,
  644. };
  645. static const struct intel_gt_definition xelpmp_extra_gt[] = {
  646. {
  647. .type = GT_MEDIA,
  648. .name = "Standalone Media GT",
  649. .gsi_offset = MTL_MEDIA_GSI_BASE,
  650. .engine_mask = BIT(VECS0) | BIT(VCS0) | BIT(VCS2) | BIT(GSC0),
  651. },
  652. {}
  653. };
  654. static const struct intel_device_info mtl_info = {
  655. XE_HP_FEATURES,
  656. /*
  657. * Real graphics IP version will be obtained from hardware GMD_ID
  658. * register. Value provided here is just for sanity checking.
  659. */
  660. .__runtime.graphics.ip.ver = 12,
  661. .__runtime.graphics.ip.rel = 70,
  662. .__runtime.media.ip.ver = 13,
  663. PLATFORM(INTEL_METEORLAKE),
  664. .extra_gt_list = xelpmp_extra_gt,
  665. .has_flat_ccs = 0,
  666. .has_gmd_id = 1,
  667. .has_guc_deprivilege = 1,
  668. .has_guc_tlb_invalidation = 1,
  669. .has_llc = 0,
  670. .has_mslice_steering = 0,
  671. .has_snoop = 1,
  672. .max_pat_index = 4,
  673. .has_pxp = 1,
  674. .memory_regions = BIT(INTEL_REGION_SMEM) | BIT(INTEL_REGION_STOLEN_LMEM),
  675. .platform_engine_mask = BIT(RCS0) | BIT(BCS0) | BIT(CCS0),
  676. MTL_CACHELEVEL,
  677. };
  678. #undef PLATFORM
  679. __diag_pop();
  680. /*
  681. * Make sure any device matches here are from most specific to most
  682. * general. For example, since the Quanta match is based on the subsystem
  683. * and subvendor IDs, we need it to come before the more general IVB
  684. * PCI ID matches, otherwise we'll use the wrong info struct above.
  685. */
  686. static const struct pci_device_id pciidlist[] = {
  687. INTEL_I830_IDS(INTEL_VGA_DEVICE, &i830_info),
  688. INTEL_I845G_IDS(INTEL_VGA_DEVICE, &i845g_info),
  689. INTEL_I85X_IDS(INTEL_VGA_DEVICE, &i85x_info),
  690. INTEL_I865G_IDS(INTEL_VGA_DEVICE, &i865g_info),
  691. INTEL_I915G_IDS(INTEL_VGA_DEVICE, &i915g_info),
  692. INTEL_I915GM_IDS(INTEL_VGA_DEVICE, &i915gm_info),
  693. INTEL_I945G_IDS(INTEL_VGA_DEVICE, &i945g_info),
  694. INTEL_I945GM_IDS(INTEL_VGA_DEVICE, &i945gm_info),
  695. INTEL_I965G_IDS(INTEL_VGA_DEVICE, &i965g_info),
  696. INTEL_G33_IDS(INTEL_VGA_DEVICE, &g33_info),
  697. INTEL_I965GM_IDS(INTEL_VGA_DEVICE, &i965gm_info),
  698. INTEL_GM45_IDS(INTEL_VGA_DEVICE, &gm45_info),
  699. INTEL_G45_IDS(INTEL_VGA_DEVICE, &g45_info),
  700. INTEL_PNV_G_IDS(INTEL_VGA_DEVICE, &pnv_g_info),
  701. INTEL_PNV_M_IDS(INTEL_VGA_DEVICE, &pnv_m_info),
  702. INTEL_ILK_D_IDS(INTEL_VGA_DEVICE, &ilk_d_info),
  703. INTEL_ILK_M_IDS(INTEL_VGA_DEVICE, &ilk_m_info),
  704. INTEL_SNB_D_GT1_IDS(INTEL_VGA_DEVICE, &snb_d_gt1_info),
  705. INTEL_SNB_D_GT2_IDS(INTEL_VGA_DEVICE, &snb_d_gt2_info),
  706. INTEL_SNB_M_GT1_IDS(INTEL_VGA_DEVICE, &snb_m_gt1_info),
  707. INTEL_SNB_M_GT2_IDS(INTEL_VGA_DEVICE, &snb_m_gt2_info),
  708. INTEL_IVB_Q_IDS(INTEL_VGA_DEVICE, &ivb_q_info), /* must be first IVB */
  709. INTEL_IVB_M_GT1_IDS(INTEL_VGA_DEVICE, &ivb_m_gt1_info),
  710. INTEL_IVB_M_GT2_IDS(INTEL_VGA_DEVICE, &ivb_m_gt2_info),
  711. INTEL_IVB_D_GT1_IDS(INTEL_VGA_DEVICE, &ivb_d_gt1_info),
  712. INTEL_IVB_D_GT2_IDS(INTEL_VGA_DEVICE, &ivb_d_gt2_info),
  713. INTEL_HSW_GT1_IDS(INTEL_VGA_DEVICE, &hsw_gt1_info),
  714. INTEL_HSW_GT2_IDS(INTEL_VGA_DEVICE, &hsw_gt2_info),
  715. INTEL_HSW_GT3_IDS(INTEL_VGA_DEVICE, &hsw_gt3_info),
  716. INTEL_VLV_IDS(INTEL_VGA_DEVICE, &vlv_info),
  717. INTEL_BDW_GT1_IDS(INTEL_VGA_DEVICE, &bdw_gt1_info),
  718. INTEL_BDW_GT2_IDS(INTEL_VGA_DEVICE, &bdw_gt2_info),
  719. INTEL_BDW_GT3_IDS(INTEL_VGA_DEVICE, &bdw_gt3_info),
  720. INTEL_BDW_RSVD_IDS(INTEL_VGA_DEVICE, &bdw_rsvd_info),
  721. INTEL_CHV_IDS(INTEL_VGA_DEVICE, &chv_info),
  722. INTEL_SKL_GT1_IDS(INTEL_VGA_DEVICE, &skl_gt1_info),
  723. INTEL_SKL_GT2_IDS(INTEL_VGA_DEVICE, &skl_gt2_info),
  724. INTEL_SKL_GT3_IDS(INTEL_VGA_DEVICE, &skl_gt3_info),
  725. INTEL_SKL_GT4_IDS(INTEL_VGA_DEVICE, &skl_gt4_info),
  726. INTEL_BXT_IDS(INTEL_VGA_DEVICE, &bxt_info),
  727. INTEL_GLK_IDS(INTEL_VGA_DEVICE, &glk_info),
  728. INTEL_KBL_GT1_IDS(INTEL_VGA_DEVICE, &kbl_gt1_info),
  729. INTEL_KBL_GT2_IDS(INTEL_VGA_DEVICE, &kbl_gt2_info),
  730. INTEL_KBL_GT3_IDS(INTEL_VGA_DEVICE, &kbl_gt3_info),
  731. INTEL_KBL_GT4_IDS(INTEL_VGA_DEVICE, &kbl_gt3_info),
  732. INTEL_AML_KBL_GT2_IDS(INTEL_VGA_DEVICE, &kbl_gt2_info),
  733. INTEL_CFL_S_GT1_IDS(INTEL_VGA_DEVICE, &cfl_gt1_info),
  734. INTEL_CFL_S_GT2_IDS(INTEL_VGA_DEVICE, &cfl_gt2_info),
  735. INTEL_CFL_H_GT1_IDS(INTEL_VGA_DEVICE, &cfl_gt1_info),
  736. INTEL_CFL_H_GT2_IDS(INTEL_VGA_DEVICE, &cfl_gt2_info),
  737. INTEL_CFL_U_GT2_IDS(INTEL_VGA_DEVICE, &cfl_gt2_info),
  738. INTEL_CFL_U_GT3_IDS(INTEL_VGA_DEVICE, &cfl_gt3_info),
  739. INTEL_WHL_U_GT1_IDS(INTEL_VGA_DEVICE, &cfl_gt1_info),
  740. INTEL_WHL_U_GT2_IDS(INTEL_VGA_DEVICE, &cfl_gt2_info),
  741. INTEL_AML_CFL_GT2_IDS(INTEL_VGA_DEVICE, &cfl_gt2_info),
  742. INTEL_WHL_U_GT3_IDS(INTEL_VGA_DEVICE, &cfl_gt3_info),
  743. INTEL_CML_GT1_IDS(INTEL_VGA_DEVICE, &cml_gt1_info),
  744. INTEL_CML_GT2_IDS(INTEL_VGA_DEVICE, &cml_gt2_info),
  745. INTEL_CML_U_GT1_IDS(INTEL_VGA_DEVICE, &cml_gt1_info),
  746. INTEL_CML_U_GT2_IDS(INTEL_VGA_DEVICE, &cml_gt2_info),
  747. INTEL_ICL_IDS(INTEL_VGA_DEVICE, &icl_info),
  748. INTEL_EHL_IDS(INTEL_VGA_DEVICE, &ehl_info),
  749. INTEL_JSL_IDS(INTEL_VGA_DEVICE, &jsl_info),
  750. INTEL_TGL_IDS(INTEL_VGA_DEVICE, &tgl_info),
  751. INTEL_RKL_IDS(INTEL_VGA_DEVICE, &rkl_info),
  752. INTEL_ADLS_IDS(INTEL_VGA_DEVICE, &adl_s_info),
  753. INTEL_ADLP_IDS(INTEL_VGA_DEVICE, &adl_p_info),
  754. INTEL_ADLN_IDS(INTEL_VGA_DEVICE, &adl_p_info),
  755. INTEL_DG1_IDS(INTEL_VGA_DEVICE, &dg1_info),
  756. INTEL_RPLS_IDS(INTEL_VGA_DEVICE, &adl_s_info),
  757. INTEL_RPLU_IDS(INTEL_VGA_DEVICE, &adl_p_info),
  758. INTEL_RPLP_IDS(INTEL_VGA_DEVICE, &adl_p_info),
  759. INTEL_DG2_IDS(INTEL_VGA_DEVICE, &dg2_info),
  760. INTEL_ATS_M_IDS(INTEL_VGA_DEVICE, &ats_m_info),
  761. INTEL_ARL_IDS(INTEL_VGA_DEVICE, &mtl_info),
  762. INTEL_MTL_IDS(INTEL_VGA_DEVICE, &mtl_info),
  763. {}
  764. };
  765. MODULE_DEVICE_TABLE(pci, pciidlist);
  766. static void i915_pci_remove(struct pci_dev *pdev)
  767. {
  768. struct drm_i915_private *i915;
  769. i915 = pdev_to_i915(pdev);
  770. if (!i915) /* driver load aborted, nothing to cleanup */
  771. return;
  772. i915_driver_remove(i915);
  773. pci_set_drvdata(pdev, NULL);
  774. }
  775. /* is device_id present in comma separated list of ids */
  776. static bool device_id_in_list(u16 device_id, const char *devices, bool negative)
  777. {
  778. char *s, *p, *tok;
  779. bool ret;
  780. if (!devices || !*devices)
  781. return false;
  782. /* match everything */
  783. if (negative && strcmp(devices, "!*") == 0)
  784. return true;
  785. if (!negative && strcmp(devices, "*") == 0)
  786. return true;
  787. s = kstrdup(devices, GFP_KERNEL);
  788. if (!s)
  789. return false;
  790. for (p = s, ret = false; (tok = strsep(&p, ",")) != NULL; ) {
  791. u16 val;
  792. if (negative && tok[0] == '!')
  793. tok++;
  794. else if ((negative && tok[0] != '!') ||
  795. (!negative && tok[0] == '!'))
  796. continue;
  797. if (kstrtou16(tok, 16, &val) == 0 && val == device_id) {
  798. ret = true;
  799. break;
  800. }
  801. }
  802. kfree(s);
  803. return ret;
  804. }
  805. static bool id_forced(u16 device_id)
  806. {
  807. return device_id_in_list(device_id, i915_modparams.force_probe, false);
  808. }
  809. static bool id_blocked(u16 device_id)
  810. {
  811. return device_id_in_list(device_id, i915_modparams.force_probe, true);
  812. }
  813. bool i915_pci_resource_valid(struct pci_dev *pdev, int bar)
  814. {
  815. if (!pci_resource_flags(pdev, bar))
  816. return false;
  817. if (pci_resource_flags(pdev, bar) & IORESOURCE_UNSET)
  818. return false;
  819. if (!pci_resource_len(pdev, bar))
  820. return false;
  821. return true;
  822. }
  823. static bool intel_mmio_bar_valid(struct pci_dev *pdev, struct intel_device_info *intel_info)
  824. {
  825. return i915_pci_resource_valid(pdev, intel_mmio_bar(intel_info->__runtime.graphics.ip.ver));
  826. }
  827. static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
  828. {
  829. struct intel_device_info *intel_info =
  830. (struct intel_device_info *) ent->driver_data;
  831. int err;
  832. if (intel_info->require_force_probe && !id_forced(pdev->device)) {
  833. dev_info(&pdev->dev,
  834. "Your graphics device %04x is not properly supported by i915 in this\n"
  835. "kernel version. To force driver probe anyway, use i915.force_probe=%04x\n"
  836. "module parameter or CONFIG_DRM_I915_FORCE_PROBE=%04x configuration option,\n"
  837. "or (recommended) check for kernel updates.\n",
  838. pdev->device, pdev->device, pdev->device);
  839. return -ENODEV;
  840. }
  841. if (id_blocked(pdev->device)) {
  842. dev_info(&pdev->dev, "I915 probe blocked for Device ID %04x.\n",
  843. pdev->device);
  844. return -ENODEV;
  845. }
  846. if (intel_info->require_force_probe) {
  847. dev_info(&pdev->dev, "Force probing unsupported Device ID %04x, tainting kernel\n",
  848. pdev->device);
  849. add_taint(TAINT_USER, LOCKDEP_STILL_OK);
  850. }
  851. /* Only bind to function 0 of the device. Early generations
  852. * used function 1 as a placeholder for multi-head. This causes
  853. * us confusion instead, especially on the systems where both
  854. * functions have the same PCI-ID!
  855. */
  856. if (PCI_FUNC(pdev->devfn))
  857. return -ENODEV;
  858. if (!intel_mmio_bar_valid(pdev, intel_info))
  859. return -ENXIO;
  860. /* Detect if we need to wait for other drivers early on */
  861. if (intel_display_driver_probe_defer(pdev))
  862. return -EPROBE_DEFER;
  863. err = i915_driver_probe(pdev, ent);
  864. if (err)
  865. return err;
  866. err = i915_live_selftests(pdev);
  867. if (err) {
  868. i915_pci_remove(pdev);
  869. return err > 0 ? -ENOTTY : err;
  870. }
  871. err = i915_perf_selftests(pdev);
  872. if (err) {
  873. i915_pci_remove(pdev);
  874. return err > 0 ? -ENOTTY : err;
  875. }
  876. return 0;
  877. }
  878. ALLOW_ERROR_INJECTION(i915_pci_probe, ERRNO);
  879. static void i915_pci_shutdown(struct pci_dev *pdev)
  880. {
  881. struct drm_i915_private *i915 = pdev_to_i915(pdev);
  882. i915_driver_shutdown(i915);
  883. }
  884. static struct pci_driver i915_pci_driver = {
  885. .name = DRIVER_NAME,
  886. .id_table = pciidlist,
  887. .probe = i915_pci_probe,
  888. .remove = i915_pci_remove,
  889. .shutdown = i915_pci_shutdown,
  890. .driver.pm = &i915_pm_ops,
  891. };
  892. int i915_pci_register_driver(void)
  893. {
  894. return pci_register_driver(&i915_pci_driver);
  895. }
  896. void i915_pci_unregister_driver(void)
  897. {
  898. pci_unregister_driver(&i915_pci_driver);
  899. }