intel_device_info.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  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/string_helpers.h>
  25. #include <drm/drm_print.h>
  26. #include <drm/intel/pciids.h>
  27. #include "gt/intel_gt_regs.h"
  28. #include "i915_drv.h"
  29. #include "i915_reg.h"
  30. #include "i915_utils.h"
  31. #include "intel_device_info.h"
  32. #define PLATFORM_NAME(x) [INTEL_##x] = #x
  33. static const char * const platform_names[] = {
  34. PLATFORM_NAME(I830),
  35. PLATFORM_NAME(I845G),
  36. PLATFORM_NAME(I85X),
  37. PLATFORM_NAME(I865G),
  38. PLATFORM_NAME(I915G),
  39. PLATFORM_NAME(I915GM),
  40. PLATFORM_NAME(I945G),
  41. PLATFORM_NAME(I945GM),
  42. PLATFORM_NAME(G33),
  43. PLATFORM_NAME(PINEVIEW),
  44. PLATFORM_NAME(I965G),
  45. PLATFORM_NAME(I965GM),
  46. PLATFORM_NAME(G45),
  47. PLATFORM_NAME(GM45),
  48. PLATFORM_NAME(IRONLAKE),
  49. PLATFORM_NAME(SANDYBRIDGE),
  50. PLATFORM_NAME(IVYBRIDGE),
  51. PLATFORM_NAME(VALLEYVIEW),
  52. PLATFORM_NAME(HASWELL),
  53. PLATFORM_NAME(BROADWELL),
  54. PLATFORM_NAME(CHERRYVIEW),
  55. PLATFORM_NAME(SKYLAKE),
  56. PLATFORM_NAME(BROXTON),
  57. PLATFORM_NAME(KABYLAKE),
  58. PLATFORM_NAME(GEMINILAKE),
  59. PLATFORM_NAME(COFFEELAKE),
  60. PLATFORM_NAME(COMETLAKE),
  61. PLATFORM_NAME(ICELAKE),
  62. PLATFORM_NAME(ELKHARTLAKE),
  63. PLATFORM_NAME(JASPERLAKE),
  64. PLATFORM_NAME(TIGERLAKE),
  65. PLATFORM_NAME(ROCKETLAKE),
  66. PLATFORM_NAME(DG1),
  67. PLATFORM_NAME(ALDERLAKE_S),
  68. PLATFORM_NAME(ALDERLAKE_P),
  69. PLATFORM_NAME(DG2),
  70. PLATFORM_NAME(METEORLAKE),
  71. };
  72. #undef PLATFORM_NAME
  73. const char *intel_platform_name(enum intel_platform platform)
  74. {
  75. BUILD_BUG_ON(ARRAY_SIZE(platform_names) != INTEL_MAX_PLATFORMS);
  76. if (WARN_ON_ONCE(platform >= ARRAY_SIZE(platform_names) ||
  77. platform_names[platform] == NULL))
  78. return "<unknown>";
  79. return platform_names[platform];
  80. }
  81. void intel_device_info_print(const struct intel_device_info *info,
  82. const struct intel_runtime_info *runtime,
  83. struct drm_printer *p)
  84. {
  85. if (runtime->graphics.ip.rel)
  86. drm_printf(p, "graphics version: %u.%02u\n",
  87. runtime->graphics.ip.ver,
  88. runtime->graphics.ip.rel);
  89. else
  90. drm_printf(p, "graphics version: %u\n",
  91. runtime->graphics.ip.ver);
  92. if (runtime->media.ip.rel)
  93. drm_printf(p, "media version: %u.%02u\n",
  94. runtime->media.ip.ver,
  95. runtime->media.ip.rel);
  96. else
  97. drm_printf(p, "media version: %u\n",
  98. runtime->media.ip.ver);
  99. drm_printf(p, "graphics stepping: %s\n", intel_step_name(runtime->step.graphics_step));
  100. drm_printf(p, "media stepping: %s\n", intel_step_name(runtime->step.media_step));
  101. drm_printf(p, "gt: %d\n", info->gt);
  102. drm_printf(p, "memory-regions: 0x%x\n", info->memory_regions);
  103. drm_printf(p, "page-sizes: 0x%x\n", runtime->page_sizes);
  104. drm_printf(p, "platform: %s\n", intel_platform_name(info->platform));
  105. drm_printf(p, "ppgtt-size: %d\n", runtime->ppgtt_size);
  106. drm_printf(p, "ppgtt-type: %d\n", runtime->ppgtt_type);
  107. drm_printf(p, "dma_mask_size: %u\n", info->dma_mask_size);
  108. #define PRINT_FLAG(name) drm_printf(p, "%s: %s\n", #name, str_yes_no(info->name))
  109. DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG);
  110. #undef PRINT_FLAG
  111. drm_printf(p, "has_pooled_eu: %s\n", str_yes_no(runtime->has_pooled_eu));
  112. }
  113. #define ID(id) (id)
  114. static const u16 subplatform_ult_ids[] = {
  115. INTEL_HSW_ULT_GT1_IDS(ID),
  116. INTEL_HSW_ULT_GT2_IDS(ID),
  117. INTEL_HSW_ULT_GT3_IDS(ID),
  118. INTEL_BDW_ULT_GT1_IDS(ID),
  119. INTEL_BDW_ULT_GT2_IDS(ID),
  120. INTEL_BDW_ULT_GT3_IDS(ID),
  121. INTEL_BDW_ULT_RSVD_IDS(ID),
  122. INTEL_SKL_ULT_GT1_IDS(ID),
  123. INTEL_SKL_ULT_GT2_IDS(ID),
  124. INTEL_SKL_ULT_GT3_IDS(ID),
  125. INTEL_KBL_ULT_GT1_IDS(ID),
  126. INTEL_KBL_ULT_GT2_IDS(ID),
  127. INTEL_KBL_ULT_GT3_IDS(ID),
  128. INTEL_CFL_U_GT2_IDS(ID),
  129. INTEL_CFL_U_GT3_IDS(ID),
  130. INTEL_WHL_U_GT1_IDS(ID),
  131. INTEL_WHL_U_GT2_IDS(ID),
  132. INTEL_WHL_U_GT3_IDS(ID),
  133. INTEL_CML_U_GT1_IDS(ID),
  134. INTEL_CML_U_GT2_IDS(ID),
  135. };
  136. static const u16 subplatform_ulx_ids[] = {
  137. INTEL_HSW_ULX_GT1_IDS(ID),
  138. INTEL_HSW_ULX_GT2_IDS(ID),
  139. INTEL_BDW_ULX_GT1_IDS(ID),
  140. INTEL_BDW_ULX_GT2_IDS(ID),
  141. INTEL_BDW_ULX_GT3_IDS(ID),
  142. INTEL_BDW_ULX_RSVD_IDS(ID),
  143. INTEL_SKL_ULX_GT1_IDS(ID),
  144. INTEL_SKL_ULX_GT2_IDS(ID),
  145. INTEL_KBL_ULX_GT1_IDS(ID),
  146. INTEL_KBL_ULX_GT2_IDS(ID),
  147. INTEL_AML_KBL_GT2_IDS(ID),
  148. INTEL_AML_CFL_GT2_IDS(ID),
  149. };
  150. static const u16 subplatform_portf_ids[] = {
  151. INTEL_ICL_PORT_F_IDS(ID),
  152. };
  153. static const u16 subplatform_uy_ids[] = {
  154. INTEL_TGL_GT2_IDS(ID),
  155. };
  156. static const u16 subplatform_n_ids[] = {
  157. INTEL_ADLN_IDS(ID),
  158. };
  159. static const u16 subplatform_rpl_ids[] = {
  160. INTEL_RPLS_IDS(ID),
  161. INTEL_RPLU_IDS(ID),
  162. INTEL_RPLP_IDS(ID),
  163. };
  164. static const u16 subplatform_rplu_ids[] = {
  165. INTEL_RPLU_IDS(ID),
  166. };
  167. static const u16 subplatform_g10_ids[] = {
  168. INTEL_DG2_G10_IDS(ID),
  169. INTEL_ATS_M150_IDS(ID),
  170. };
  171. static const u16 subplatform_g11_ids[] = {
  172. INTEL_DG2_G11_IDS(ID),
  173. INTEL_ATS_M75_IDS(ID),
  174. };
  175. static const u16 subplatform_g12_ids[] = {
  176. INTEL_DG2_G12_IDS(ID),
  177. };
  178. static const u16 subplatform_dg2_d_ids[] = {
  179. INTEL_DG2_D_IDS(ID),
  180. };
  181. static const u16 subplatform_arl_h_ids[] = {
  182. INTEL_ARL_H_IDS(ID),
  183. };
  184. static const u16 subplatform_arl_u_ids[] = {
  185. INTEL_ARL_U_IDS(ID),
  186. };
  187. static const u16 subplatform_arl_s_ids[] = {
  188. INTEL_ARL_S_IDS(ID),
  189. };
  190. static bool find_devid(u16 id, const u16 *p, unsigned int num)
  191. {
  192. for (; num; num--, p++) {
  193. if (*p == id)
  194. return true;
  195. }
  196. return false;
  197. }
  198. static void intel_device_info_subplatform_init(struct drm_i915_private *i915)
  199. {
  200. const struct intel_device_info *info = INTEL_INFO(i915);
  201. const struct intel_runtime_info *rinfo = RUNTIME_INFO(i915);
  202. const unsigned int pi = __platform_mask_index(rinfo, info->platform);
  203. const unsigned int pb = __platform_mask_bit(rinfo, info->platform);
  204. u16 devid = INTEL_DEVID(i915);
  205. u32 mask = 0;
  206. /* Make sure IS_<platform> checks are working. */
  207. RUNTIME_INFO(i915)->platform_mask[pi] = BIT(pb);
  208. /* Find and mark subplatform bits based on the PCI device id. */
  209. if (find_devid(devid, subplatform_ult_ids,
  210. ARRAY_SIZE(subplatform_ult_ids))) {
  211. mask = BIT(INTEL_SUBPLATFORM_ULT);
  212. } else if (find_devid(devid, subplatform_ulx_ids,
  213. ARRAY_SIZE(subplatform_ulx_ids))) {
  214. mask = BIT(INTEL_SUBPLATFORM_ULX);
  215. if (IS_HASWELL(i915) || IS_BROADWELL(i915)) {
  216. /* ULX machines are also considered ULT. */
  217. mask |= BIT(INTEL_SUBPLATFORM_ULT);
  218. }
  219. } else if (find_devid(devid, subplatform_portf_ids,
  220. ARRAY_SIZE(subplatform_portf_ids))) {
  221. mask = BIT(INTEL_SUBPLATFORM_PORTF);
  222. } else if (find_devid(devid, subplatform_uy_ids,
  223. ARRAY_SIZE(subplatform_uy_ids))) {
  224. mask = BIT(INTEL_SUBPLATFORM_UY);
  225. } else if (find_devid(devid, subplatform_n_ids,
  226. ARRAY_SIZE(subplatform_n_ids))) {
  227. mask = BIT(INTEL_SUBPLATFORM_N);
  228. } else if (find_devid(devid, subplatform_rpl_ids,
  229. ARRAY_SIZE(subplatform_rpl_ids))) {
  230. mask = BIT(INTEL_SUBPLATFORM_RPL);
  231. if (find_devid(devid, subplatform_rplu_ids,
  232. ARRAY_SIZE(subplatform_rplu_ids)))
  233. mask |= BIT(INTEL_SUBPLATFORM_RPLU);
  234. } else if (find_devid(devid, subplatform_g10_ids,
  235. ARRAY_SIZE(subplatform_g10_ids))) {
  236. mask = BIT(INTEL_SUBPLATFORM_G10);
  237. } else if (find_devid(devid, subplatform_g11_ids,
  238. ARRAY_SIZE(subplatform_g11_ids))) {
  239. mask = BIT(INTEL_SUBPLATFORM_G11);
  240. } else if (find_devid(devid, subplatform_g12_ids,
  241. ARRAY_SIZE(subplatform_g12_ids))) {
  242. mask = BIT(INTEL_SUBPLATFORM_G12);
  243. } else if (find_devid(devid, subplatform_arl_h_ids,
  244. ARRAY_SIZE(subplatform_arl_h_ids))) {
  245. mask = BIT(INTEL_SUBPLATFORM_ARL_H);
  246. } else if (find_devid(devid, subplatform_arl_u_ids,
  247. ARRAY_SIZE(subplatform_arl_u_ids))) {
  248. mask = BIT(INTEL_SUBPLATFORM_ARL_U);
  249. } else if (find_devid(devid, subplatform_arl_s_ids,
  250. ARRAY_SIZE(subplatform_arl_s_ids))) {
  251. mask = BIT(INTEL_SUBPLATFORM_ARL_S);
  252. }
  253. /* DG2_D ids span across multiple DG2 subplatforms */
  254. if (find_devid(devid, subplatform_dg2_d_ids,
  255. ARRAY_SIZE(subplatform_dg2_d_ids)))
  256. mask |= BIT(INTEL_SUBPLATFORM_D);
  257. GEM_BUG_ON(mask & ~INTEL_SUBPLATFORM_MASK);
  258. RUNTIME_INFO(i915)->platform_mask[pi] |= mask;
  259. }
  260. static void ip_ver_read(struct drm_i915_private *i915, u32 offset, struct intel_ip_version *ip)
  261. {
  262. struct pci_dev *pdev = to_pci_dev(i915->drm.dev);
  263. void __iomem *addr;
  264. u32 val;
  265. u8 expected_ver = ip->ver;
  266. u8 expected_rel = ip->rel;
  267. addr = pci_iomap_range(pdev, 0, offset, sizeof(u32));
  268. if (drm_WARN_ON(&i915->drm, !addr))
  269. return;
  270. val = ioread32(addr);
  271. pci_iounmap(pdev, addr);
  272. ip->ver = REG_FIELD_GET(GMD_ID_ARCH_MASK, val);
  273. ip->rel = REG_FIELD_GET(GMD_ID_RELEASE_MASK, val);
  274. ip->step = REG_FIELD_GET(GMD_ID_STEP, val);
  275. /* Sanity check against expected versions from device info */
  276. if (IP_VER(ip->ver, ip->rel) < IP_VER(expected_ver, expected_rel))
  277. drm_dbg(&i915->drm,
  278. "Hardware reports GMD IP version %u.%u (REG[0x%x] = 0x%08x) but minimum expected is %u.%u\n",
  279. ip->ver, ip->rel, offset, val, expected_ver, expected_rel);
  280. }
  281. /*
  282. * Setup the graphics version for the current device. This must be done before
  283. * any code that performs checks on GRAPHICS_VER or DISPLAY_VER, so this
  284. * function should be called very early in the driver initialization sequence.
  285. *
  286. * Regular MMIO access is not yet setup at the point this function is called so
  287. * we peek at the appropriate MMIO offset directly. The GMD_ID register is
  288. * part of an 'always on' power well by design, so we don't need to worry about
  289. * forcewake while reading it.
  290. */
  291. static void intel_ipver_early_init(struct drm_i915_private *i915)
  292. {
  293. struct intel_runtime_info *runtime = RUNTIME_INFO(i915);
  294. if (!HAS_GMD_ID(i915)) {
  295. drm_WARN_ON(&i915->drm, RUNTIME_INFO(i915)->graphics.ip.ver > 12);
  296. /*
  297. * On older platforms, graphics and media share the same ip
  298. * version and release.
  299. */
  300. RUNTIME_INFO(i915)->media.ip =
  301. RUNTIME_INFO(i915)->graphics.ip;
  302. return;
  303. }
  304. ip_ver_read(i915, i915_mmio_reg_offset(GMD_ID_GRAPHICS),
  305. &runtime->graphics.ip);
  306. /* Wa_22012778468 */
  307. if (runtime->graphics.ip.ver == 0x0 &&
  308. INTEL_INFO(i915)->platform == INTEL_METEORLAKE) {
  309. RUNTIME_INFO(i915)->graphics.ip.ver = 12;
  310. RUNTIME_INFO(i915)->graphics.ip.rel = 70;
  311. }
  312. ip_ver_read(i915, i915_mmio_reg_offset(GMD_ID_MEDIA),
  313. &runtime->media.ip);
  314. }
  315. /**
  316. * intel_device_info_runtime_init_early - initialize early runtime info
  317. * @i915: the i915 device
  318. *
  319. * Determine early intel_device_info fields at runtime. This function needs
  320. * to be called before the MMIO has been setup.
  321. */
  322. void intel_device_info_runtime_init_early(struct drm_i915_private *i915)
  323. {
  324. intel_ipver_early_init(i915);
  325. intel_device_info_subplatform_init(i915);
  326. }
  327. /**
  328. * intel_device_info_runtime_init - initialize runtime info
  329. * @dev_priv: the i915 device
  330. *
  331. * Determine various intel_device_info fields at runtime.
  332. *
  333. * Use it when either:
  334. * - it's judged too laborious to fill n static structures with the limit
  335. * when a simple if statement does the job,
  336. * - run-time checks (eg read fuse/strap registers) are needed.
  337. *
  338. * This function needs to be called:
  339. * - after the MMIO has been setup as we are reading registers,
  340. * - after the PCH has been detected,
  341. * - before the first usage of the fields it can tweak.
  342. */
  343. void intel_device_info_runtime_init(struct drm_i915_private *dev_priv)
  344. {
  345. struct intel_runtime_info *runtime = RUNTIME_INFO(dev_priv);
  346. BUILD_BUG_ON(BITS_PER_TYPE(intel_engine_mask_t) < I915_NUM_ENGINES);
  347. if (GRAPHICS_VER(dev_priv) == 6 && i915_vtd_active(dev_priv)) {
  348. drm_info(&dev_priv->drm,
  349. "Disabling ppGTT for VT-d support\n");
  350. runtime->ppgtt_type = INTEL_PPGTT_NONE;
  351. }
  352. }
  353. /*
  354. * Set up device info and initial runtime info at driver create.
  355. *
  356. * Note: i915 is only an allocated blob of memory at this point.
  357. */
  358. void intel_device_info_driver_create(struct drm_i915_private *i915,
  359. u16 device_id,
  360. const struct intel_device_info *match_info)
  361. {
  362. struct intel_runtime_info *runtime;
  363. /* Setup INTEL_INFO() */
  364. i915->__info = match_info;
  365. /* Initialize initial runtime info from static const data and pdev. */
  366. runtime = RUNTIME_INFO(i915);
  367. memcpy(runtime, &INTEL_INFO(i915)->__runtime, sizeof(*runtime));
  368. runtime->device_id = device_id;
  369. }
  370. void intel_driver_caps_print(const struct intel_driver_caps *caps,
  371. struct drm_printer *p)
  372. {
  373. drm_printf(p, "Has logical contexts? %s\n",
  374. str_yes_no(caps->has_logical_contexts));
  375. drm_printf(p, "scheduler: 0x%x\n", caps->scheduler);
  376. }