intel_device_info.c 13 KB

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