xref: /linux/drivers/gpu/drm/i915/intel_device_info.c (revision f868cd2517763c66783c6000b29d97f0b966b311)
194b4f3baSChris Wilson /*
294b4f3baSChris Wilson  * Copyright © 2016 Intel Corporation
394b4f3baSChris Wilson  *
494b4f3baSChris Wilson  * Permission is hereby granted, free of charge, to any person obtaining a
594b4f3baSChris Wilson  * copy of this software and associated documentation files (the "Software"),
694b4f3baSChris Wilson  * to deal in the Software without restriction, including without limitation
794b4f3baSChris Wilson  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
894b4f3baSChris Wilson  * and/or sell copies of the Software, and to permit persons to whom the
994b4f3baSChris Wilson  * Software is furnished to do so, subject to the following conditions:
1094b4f3baSChris Wilson  *
1194b4f3baSChris Wilson  * The above copyright notice and this permission notice (including the next
1294b4f3baSChris Wilson  * paragraph) shall be included in all copies or substantial portions of the
1394b4f3baSChris Wilson  * Software.
1494b4f3baSChris Wilson  *
1594b4f3baSChris Wilson  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1694b4f3baSChris Wilson  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1794b4f3baSChris Wilson  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
1894b4f3baSChris Wilson  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1994b4f3baSChris Wilson  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
2094b4f3baSChris Wilson  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
2194b4f3baSChris Wilson  * IN THE SOFTWARE.
2294b4f3baSChris Wilson  *
2394b4f3baSChris Wilson  */
2494b4f3baSChris Wilson 
2501fabda8SLucas De Marchi #include <linux/string_helpers.h>
2601fabda8SLucas De Marchi 
27a8c9b849SMichal Wajdeczko #include <drm/drm_print.h>
28aef8dc43SJani Nikula #include <drm/intel/i915_pciids.h>
29a8c9b849SMichal Wajdeczko 
30c2c70752SMatt Roper #include "gt/intel_gt_regs.h"
3194b4f3baSChris Wilson #include "i915_drv.h"
32801543b2SJani Nikula #include "i915_reg.h"
33a7f46d5bSTvrtko Ursulin #include "i915_utils.h"
34801543b2SJani Nikula #include "intel_device_info.h"
3594b4f3baSChris Wilson 
362e0d26f8SJani Nikula #define PLATFORM_NAME(x) [INTEL_##x] = #x
372e0d26f8SJani Nikula static const char * const platform_names[] = {
382e0d26f8SJani Nikula 	PLATFORM_NAME(I830),
392e0d26f8SJani Nikula 	PLATFORM_NAME(I845G),
402e0d26f8SJani Nikula 	PLATFORM_NAME(I85X),
412e0d26f8SJani Nikula 	PLATFORM_NAME(I865G),
422e0d26f8SJani Nikula 	PLATFORM_NAME(I915G),
432e0d26f8SJani Nikula 	PLATFORM_NAME(I915GM),
442e0d26f8SJani Nikula 	PLATFORM_NAME(I945G),
452e0d26f8SJani Nikula 	PLATFORM_NAME(I945GM),
462e0d26f8SJani Nikula 	PLATFORM_NAME(G33),
472e0d26f8SJani Nikula 	PLATFORM_NAME(PINEVIEW),
48c0f86832SJani Nikula 	PLATFORM_NAME(I965G),
49c0f86832SJani Nikula 	PLATFORM_NAME(I965GM),
50f69c11aeSJani Nikula 	PLATFORM_NAME(G45),
51f69c11aeSJani Nikula 	PLATFORM_NAME(GM45),
522e0d26f8SJani Nikula 	PLATFORM_NAME(IRONLAKE),
532e0d26f8SJani Nikula 	PLATFORM_NAME(SANDYBRIDGE),
542e0d26f8SJani Nikula 	PLATFORM_NAME(IVYBRIDGE),
552e0d26f8SJani Nikula 	PLATFORM_NAME(VALLEYVIEW),
562e0d26f8SJani Nikula 	PLATFORM_NAME(HASWELL),
572e0d26f8SJani Nikula 	PLATFORM_NAME(BROADWELL),
582e0d26f8SJani Nikula 	PLATFORM_NAME(CHERRYVIEW),
592e0d26f8SJani Nikula 	PLATFORM_NAME(SKYLAKE),
602e0d26f8SJani Nikula 	PLATFORM_NAME(BROXTON),
612e0d26f8SJani Nikula 	PLATFORM_NAME(KABYLAKE),
622e0d26f8SJani Nikula 	PLATFORM_NAME(GEMINILAKE),
6371851fa8SRodrigo Vivi 	PLATFORM_NAME(COFFEELAKE),
645f4ae270SChris Wilson 	PLATFORM_NAME(COMETLAKE),
6541231001SRodrigo Vivi 	PLATFORM_NAME(ICELAKE),
66897f2961SBob Paauwe 	PLATFORM_NAME(ELKHARTLAKE),
6724ea098bSTejas Upadhyay 	PLATFORM_NAME(JASPERLAKE),
68abd3a0feSDaniele Ceraolo Spurio 	PLATFORM_NAME(TIGERLAKE),
69123f62deSMatt Roper 	PLATFORM_NAME(ROCKETLAKE),
7005e26584SAbdiel Janulgue 	PLATFORM_NAME(DG1),
710883d63bSCaz Yokoyama 	PLATFORM_NAME(ALDERLAKE_S),
72bdd27cadSClinton Taylor 	PLATFORM_NAME(ALDERLAKE_P),
739e22cfc5SMatt Roper 	PLATFORM_NAME(DG2),
74bcf9b296SRadhakrishna Sripada 	PLATFORM_NAME(METEORLAKE),
752e0d26f8SJani Nikula };
762e0d26f8SJani Nikula #undef PLATFORM_NAME
772e0d26f8SJani Nikula 
intel_platform_name(enum intel_platform platform)782e0d26f8SJani Nikula const char *intel_platform_name(enum intel_platform platform)
792e0d26f8SJani Nikula {
809160095cSJani Nikula 	BUILD_BUG_ON(ARRAY_SIZE(platform_names) != INTEL_MAX_PLATFORMS);
819160095cSJani Nikula 
822e0d26f8SJani Nikula 	if (WARN_ON_ONCE(platform >= ARRAY_SIZE(platform_names) ||
832e0d26f8SJani Nikula 			 platform_names[platform] == NULL))
842e0d26f8SJani Nikula 		return "<unknown>";
852e0d26f8SJani Nikula 
862e0d26f8SJani Nikula 	return platform_names[platform];
872e0d26f8SJani Nikula }
882e0d26f8SJani Nikula 
intel_device_info_print(const struct intel_device_info * info,const struct intel_runtime_info * runtime,struct drm_printer * p)89c7d3c844SJani Nikula void intel_device_info_print(const struct intel_device_info *info,
90c7d3c844SJani Nikula 			     const struct intel_runtime_info *runtime,
91a8c9b849SMichal Wajdeczko 			     struct drm_printer *p)
92a8c9b849SMichal Wajdeczko {
93f9e932a8SRadhakrishna Sripada 	if (runtime->graphics.ip.rel)
94f9e932a8SRadhakrishna Sripada 		drm_printf(p, "graphics version: %u.%02u\n",
95f9e932a8SRadhakrishna Sripada 			   runtime->graphics.ip.ver,
96f9e932a8SRadhakrishna Sripada 			   runtime->graphics.ip.rel);
97ca6374e2SLucas De Marchi 	else
98f9e932a8SRadhakrishna Sripada 		drm_printf(p, "graphics version: %u\n",
99f9e932a8SRadhakrishna Sripada 			   runtime->graphics.ip.ver);
100ca6374e2SLucas De Marchi 
101f9e932a8SRadhakrishna Sripada 	if (runtime->media.ip.rel)
102f9e932a8SRadhakrishna Sripada 		drm_printf(p, "media version: %u.%02u\n",
103f9e932a8SRadhakrishna Sripada 			   runtime->media.ip.ver,
104f9e932a8SRadhakrishna Sripada 			   runtime->media.ip.rel);
105ca6374e2SLucas De Marchi 	else
106f9e932a8SRadhakrishna Sripada 		drm_printf(p, "media version: %u\n",
107f9e932a8SRadhakrishna Sripada 			   runtime->media.ip.ver);
108ca6374e2SLucas De Marchi 
1093cd7cb2aSVille Syrjälä 	drm_printf(p, "graphics stepping: %s\n", intel_step_name(runtime->step.graphics_step));
1103cd7cb2aSVille Syrjälä 	drm_printf(p, "media stepping: %s\n", intel_step_name(runtime->step.media_step));
1113cd7cb2aSVille Syrjälä 
11272404978SChris Wilson 	drm_printf(p, "gt: %d\n", info->gt);
1138776711eSJani Nikula 	drm_printf(p, "memory-regions: 0x%x\n", info->memory_regions);
1142cfd1b38SVille Syrjälä 	drm_printf(p, "page-sizes: 0x%x\n", runtime->page_sizes);
11572404978SChris Wilson 	drm_printf(p, "platform: %s\n", intel_platform_name(info->platform));
116268c67e5SJani Nikula 	drm_printf(p, "ppgtt-size: %d\n", runtime->ppgtt_size);
117268c67e5SJani Nikula 	drm_printf(p, "ppgtt-type: %d\n", runtime->ppgtt_type);
11831a02eb7SMichael J. Ruhl 	drm_printf(p, "dma_mask_size: %u\n", info->dma_mask_size);
11972404978SChris Wilson 
12001fabda8SLucas De Marchi #define PRINT_FLAG(name) drm_printf(p, "%s: %s\n", #name, str_yes_no(info->name))
121a8c9b849SMichal Wajdeczko 	DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG);
122a8c9b849SMichal Wajdeczko #undef PRINT_FLAG
123d53db442SJosé Roberto de Souza 
12439a445bbSJani Nikula 	drm_printf(p, "has_pooled_eu: %s\n", str_yes_no(runtime->has_pooled_eu));
125dab91783SLionel Landwerlin }
126dab91783SLionel Landwerlin 
1273c7bbd4cSJani Nikula #define ID(id) (id)
128805446c8STvrtko Ursulin 
129805446c8STvrtko Ursulin static const u16 subplatform_ult_ids[] = {
1303c7bbd4cSJani Nikula 	INTEL_HSW_ULT_GT1_IDS(ID),
1313c7bbd4cSJani Nikula 	INTEL_HSW_ULT_GT2_IDS(ID),
1323c7bbd4cSJani Nikula 	INTEL_HSW_ULT_GT3_IDS(ID),
1333c7bbd4cSJani Nikula 	INTEL_BDW_ULT_GT1_IDS(ID),
1343c7bbd4cSJani Nikula 	INTEL_BDW_ULT_GT2_IDS(ID),
1353c7bbd4cSJani Nikula 	INTEL_BDW_ULT_GT3_IDS(ID),
1363c7bbd4cSJani Nikula 	INTEL_BDW_ULT_RSVD_IDS(ID),
1373c7bbd4cSJani Nikula 	INTEL_SKL_ULT_GT1_IDS(ID),
1383c7bbd4cSJani Nikula 	INTEL_SKL_ULT_GT2_IDS(ID),
1393c7bbd4cSJani Nikula 	INTEL_SKL_ULT_GT3_IDS(ID),
1403c7bbd4cSJani Nikula 	INTEL_KBL_ULT_GT1_IDS(ID),
1413c7bbd4cSJani Nikula 	INTEL_KBL_ULT_GT2_IDS(ID),
1423c7bbd4cSJani Nikula 	INTEL_KBL_ULT_GT3_IDS(ID),
1433c7bbd4cSJani Nikula 	INTEL_CFL_U_GT2_IDS(ID),
1443c7bbd4cSJani Nikula 	INTEL_CFL_U_GT3_IDS(ID),
1453c7bbd4cSJani Nikula 	INTEL_WHL_U_GT1_IDS(ID),
1463c7bbd4cSJani Nikula 	INTEL_WHL_U_GT2_IDS(ID),
1473c7bbd4cSJani Nikula 	INTEL_WHL_U_GT3_IDS(ID),
1483c7bbd4cSJani Nikula 	INTEL_CML_U_GT1_IDS(ID),
1493c7bbd4cSJani Nikula 	INTEL_CML_U_GT2_IDS(ID),
150805446c8STvrtko Ursulin };
151805446c8STvrtko Ursulin 
152805446c8STvrtko Ursulin static const u16 subplatform_ulx_ids[] = {
1533c7bbd4cSJani Nikula 	INTEL_HSW_ULX_GT1_IDS(ID),
1543c7bbd4cSJani Nikula 	INTEL_HSW_ULX_GT2_IDS(ID),
1553c7bbd4cSJani Nikula 	INTEL_BDW_ULX_GT1_IDS(ID),
1563c7bbd4cSJani Nikula 	INTEL_BDW_ULX_GT2_IDS(ID),
1573c7bbd4cSJani Nikula 	INTEL_BDW_ULX_GT3_IDS(ID),
1583c7bbd4cSJani Nikula 	INTEL_BDW_ULX_RSVD_IDS(ID),
1593c7bbd4cSJani Nikula 	INTEL_SKL_ULX_GT1_IDS(ID),
1603c7bbd4cSJani Nikula 	INTEL_SKL_ULX_GT2_IDS(ID),
1613c7bbd4cSJani Nikula 	INTEL_KBL_ULX_GT1_IDS(ID),
1623c7bbd4cSJani Nikula 	INTEL_KBL_ULX_GT2_IDS(ID),
1633c7bbd4cSJani Nikula 	INTEL_AML_KBL_GT2_IDS(ID),
1643c7bbd4cSJani Nikula 	INTEL_AML_CFL_GT2_IDS(ID),
165805446c8STvrtko Ursulin };
166805446c8STvrtko Ursulin 
167805446c8STvrtko Ursulin static const u16 subplatform_portf_ids[] = {
1683c7bbd4cSJani Nikula 	INTEL_ICL_PORT_F_IDS(ID),
169805446c8STvrtko Ursulin };
170805446c8STvrtko Ursulin 
171b9ef8939SJosé Roberto de Souza static const u16 subplatform_uy_ids[] = {
1723c7bbd4cSJani Nikula 	INTEL_TGL_GT2_IDS(ID),
173b9ef8939SJosé Roberto de Souza };
174b9ef8939SJosé Roberto de Souza 
1757e28d0b2STejas Upadhyay static const u16 subplatform_n_ids[] = {
1763c7bbd4cSJani Nikula 	INTEL_ADLN_IDS(ID),
1777e28d0b2STejas Upadhyay };
1787e28d0b2STejas Upadhyay 
17972c3c8d6SMatt Atwood static const u16 subplatform_rpl_ids[] = {
1803c7bbd4cSJani Nikula 	INTEL_RPLS_IDS(ID),
1813c7bbd4cSJani Nikula 	INTEL_RPLU_IDS(ID),
1823c7bbd4cSJani Nikula 	INTEL_RPLP_IDS(ID),
18352407c22SAnusha Srivatsa };
18452407c22SAnusha Srivatsa 
18561b795a9SChaitanya Kumar Borah static const u16 subplatform_rplu_ids[] = {
1863c7bbd4cSJani Nikula 	INTEL_RPLU_IDS(ID),
18761b795a9SChaitanya Kumar Borah };
18861b795a9SChaitanya Kumar Borah 
1891bc4ae0cSMatt Roper static const u16 subplatform_g10_ids[] = {
1903c7bbd4cSJani Nikula 	INTEL_DG2_G10_IDS(ID),
1913c7bbd4cSJani Nikula 	INTEL_ATS_M150_IDS(ID),
1921bc4ae0cSMatt Roper };
1931bc4ae0cSMatt Roper 
1941bc4ae0cSMatt Roper static const u16 subplatform_g11_ids[] = {
1953c7bbd4cSJani Nikula 	INTEL_DG2_G11_IDS(ID),
1963c7bbd4cSJani Nikula 	INTEL_ATS_M75_IDS(ID),
1971bc4ae0cSMatt Roper };
1981bc4ae0cSMatt Roper 
1991bc4ae0cSMatt Roper static const u16 subplatform_g12_ids[] = {
2003c7bbd4cSJani Nikula 	INTEL_DG2_G12_IDS(ID),
201805446c8STvrtko Ursulin };
202805446c8STvrtko Ursulin 
203*db0fc586SDaniele Ceraolo Spurio static const u16 subplatform_arl_h_ids[] = {
204*db0fc586SDaniele Ceraolo Spurio 	INTEL_ARL_H_IDS(ID),
205*db0fc586SDaniele Ceraolo Spurio };
206*db0fc586SDaniele Ceraolo Spurio 
207*db0fc586SDaniele Ceraolo Spurio static const u16 subplatform_arl_u_ids[] = {
208*db0fc586SDaniele Ceraolo Spurio 	INTEL_ARL_U_IDS(ID),
209*db0fc586SDaniele Ceraolo Spurio };
210*db0fc586SDaniele Ceraolo Spurio 
211*db0fc586SDaniele Ceraolo Spurio static const u16 subplatform_arl_s_ids[] = {
212*db0fc586SDaniele Ceraolo Spurio 	INTEL_ARL_S_IDS(ID),
21367733d7aSJohn Harrison };
21467733d7aSJohn Harrison 
find_devid(u16 id,const u16 * p,unsigned int num)215805446c8STvrtko Ursulin static bool find_devid(u16 id, const u16 *p, unsigned int num)
216805446c8STvrtko Ursulin {
217805446c8STvrtko Ursulin 	for (; num; num--, p++) {
218805446c8STvrtko Ursulin 		if (*p == id)
219805446c8STvrtko Ursulin 			return true;
220805446c8STvrtko Ursulin 	}
221805446c8STvrtko Ursulin 
222805446c8STvrtko Ursulin 	return false;
223805446c8STvrtko Ursulin }
224805446c8STvrtko Ursulin 
intel_device_info_subplatform_init(struct drm_i915_private * i915)225c2c70752SMatt Roper static void intel_device_info_subplatform_init(struct drm_i915_private *i915)
226805446c8STvrtko Ursulin {
227805446c8STvrtko Ursulin 	const struct intel_device_info *info = INTEL_INFO(i915);
228805446c8STvrtko Ursulin 	const struct intel_runtime_info *rinfo = RUNTIME_INFO(i915);
229805446c8STvrtko Ursulin 	const unsigned int pi = __platform_mask_index(rinfo, info->platform);
230805446c8STvrtko Ursulin 	const unsigned int pb = __platform_mask_bit(rinfo, info->platform);
231805446c8STvrtko Ursulin 	u16 devid = INTEL_DEVID(i915);
232640cde65STvrtko Ursulin 	u32 mask = 0;
233805446c8STvrtko Ursulin 
234805446c8STvrtko Ursulin 	/* Make sure IS_<platform> checks are working. */
235805446c8STvrtko Ursulin 	RUNTIME_INFO(i915)->platform_mask[pi] = BIT(pb);
236805446c8STvrtko Ursulin 
237805446c8STvrtko Ursulin 	/* Find and mark subplatform bits based on the PCI device id. */
238805446c8STvrtko Ursulin 	if (find_devid(devid, subplatform_ult_ids,
239805446c8STvrtko Ursulin 		       ARRAY_SIZE(subplatform_ult_ids))) {
240805446c8STvrtko Ursulin 		mask = BIT(INTEL_SUBPLATFORM_ULT);
241805446c8STvrtko Ursulin 	} else if (find_devid(devid, subplatform_ulx_ids,
242805446c8STvrtko Ursulin 			      ARRAY_SIZE(subplatform_ulx_ids))) {
243805446c8STvrtko Ursulin 		mask = BIT(INTEL_SUBPLATFORM_ULX);
244805446c8STvrtko Ursulin 		if (IS_HASWELL(i915) || IS_BROADWELL(i915)) {
245805446c8STvrtko Ursulin 			/* ULX machines are also considered ULT. */
246805446c8STvrtko Ursulin 			mask |= BIT(INTEL_SUBPLATFORM_ULT);
247805446c8STvrtko Ursulin 		}
248805446c8STvrtko Ursulin 	} else if (find_devid(devid, subplatform_portf_ids,
249805446c8STvrtko Ursulin 			      ARRAY_SIZE(subplatform_portf_ids))) {
250805446c8STvrtko Ursulin 		mask = BIT(INTEL_SUBPLATFORM_PORTF);
251b9ef8939SJosé Roberto de Souza 	} else if (find_devid(devid, subplatform_uy_ids,
252b9ef8939SJosé Roberto de Souza 			   ARRAY_SIZE(subplatform_uy_ids))) {
253b9ef8939SJosé Roberto de Souza 		mask = BIT(INTEL_SUBPLATFORM_UY);
2547e28d0b2STejas Upadhyay 	} else if (find_devid(devid, subplatform_n_ids,
2557e28d0b2STejas Upadhyay 				ARRAY_SIZE(subplatform_n_ids))) {
2567e28d0b2STejas Upadhyay 		mask = BIT(INTEL_SUBPLATFORM_N);
25772c3c8d6SMatt Atwood 	} else if (find_devid(devid, subplatform_rpl_ids,
25872c3c8d6SMatt Atwood 			      ARRAY_SIZE(subplatform_rpl_ids))) {
25972c3c8d6SMatt Atwood 		mask = BIT(INTEL_SUBPLATFORM_RPL);
26061b795a9SChaitanya Kumar Borah 		if (find_devid(devid, subplatform_rplu_ids,
26161b795a9SChaitanya Kumar Borah 			       ARRAY_SIZE(subplatform_rplu_ids)))
26261b795a9SChaitanya Kumar Borah 			mask |= BIT(INTEL_SUBPLATFORM_RPLU);
2631bc4ae0cSMatt Roper 	} else if (find_devid(devid, subplatform_g10_ids,
2641bc4ae0cSMatt Roper 			      ARRAY_SIZE(subplatform_g10_ids))) {
2651bc4ae0cSMatt Roper 		mask = BIT(INTEL_SUBPLATFORM_G10);
2661bc4ae0cSMatt Roper 	} else if (find_devid(devid, subplatform_g11_ids,
2671bc4ae0cSMatt Roper 			      ARRAY_SIZE(subplatform_g11_ids))) {
2681bc4ae0cSMatt Roper 		mask = BIT(INTEL_SUBPLATFORM_G11);
2691bc4ae0cSMatt Roper 	} else if (find_devid(devid, subplatform_g12_ids,
2701bc4ae0cSMatt Roper 			      ARRAY_SIZE(subplatform_g12_ids))) {
2711bc4ae0cSMatt Roper 		mask = BIT(INTEL_SUBPLATFORM_G12);
272*db0fc586SDaniele Ceraolo Spurio 	} else if (find_devid(devid, subplatform_arl_h_ids,
273*db0fc586SDaniele Ceraolo Spurio 			      ARRAY_SIZE(subplatform_arl_h_ids))) {
274*db0fc586SDaniele Ceraolo Spurio 		mask = BIT(INTEL_SUBPLATFORM_ARL_H);
275*db0fc586SDaniele Ceraolo Spurio 	} else if (find_devid(devid, subplatform_arl_u_ids,
276*db0fc586SDaniele Ceraolo Spurio 			      ARRAY_SIZE(subplatform_arl_u_ids))) {
277*db0fc586SDaniele Ceraolo Spurio 		mask = BIT(INTEL_SUBPLATFORM_ARL_U);
278*db0fc586SDaniele Ceraolo Spurio 	} else if (find_devid(devid, subplatform_arl_s_ids,
279*db0fc586SDaniele Ceraolo Spurio 			      ARRAY_SIZE(subplatform_arl_s_ids))) {
280*db0fc586SDaniele Ceraolo Spurio 		mask = BIT(INTEL_SUBPLATFORM_ARL_S);
281805446c8STvrtko Ursulin 	}
282805446c8STvrtko Ursulin 
28356afa701STvrtko Ursulin 	GEM_BUG_ON(mask & ~INTEL_SUBPLATFORM_MASK);
284805446c8STvrtko Ursulin 
285805446c8STvrtko Ursulin 	RUNTIME_INFO(i915)->platform_mask[pi] |= mask;
286805446c8STvrtko Ursulin }
287805446c8STvrtko Ursulin 
ip_ver_read(struct drm_i915_private * i915,u32 offset,struct intel_ip_version * ip)288ef7e222cSRadhakrishna Sripada static void ip_ver_read(struct drm_i915_private *i915, u32 offset, struct intel_ip_version *ip)
289c2c70752SMatt Roper {
290c2c70752SMatt Roper 	struct pci_dev *pdev = to_pci_dev(i915->drm.dev);
291c2c70752SMatt Roper 	void __iomem *addr;
292c2c70752SMatt Roper 	u32 val;
293c2c70752SMatt Roper 	u8 expected_ver = ip->ver;
294c2c70752SMatt Roper 	u8 expected_rel = ip->rel;
295c2c70752SMatt Roper 
296c2c70752SMatt Roper 	addr = pci_iomap_range(pdev, 0, offset, sizeof(u32));
297c2c70752SMatt Roper 	if (drm_WARN_ON(&i915->drm, !addr))
298c2c70752SMatt Roper 		return;
299c2c70752SMatt Roper 
300c2c70752SMatt Roper 	val = ioread32(addr);
301c2c70752SMatt Roper 	pci_iounmap(pdev, addr);
302c2c70752SMatt Roper 
303c2c70752SMatt Roper 	ip->ver = REG_FIELD_GET(GMD_ID_ARCH_MASK, val);
304c2c70752SMatt Roper 	ip->rel = REG_FIELD_GET(GMD_ID_RELEASE_MASK, val);
305c2c70752SMatt Roper 	ip->step = REG_FIELD_GET(GMD_ID_STEP, val);
306c2c70752SMatt Roper 
307c2c70752SMatt Roper 	/* Sanity check against expected versions from device info */
308c2c70752SMatt Roper 	if (IP_VER(ip->ver, ip->rel) < IP_VER(expected_ver, expected_rel))
309c2c70752SMatt Roper 		drm_dbg(&i915->drm,
310c2c70752SMatt Roper 			"Hardware reports GMD IP version %u.%u (REG[0x%x] = 0x%08x) but minimum expected is %u.%u\n",
311c2c70752SMatt Roper 			ip->ver, ip->rel, offset, val, expected_ver, expected_rel);
312c2c70752SMatt Roper }
313c2c70752SMatt Roper 
314c2c70752SMatt Roper /*
315c2c70752SMatt Roper  * Setup the graphics version for the current device.  This must be done before
316c2c70752SMatt Roper  * any code that performs checks on GRAPHICS_VER or DISPLAY_VER, so this
317c2c70752SMatt Roper  * function should be called very early in the driver initialization sequence.
318c2c70752SMatt Roper  *
319c2c70752SMatt Roper  * Regular MMIO access is not yet setup at the point this function is called so
320c2c70752SMatt Roper  * we peek at the appropriate MMIO offset directly.  The GMD_ID register is
321c2c70752SMatt Roper  * part of an 'always on' power well by design, so we don't need to worry about
322c2c70752SMatt Roper  * forcewake while reading it.
323c2c70752SMatt Roper  */
intel_ipver_early_init(struct drm_i915_private * i915)324c2c70752SMatt Roper static void intel_ipver_early_init(struct drm_i915_private *i915)
325c2c70752SMatt Roper {
326c2c70752SMatt Roper 	struct intel_runtime_info *runtime = RUNTIME_INFO(i915);
327c2c70752SMatt Roper 
32880c1fb2eSRadhakrishna Sripada 	if (!HAS_GMD_ID(i915)) {
32980c1fb2eSRadhakrishna Sripada 		drm_WARN_ON(&i915->drm, RUNTIME_INFO(i915)->graphics.ip.ver > 12);
33080c1fb2eSRadhakrishna Sripada 		/*
33180c1fb2eSRadhakrishna Sripada 		 * On older platforms, graphics and media share the same ip
33280c1fb2eSRadhakrishna Sripada 		 * version and release.
33380c1fb2eSRadhakrishna Sripada 		 */
33480c1fb2eSRadhakrishna Sripada 		RUNTIME_INFO(i915)->media.ip =
33580c1fb2eSRadhakrishna Sripada 			RUNTIME_INFO(i915)->graphics.ip;
336c2c70752SMatt Roper 		return;
33780c1fb2eSRadhakrishna Sripada 	}
338c2c70752SMatt Roper 
339c2c70752SMatt Roper 	ip_ver_read(i915, i915_mmio_reg_offset(GMD_ID_GRAPHICS),
340c2c70752SMatt Roper 		    &runtime->graphics.ip);
34141bb543fSMatt Roper 	/* Wa_22012778468 */
34241bb543fSMatt Roper 	if (runtime->graphics.ip.ver == 0x0 &&
34341bb543fSMatt Roper 	    INTEL_INFO(i915)->platform == INTEL_METEORLAKE) {
34441bb543fSMatt Roper 		RUNTIME_INFO(i915)->graphics.ip.ver = 12;
34541bb543fSMatt Roper 		RUNTIME_INFO(i915)->graphics.ip.rel = 70;
34641bb543fSMatt Roper 	}
347c2c70752SMatt Roper 	ip_ver_read(i915, i915_mmio_reg_offset(GMD_ID_MEDIA),
348c2c70752SMatt Roper 		    &runtime->media.ip);
349c2c70752SMatt Roper }
350c2c70752SMatt Roper 
351c2c70752SMatt Roper /**
352c2c70752SMatt Roper  * intel_device_info_runtime_init_early - initialize early runtime info
353c2c70752SMatt Roper  * @i915: the i915 device
354c2c70752SMatt Roper  *
355c2c70752SMatt Roper  * Determine early intel_device_info fields at runtime. This function needs
356c2c70752SMatt Roper  * to be called before the MMIO has been setup.
357c2c70752SMatt Roper  */
intel_device_info_runtime_init_early(struct drm_i915_private * i915)358c2c70752SMatt Roper void intel_device_info_runtime_init_early(struct drm_i915_private *i915)
359c2c70752SMatt Roper {
360c2c70752SMatt Roper 	intel_ipver_early_init(i915);
361c2c70752SMatt Roper 	intel_device_info_subplatform_init(i915);
362c2c70752SMatt Roper }
363c2c70752SMatt Roper 
3646a7e51f3SMichal Wajdeczko /**
3656a7e51f3SMichal Wajdeczko  * intel_device_info_runtime_init - initialize runtime info
366963cc126SChris Wilson  * @dev_priv: the i915 device
3676a7e51f3SMichal Wajdeczko  *
36894b4f3baSChris Wilson  * Determine various intel_device_info fields at runtime.
36994b4f3baSChris Wilson  *
37094b4f3baSChris Wilson  * Use it when either:
37194b4f3baSChris Wilson  *   - it's judged too laborious to fill n static structures with the limit
37294b4f3baSChris Wilson  *     when a simple if statement does the job,
37394b4f3baSChris Wilson  *   - run-time checks (eg read fuse/strap registers) are needed.
37494b4f3baSChris Wilson  *
37594b4f3baSChris Wilson  * This function needs to be called:
37694b4f3baSChris Wilson  *   - after the MMIO has been setup as we are reading registers,
37794b4f3baSChris Wilson  *   - after the PCH has been detected,
37894b4f3baSChris Wilson  *   - before the first usage of the fields it can tweak.
37994b4f3baSChris Wilson  */
intel_device_info_runtime_init(struct drm_i915_private * dev_priv)3801400cc7eSJani Nikula void intel_device_info_runtime_init(struct drm_i915_private *dev_priv)
38194b4f3baSChris Wilson {
3820258404fSJani Nikula 	struct intel_runtime_info *runtime = RUNTIME_INFO(dev_priv);
38394b4f3baSChris Wilson 
3848a68d464SChris Wilson 	BUILD_BUG_ON(BITS_PER_TYPE(intel_engine_mask_t) < I915_NUM_ENGINES);
385022d3093STvrtko Ursulin 
386a7f46d5bSTvrtko Ursulin 	if (GRAPHICS_VER(dev_priv) == 6 && i915_vtd_active(dev_priv)) {
38768b32717SWambui Karuga 		drm_info(&dev_priv->drm,
38868b32717SWambui Karuga 			 "Disabling ppGTT for VT-d support\n");
389268c67e5SJani Nikula 		runtime->ppgtt_type = INTEL_PPGTT_NONE;
3904bdafb9dSChris Wilson 	}
391d194314dSChris Wilson }
3923fed1808SChris Wilson 
393446a20c9SJani Nikula /*
394446a20c9SJani Nikula  * Set up device info and initial runtime info at driver create.
395446a20c9SJani Nikula  *
396446a20c9SJani Nikula  * Note: i915 is only an allocated blob of memory at this point.
397446a20c9SJani Nikula  */
intel_device_info_driver_create(struct drm_i915_private * i915,u16 device_id,const struct intel_device_info * match_info)398446a20c9SJani Nikula void intel_device_info_driver_create(struct drm_i915_private *i915,
399446a20c9SJani Nikula 				     u16 device_id,
400446a20c9SJani Nikula 				     const struct intel_device_info *match_info)
401446a20c9SJani Nikula {
402446a20c9SJani Nikula 	struct intel_runtime_info *runtime;
403446a20c9SJani Nikula 
4040c4f52baSJani Nikula 	/* Setup INTEL_INFO() */
4050c4f52baSJani Nikula 	i915->__info = match_info;
406446a20c9SJani Nikula 
407446a20c9SJani Nikula 	/* Initialize initial runtime info from static const data and pdev. */
408446a20c9SJani Nikula 	runtime = RUNTIME_INFO(i915);
409446a20c9SJani Nikula 	memcpy(runtime, &INTEL_INFO(i915)->__runtime, sizeof(*runtime));
41069d43981SMatt Roper 
411446a20c9SJani Nikula 	runtime->device_id = device_id;
412446a20c9SJani Nikula }
413446a20c9SJani Nikula 
intel_driver_caps_print(const struct intel_driver_caps * caps,struct drm_printer * p)4143fed1808SChris Wilson void intel_driver_caps_print(const struct intel_driver_caps *caps,
4153fed1808SChris Wilson 			     struct drm_printer *p)
4163fed1808SChris Wilson {
417481827b4SChris Wilson 	drm_printf(p, "Has logical contexts? %s\n",
41801fabda8SLucas De Marchi 		   str_yes_no(caps->has_logical_contexts));
4192cfd1b38SVille Syrjälä 	drm_printf(p, "scheduler: 0x%x\n", caps->scheduler);
4203fed1808SChris Wilson }
421