2 * Copyright © 2016 Intel Corporation
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:
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
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
25 #include <drm/drm_print.h>
27 #include "intel_device_info.h"
30 #define PLATFORM_NAME(x) [INTEL_##x] = #x
31 static const char * const platform_names[] = {
37 PLATFORM_NAME(I915GM),
39 PLATFORM_NAME(I945GM),
41 PLATFORM_NAME(PINEVIEW),
43 PLATFORM_NAME(I965GM),
46 PLATFORM_NAME(IRONLAKE),
47 PLATFORM_NAME(SANDYBRIDGE),
48 PLATFORM_NAME(IVYBRIDGE),
49 PLATFORM_NAME(VALLEYVIEW),
50 PLATFORM_NAME(HASWELL),
51 PLATFORM_NAME(BROADWELL),
52 PLATFORM_NAME(CHERRYVIEW),
53 PLATFORM_NAME(SKYLAKE),
54 PLATFORM_NAME(BROXTON),
55 PLATFORM_NAME(KABYLAKE),
56 PLATFORM_NAME(GEMINILAKE),
57 PLATFORM_NAME(COFFEELAKE),
58 PLATFORM_NAME(CANNONLAKE),
59 PLATFORM_NAME(ICELAKE),
60 PLATFORM_NAME(ELKHARTLAKE),
61 PLATFORM_NAME(TIGERLAKE),
65 const char *intel_platform_name(enum intel_platform platform)
67 BUILD_BUG_ON(ARRAY_SIZE(platform_names) != INTEL_MAX_PLATFORMS);
69 if (WARN_ON_ONCE(platform >= ARRAY_SIZE(platform_names) ||
70 platform_names[platform] == NULL))
73 return platform_names[platform];
76 void intel_device_info_dump_flags(const struct intel_device_info *info,
77 struct drm_printer *p)
79 #define PRINT_FLAG(name) drm_printf(p, "%s: %s\n", #name, yesno(info->name));
80 DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG);
83 #define PRINT_FLAG(name) drm_printf(p, "%s: %s\n", #name, yesno(info->display.name));
84 DEV_INFO_DISPLAY_FOR_EACH_FLAG(PRINT_FLAG);
88 static void sseu_dump(const struct sseu_dev_info *sseu, struct drm_printer *p)
92 drm_printf(p, "slice total: %u, mask=%04x\n",
93 hweight8(sseu->slice_mask), sseu->slice_mask);
94 drm_printf(p, "subslice total: %u\n", intel_sseu_subslice_total(sseu));
95 for (s = 0; s < sseu->max_slices; s++) {
96 drm_printf(p, "slice%d: %u subslices, mask=%04x\n",
97 s, intel_sseu_subslices_per_slice(sseu, s),
98 sseu->subslice_mask[s]);
100 drm_printf(p, "EU total: %u\n", sseu->eu_total);
101 drm_printf(p, "EU per subslice: %u\n", sseu->eu_per_subslice);
102 drm_printf(p, "has slice power gating: %s\n",
103 yesno(sseu->has_slice_pg));
104 drm_printf(p, "has subslice power gating: %s\n",
105 yesno(sseu->has_subslice_pg));
106 drm_printf(p, "has EU power gating: %s\n", yesno(sseu->has_eu_pg));
109 void intel_device_info_dump_runtime(const struct intel_runtime_info *info,
110 struct drm_printer *p)
112 sseu_dump(&info->sseu, p);
114 drm_printf(p, "CS timestamp frequency: %u kHz\n",
115 info->cs_timestamp_frequency_khz);
118 static int sseu_eu_idx(const struct sseu_dev_info *sseu, int slice,
121 int subslice_stride = GEN_SSEU_STRIDE(sseu->max_eus_per_subslice);
122 int slice_stride = sseu->max_subslices * subslice_stride;
124 return slice * slice_stride + subslice * subslice_stride;
127 static u16 sseu_get_eus(const struct sseu_dev_info *sseu, int slice,
130 int i, offset = sseu_eu_idx(sseu, slice, subslice);
133 for (i = 0; i < GEN_SSEU_STRIDE(sseu->max_eus_per_subslice); i++) {
134 eu_mask |= ((u16)sseu->eu_mask[offset + i]) <<
141 static void sseu_set_eus(struct sseu_dev_info *sseu, int slice, int subslice,
144 int i, offset = sseu_eu_idx(sseu, slice, subslice);
146 for (i = 0; i < GEN_SSEU_STRIDE(sseu->max_eus_per_subslice); i++) {
147 sseu->eu_mask[offset + i] =
148 (eu_mask >> (BITS_PER_BYTE * i)) & 0xff;
152 void intel_device_info_dump_topology(const struct sseu_dev_info *sseu,
153 struct drm_printer *p)
157 if (sseu->max_slices == 0) {
158 drm_printf(p, "Unavailable\n");
162 for (s = 0; s < sseu->max_slices; s++) {
163 drm_printf(p, "slice%d: %u subslice(s) (0x%hhx):\n",
164 s, intel_sseu_subslices_per_slice(sseu, s),
165 sseu->subslice_mask[s]);
167 for (ss = 0; ss < sseu->max_subslices; ss++) {
168 u16 enabled_eus = sseu_get_eus(sseu, s, ss);
170 drm_printf(p, "\tsubslice%d: %u EUs (0x%hx)\n",
171 ss, hweight16(enabled_eus), enabled_eus);
176 static u16 compute_eu_total(const struct sseu_dev_info *sseu)
180 for (i = 0; i < ARRAY_SIZE(sseu->eu_mask); i++)
181 total += hweight8(sseu->eu_mask[i]);
186 static void gen11_sseu_info_init(struct drm_i915_private *dev_priv)
188 struct sseu_dev_info *sseu = &RUNTIME_INFO(dev_priv)->sseu;
190 u32 ss_en, ss_en_mask;
194 if (IS_ELKHARTLAKE(dev_priv)) {
195 sseu->max_slices = 1;
196 sseu->max_subslices = 4;
197 sseu->max_eus_per_subslice = 8;
199 sseu->max_slices = 1;
200 sseu->max_subslices = 8;
201 sseu->max_eus_per_subslice = 8;
204 s_en = I915_READ(GEN11_GT_SLICE_ENABLE) & GEN11_GT_S_ENA_MASK;
205 ss_en = ~I915_READ(GEN11_GT_SUBSLICE_DISABLE);
206 ss_en_mask = BIT(sseu->max_subslices) - 1;
207 eu_en = ~(I915_READ(GEN11_EU_DISABLE) & GEN11_EU_DIS_MASK);
209 for (s = 0; s < sseu->max_slices; s++) {
211 int ss_idx = sseu->max_subslices * s;
214 sseu->slice_mask |= BIT(s);
215 sseu->subslice_mask[s] = (ss_en >> ss_idx) & ss_en_mask;
216 for (ss = 0; ss < sseu->max_subslices; ss++) {
217 if (sseu->subslice_mask[s] & BIT(ss))
218 sseu_set_eus(sseu, s, ss, eu_en);
222 sseu->eu_per_subslice = hweight8(eu_en);
223 sseu->eu_total = compute_eu_total(sseu);
225 /* ICL has no power gating restrictions. */
226 sseu->has_slice_pg = 1;
227 sseu->has_subslice_pg = 1;
231 static void gen10_sseu_info_init(struct drm_i915_private *dev_priv)
233 struct sseu_dev_info *sseu = &RUNTIME_INFO(dev_priv)->sseu;
234 const u32 fuse2 = I915_READ(GEN8_FUSE2);
236 const int eu_mask = 0xff;
237 u32 subslice_mask, eu_en;
239 sseu->slice_mask = (fuse2 & GEN10_F2_S_ENA_MASK) >>
240 GEN10_F2_S_ENA_SHIFT;
241 sseu->max_slices = 6;
242 sseu->max_subslices = 4;
243 sseu->max_eus_per_subslice = 8;
245 subslice_mask = (1 << 4) - 1;
246 subslice_mask &= ~((fuse2 & GEN10_F2_SS_DIS_MASK) >>
247 GEN10_F2_SS_DIS_SHIFT);
250 * Slice0 can have up to 3 subslices, but there are only 2 in
253 sseu->subslice_mask[0] = subslice_mask;
254 for (s = 1; s < sseu->max_slices; s++)
255 sseu->subslice_mask[s] = subslice_mask & 0x3;
258 eu_en = ~I915_READ(GEN8_EU_DISABLE0);
259 for (ss = 0; ss < sseu->max_subslices; ss++)
260 sseu_set_eus(sseu, 0, ss, (eu_en >> (8 * ss)) & eu_mask);
262 sseu_set_eus(sseu, 1, 0, (eu_en >> 24) & eu_mask);
263 eu_en = ~I915_READ(GEN8_EU_DISABLE1);
264 sseu_set_eus(sseu, 1, 1, eu_en & eu_mask);
266 sseu_set_eus(sseu, 2, 0, (eu_en >> 8) & eu_mask);
267 sseu_set_eus(sseu, 2, 1, (eu_en >> 16) & eu_mask);
269 sseu_set_eus(sseu, 3, 0, (eu_en >> 24) & eu_mask);
270 eu_en = ~I915_READ(GEN8_EU_DISABLE2);
271 sseu_set_eus(sseu, 3, 1, eu_en & eu_mask);
273 sseu_set_eus(sseu, 4, 0, (eu_en >> 8) & eu_mask);
274 sseu_set_eus(sseu, 4, 1, (eu_en >> 16) & eu_mask);
276 sseu_set_eus(sseu, 5, 0, (eu_en >> 24) & eu_mask);
277 eu_en = ~I915_READ(GEN10_EU_DISABLE3);
278 sseu_set_eus(sseu, 5, 1, eu_en & eu_mask);
280 /* Do a second pass where we mark the subslices disabled if all their
283 for (s = 0; s < sseu->max_slices; s++) {
284 for (ss = 0; ss < sseu->max_subslices; ss++) {
285 if (sseu_get_eus(sseu, s, ss) == 0)
286 sseu->subslice_mask[s] &= ~BIT(ss);
290 sseu->eu_total = compute_eu_total(sseu);
293 * CNL is expected to always have a uniform distribution
294 * of EU across subslices with the exception that any one
295 * EU in any one subslice may be fused off for die
298 sseu->eu_per_subslice = intel_sseu_subslice_total(sseu) ?
299 DIV_ROUND_UP(sseu->eu_total,
300 intel_sseu_subslice_total(sseu)) :
303 /* No restrictions on Power Gating */
304 sseu->has_slice_pg = 1;
305 sseu->has_subslice_pg = 1;
309 static void cherryview_sseu_info_init(struct drm_i915_private *dev_priv)
311 struct sseu_dev_info *sseu = &RUNTIME_INFO(dev_priv)->sseu;
314 fuse = I915_READ(CHV_FUSE_GT);
316 sseu->slice_mask = BIT(0);
317 sseu->max_slices = 1;
318 sseu->max_subslices = 2;
319 sseu->max_eus_per_subslice = 8;
321 if (!(fuse & CHV_FGT_DISABLE_SS0)) {
323 ((fuse & CHV_FGT_EU_DIS_SS0_R0_MASK) >>
324 CHV_FGT_EU_DIS_SS0_R0_SHIFT) |
325 (((fuse & CHV_FGT_EU_DIS_SS0_R1_MASK) >>
326 CHV_FGT_EU_DIS_SS0_R1_SHIFT) << 4);
328 sseu->subslice_mask[0] |= BIT(0);
329 sseu_set_eus(sseu, 0, 0, ~disabled_mask);
332 if (!(fuse & CHV_FGT_DISABLE_SS1)) {
334 ((fuse & CHV_FGT_EU_DIS_SS1_R0_MASK) >>
335 CHV_FGT_EU_DIS_SS1_R0_SHIFT) |
336 (((fuse & CHV_FGT_EU_DIS_SS1_R1_MASK) >>
337 CHV_FGT_EU_DIS_SS1_R1_SHIFT) << 4);
339 sseu->subslice_mask[0] |= BIT(1);
340 sseu_set_eus(sseu, 0, 1, ~disabled_mask);
343 sseu->eu_total = compute_eu_total(sseu);
346 * CHV expected to always have a uniform distribution of EU
349 sseu->eu_per_subslice = intel_sseu_subslice_total(sseu) ?
351 intel_sseu_subslice_total(sseu) :
354 * CHV supports subslice power gating on devices with more than
355 * one subslice, and supports EU power gating on devices with
356 * more than one EU pair per subslice.
358 sseu->has_slice_pg = 0;
359 sseu->has_subslice_pg = intel_sseu_subslice_total(sseu) > 1;
360 sseu->has_eu_pg = (sseu->eu_per_subslice > 2);
363 static void gen9_sseu_info_init(struct drm_i915_private *dev_priv)
365 struct intel_device_info *info = mkwrite_device_info(dev_priv);
366 struct sseu_dev_info *sseu = &RUNTIME_INFO(dev_priv)->sseu;
368 u32 fuse2, eu_disable, subslice_mask;
369 const u8 eu_mask = 0xff;
371 fuse2 = I915_READ(GEN8_FUSE2);
372 sseu->slice_mask = (fuse2 & GEN8_F2_S_ENA_MASK) >> GEN8_F2_S_ENA_SHIFT;
374 /* BXT has a single slice and at most 3 subslices. */
375 sseu->max_slices = IS_GEN9_LP(dev_priv) ? 1 : 3;
376 sseu->max_subslices = IS_GEN9_LP(dev_priv) ? 3 : 4;
377 sseu->max_eus_per_subslice = 8;
380 * The subslice disable field is global, i.e. it applies
381 * to each of the enabled slices.
383 subslice_mask = (1 << sseu->max_subslices) - 1;
384 subslice_mask &= ~((fuse2 & GEN9_F2_SS_DIS_MASK) >>
385 GEN9_F2_SS_DIS_SHIFT);
388 * Iterate through enabled slices and subslices to
389 * count the total enabled EU.
391 for (s = 0; s < sseu->max_slices; s++) {
392 if (!(sseu->slice_mask & BIT(s)))
393 /* skip disabled slice */
396 sseu->subslice_mask[s] = subslice_mask;
398 eu_disable = I915_READ(GEN9_EU_DISABLE(s));
399 for (ss = 0; ss < sseu->max_subslices; ss++) {
403 if (!(sseu->subslice_mask[s] & BIT(ss)))
404 /* skip disabled subslice */
407 eu_disabled_mask = (eu_disable >> (ss * 8)) & eu_mask;
409 sseu_set_eus(sseu, s, ss, ~eu_disabled_mask);
411 eu_per_ss = sseu->max_eus_per_subslice -
412 hweight8(eu_disabled_mask);
415 * Record which subslice(s) has(have) 7 EUs. we
416 * can tune the hash used to spread work among
417 * subslices if they are unbalanced.
420 sseu->subslice_7eu[s] |= BIT(ss);
424 sseu->eu_total = compute_eu_total(sseu);
427 * SKL is expected to always have a uniform distribution
428 * of EU across subslices with the exception that any one
429 * EU in any one subslice may be fused off for die
430 * recovery. BXT is expected to be perfectly uniform in EU
433 sseu->eu_per_subslice = intel_sseu_subslice_total(sseu) ?
434 DIV_ROUND_UP(sseu->eu_total,
435 intel_sseu_subslice_total(sseu)) :
438 * SKL+ supports slice power gating on devices with more than
439 * one slice, and supports EU power gating on devices with
440 * more than one EU pair per subslice. BXT+ supports subslice
441 * power gating on devices with more than one subslice, and
442 * supports EU power gating on devices with more than one EU
446 !IS_GEN9_LP(dev_priv) && hweight8(sseu->slice_mask) > 1;
447 sseu->has_subslice_pg =
448 IS_GEN9_LP(dev_priv) && intel_sseu_subslice_total(sseu) > 1;
449 sseu->has_eu_pg = sseu->eu_per_subslice > 2;
451 if (IS_GEN9_LP(dev_priv)) {
452 #define IS_SS_DISABLED(ss) (!(sseu->subslice_mask[0] & BIT(ss)))
453 info->has_pooled_eu = hweight8(sseu->subslice_mask[0]) == 3;
455 sseu->min_eu_in_pool = 0;
456 if (info->has_pooled_eu) {
457 if (IS_SS_DISABLED(2) || IS_SS_DISABLED(0))
458 sseu->min_eu_in_pool = 3;
459 else if (IS_SS_DISABLED(1))
460 sseu->min_eu_in_pool = 6;
462 sseu->min_eu_in_pool = 9;
464 #undef IS_SS_DISABLED
468 static void broadwell_sseu_info_init(struct drm_i915_private *dev_priv)
470 struct sseu_dev_info *sseu = &RUNTIME_INFO(dev_priv)->sseu;
472 u32 fuse2, subslice_mask, eu_disable[3]; /* s_max */
474 fuse2 = I915_READ(GEN8_FUSE2);
475 sseu->slice_mask = (fuse2 & GEN8_F2_S_ENA_MASK) >> GEN8_F2_S_ENA_SHIFT;
476 sseu->max_slices = 3;
477 sseu->max_subslices = 3;
478 sseu->max_eus_per_subslice = 8;
481 * The subslice disable field is global, i.e. it applies
482 * to each of the enabled slices.
484 subslice_mask = GENMASK(sseu->max_subslices - 1, 0);
485 subslice_mask &= ~((fuse2 & GEN8_F2_SS_DIS_MASK) >>
486 GEN8_F2_SS_DIS_SHIFT);
488 eu_disable[0] = I915_READ(GEN8_EU_DISABLE0) & GEN8_EU_DIS0_S0_MASK;
489 eu_disable[1] = (I915_READ(GEN8_EU_DISABLE0) >> GEN8_EU_DIS0_S1_SHIFT) |
490 ((I915_READ(GEN8_EU_DISABLE1) & GEN8_EU_DIS1_S1_MASK) <<
491 (32 - GEN8_EU_DIS0_S1_SHIFT));
492 eu_disable[2] = (I915_READ(GEN8_EU_DISABLE1) >> GEN8_EU_DIS1_S2_SHIFT) |
493 ((I915_READ(GEN8_EU_DISABLE2) & GEN8_EU_DIS2_S2_MASK) <<
494 (32 - GEN8_EU_DIS1_S2_SHIFT));
497 * Iterate through enabled slices and subslices to
498 * count the total enabled EU.
500 for (s = 0; s < sseu->max_slices; s++) {
501 if (!(sseu->slice_mask & BIT(s)))
502 /* skip disabled slice */
505 sseu->subslice_mask[s] = subslice_mask;
507 for (ss = 0; ss < sseu->max_subslices; ss++) {
511 if (!(sseu->subslice_mask[s] & BIT(ss)))
512 /* skip disabled subslice */
516 eu_disable[s] >> (ss * sseu->max_eus_per_subslice);
518 sseu_set_eus(sseu, s, ss, ~eu_disabled_mask);
520 n_disabled = hweight8(eu_disabled_mask);
523 * Record which subslices have 7 EUs.
525 if (sseu->max_eus_per_subslice - n_disabled == 7)
526 sseu->subslice_7eu[s] |= 1 << ss;
530 sseu->eu_total = compute_eu_total(sseu);
533 * BDW is expected to always have a uniform distribution of EU across
534 * subslices with the exception that any one EU in any one subslice may
535 * be fused off for die recovery.
537 sseu->eu_per_subslice = intel_sseu_subslice_total(sseu) ?
538 DIV_ROUND_UP(sseu->eu_total,
539 intel_sseu_subslice_total(sseu)) :
543 * BDW supports slice power gating on devices with more than
546 sseu->has_slice_pg = hweight8(sseu->slice_mask) > 1;
547 sseu->has_subslice_pg = 0;
551 static void haswell_sseu_info_init(struct drm_i915_private *dev_priv)
553 struct sseu_dev_info *sseu = &RUNTIME_INFO(dev_priv)->sseu;
558 * There isn't a register to tell us how many slices/subslices. We
559 * work off the PCI-ids here.
561 switch (INTEL_INFO(dev_priv)->gt) {
563 MISSING_CASE(INTEL_INFO(dev_priv)->gt);
566 sseu->slice_mask = BIT(0);
567 sseu->subslice_mask[0] = BIT(0);
570 sseu->slice_mask = BIT(0);
571 sseu->subslice_mask[0] = BIT(0) | BIT(1);
574 sseu->slice_mask = BIT(0) | BIT(1);
575 sseu->subslice_mask[0] = BIT(0) | BIT(1);
576 sseu->subslice_mask[1] = BIT(0) | BIT(1);
580 sseu->max_slices = hweight8(sseu->slice_mask);
581 sseu->max_subslices = hweight8(sseu->subslice_mask[0]);
583 fuse1 = I915_READ(HSW_PAVP_FUSE1);
584 switch ((fuse1 & HSW_F1_EU_DIS_MASK) >> HSW_F1_EU_DIS_SHIFT) {
586 MISSING_CASE((fuse1 & HSW_F1_EU_DIS_MASK) >>
587 HSW_F1_EU_DIS_SHIFT);
589 case HSW_F1_EU_DIS_10EUS:
590 sseu->eu_per_subslice = 10;
592 case HSW_F1_EU_DIS_8EUS:
593 sseu->eu_per_subslice = 8;
595 case HSW_F1_EU_DIS_6EUS:
596 sseu->eu_per_subslice = 6;
599 sseu->max_eus_per_subslice = sseu->eu_per_subslice;
601 for (s = 0; s < sseu->max_slices; s++) {
602 for (ss = 0; ss < sseu->max_subslices; ss++) {
603 sseu_set_eus(sseu, s, ss,
604 (1UL << sseu->eu_per_subslice) - 1);
608 sseu->eu_total = compute_eu_total(sseu);
610 /* No powergating for you. */
611 sseu->has_slice_pg = 0;
612 sseu->has_subslice_pg = 0;
616 static u32 read_reference_ts_freq(struct drm_i915_private *dev_priv)
618 u32 ts_override = I915_READ(GEN9_TIMESTAMP_OVERRIDE);
619 u32 base_freq, frac_freq;
621 base_freq = ((ts_override & GEN9_TIMESTAMP_OVERRIDE_US_COUNTER_DIVIDER_MASK) >>
622 GEN9_TIMESTAMP_OVERRIDE_US_COUNTER_DIVIDER_SHIFT) + 1;
625 frac_freq = ((ts_override &
626 GEN9_TIMESTAMP_OVERRIDE_US_COUNTER_DENOMINATOR_MASK) >>
627 GEN9_TIMESTAMP_OVERRIDE_US_COUNTER_DENOMINATOR_SHIFT);
628 frac_freq = 1000 / (frac_freq + 1);
630 return base_freq + frac_freq;
633 static u32 gen10_get_crystal_clock_freq(struct drm_i915_private *dev_priv,
636 u32 f19_2_mhz = 19200;
638 u32 crystal_clock = (rpm_config_reg &
639 GEN9_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_MASK) >>
640 GEN9_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_SHIFT;
642 switch (crystal_clock) {
643 case GEN9_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_19_2_MHZ:
645 case GEN9_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_24_MHZ:
648 MISSING_CASE(crystal_clock);
653 static u32 gen11_get_crystal_clock_freq(struct drm_i915_private *dev_priv,
656 u32 f19_2_mhz = 19200;
659 u32 f38_4_mhz = 38400;
660 u32 crystal_clock = (rpm_config_reg &
661 GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_MASK) >>
662 GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_SHIFT;
664 switch (crystal_clock) {
665 case GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_24_MHZ:
667 case GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_19_2_MHZ:
669 case GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_38_4_MHZ:
671 case GEN11_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_25_MHZ:
674 MISSING_CASE(crystal_clock);
679 static u32 read_timestamp_frequency(struct drm_i915_private *dev_priv)
681 u32 f12_5_mhz = 12500;
682 u32 f19_2_mhz = 19200;
685 if (INTEL_GEN(dev_priv) <= 4) {
688 * "The value in this register increments once every 16
689 * hclks." (through the “Clocking Configuration”
690 * (“CLKCFG”) MCHBAR register)
692 return dev_priv->rawclk_freq / 16;
693 } else if (INTEL_GEN(dev_priv) <= 8) {
696 * "The PCU TSC counts 10ns increments; this timestamp
697 * reflects bits 38:3 of the TSC (i.e. 80ns granularity,
698 * rolling over every 1.5 hours).
701 } else if (INTEL_GEN(dev_priv) <= 9) {
702 u32 ctc_reg = I915_READ(CTC_MODE);
705 if ((ctc_reg & CTC_SOURCE_PARAMETER_MASK) == CTC_SOURCE_DIVIDE_LOGIC) {
706 freq = read_reference_ts_freq(dev_priv);
708 freq = IS_GEN9_LP(dev_priv) ? f19_2_mhz : f24_mhz;
710 /* Now figure out how the command stream's timestamp
711 * register increments from this frequency (it might
712 * increment only every few clock cycle).
714 freq >>= 3 - ((ctc_reg & CTC_SHIFT_PARAMETER_MASK) >>
715 CTC_SHIFT_PARAMETER_SHIFT);
719 } else if (INTEL_GEN(dev_priv) <= 12) {
720 u32 ctc_reg = I915_READ(CTC_MODE);
723 /* First figure out the reference frequency. There are 2 ways
724 * we can compute the frequency, either through the
725 * TIMESTAMP_OVERRIDE register or through RPM_CONFIG. CTC_MODE
726 * tells us which one we should use.
728 if ((ctc_reg & CTC_SOURCE_PARAMETER_MASK) == CTC_SOURCE_DIVIDE_LOGIC) {
729 freq = read_reference_ts_freq(dev_priv);
731 u32 rpm_config_reg = I915_READ(RPM_CONFIG0);
733 if (INTEL_GEN(dev_priv) <= 10)
734 freq = gen10_get_crystal_clock_freq(dev_priv,
737 freq = gen11_get_crystal_clock_freq(dev_priv,
740 /* Now figure out how the command stream's timestamp
741 * register increments from this frequency (it might
742 * increment only every few clock cycle).
744 freq >>= 3 - ((rpm_config_reg &
745 GEN10_RPM_CONFIG0_CTC_SHIFT_PARAMETER_MASK) >>
746 GEN10_RPM_CONFIG0_CTC_SHIFT_PARAMETER_SHIFT);
752 MISSING_CASE("Unknown gen, unable to read command streamer timestamp frequency\n");
756 #undef INTEL_VGA_DEVICE
757 #define INTEL_VGA_DEVICE(id, info) (id)
759 static const u16 subplatform_ult_ids[] = {
760 INTEL_HSW_ULT_GT1_IDS(0),
761 INTEL_HSW_ULT_GT2_IDS(0),
762 INTEL_HSW_ULT_GT3_IDS(0),
763 INTEL_BDW_ULT_GT1_IDS(0),
764 INTEL_BDW_ULT_GT2_IDS(0),
765 INTEL_BDW_ULT_GT3_IDS(0),
766 INTEL_BDW_ULT_RSVD_IDS(0),
767 INTEL_SKL_ULT_GT1_IDS(0),
768 INTEL_SKL_ULT_GT2_IDS(0),
769 INTEL_SKL_ULT_GT3_IDS(0),
770 INTEL_KBL_ULT_GT1_IDS(0),
771 INTEL_KBL_ULT_GT2_IDS(0),
772 INTEL_KBL_ULT_GT3_IDS(0),
773 INTEL_CFL_U_GT2_IDS(0),
774 INTEL_CFL_U_GT3_IDS(0),
775 INTEL_WHL_U_GT1_IDS(0),
776 INTEL_WHL_U_GT2_IDS(0),
777 INTEL_WHL_U_GT3_IDS(0),
780 static const u16 subplatform_ulx_ids[] = {
781 INTEL_HSW_ULX_GT1_IDS(0),
782 INTEL_HSW_ULX_GT2_IDS(0),
783 INTEL_BDW_ULX_GT1_IDS(0),
784 INTEL_BDW_ULX_GT2_IDS(0),
785 INTEL_BDW_ULX_GT3_IDS(0),
786 INTEL_BDW_ULX_RSVD_IDS(0),
787 INTEL_SKL_ULX_GT1_IDS(0),
788 INTEL_SKL_ULX_GT2_IDS(0),
789 INTEL_KBL_ULX_GT1_IDS(0),
790 INTEL_KBL_ULX_GT2_IDS(0),
791 INTEL_AML_KBL_GT2_IDS(0),
792 INTEL_AML_CFL_GT2_IDS(0),
795 static const u16 subplatform_portf_ids[] = {
796 INTEL_CNL_PORT_F_IDS(0),
797 INTEL_ICL_PORT_F_IDS(0),
800 static bool find_devid(u16 id, const u16 *p, unsigned int num)
802 for (; num; num--, p++) {
810 void intel_device_info_subplatform_init(struct drm_i915_private *i915)
812 const struct intel_device_info *info = INTEL_INFO(i915);
813 const struct intel_runtime_info *rinfo = RUNTIME_INFO(i915);
814 const unsigned int pi = __platform_mask_index(rinfo, info->platform);
815 const unsigned int pb = __platform_mask_bit(rinfo, info->platform);
816 u16 devid = INTEL_DEVID(i915);
819 /* Make sure IS_<platform> checks are working. */
820 RUNTIME_INFO(i915)->platform_mask[pi] = BIT(pb);
822 /* Find and mark subplatform bits based on the PCI device id. */
823 if (find_devid(devid, subplatform_ult_ids,
824 ARRAY_SIZE(subplatform_ult_ids))) {
825 mask = BIT(INTEL_SUBPLATFORM_ULT);
826 } else if (find_devid(devid, subplatform_ulx_ids,
827 ARRAY_SIZE(subplatform_ulx_ids))) {
828 mask = BIT(INTEL_SUBPLATFORM_ULX);
829 if (IS_HASWELL(i915) || IS_BROADWELL(i915)) {
830 /* ULX machines are also considered ULT. */
831 mask |= BIT(INTEL_SUBPLATFORM_ULT);
833 } else if (find_devid(devid, subplatform_portf_ids,
834 ARRAY_SIZE(subplatform_portf_ids))) {
835 mask = BIT(INTEL_SUBPLATFORM_PORTF);
838 GEM_BUG_ON(mask & ~INTEL_SUBPLATFORM_BITS);
840 RUNTIME_INFO(i915)->platform_mask[pi] |= mask;
844 * intel_device_info_runtime_init - initialize runtime info
845 * @dev_priv: the i915 device
847 * Determine various intel_device_info fields at runtime.
849 * Use it when either:
850 * - it's judged too laborious to fill n static structures with the limit
851 * when a simple if statement does the job,
852 * - run-time checks (eg read fuse/strap registers) are needed.
854 * This function needs to be called:
855 * - after the MMIO has been setup as we are reading registers,
856 * - after the PCH has been detected,
857 * - before the first usage of the fields it can tweak.
859 void intel_device_info_runtime_init(struct drm_i915_private *dev_priv)
861 struct intel_device_info *info = mkwrite_device_info(dev_priv);
862 struct intel_runtime_info *runtime = RUNTIME_INFO(dev_priv);
865 if (INTEL_GEN(dev_priv) >= 10) {
866 for_each_pipe(dev_priv, pipe)
867 runtime->num_scalers[pipe] = 2;
868 } else if (IS_GEN(dev_priv, 9)) {
869 runtime->num_scalers[PIPE_A] = 2;
870 runtime->num_scalers[PIPE_B] = 2;
871 runtime->num_scalers[PIPE_C] = 1;
874 BUILD_BUG_ON(BITS_PER_TYPE(intel_engine_mask_t) < I915_NUM_ENGINES);
876 if (INTEL_GEN(dev_priv) >= 11)
877 for_each_pipe(dev_priv, pipe)
878 runtime->num_sprites[pipe] = 6;
879 else if (IS_GEN(dev_priv, 10) || IS_GEMINILAKE(dev_priv))
880 for_each_pipe(dev_priv, pipe)
881 runtime->num_sprites[pipe] = 3;
882 else if (IS_BROXTON(dev_priv)) {
884 * Skylake and Broxton currently don't expose the topmost plane as its
885 * use is exclusive with the legacy cursor and we only want to expose
886 * one of those, not both. Until we can safely expose the topmost plane
887 * as a DRM_PLANE_TYPE_CURSOR with all the features exposed/supported,
888 * we don't expose the topmost plane at all to prevent ABI breakage
892 runtime->num_sprites[PIPE_A] = 2;
893 runtime->num_sprites[PIPE_B] = 2;
894 runtime->num_sprites[PIPE_C] = 1;
895 } else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
896 for_each_pipe(dev_priv, pipe)
897 runtime->num_sprites[pipe] = 2;
898 } else if (INTEL_GEN(dev_priv) >= 5 || IS_G4X(dev_priv)) {
899 for_each_pipe(dev_priv, pipe)
900 runtime->num_sprites[pipe] = 1;
903 if (i915_modparams.disable_display) {
904 DRM_INFO("Display disabled (module parameter)\n");
906 } else if (HAS_DISPLAY(dev_priv) &&
907 (IS_GEN_RANGE(dev_priv, 7, 8)) &&
908 HAS_PCH_SPLIT(dev_priv)) {
909 u32 fuse_strap = I915_READ(FUSE_STRAP);
910 u32 sfuse_strap = I915_READ(SFUSE_STRAP);
913 * SFUSE_STRAP is supposed to have a bit signalling the display
914 * is fused off. Unfortunately it seems that, at least in
915 * certain cases, fused off display means that PCH display
916 * reads don't land anywhere. In that case, we read 0s.
918 * On CPT/PPT, we can detect this case as SFUSE_STRAP_FUSE_LOCK
919 * should be set when taking over after the firmware.
921 if (fuse_strap & ILK_INTERNAL_DISPLAY_DISABLE ||
922 sfuse_strap & SFUSE_STRAP_DISPLAY_DISABLED ||
923 (HAS_PCH_CPT(dev_priv) &&
924 !(sfuse_strap & SFUSE_STRAP_FUSE_LOCK))) {
925 DRM_INFO("Display fused off, disabling\n");
927 } else if (fuse_strap & IVB_PIPE_C_DISABLE) {
928 DRM_INFO("PipeC fused off\n");
929 info->num_pipes -= 1;
931 } else if (HAS_DISPLAY(dev_priv) && INTEL_GEN(dev_priv) >= 9) {
932 u32 dfsm = I915_READ(SKL_DFSM);
933 u8 enabled_mask = BIT(info->num_pipes) - 1;
935 if (dfsm & SKL_DFSM_PIPE_A_DISABLE)
936 enabled_mask &= ~BIT(PIPE_A);
937 if (dfsm & SKL_DFSM_PIPE_B_DISABLE)
938 enabled_mask &= ~BIT(PIPE_B);
939 if (dfsm & SKL_DFSM_PIPE_C_DISABLE)
940 enabled_mask &= ~BIT(PIPE_C);
941 if (INTEL_GEN(dev_priv) >= 12 &&
942 (dfsm & TGL_DFSM_PIPE_D_DISABLE))
943 enabled_mask &= ~BIT(PIPE_D);
946 * At least one pipe should be enabled and if there are
947 * disabled pipes, they should be the last ones, with no holes
950 if (enabled_mask == 0 || !is_power_of_2(enabled_mask + 1))
951 DRM_ERROR("invalid pipe fuse configuration: enabled_mask=0x%x\n",
954 info->num_pipes = hweight8(enabled_mask);
957 /* Initialize slice/subslice/EU info */
958 if (IS_HASWELL(dev_priv))
959 haswell_sseu_info_init(dev_priv);
960 else if (IS_CHERRYVIEW(dev_priv))
961 cherryview_sseu_info_init(dev_priv);
962 else if (IS_BROADWELL(dev_priv))
963 broadwell_sseu_info_init(dev_priv);
964 else if (IS_GEN(dev_priv, 9))
965 gen9_sseu_info_init(dev_priv);
966 else if (IS_GEN(dev_priv, 10))
967 gen10_sseu_info_init(dev_priv);
968 else if (INTEL_GEN(dev_priv) >= 11)
969 gen11_sseu_info_init(dev_priv);
971 if (IS_GEN(dev_priv, 6) && intel_vtd_active()) {
972 DRM_INFO("Disabling ppGTT for VT-d support\n");
973 info->ppgtt_type = INTEL_PPGTT_NONE;
976 /* Initialize command stream timestamp frequency */
977 runtime->cs_timestamp_frequency_khz = read_timestamp_frequency(dev_priv);
980 void intel_driver_caps_print(const struct intel_driver_caps *caps,
981 struct drm_printer *p)
983 drm_printf(p, "Has logical contexts? %s\n",
984 yesno(caps->has_logical_contexts));
985 drm_printf(p, "scheduler: %x\n", caps->scheduler);
989 * Determine which engines are fused off in our particular hardware. Since the
990 * fuse register is in the blitter powerwell, we need forcewake to be ready at
991 * this point (but later we need to prune the forcewake domains for engines that
992 * are indeed fused off).
994 void intel_device_info_init_mmio(struct drm_i915_private *dev_priv)
996 struct intel_device_info *info = mkwrite_device_info(dev_priv);
997 unsigned int logical_vdbox = 0;
1003 if (INTEL_GEN(dev_priv) < 11)
1006 media_fuse = ~I915_READ(GEN11_GT_VEBOX_VDBOX_DISABLE);
1008 vdbox_mask = media_fuse & GEN11_GT_VDBOX_DISABLE_MASK;
1009 vebox_mask = (media_fuse & GEN11_GT_VEBOX_DISABLE_MASK) >>
1010 GEN11_GT_VEBOX_DISABLE_SHIFT;
1012 for (i = 0; i < I915_MAX_VCS; i++) {
1013 if (!HAS_ENGINE(dev_priv, _VCS(i)))
1016 if (!(BIT(i) & vdbox_mask)) {
1017 info->engine_mask &= ~BIT(_VCS(i));
1018 DRM_DEBUG_DRIVER("vcs%u fused off\n", i);
1023 * In Gen11, only even numbered logical VDBOXes are
1024 * hooked up to an SFC (Scaler & Format Converter) unit.
1025 * In TGL each VDBOX has access to an SFC.
1027 if (IS_TIGERLAKE(dev_priv) || logical_vdbox++ % 2 == 0)
1028 RUNTIME_INFO(dev_priv)->vdbox_sfc_access |= BIT(i);
1030 DRM_DEBUG_DRIVER("vdbox enable: %04x, instances: %04lx\n",
1031 vdbox_mask, VDBOX_MASK(dev_priv));
1032 GEM_BUG_ON(vdbox_mask != VDBOX_MASK(dev_priv));
1034 for (i = 0; i < I915_MAX_VECS; i++) {
1035 if (!HAS_ENGINE(dev_priv, _VECS(i)))
1038 if (!(BIT(i) & vebox_mask)) {
1039 info->engine_mask &= ~BIT(_VECS(i));
1040 DRM_DEBUG_DRIVER("vecs%u fused off\n", i);
1043 DRM_DEBUG_DRIVER("vebox enable: %04x, instances: %04lx\n",
1044 vebox_mask, VEBOX_MASK(dev_priv));
1045 GEM_BUG_ON(vebox_mask != VEBOX_MASK(dev_priv));