intel_device_info.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  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 "i915_drv.h"
  25. #define PLATFORM_NAME(x) [INTEL_##x] = #x
  26. static const char * const platform_names[] = {
  27. PLATFORM_NAME(I830),
  28. PLATFORM_NAME(I845G),
  29. PLATFORM_NAME(I85X),
  30. PLATFORM_NAME(I865G),
  31. PLATFORM_NAME(I915G),
  32. PLATFORM_NAME(I915GM),
  33. PLATFORM_NAME(I945G),
  34. PLATFORM_NAME(I945GM),
  35. PLATFORM_NAME(G33),
  36. PLATFORM_NAME(PINEVIEW),
  37. PLATFORM_NAME(I965G),
  38. PLATFORM_NAME(I965GM),
  39. PLATFORM_NAME(G45),
  40. PLATFORM_NAME(GM45),
  41. PLATFORM_NAME(IRONLAKE),
  42. PLATFORM_NAME(SANDYBRIDGE),
  43. PLATFORM_NAME(IVYBRIDGE),
  44. PLATFORM_NAME(VALLEYVIEW),
  45. PLATFORM_NAME(HASWELL),
  46. PLATFORM_NAME(BROADWELL),
  47. PLATFORM_NAME(CHERRYVIEW),
  48. PLATFORM_NAME(SKYLAKE),
  49. PLATFORM_NAME(BROXTON),
  50. PLATFORM_NAME(KABYLAKE),
  51. PLATFORM_NAME(GEMINILAKE),
  52. PLATFORM_NAME(COFFEELAKE),
  53. PLATFORM_NAME(CANNONLAKE),
  54. };
  55. #undef PLATFORM_NAME
  56. const char *intel_platform_name(enum intel_platform platform)
  57. {
  58. BUILD_BUG_ON(ARRAY_SIZE(platform_names) != INTEL_MAX_PLATFORMS);
  59. if (WARN_ON_ONCE(platform >= ARRAY_SIZE(platform_names) ||
  60. platform_names[platform] == NULL))
  61. return "<unknown>";
  62. return platform_names[platform];
  63. }
  64. void intel_device_info_dump(struct drm_i915_private *dev_priv)
  65. {
  66. const struct intel_device_info *info = &dev_priv->info;
  67. DRM_DEBUG_DRIVER("i915 device info: platform=%s gen=%i pciid=0x%04x rev=0x%02x",
  68. intel_platform_name(info->platform),
  69. info->gen,
  70. dev_priv->drm.pdev->device,
  71. dev_priv->drm.pdev->revision);
  72. #define PRINT_FLAG(name) \
  73. DRM_DEBUG_DRIVER("i915 device info: " #name ": %s", yesno(info->name))
  74. DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG);
  75. #undef PRINT_FLAG
  76. }
  77. static void cherryview_sseu_info_init(struct drm_i915_private *dev_priv)
  78. {
  79. struct sseu_dev_info *sseu = &mkwrite_device_info(dev_priv)->sseu;
  80. u32 fuse, eu_dis;
  81. fuse = I915_READ(CHV_FUSE_GT);
  82. sseu->slice_mask = BIT(0);
  83. if (!(fuse & CHV_FGT_DISABLE_SS0)) {
  84. sseu->subslice_mask |= BIT(0);
  85. eu_dis = fuse & (CHV_FGT_EU_DIS_SS0_R0_MASK |
  86. CHV_FGT_EU_DIS_SS0_R1_MASK);
  87. sseu->eu_total += 8 - hweight32(eu_dis);
  88. }
  89. if (!(fuse & CHV_FGT_DISABLE_SS1)) {
  90. sseu->subslice_mask |= BIT(1);
  91. eu_dis = fuse & (CHV_FGT_EU_DIS_SS1_R0_MASK |
  92. CHV_FGT_EU_DIS_SS1_R1_MASK);
  93. sseu->eu_total += 8 - hweight32(eu_dis);
  94. }
  95. /*
  96. * CHV expected to always have a uniform distribution of EU
  97. * across subslices.
  98. */
  99. sseu->eu_per_subslice = sseu_subslice_total(sseu) ?
  100. sseu->eu_total / sseu_subslice_total(sseu) :
  101. 0;
  102. /*
  103. * CHV supports subslice power gating on devices with more than
  104. * one subslice, and supports EU power gating on devices with
  105. * more than one EU pair per subslice.
  106. */
  107. sseu->has_slice_pg = 0;
  108. sseu->has_subslice_pg = sseu_subslice_total(sseu) > 1;
  109. sseu->has_eu_pg = (sseu->eu_per_subslice > 2);
  110. }
  111. static void gen9_sseu_info_init(struct drm_i915_private *dev_priv)
  112. {
  113. struct intel_device_info *info = mkwrite_device_info(dev_priv);
  114. struct sseu_dev_info *sseu = &info->sseu;
  115. int s_max = 3, ss_max = 4, eu_max = 8;
  116. int s, ss;
  117. u32 fuse2, eu_disable;
  118. u8 eu_mask = 0xff;
  119. fuse2 = I915_READ(GEN8_FUSE2);
  120. sseu->slice_mask = (fuse2 & GEN8_F2_S_ENA_MASK) >> GEN8_F2_S_ENA_SHIFT;
  121. /*
  122. * The subslice disable field is global, i.e. it applies
  123. * to each of the enabled slices.
  124. */
  125. sseu->subslice_mask = (1 << ss_max) - 1;
  126. sseu->subslice_mask &= ~((fuse2 & GEN9_F2_SS_DIS_MASK) >>
  127. GEN9_F2_SS_DIS_SHIFT);
  128. /*
  129. * Iterate through enabled slices and subslices to
  130. * count the total enabled EU.
  131. */
  132. for (s = 0; s < s_max; s++) {
  133. if (!(sseu->slice_mask & BIT(s)))
  134. /* skip disabled slice */
  135. continue;
  136. eu_disable = I915_READ(GEN9_EU_DISABLE(s));
  137. for (ss = 0; ss < ss_max; ss++) {
  138. int eu_per_ss;
  139. if (!(sseu->subslice_mask & BIT(ss)))
  140. /* skip disabled subslice */
  141. continue;
  142. eu_per_ss = eu_max - hweight8((eu_disable >> (ss*8)) &
  143. eu_mask);
  144. /*
  145. * Record which subslice(s) has(have) 7 EUs. we
  146. * can tune the hash used to spread work among
  147. * subslices if they are unbalanced.
  148. */
  149. if (eu_per_ss == 7)
  150. sseu->subslice_7eu[s] |= BIT(ss);
  151. sseu->eu_total += eu_per_ss;
  152. }
  153. }
  154. /*
  155. * SKL is expected to always have a uniform distribution
  156. * of EU across subslices with the exception that any one
  157. * EU in any one subslice may be fused off for die
  158. * recovery. BXT is expected to be perfectly uniform in EU
  159. * distribution.
  160. */
  161. sseu->eu_per_subslice = sseu_subslice_total(sseu) ?
  162. DIV_ROUND_UP(sseu->eu_total,
  163. sseu_subslice_total(sseu)) : 0;
  164. /*
  165. * SKL+ supports slice power gating on devices with more than
  166. * one slice, and supports EU power gating on devices with
  167. * more than one EU pair per subslice. BXT+ supports subslice
  168. * power gating on devices with more than one subslice, and
  169. * supports EU power gating on devices with more than one EU
  170. * pair per subslice.
  171. */
  172. sseu->has_slice_pg =
  173. !IS_GEN9_LP(dev_priv) && hweight8(sseu->slice_mask) > 1;
  174. sseu->has_subslice_pg =
  175. IS_GEN9_LP(dev_priv) && sseu_subslice_total(sseu) > 1;
  176. sseu->has_eu_pg = sseu->eu_per_subslice > 2;
  177. if (IS_GEN9_LP(dev_priv)) {
  178. #define IS_SS_DISABLED(ss) (!(sseu->subslice_mask & BIT(ss)))
  179. info->has_pooled_eu = hweight8(sseu->subslice_mask) == 3;
  180. /*
  181. * There is a HW issue in 2x6 fused down parts that requires
  182. * Pooled EU to be enabled as a WA. The pool configuration
  183. * changes depending upon which subslice is fused down. This
  184. * doesn't affect if the device has all 3 subslices enabled.
  185. */
  186. /* WaEnablePooledEuFor2x6:bxt */
  187. info->has_pooled_eu |= (hweight8(sseu->subslice_mask) == 2 &&
  188. IS_BXT_REVID(dev_priv, 0, BXT_REVID_B_LAST));
  189. sseu->min_eu_in_pool = 0;
  190. if (info->has_pooled_eu) {
  191. if (IS_SS_DISABLED(2) || IS_SS_DISABLED(0))
  192. sseu->min_eu_in_pool = 3;
  193. else if (IS_SS_DISABLED(1))
  194. sseu->min_eu_in_pool = 6;
  195. else
  196. sseu->min_eu_in_pool = 9;
  197. }
  198. #undef IS_SS_DISABLED
  199. }
  200. }
  201. static void broadwell_sseu_info_init(struct drm_i915_private *dev_priv)
  202. {
  203. struct sseu_dev_info *sseu = &mkwrite_device_info(dev_priv)->sseu;
  204. const int s_max = 3, ss_max = 3, eu_max = 8;
  205. int s, ss;
  206. u32 fuse2, eu_disable[3]; /* s_max */
  207. fuse2 = I915_READ(GEN8_FUSE2);
  208. sseu->slice_mask = (fuse2 & GEN8_F2_S_ENA_MASK) >> GEN8_F2_S_ENA_SHIFT;
  209. /*
  210. * The subslice disable field is global, i.e. it applies
  211. * to each of the enabled slices.
  212. */
  213. sseu->subslice_mask = GENMASK(ss_max - 1, 0);
  214. sseu->subslice_mask &= ~((fuse2 & GEN8_F2_SS_DIS_MASK) >>
  215. GEN8_F2_SS_DIS_SHIFT);
  216. eu_disable[0] = I915_READ(GEN8_EU_DISABLE0) & GEN8_EU_DIS0_S0_MASK;
  217. eu_disable[1] = (I915_READ(GEN8_EU_DISABLE0) >> GEN8_EU_DIS0_S1_SHIFT) |
  218. ((I915_READ(GEN8_EU_DISABLE1) & GEN8_EU_DIS1_S1_MASK) <<
  219. (32 - GEN8_EU_DIS0_S1_SHIFT));
  220. eu_disable[2] = (I915_READ(GEN8_EU_DISABLE1) >> GEN8_EU_DIS1_S2_SHIFT) |
  221. ((I915_READ(GEN8_EU_DISABLE2) & GEN8_EU_DIS2_S2_MASK) <<
  222. (32 - GEN8_EU_DIS1_S2_SHIFT));
  223. /*
  224. * Iterate through enabled slices and subslices to
  225. * count the total enabled EU.
  226. */
  227. for (s = 0; s < s_max; s++) {
  228. if (!(sseu->slice_mask & BIT(s)))
  229. /* skip disabled slice */
  230. continue;
  231. for (ss = 0; ss < ss_max; ss++) {
  232. u32 n_disabled;
  233. if (!(sseu->subslice_mask & BIT(ss)))
  234. /* skip disabled subslice */
  235. continue;
  236. n_disabled = hweight8(eu_disable[s] >> (ss * eu_max));
  237. /*
  238. * Record which subslices have 7 EUs.
  239. */
  240. if (eu_max - n_disabled == 7)
  241. sseu->subslice_7eu[s] |= 1 << ss;
  242. sseu->eu_total += eu_max - n_disabled;
  243. }
  244. }
  245. /*
  246. * BDW is expected to always have a uniform distribution of EU across
  247. * subslices with the exception that any one EU in any one subslice may
  248. * be fused off for die recovery.
  249. */
  250. sseu->eu_per_subslice = sseu_subslice_total(sseu) ?
  251. DIV_ROUND_UP(sseu->eu_total,
  252. sseu_subslice_total(sseu)) : 0;
  253. /*
  254. * BDW supports slice power gating on devices with more than
  255. * one slice.
  256. */
  257. sseu->has_slice_pg = hweight8(sseu->slice_mask) > 1;
  258. sseu->has_subslice_pg = 0;
  259. sseu->has_eu_pg = 0;
  260. }
  261. /*
  262. * Determine various intel_device_info fields at runtime.
  263. *
  264. * Use it when either:
  265. * - it's judged too laborious to fill n static structures with the limit
  266. * when a simple if statement does the job,
  267. * - run-time checks (eg read fuse/strap registers) are needed.
  268. *
  269. * This function needs to be called:
  270. * - after the MMIO has been setup as we are reading registers,
  271. * - after the PCH has been detected,
  272. * - before the first usage of the fields it can tweak.
  273. */
  274. void intel_device_info_runtime_init(struct drm_i915_private *dev_priv)
  275. {
  276. struct intel_device_info *info = mkwrite_device_info(dev_priv);
  277. enum pipe pipe;
  278. if (INTEL_GEN(dev_priv) >= 9) {
  279. info->num_scalers[PIPE_A] = 2;
  280. info->num_scalers[PIPE_B] = 2;
  281. info->num_scalers[PIPE_C] = 1;
  282. }
  283. /*
  284. * Skylake and Broxton currently don't expose the topmost plane as its
  285. * use is exclusive with the legacy cursor and we only want to expose
  286. * one of those, not both. Until we can safely expose the topmost plane
  287. * as a DRM_PLANE_TYPE_CURSOR with all the features exposed/supported,
  288. * we don't expose the topmost plane at all to prevent ABI breakage
  289. * down the line.
  290. */
  291. if (IS_GEN10(dev_priv) || IS_GEMINILAKE(dev_priv))
  292. for_each_pipe(dev_priv, pipe)
  293. info->num_sprites[pipe] = 3;
  294. else if (IS_BROXTON(dev_priv)) {
  295. info->num_sprites[PIPE_A] = 2;
  296. info->num_sprites[PIPE_B] = 2;
  297. info->num_sprites[PIPE_C] = 1;
  298. } else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
  299. for_each_pipe(dev_priv, pipe)
  300. info->num_sprites[pipe] = 2;
  301. } else if (INTEL_GEN(dev_priv) >= 5 || IS_G4X(dev_priv)) {
  302. for_each_pipe(dev_priv, pipe)
  303. info->num_sprites[pipe] = 1;
  304. }
  305. if (i915.disable_display) {
  306. DRM_INFO("Display disabled (module parameter)\n");
  307. info->num_pipes = 0;
  308. } else if (info->num_pipes > 0 &&
  309. (IS_GEN7(dev_priv) || IS_GEN8(dev_priv)) &&
  310. HAS_PCH_SPLIT(dev_priv)) {
  311. u32 fuse_strap = I915_READ(FUSE_STRAP);
  312. u32 sfuse_strap = I915_READ(SFUSE_STRAP);
  313. /*
  314. * SFUSE_STRAP is supposed to have a bit signalling the display
  315. * is fused off. Unfortunately it seems that, at least in
  316. * certain cases, fused off display means that PCH display
  317. * reads don't land anywhere. In that case, we read 0s.
  318. *
  319. * On CPT/PPT, we can detect this case as SFUSE_STRAP_FUSE_LOCK
  320. * should be set when taking over after the firmware.
  321. */
  322. if (fuse_strap & ILK_INTERNAL_DISPLAY_DISABLE ||
  323. sfuse_strap & SFUSE_STRAP_DISPLAY_DISABLED ||
  324. (HAS_PCH_CPT(dev_priv) &&
  325. !(sfuse_strap & SFUSE_STRAP_FUSE_LOCK))) {
  326. DRM_INFO("Display fused off, disabling\n");
  327. info->num_pipes = 0;
  328. } else if (fuse_strap & IVB_PIPE_C_DISABLE) {
  329. DRM_INFO("PipeC fused off\n");
  330. info->num_pipes -= 1;
  331. }
  332. } else if (info->num_pipes > 0 && IS_GEN9(dev_priv)) {
  333. u32 dfsm = I915_READ(SKL_DFSM);
  334. u8 disabled_mask = 0;
  335. bool invalid;
  336. int num_bits;
  337. if (dfsm & SKL_DFSM_PIPE_A_DISABLE)
  338. disabled_mask |= BIT(PIPE_A);
  339. if (dfsm & SKL_DFSM_PIPE_B_DISABLE)
  340. disabled_mask |= BIT(PIPE_B);
  341. if (dfsm & SKL_DFSM_PIPE_C_DISABLE)
  342. disabled_mask |= BIT(PIPE_C);
  343. num_bits = hweight8(disabled_mask);
  344. switch (disabled_mask) {
  345. case BIT(PIPE_A):
  346. case BIT(PIPE_B):
  347. case BIT(PIPE_A) | BIT(PIPE_B):
  348. case BIT(PIPE_A) | BIT(PIPE_C):
  349. invalid = true;
  350. break;
  351. default:
  352. invalid = false;
  353. }
  354. if (num_bits > info->num_pipes || invalid)
  355. DRM_ERROR("invalid pipe fuse configuration: 0x%x\n",
  356. disabled_mask);
  357. else
  358. info->num_pipes -= num_bits;
  359. }
  360. /* Initialize slice/subslice/EU info */
  361. if (IS_CHERRYVIEW(dev_priv))
  362. cherryview_sseu_info_init(dev_priv);
  363. else if (IS_BROADWELL(dev_priv))
  364. broadwell_sseu_info_init(dev_priv);
  365. else if (INTEL_INFO(dev_priv)->gen >= 9)
  366. gen9_sseu_info_init(dev_priv);
  367. info->has_snoop = !info->has_llc;
  368. DRM_DEBUG_DRIVER("slice mask: %04x\n", info->sseu.slice_mask);
  369. DRM_DEBUG_DRIVER("slice total: %u\n", hweight8(info->sseu.slice_mask));
  370. DRM_DEBUG_DRIVER("subslice total: %u\n",
  371. sseu_subslice_total(&info->sseu));
  372. DRM_DEBUG_DRIVER("subslice mask %04x\n", info->sseu.subslice_mask);
  373. DRM_DEBUG_DRIVER("subslice per slice: %u\n",
  374. hweight8(info->sseu.subslice_mask));
  375. DRM_DEBUG_DRIVER("EU total: %u\n", info->sseu.eu_total);
  376. DRM_DEBUG_DRIVER("EU per subslice: %u\n", info->sseu.eu_per_subslice);
  377. DRM_DEBUG_DRIVER("has slice power gating: %s\n",
  378. info->sseu.has_slice_pg ? "y" : "n");
  379. DRM_DEBUG_DRIVER("has subslice power gating: %s\n",
  380. info->sseu.has_subslice_pg ? "y" : "n");
  381. DRM_DEBUG_DRIVER("has EU power gating: %s\n",
  382. info->sseu.has_eu_pg ? "y" : "n");
  383. }