blob: 1c780cc4cd482b9d6dc23553b9225235503dafa0 [file] [log] [blame]
Chris Wilson94b4f3b2016-07-05 10:40:20 +01001/*
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
Michal Wajdeczkoa8c9b842017-12-19 11:43:44 +000025#include <drm/drm_print.h>
26
Michal Wajdeczkob9785202017-12-21 21:57:32 +000027#include "intel_device_info.h"
Chris Wilson94b4f3b2016-07-05 10:40:20 +010028#include "i915_drv.h"
29
Jani Nikula2e0d26f2016-12-01 14:49:55 +020030#define PLATFORM_NAME(x) [INTEL_##x] = #x
31static const char * const platform_names[] = {
32 PLATFORM_NAME(I830),
33 PLATFORM_NAME(I845G),
34 PLATFORM_NAME(I85X),
35 PLATFORM_NAME(I865G),
36 PLATFORM_NAME(I915G),
37 PLATFORM_NAME(I915GM),
38 PLATFORM_NAME(I945G),
39 PLATFORM_NAME(I945GM),
40 PLATFORM_NAME(G33),
41 PLATFORM_NAME(PINEVIEW),
Jani Nikulac0f86832016-12-07 12:13:04 +020042 PLATFORM_NAME(I965G),
43 PLATFORM_NAME(I965GM),
Jani Nikulaf69c11a2016-11-30 17:43:05 +020044 PLATFORM_NAME(G45),
45 PLATFORM_NAME(GM45),
Jani Nikula2e0d26f2016-12-01 14:49:55 +020046 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),
Rodrigo Vivi71851fa2017-06-08 08:49:58 -070057 PLATFORM_NAME(COFFEELAKE),
Rodrigo Vivi413f3c12017-06-06 13:30:30 -070058 PLATFORM_NAME(CANNONLAKE),
Rodrigo Vivi412310012018-01-11 16:00:04 -020059 PLATFORM_NAME(ICELAKE),
Jani Nikula2e0d26f2016-12-01 14:49:55 +020060};
61#undef PLATFORM_NAME
62
63const char *intel_platform_name(enum intel_platform platform)
64{
Jani Nikula91600952017-02-28 13:11:43 +020065 BUILD_BUG_ON(ARRAY_SIZE(platform_names) != INTEL_MAX_PLATFORMS);
66
Jani Nikula2e0d26f2016-12-01 14:49:55 +020067 if (WARN_ON_ONCE(platform >= ARRAY_SIZE(platform_names) ||
68 platform_names[platform] == NULL))
69 return "<unknown>";
70
71 return platform_names[platform];
72}
73
Michal Wajdeczkoa8c9b842017-12-19 11:43:44 +000074void intel_device_info_dump_flags(const struct intel_device_info *info,
75 struct drm_printer *p)
76{
77#define PRINT_FLAG(name) drm_printf(p, "%s: %s\n", #name, yesno(info->name));
78 DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG);
79#undef PRINT_FLAG
80}
81
Michal Wajdeczko5fbbe8d2017-12-21 21:57:34 +000082static void sseu_dump(const struct sseu_dev_info *sseu, struct drm_printer *p)
83{
84 drm_printf(p, "slice mask: %04x\n", sseu->slice_mask);
85 drm_printf(p, "slice total: %u\n", hweight8(sseu->slice_mask));
86 drm_printf(p, "subslice total: %u\n", sseu_subslice_total(sseu));
87 drm_printf(p, "subslice mask %04x\n", sseu->subslice_mask);
88 drm_printf(p, "subslice per slice: %u\n",
89 hweight8(sseu->subslice_mask));
90 drm_printf(p, "EU total: %u\n", sseu->eu_total);
91 drm_printf(p, "EU per subslice: %u\n", sseu->eu_per_subslice);
92 drm_printf(p, "has slice power gating: %s\n",
93 yesno(sseu->has_slice_pg));
94 drm_printf(p, "has subslice power gating: %s\n",
95 yesno(sseu->has_subslice_pg));
96 drm_printf(p, "has EU power gating: %s\n", yesno(sseu->has_eu_pg));
97}
98
99void intel_device_info_dump_runtime(const struct intel_device_info *info,
100 struct drm_printer *p)
101{
102 sseu_dump(&info->sseu, p);
103
104 drm_printf(p, "CS timestamp frequency: %u kHz\n",
105 info->cs_timestamp_frequency_khz);
106}
107
Michal Wajdeczkoeb10ed92017-12-19 11:43:45 +0000108void intel_device_info_dump(const struct intel_device_info *info,
109 struct drm_printer *p)
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100110{
Michal Wajdeczkoeb10ed92017-12-19 11:43:45 +0000111 struct drm_i915_private *dev_priv =
112 container_of(info, struct drm_i915_private, info);
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100113
Michal Wajdeczkoeb10ed92017-12-19 11:43:45 +0000114 drm_printf(p, "pciid=0x%04x rev=0x%02x platform=%s gen=%i\n",
115 INTEL_DEVID(dev_priv),
116 INTEL_REVID(dev_priv),
117 intel_platform_name(info->platform),
118 info->gen);
Michal Wajdeczkoa8c9b842017-12-19 11:43:44 +0000119
Michal Wajdeczkoeb10ed92017-12-19 11:43:45 +0000120 intel_device_info_dump_flags(info, p);
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100121}
122
Ben Widawsky4e9767b2017-09-20 11:35:24 -0700123static void gen10_sseu_info_init(struct drm_i915_private *dev_priv)
124{
125 struct sseu_dev_info *sseu = &mkwrite_device_info(dev_priv)->sseu;
126 const u32 fuse2 = I915_READ(GEN8_FUSE2);
127
128 sseu->slice_mask = (fuse2 & GEN10_F2_S_ENA_MASK) >>
129 GEN10_F2_S_ENA_SHIFT;
130 sseu->subslice_mask = (1 << 4) - 1;
131 sseu->subslice_mask &= ~((fuse2 & GEN10_F2_SS_DIS_MASK) >>
132 GEN10_F2_SS_DIS_SHIFT);
133
134 sseu->eu_total = hweight32(~I915_READ(GEN8_EU_DISABLE0));
135 sseu->eu_total += hweight32(~I915_READ(GEN8_EU_DISABLE1));
136 sseu->eu_total += hweight32(~I915_READ(GEN8_EU_DISABLE2));
137 sseu->eu_total += hweight8(~(I915_READ(GEN10_EU_DISABLE3) &
138 GEN10_EU_DIS_SS_MASK));
139
140 /*
141 * CNL is expected to always have a uniform distribution
142 * of EU across subslices with the exception that any one
143 * EU in any one subslice may be fused off for die
144 * recovery.
145 */
146 sseu->eu_per_subslice = sseu_subslice_total(sseu) ?
147 DIV_ROUND_UP(sseu->eu_total,
148 sseu_subslice_total(sseu)) : 0;
149
150 /* No restrictions on Power Gating */
151 sseu->has_slice_pg = 1;
152 sseu->has_subslice_pg = 1;
153 sseu->has_eu_pg = 1;
154}
155
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100156static void cherryview_sseu_info_init(struct drm_i915_private *dev_priv)
157{
Imre Deak43b67992016-08-31 19:13:02 +0300158 struct sseu_dev_info *sseu = &mkwrite_device_info(dev_priv)->sseu;
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100159 u32 fuse, eu_dis;
160
161 fuse = I915_READ(CHV_FUSE_GT);
162
Imre Deakf08a0c92016-08-31 19:13:04 +0300163 sseu->slice_mask = BIT(0);
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100164
165 if (!(fuse & CHV_FGT_DISABLE_SS0)) {
Imre Deak57ec1712016-08-31 19:13:05 +0300166 sseu->subslice_mask |= BIT(0);
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100167 eu_dis = fuse & (CHV_FGT_EU_DIS_SS0_R0_MASK |
168 CHV_FGT_EU_DIS_SS0_R1_MASK);
Imre Deak43b67992016-08-31 19:13:02 +0300169 sseu->eu_total += 8 - hweight32(eu_dis);
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100170 }
171
172 if (!(fuse & CHV_FGT_DISABLE_SS1)) {
Imre Deak57ec1712016-08-31 19:13:05 +0300173 sseu->subslice_mask |= BIT(1);
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100174 eu_dis = fuse & (CHV_FGT_EU_DIS_SS1_R0_MASK |
175 CHV_FGT_EU_DIS_SS1_R1_MASK);
Imre Deak43b67992016-08-31 19:13:02 +0300176 sseu->eu_total += 8 - hweight32(eu_dis);
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100177 }
178
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100179 /*
180 * CHV expected to always have a uniform distribution of EU
181 * across subslices.
182 */
Imre Deak57ec1712016-08-31 19:13:05 +0300183 sseu->eu_per_subslice = sseu_subslice_total(sseu) ?
184 sseu->eu_total / sseu_subslice_total(sseu) :
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100185 0;
186 /*
187 * CHV supports subslice power gating on devices with more than
188 * one subslice, and supports EU power gating on devices with
189 * more than one EU pair per subslice.
190 */
Imre Deak43b67992016-08-31 19:13:02 +0300191 sseu->has_slice_pg = 0;
Imre Deak57ec1712016-08-31 19:13:05 +0300192 sseu->has_subslice_pg = sseu_subslice_total(sseu) > 1;
Imre Deak43b67992016-08-31 19:13:02 +0300193 sseu->has_eu_pg = (sseu->eu_per_subslice > 2);
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100194}
195
196static void gen9_sseu_info_init(struct drm_i915_private *dev_priv)
197{
198 struct intel_device_info *info = mkwrite_device_info(dev_priv);
Imre Deak43b67992016-08-31 19:13:02 +0300199 struct sseu_dev_info *sseu = &info->sseu;
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100200 int s_max = 3, ss_max = 4, eu_max = 8;
201 int s, ss;
Imre Deak57ec1712016-08-31 19:13:05 +0300202 u32 fuse2, eu_disable;
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100203 u8 eu_mask = 0xff;
204
205 fuse2 = I915_READ(GEN8_FUSE2);
Imre Deakf08a0c92016-08-31 19:13:04 +0300206 sseu->slice_mask = (fuse2 & GEN8_F2_S_ENA_MASK) >> GEN8_F2_S_ENA_SHIFT;
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100207
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100208 /*
209 * The subslice disable field is global, i.e. it applies
210 * to each of the enabled slices.
211 */
Imre Deak57ec1712016-08-31 19:13:05 +0300212 sseu->subslice_mask = (1 << ss_max) - 1;
213 sseu->subslice_mask &= ~((fuse2 & GEN9_F2_SS_DIS_MASK) >>
214 GEN9_F2_SS_DIS_SHIFT);
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100215
216 /*
217 * Iterate through enabled slices and subslices to
218 * count the total enabled EU.
219 */
220 for (s = 0; s < s_max; s++) {
Imre Deakf08a0c92016-08-31 19:13:04 +0300221 if (!(sseu->slice_mask & BIT(s)))
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100222 /* skip disabled slice */
223 continue;
224
225 eu_disable = I915_READ(GEN9_EU_DISABLE(s));
226 for (ss = 0; ss < ss_max; ss++) {
227 int eu_per_ss;
228
Imre Deak57ec1712016-08-31 19:13:05 +0300229 if (!(sseu->subslice_mask & BIT(ss)))
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100230 /* skip disabled subslice */
231 continue;
232
233 eu_per_ss = eu_max - hweight8((eu_disable >> (ss*8)) &
234 eu_mask);
235
236 /*
237 * Record which subslice(s) has(have) 7 EUs. we
238 * can tune the hash used to spread work among
239 * subslices if they are unbalanced.
240 */
241 if (eu_per_ss == 7)
Imre Deak43b67992016-08-31 19:13:02 +0300242 sseu->subslice_7eu[s] |= BIT(ss);
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100243
Imre Deak43b67992016-08-31 19:13:02 +0300244 sseu->eu_total += eu_per_ss;
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100245 }
246 }
247
248 /*
249 * SKL is expected to always have a uniform distribution
250 * of EU across subslices with the exception that any one
251 * EU in any one subslice may be fused off for die
252 * recovery. BXT is expected to be perfectly uniform in EU
253 * distribution.
254 */
Imre Deak57ec1712016-08-31 19:13:05 +0300255 sseu->eu_per_subslice = sseu_subslice_total(sseu) ?
Imre Deak43b67992016-08-31 19:13:02 +0300256 DIV_ROUND_UP(sseu->eu_total,
Imre Deak57ec1712016-08-31 19:13:05 +0300257 sseu_subslice_total(sseu)) : 0;
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100258 /*
Rodrigo Vivic7ae7e92017-06-06 13:30:36 -0700259 * SKL+ supports slice power gating on devices with more than
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100260 * one slice, and supports EU power gating on devices with
Rodrigo Vivic7ae7e92017-06-06 13:30:36 -0700261 * more than one EU pair per subslice. BXT+ supports subslice
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100262 * power gating on devices with more than one subslice, and
263 * supports EU power gating on devices with more than one EU
264 * pair per subslice.
265 */
Imre Deak43b67992016-08-31 19:13:02 +0300266 sseu->has_slice_pg =
Rodrigo Vivic7ae7e92017-06-06 13:30:36 -0700267 !IS_GEN9_LP(dev_priv) && hweight8(sseu->slice_mask) > 1;
Imre Deak43b67992016-08-31 19:13:02 +0300268 sseu->has_subslice_pg =
Michel Thierry254e0932017-01-09 16:51:35 +0200269 IS_GEN9_LP(dev_priv) && sseu_subslice_total(sseu) > 1;
Imre Deak43b67992016-08-31 19:13:02 +0300270 sseu->has_eu_pg = sseu->eu_per_subslice > 2;
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100271
Ander Conselvan de Oliveira234516a2017-03-17 16:04:36 +0200272 if (IS_GEN9_LP(dev_priv)) {
Imre Deak57ec1712016-08-31 19:13:05 +0300273#define IS_SS_DISABLED(ss) (!(sseu->subslice_mask & BIT(ss)))
Ander Conselvan de Oliveira234516a2017-03-17 16:04:36 +0200274 info->has_pooled_eu = hweight8(sseu->subslice_mask) == 3;
275
Imre Deak43b67992016-08-31 19:13:02 +0300276 sseu->min_eu_in_pool = 0;
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100277 if (info->has_pooled_eu) {
Imre Deak57ec1712016-08-31 19:13:05 +0300278 if (IS_SS_DISABLED(2) || IS_SS_DISABLED(0))
Imre Deak43b67992016-08-31 19:13:02 +0300279 sseu->min_eu_in_pool = 3;
Imre Deak57ec1712016-08-31 19:13:05 +0300280 else if (IS_SS_DISABLED(1))
Imre Deak43b67992016-08-31 19:13:02 +0300281 sseu->min_eu_in_pool = 6;
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100282 else
Imre Deak43b67992016-08-31 19:13:02 +0300283 sseu->min_eu_in_pool = 9;
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100284 }
285#undef IS_SS_DISABLED
286 }
287}
288
289static void broadwell_sseu_info_init(struct drm_i915_private *dev_priv)
290{
Imre Deak43b67992016-08-31 19:13:02 +0300291 struct sseu_dev_info *sseu = &mkwrite_device_info(dev_priv)->sseu;
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100292 const int s_max = 3, ss_max = 3, eu_max = 8;
293 int s, ss;
Jani Nikulaff64aa12016-10-04 12:54:12 +0300294 u32 fuse2, eu_disable[3]; /* s_max */
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100295
296 fuse2 = I915_READ(GEN8_FUSE2);
Imre Deakf08a0c92016-08-31 19:13:04 +0300297 sseu->slice_mask = (fuse2 & GEN8_F2_S_ENA_MASK) >> GEN8_F2_S_ENA_SHIFT;
Imre Deak57ec1712016-08-31 19:13:05 +0300298 /*
299 * The subslice disable field is global, i.e. it applies
300 * to each of the enabled slices.
301 */
Joonas Lahtinen3c779a42017-02-08 15:12:09 +0200302 sseu->subslice_mask = GENMASK(ss_max - 1, 0);
Imre Deak57ec1712016-08-31 19:13:05 +0300303 sseu->subslice_mask &= ~((fuse2 & GEN8_F2_SS_DIS_MASK) >>
304 GEN8_F2_SS_DIS_SHIFT);
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100305
306 eu_disable[0] = I915_READ(GEN8_EU_DISABLE0) & GEN8_EU_DIS0_S0_MASK;
307 eu_disable[1] = (I915_READ(GEN8_EU_DISABLE0) >> GEN8_EU_DIS0_S1_SHIFT) |
308 ((I915_READ(GEN8_EU_DISABLE1) & GEN8_EU_DIS1_S1_MASK) <<
309 (32 - GEN8_EU_DIS0_S1_SHIFT));
310 eu_disable[2] = (I915_READ(GEN8_EU_DISABLE1) >> GEN8_EU_DIS1_S2_SHIFT) |
311 ((I915_READ(GEN8_EU_DISABLE2) & GEN8_EU_DIS2_S2_MASK) <<
312 (32 - GEN8_EU_DIS1_S2_SHIFT));
313
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100314 /*
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100315 * Iterate through enabled slices and subslices to
316 * count the total enabled EU.
317 */
318 for (s = 0; s < s_max; s++) {
Imre Deakf08a0c92016-08-31 19:13:04 +0300319 if (!(sseu->slice_mask & BIT(s)))
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100320 /* skip disabled slice */
321 continue;
322
323 for (ss = 0; ss < ss_max; ss++) {
324 u32 n_disabled;
325
Imre Deak57ec1712016-08-31 19:13:05 +0300326 if (!(sseu->subslice_mask & BIT(ss)))
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100327 /* skip disabled subslice */
328 continue;
329
330 n_disabled = hweight8(eu_disable[s] >> (ss * eu_max));
331
332 /*
333 * Record which subslices have 7 EUs.
334 */
335 if (eu_max - n_disabled == 7)
Imre Deak43b67992016-08-31 19:13:02 +0300336 sseu->subslice_7eu[s] |= 1 << ss;
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100337
Imre Deak43b67992016-08-31 19:13:02 +0300338 sseu->eu_total += eu_max - n_disabled;
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100339 }
340 }
341
342 /*
343 * BDW is expected to always have a uniform distribution of EU across
344 * subslices with the exception that any one EU in any one subslice may
345 * be fused off for die recovery.
346 */
Imre Deak57ec1712016-08-31 19:13:05 +0300347 sseu->eu_per_subslice = sseu_subslice_total(sseu) ?
348 DIV_ROUND_UP(sseu->eu_total,
349 sseu_subslice_total(sseu)) : 0;
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100350
351 /*
352 * BDW supports slice power gating on devices with more than
353 * one slice.
354 */
Imre Deakf08a0c92016-08-31 19:13:04 +0300355 sseu->has_slice_pg = hweight8(sseu->slice_mask) > 1;
Imre Deak43b67992016-08-31 19:13:02 +0300356 sseu->has_subslice_pg = 0;
357 sseu->has_eu_pg = 0;
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100358}
359
Lionel Landwerlinb8ec7592018-02-21 20:49:02 +0000360static void haswell_sseu_info_init(struct drm_i915_private *dev_priv)
361{
362 struct intel_device_info *info = mkwrite_device_info(dev_priv);
363 struct sseu_dev_info *sseu = &info->sseu;
364 u32 fuse1;
365
366 /*
367 * There isn't a register to tell us how many slices/subslices. We
368 * work off the PCI-ids here.
369 */
370 switch (info->gt) {
371 default:
372 MISSING_CASE(info->gt);
373 /* fall through */
374 case 1:
375 sseu->slice_mask = BIT(0);
376 sseu->subslice_mask = BIT(0);
377 break;
378 case 2:
379 sseu->slice_mask = BIT(0);
380 sseu->subslice_mask = BIT(0) | BIT(1);
381 break;
382 case 3:
383 sseu->slice_mask = BIT(0) | BIT(1);
384 sseu->subslice_mask = BIT(0) | BIT(1);
385 break;
386 }
387
388 fuse1 = I915_READ(HSW_PAVP_FUSE1);
389 switch ((fuse1 & HSW_F1_EU_DIS_MASK) >> HSW_F1_EU_DIS_SHIFT) {
390 default:
391 MISSING_CASE((fuse1 & HSW_F1_EU_DIS_MASK) >>
392 HSW_F1_EU_DIS_SHIFT);
393 /* fall through */
394 case HSW_F1_EU_DIS_10EUS:
395 sseu->eu_per_subslice = 10;
396 break;
397 case HSW_F1_EU_DIS_8EUS:
398 sseu->eu_per_subslice = 8;
399 break;
400 case HSW_F1_EU_DIS_6EUS:
401 sseu->eu_per_subslice = 6;
402 break;
403 }
404
405 sseu->eu_total = sseu_subslice_total(sseu) * sseu->eu_per_subslice;
406
407 /* No powergating for you. */
408 sseu->has_slice_pg = 0;
409 sseu->has_subslice_pg = 0;
410 sseu->has_eu_pg = 0;
411}
412
Lionel Landwerlinf577a032017-11-13 23:34:53 +0000413static u32 read_reference_ts_freq(struct drm_i915_private *dev_priv)
Lionel Landwerlindab91782017-11-10 19:08:44 +0000414{
415 u32 ts_override = I915_READ(GEN9_TIMESTAMP_OVERRIDE);
Lionel Landwerlinf577a032017-11-13 23:34:53 +0000416 u32 base_freq, frac_freq;
Lionel Landwerlindab91782017-11-10 19:08:44 +0000417
418 base_freq = ((ts_override & GEN9_TIMESTAMP_OVERRIDE_US_COUNTER_DIVIDER_MASK) >>
419 GEN9_TIMESTAMP_OVERRIDE_US_COUNTER_DIVIDER_SHIFT) + 1;
Lionel Landwerlinf577a032017-11-13 23:34:53 +0000420 base_freq *= 1000;
Lionel Landwerlindab91782017-11-10 19:08:44 +0000421
422 frac_freq = ((ts_override &
423 GEN9_TIMESTAMP_OVERRIDE_US_COUNTER_DENOMINATOR_MASK) >>
424 GEN9_TIMESTAMP_OVERRIDE_US_COUNTER_DENOMINATOR_SHIFT);
Lionel Landwerlinf577a032017-11-13 23:34:53 +0000425 frac_freq = 1000 / (frac_freq + 1);
Lionel Landwerlindab91782017-11-10 19:08:44 +0000426
427 return base_freq + frac_freq;
428}
429
Lionel Landwerlinf577a032017-11-13 23:34:53 +0000430static u32 read_timestamp_frequency(struct drm_i915_private *dev_priv)
Lionel Landwerlindab91782017-11-10 19:08:44 +0000431{
Lionel Landwerlinf577a032017-11-13 23:34:53 +0000432 u32 f12_5_mhz = 12500;
433 u32 f19_2_mhz = 19200;
434 u32 f24_mhz = 24000;
Lionel Landwerlindab91782017-11-10 19:08:44 +0000435
436 if (INTEL_GEN(dev_priv) <= 4) {
437 /* PRMs say:
438 *
439 * "The value in this register increments once every 16
440 * hclks." (through the “Clocking Configuration”
441 * (“CLKCFG”) MCHBAR register)
442 */
Lionel Landwerlinf577a032017-11-13 23:34:53 +0000443 return dev_priv->rawclk_freq / 16;
Lionel Landwerlindab91782017-11-10 19:08:44 +0000444 } else if (INTEL_GEN(dev_priv) <= 8) {
445 /* PRMs say:
446 *
447 * "The PCU TSC counts 10ns increments; this timestamp
448 * reflects bits 38:3 of the TSC (i.e. 80ns granularity,
449 * rolling over every 1.5 hours).
450 */
451 return f12_5_mhz;
452 } else if (INTEL_GEN(dev_priv) <= 9) {
453 u32 ctc_reg = I915_READ(CTC_MODE);
Lionel Landwerlinf577a032017-11-13 23:34:53 +0000454 u32 freq = 0;
Lionel Landwerlindab91782017-11-10 19:08:44 +0000455
456 if ((ctc_reg & CTC_SOURCE_PARAMETER_MASK) == CTC_SOURCE_DIVIDE_LOGIC) {
457 freq = read_reference_ts_freq(dev_priv);
458 } else {
459 freq = IS_GEN9_LP(dev_priv) ? f19_2_mhz : f24_mhz;
460
461 /* Now figure out how the command stream's timestamp
462 * register increments from this frequency (it might
463 * increment only every few clock cycle).
464 */
465 freq >>= 3 - ((ctc_reg & CTC_SHIFT_PARAMETER_MASK) >>
466 CTC_SHIFT_PARAMETER_SHIFT);
467 }
468
469 return freq;
470 } else if (INTEL_GEN(dev_priv) <= 10) {
471 u32 ctc_reg = I915_READ(CTC_MODE);
Lionel Landwerlinf577a032017-11-13 23:34:53 +0000472 u32 freq = 0;
Lionel Landwerlindab91782017-11-10 19:08:44 +0000473 u32 rpm_config_reg = 0;
474
475 /* First figure out the reference frequency. There are 2 ways
476 * we can compute the frequency, either through the
477 * TIMESTAMP_OVERRIDE register or through RPM_CONFIG. CTC_MODE
478 * tells us which one we should use.
479 */
480 if ((ctc_reg & CTC_SOURCE_PARAMETER_MASK) == CTC_SOURCE_DIVIDE_LOGIC) {
481 freq = read_reference_ts_freq(dev_priv);
482 } else {
483 u32 crystal_clock;
484
485 rpm_config_reg = I915_READ(RPM_CONFIG0);
486 crystal_clock = (rpm_config_reg &
487 GEN9_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_MASK) >>
488 GEN9_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_SHIFT;
489 switch (crystal_clock) {
490 case GEN9_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_19_2_MHZ:
491 freq = f19_2_mhz;
492 break;
493 case GEN9_RPM_CONFIG0_CRYSTAL_CLOCK_FREQ_24_MHZ:
494 freq = f24_mhz;
495 break;
496 }
Lionel Landwerlindab91782017-11-10 19:08:44 +0000497
Lionel Landwerlin53ff2642017-11-13 23:34:55 +0000498 /* Now figure out how the command stream's timestamp
499 * register increments from this frequency (it might
500 * increment only every few clock cycle).
501 */
502 freq >>= 3 - ((rpm_config_reg &
503 GEN10_RPM_CONFIG0_CTC_SHIFT_PARAMETER_MASK) >>
504 GEN10_RPM_CONFIG0_CTC_SHIFT_PARAMETER_SHIFT);
505 }
Lionel Landwerlindab91782017-11-10 19:08:44 +0000506
507 return freq;
508 }
509
Lionel Landwerlinfe66e922017-12-13 17:11:54 +0000510 MISSING_CASE("Unknown gen, unable to read command streamer timestamp frequency\n");
Lionel Landwerlindab91782017-11-10 19:08:44 +0000511 return 0;
512}
513
Michal Wajdeczko6a7e51f2017-12-21 21:57:33 +0000514/**
515 * intel_device_info_runtime_init - initialize runtime info
516 * @info: intel device info struct
517 *
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100518 * Determine various intel_device_info fields at runtime.
519 *
520 * Use it when either:
521 * - it's judged too laborious to fill n static structures with the limit
522 * when a simple if statement does the job,
523 * - run-time checks (eg read fuse/strap registers) are needed.
524 *
525 * This function needs to be called:
526 * - after the MMIO has been setup as we are reading registers,
527 * - after the PCH has been detected,
528 * - before the first usage of the fields it can tweak.
529 */
Michal Wajdeczko6a7e51f2017-12-21 21:57:33 +0000530void intel_device_info_runtime_init(struct intel_device_info *info)
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100531{
Michal Wajdeczko6a7e51f2017-12-21 21:57:33 +0000532 struct drm_i915_private *dev_priv =
533 container_of(info, struct drm_i915_private, info);
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100534 enum pipe pipe;
535
Mika Kahola6e7406d2017-11-01 12:08:50 +0200536 if (INTEL_GEN(dev_priv) >= 10) {
537 for_each_pipe(dev_priv, pipe)
538 info->num_scalers[pipe] = 2;
539 } else if (INTEL_GEN(dev_priv) == 9) {
Ander Conselvan de Oliveira0bf02302017-01-02 15:54:41 +0200540 info->num_scalers[PIPE_A] = 2;
541 info->num_scalers[PIPE_B] = 2;
542 info->num_scalers[PIPE_C] = 1;
543 }
544
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100545 /*
546 * Skylake and Broxton currently don't expose the topmost plane as its
547 * use is exclusive with the legacy cursor and we only want to expose
548 * one of those, not both. Until we can safely expose the topmost plane
549 * as a DRM_PLANE_TYPE_CURSOR with all the features exposed/supported,
550 * we don't expose the topmost plane at all to prevent ABI breakage
551 * down the line.
552 */
James Irwin8366be92017-06-06 13:30:35 -0700553 if (IS_GEN10(dev_priv) || IS_GEMINILAKE(dev_priv))
Ander Conselvan de Oliveirae9c98822016-12-02 10:23:57 +0200554 for_each_pipe(dev_priv, pipe)
555 info->num_sprites[pipe] = 3;
556 else if (IS_BROXTON(dev_priv)) {
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100557 info->num_sprites[PIPE_A] = 2;
558 info->num_sprites[PIPE_B] = 2;
559 info->num_sprites[PIPE_C] = 1;
Ville Syrjälä33edc242016-10-25 18:58:00 +0300560 } else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100561 for_each_pipe(dev_priv, pipe)
562 info->num_sprites[pipe] = 2;
Ville Syrjäläab330812017-04-21 21:14:32 +0300563 } else if (INTEL_GEN(dev_priv) >= 5 || IS_G4X(dev_priv)) {
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100564 for_each_pipe(dev_priv, pipe)
565 info->num_sprites[pipe] = 1;
Ville Syrjälä33edc242016-10-25 18:58:00 +0300566 }
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100567
Michal Wajdeczko4f044a82017-09-19 19:38:44 +0000568 if (i915_modparams.disable_display) {
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100569 DRM_INFO("Display disabled (module parameter)\n");
570 info->num_pipes = 0;
571 } else if (info->num_pipes > 0 &&
572 (IS_GEN7(dev_priv) || IS_GEN8(dev_priv)) &&
573 HAS_PCH_SPLIT(dev_priv)) {
574 u32 fuse_strap = I915_READ(FUSE_STRAP);
575 u32 sfuse_strap = I915_READ(SFUSE_STRAP);
576
577 /*
578 * SFUSE_STRAP is supposed to have a bit signalling the display
579 * is fused off. Unfortunately it seems that, at least in
580 * certain cases, fused off display means that PCH display
581 * reads don't land anywhere. In that case, we read 0s.
582 *
583 * On CPT/PPT, we can detect this case as SFUSE_STRAP_FUSE_LOCK
584 * should be set when taking over after the firmware.
585 */
586 if (fuse_strap & ILK_INTERNAL_DISPLAY_DISABLE ||
587 sfuse_strap & SFUSE_STRAP_DISPLAY_DISABLED ||
Ville Syrjäläb9eb89b2017-06-20 16:03:06 +0300588 (HAS_PCH_CPT(dev_priv) &&
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100589 !(sfuse_strap & SFUSE_STRAP_FUSE_LOCK))) {
590 DRM_INFO("Display fused off, disabling\n");
591 info->num_pipes = 0;
592 } else if (fuse_strap & IVB_PIPE_C_DISABLE) {
593 DRM_INFO("PipeC fused off\n");
594 info->num_pipes -= 1;
595 }
596 } else if (info->num_pipes > 0 && IS_GEN9(dev_priv)) {
597 u32 dfsm = I915_READ(SKL_DFSM);
598 u8 disabled_mask = 0;
599 bool invalid;
600 int num_bits;
601
602 if (dfsm & SKL_DFSM_PIPE_A_DISABLE)
603 disabled_mask |= BIT(PIPE_A);
604 if (dfsm & SKL_DFSM_PIPE_B_DISABLE)
605 disabled_mask |= BIT(PIPE_B);
606 if (dfsm & SKL_DFSM_PIPE_C_DISABLE)
607 disabled_mask |= BIT(PIPE_C);
608
609 num_bits = hweight8(disabled_mask);
610
611 switch (disabled_mask) {
612 case BIT(PIPE_A):
613 case BIT(PIPE_B):
614 case BIT(PIPE_A) | BIT(PIPE_B):
615 case BIT(PIPE_A) | BIT(PIPE_C):
616 invalid = true;
617 break;
618 default:
619 invalid = false;
620 }
621
622 if (num_bits > info->num_pipes || invalid)
623 DRM_ERROR("invalid pipe fuse configuration: 0x%x\n",
624 disabled_mask);
625 else
626 info->num_pipes -= num_bits;
627 }
628
629 /* Initialize slice/subslice/EU info */
Lionel Landwerlinb8ec7592018-02-21 20:49:02 +0000630 if (IS_HASWELL(dev_priv))
631 haswell_sseu_info_init(dev_priv);
632 else if (IS_CHERRYVIEW(dev_priv))
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100633 cherryview_sseu_info_init(dev_priv);
634 else if (IS_BROADWELL(dev_priv))
635 broadwell_sseu_info_init(dev_priv);
Ben Widawsky4e9767b2017-09-20 11:35:24 -0700636 else if (INTEL_GEN(dev_priv) == 9)
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100637 gen9_sseu_info_init(dev_priv);
Ben Widawsky4e9767b2017-09-20 11:35:24 -0700638 else if (INTEL_GEN(dev_priv) >= 10)
639 gen10_sseu_info_init(dev_priv);
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100640
Lionel Landwerlindab91782017-11-10 19:08:44 +0000641 /* Initialize command stream timestamp frequency */
Lionel Landwerlinf577a032017-11-13 23:34:53 +0000642 info->cs_timestamp_frequency_khz = read_timestamp_frequency(dev_priv);
Chris Wilson94b4f3b2016-07-05 10:40:20 +0100643}
Chris Wilson3fed1802018-02-07 21:05:43 +0000644
645void intel_driver_caps_print(const struct intel_driver_caps *caps,
646 struct drm_printer *p)
647{
648 drm_printf(p, "scheduler: %x\n", caps->scheduler);
649}