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 <linux/string_helpers.h>
27 #include <drm/drm_print.h>
28 #include <drm/i915_pciids.h>
30 #include "display/intel_cdclk.h"
31 #include "display/intel_de.h"
32 #include "intel_device_info.h"
34 #include "i915_utils.h"
36 #define PLATFORM_NAME(x) [INTEL_##x] = #x
37 static const char * const platform_names[] = {
43 PLATFORM_NAME(I915GM),
45 PLATFORM_NAME(I945GM),
47 PLATFORM_NAME(PINEVIEW),
49 PLATFORM_NAME(I965GM),
52 PLATFORM_NAME(IRONLAKE),
53 PLATFORM_NAME(SANDYBRIDGE),
54 PLATFORM_NAME(IVYBRIDGE),
55 PLATFORM_NAME(VALLEYVIEW),
56 PLATFORM_NAME(HASWELL),
57 PLATFORM_NAME(BROADWELL),
58 PLATFORM_NAME(CHERRYVIEW),
59 PLATFORM_NAME(SKYLAKE),
60 PLATFORM_NAME(BROXTON),
61 PLATFORM_NAME(KABYLAKE),
62 PLATFORM_NAME(GEMINILAKE),
63 PLATFORM_NAME(COFFEELAKE),
64 PLATFORM_NAME(COMETLAKE),
65 PLATFORM_NAME(ICELAKE),
66 PLATFORM_NAME(ELKHARTLAKE),
67 PLATFORM_NAME(JASPERLAKE),
68 PLATFORM_NAME(TIGERLAKE),
69 PLATFORM_NAME(ROCKETLAKE),
71 PLATFORM_NAME(ALDERLAKE_S),
72 PLATFORM_NAME(ALDERLAKE_P),
73 PLATFORM_NAME(XEHPSDV),
75 PLATFORM_NAME(PONTEVECCHIO),
76 PLATFORM_NAME(METEORLAKE),
80 const char *intel_platform_name(enum intel_platform platform)
82 BUILD_BUG_ON(ARRAY_SIZE(platform_names) != INTEL_MAX_PLATFORMS);
84 if (WARN_ON_ONCE(platform >= ARRAY_SIZE(platform_names) ||
85 platform_names[platform] == NULL))
88 return platform_names[platform];
91 void intel_device_info_print_static(const struct intel_device_info *info,
92 struct drm_printer *p)
94 if (info->graphics.rel)
95 drm_printf(p, "graphics version: %u.%02u\n", info->graphics.ver,
98 drm_printf(p, "graphics version: %u\n", info->graphics.ver);
101 drm_printf(p, "media version: %u.%02u\n", info->media.ver, info->media.rel);
103 drm_printf(p, "media version: %u\n", info->media.ver);
105 if (info->display.rel)
106 drm_printf(p, "display version: %u.%02u\n", info->display.ver, info->display.rel);
108 drm_printf(p, "display version: %u\n", info->display.ver);
110 drm_printf(p, "gt: %d\n", info->gt);
111 drm_printf(p, "memory-regions: %x\n", info->memory_regions);
112 drm_printf(p, "page-sizes: %x\n", info->page_sizes);
113 drm_printf(p, "platform: %s\n", intel_platform_name(info->platform));
114 drm_printf(p, "ppgtt-size: %d\n", info->ppgtt_size);
115 drm_printf(p, "ppgtt-type: %d\n", info->ppgtt_type);
116 drm_printf(p, "dma_mask_size: %u\n", info->dma_mask_size);
118 #define PRINT_FLAG(name) drm_printf(p, "%s: %s\n", #name, str_yes_no(info->name))
119 DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG);
122 #define PRINT_FLAG(name) drm_printf(p, "%s: %s\n", #name, str_yes_no(info->display.name))
123 DEV_INFO_DISPLAY_FOR_EACH_FLAG(PRINT_FLAG);
127 void intel_device_info_print_runtime(const struct intel_runtime_info *info,
128 struct drm_printer *p)
130 drm_printf(p, "rawclk rate: %u kHz\n", info->rawclk_freq);
133 #undef INTEL_VGA_DEVICE
134 #define INTEL_VGA_DEVICE(id, info) (id)
136 static const u16 subplatform_ult_ids[] = {
137 INTEL_HSW_ULT_GT1_IDS(0),
138 INTEL_HSW_ULT_GT2_IDS(0),
139 INTEL_HSW_ULT_GT3_IDS(0),
140 INTEL_BDW_ULT_GT1_IDS(0),
141 INTEL_BDW_ULT_GT2_IDS(0),
142 INTEL_BDW_ULT_GT3_IDS(0),
143 INTEL_BDW_ULT_RSVD_IDS(0),
144 INTEL_SKL_ULT_GT1_IDS(0),
145 INTEL_SKL_ULT_GT2_IDS(0),
146 INTEL_SKL_ULT_GT3_IDS(0),
147 INTEL_KBL_ULT_GT1_IDS(0),
148 INTEL_KBL_ULT_GT2_IDS(0),
149 INTEL_KBL_ULT_GT3_IDS(0),
150 INTEL_CFL_U_GT2_IDS(0),
151 INTEL_CFL_U_GT3_IDS(0),
152 INTEL_WHL_U_GT1_IDS(0),
153 INTEL_WHL_U_GT2_IDS(0),
154 INTEL_WHL_U_GT3_IDS(0),
155 INTEL_CML_U_GT1_IDS(0),
156 INTEL_CML_U_GT2_IDS(0),
159 static const u16 subplatform_ulx_ids[] = {
160 INTEL_HSW_ULX_GT1_IDS(0),
161 INTEL_HSW_ULX_GT2_IDS(0),
162 INTEL_BDW_ULX_GT1_IDS(0),
163 INTEL_BDW_ULX_GT2_IDS(0),
164 INTEL_BDW_ULX_GT3_IDS(0),
165 INTEL_BDW_ULX_RSVD_IDS(0),
166 INTEL_SKL_ULX_GT1_IDS(0),
167 INTEL_SKL_ULX_GT2_IDS(0),
168 INTEL_KBL_ULX_GT1_IDS(0),
169 INTEL_KBL_ULX_GT2_IDS(0),
170 INTEL_AML_KBL_GT2_IDS(0),
171 INTEL_AML_CFL_GT2_IDS(0),
174 static const u16 subplatform_portf_ids[] = {
175 INTEL_ICL_PORT_F_IDS(0),
178 static const u16 subplatform_uy_ids[] = {
179 INTEL_TGL_12_GT2_IDS(0),
182 static const u16 subplatform_n_ids[] = {
186 static const u16 subplatform_rpl_ids[] = {
191 static const u16 subplatform_g10_ids[] = {
192 INTEL_DG2_G10_IDS(0),
193 INTEL_ATS_M150_IDS(0),
196 static const u16 subplatform_g11_ids[] = {
197 INTEL_DG2_G11_IDS(0),
198 INTEL_ATS_M75_IDS(0),
201 static const u16 subplatform_g12_ids[] = {
202 INTEL_DG2_G12_IDS(0),
205 static const u16 subplatform_m_ids[] = {
209 static const u16 subplatform_p_ids[] = {
213 static bool find_devid(u16 id, const u16 *p, unsigned int num)
215 for (; num; num--, p++) {
223 void intel_device_info_subplatform_init(struct drm_i915_private *i915)
225 const struct intel_device_info *info = INTEL_INFO(i915);
226 const struct intel_runtime_info *rinfo = RUNTIME_INFO(i915);
227 const unsigned int pi = __platform_mask_index(rinfo, info->platform);
228 const unsigned int pb = __platform_mask_bit(rinfo, info->platform);
229 u16 devid = INTEL_DEVID(i915);
232 /* Make sure IS_<platform> checks are working. */
233 RUNTIME_INFO(i915)->platform_mask[pi] = BIT(pb);
235 /* Find and mark subplatform bits based on the PCI device id. */
236 if (find_devid(devid, subplatform_ult_ids,
237 ARRAY_SIZE(subplatform_ult_ids))) {
238 mask = BIT(INTEL_SUBPLATFORM_ULT);
239 } else if (find_devid(devid, subplatform_ulx_ids,
240 ARRAY_SIZE(subplatform_ulx_ids))) {
241 mask = BIT(INTEL_SUBPLATFORM_ULX);
242 if (IS_HASWELL(i915) || IS_BROADWELL(i915)) {
243 /* ULX machines are also considered ULT. */
244 mask |= BIT(INTEL_SUBPLATFORM_ULT);
246 } else if (find_devid(devid, subplatform_portf_ids,
247 ARRAY_SIZE(subplatform_portf_ids))) {
248 mask = BIT(INTEL_SUBPLATFORM_PORTF);
249 } else if (find_devid(devid, subplatform_uy_ids,
250 ARRAY_SIZE(subplatform_uy_ids))) {
251 mask = BIT(INTEL_SUBPLATFORM_UY);
252 } else if (find_devid(devid, subplatform_n_ids,
253 ARRAY_SIZE(subplatform_n_ids))) {
254 mask = BIT(INTEL_SUBPLATFORM_N);
255 } else if (find_devid(devid, subplatform_rpl_ids,
256 ARRAY_SIZE(subplatform_rpl_ids))) {
257 mask = BIT(INTEL_SUBPLATFORM_RPL);
258 } else if (find_devid(devid, subplatform_g10_ids,
259 ARRAY_SIZE(subplatform_g10_ids))) {
260 mask = BIT(INTEL_SUBPLATFORM_G10);
261 } else if (find_devid(devid, subplatform_g11_ids,
262 ARRAY_SIZE(subplatform_g11_ids))) {
263 mask = BIT(INTEL_SUBPLATFORM_G11);
264 } else if (find_devid(devid, subplatform_g12_ids,
265 ARRAY_SIZE(subplatform_g12_ids))) {
266 mask = BIT(INTEL_SUBPLATFORM_G12);
267 } else if (find_devid(devid, subplatform_m_ids,
268 ARRAY_SIZE(subplatform_m_ids))) {
269 mask = BIT(INTEL_SUBPLATFORM_M);
270 } else if (find_devid(devid, subplatform_p_ids,
271 ARRAY_SIZE(subplatform_p_ids))) {
272 mask = BIT(INTEL_SUBPLATFORM_P);
275 GEM_BUG_ON(mask & ~INTEL_SUBPLATFORM_MASK);
277 RUNTIME_INFO(i915)->platform_mask[pi] |= mask;
281 * intel_device_info_runtime_init - initialize runtime info
282 * @dev_priv: the i915 device
284 * Determine various intel_device_info fields at runtime.
286 * Use it when either:
287 * - it's judged too laborious to fill n static structures with the limit
288 * when a simple if statement does the job,
289 * - run-time checks (eg read fuse/strap registers) are needed.
291 * This function needs to be called:
292 * - after the MMIO has been setup as we are reading registers,
293 * - after the PCH has been detected,
294 * - before the first usage of the fields it can tweak.
296 void intel_device_info_runtime_init(struct drm_i915_private *dev_priv)
298 struct intel_device_info *info = mkwrite_device_info(dev_priv);
299 struct intel_runtime_info *runtime = RUNTIME_INFO(dev_priv);
302 /* Wa_14011765242: adl-s A0,A1 */
303 if (IS_ADLS_DISPLAY_STEP(dev_priv, STEP_A0, STEP_A2))
304 for_each_pipe(dev_priv, pipe)
305 runtime->num_scalers[pipe] = 0;
306 else if (DISPLAY_VER(dev_priv) >= 11) {
307 for_each_pipe(dev_priv, pipe)
308 runtime->num_scalers[pipe] = 2;
309 } else if (DISPLAY_VER(dev_priv) >= 9) {
310 runtime->num_scalers[PIPE_A] = 2;
311 runtime->num_scalers[PIPE_B] = 2;
312 runtime->num_scalers[PIPE_C] = 1;
315 BUILD_BUG_ON(BITS_PER_TYPE(intel_engine_mask_t) < I915_NUM_ENGINES);
317 if (DISPLAY_VER(dev_priv) >= 13 || HAS_D12_PLANE_MINIMIZATION(dev_priv))
318 for_each_pipe(dev_priv, pipe)
319 runtime->num_sprites[pipe] = 4;
320 else if (DISPLAY_VER(dev_priv) >= 11)
321 for_each_pipe(dev_priv, pipe)
322 runtime->num_sprites[pipe] = 6;
323 else if (DISPLAY_VER(dev_priv) == 10)
324 for_each_pipe(dev_priv, pipe)
325 runtime->num_sprites[pipe] = 3;
326 else if (IS_BROXTON(dev_priv)) {
328 * Skylake and Broxton currently don't expose the topmost plane as its
329 * use is exclusive with the legacy cursor and we only want to expose
330 * one of those, not both. Until we can safely expose the topmost plane
331 * as a DRM_PLANE_TYPE_CURSOR with all the features exposed/supported,
332 * we don't expose the topmost plane at all to prevent ABI breakage
336 runtime->num_sprites[PIPE_A] = 2;
337 runtime->num_sprites[PIPE_B] = 2;
338 runtime->num_sprites[PIPE_C] = 1;
339 } else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
340 for_each_pipe(dev_priv, pipe)
341 runtime->num_sprites[pipe] = 2;
342 } else if (DISPLAY_VER(dev_priv) >= 5 || IS_G4X(dev_priv)) {
343 for_each_pipe(dev_priv, pipe)
344 runtime->num_sprites[pipe] = 1;
347 if (HAS_DISPLAY(dev_priv) && IS_GRAPHICS_VER(dev_priv, 7, 8) &&
348 HAS_PCH_SPLIT(dev_priv)) {
349 u32 fuse_strap = intel_de_read(dev_priv, FUSE_STRAP);
350 u32 sfuse_strap = intel_de_read(dev_priv, SFUSE_STRAP);
353 * SFUSE_STRAP is supposed to have a bit signalling the display
354 * is fused off. Unfortunately it seems that, at least in
355 * certain cases, fused off display means that PCH display
356 * reads don't land anywhere. In that case, we read 0s.
358 * On CPT/PPT, we can detect this case as SFUSE_STRAP_FUSE_LOCK
359 * should be set when taking over after the firmware.
361 if (fuse_strap & ILK_INTERNAL_DISPLAY_DISABLE ||
362 sfuse_strap & SFUSE_STRAP_DISPLAY_DISABLED ||
363 (HAS_PCH_CPT(dev_priv) &&
364 !(sfuse_strap & SFUSE_STRAP_FUSE_LOCK))) {
365 drm_info(&dev_priv->drm,
366 "Display fused off, disabling\n");
367 info->display.pipe_mask = 0;
368 info->display.cpu_transcoder_mask = 0;
369 info->display.fbc_mask = 0;
370 } else if (fuse_strap & IVB_PIPE_C_DISABLE) {
371 drm_info(&dev_priv->drm, "PipeC fused off\n");
372 info->display.pipe_mask &= ~BIT(PIPE_C);
373 info->display.cpu_transcoder_mask &= ~BIT(TRANSCODER_C);
375 } else if (HAS_DISPLAY(dev_priv) && DISPLAY_VER(dev_priv) >= 9) {
376 u32 dfsm = intel_de_read(dev_priv, SKL_DFSM);
378 if (dfsm & SKL_DFSM_PIPE_A_DISABLE) {
379 info->display.pipe_mask &= ~BIT(PIPE_A);
380 info->display.cpu_transcoder_mask &= ~BIT(TRANSCODER_A);
381 info->display.fbc_mask &= ~BIT(INTEL_FBC_A);
383 if (dfsm & SKL_DFSM_PIPE_B_DISABLE) {
384 info->display.pipe_mask &= ~BIT(PIPE_B);
385 info->display.cpu_transcoder_mask &= ~BIT(TRANSCODER_B);
387 if (dfsm & SKL_DFSM_PIPE_C_DISABLE) {
388 info->display.pipe_mask &= ~BIT(PIPE_C);
389 info->display.cpu_transcoder_mask &= ~BIT(TRANSCODER_C);
392 if (DISPLAY_VER(dev_priv) >= 12 &&
393 (dfsm & TGL_DFSM_PIPE_D_DISABLE)) {
394 info->display.pipe_mask &= ~BIT(PIPE_D);
395 info->display.cpu_transcoder_mask &= ~BIT(TRANSCODER_D);
398 if (dfsm & SKL_DFSM_DISPLAY_HDCP_DISABLE)
399 info->display.has_hdcp = 0;
401 if (dfsm & SKL_DFSM_DISPLAY_PM_DISABLE)
402 info->display.fbc_mask = 0;
404 if (DISPLAY_VER(dev_priv) >= 11 && (dfsm & ICL_DFSM_DMC_DISABLE))
405 info->display.has_dmc = 0;
407 if (DISPLAY_VER(dev_priv) >= 10 &&
408 (dfsm & GLK_DFSM_DISPLAY_DSC_DISABLE))
409 info->display.has_dsc = 0;
412 if (GRAPHICS_VER(dev_priv) == 6 && i915_vtd_active(dev_priv)) {
413 drm_info(&dev_priv->drm,
414 "Disabling ppGTT for VT-d support\n");
415 info->ppgtt_type = INTEL_PPGTT_NONE;
418 runtime->rawclk_freq = intel_read_rawclk(dev_priv);
419 drm_dbg(&dev_priv->drm, "rawclk rate: %d kHz\n", runtime->rawclk_freq);
421 if (!HAS_DISPLAY(dev_priv)) {
422 dev_priv->drm.driver_features &= ~(DRIVER_MODESET |
424 memset(&info->display, 0, sizeof(info->display));
425 memset(runtime->num_sprites, 0, sizeof(runtime->num_sprites));
426 memset(runtime->num_scalers, 0, sizeof(runtime->num_scalers));
430 void intel_driver_caps_print(const struct intel_driver_caps *caps,
431 struct drm_printer *p)
433 drm_printf(p, "Has logical contexts? %s\n",
434 str_yes_no(caps->has_logical_contexts));
435 drm_printf(p, "scheduler: %x\n", caps->scheduler);