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