summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/i915/intel_step.c
blob: b4162f1be76513aafe923c496b86afc836500258 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
// SPDX-License-Identifier: MIT
/*
 * Copyright © 2020,2021 Intel Corporation
 */

#include "i915_drv.h"
#include "intel_step.h"

/*
 * Some platforms have unusual ways of mapping PCI revision ID to GT/display
 * steppings.  E.g., in some cases a higher PCI revision may translate to a
 * lower stepping of the GT and/or display IP.  This file provides lookup
 * tables to map the PCI revision into a standard set of stepping values that
 * can be compared numerically.
 *
 * Also note that some revisions/steppings may have been set aside as
 * placeholders but never materialized in real hardware; in those cases there
 * may be jumps in the revision IDs or stepping values in the tables below.
 */

/*
 * Some platforms always have the same stepping value for GT and display;
 * use a macro to define these to make it easier to identify the platforms
 * where the two steppings can deviate.
 */
#define COMMON_STEP(x)  .graphics_step = STEP_##x, .display_step = STEP_##x, .media_step = STEP_##x
#define COMMON_GT_MEDIA_STEP(x)  .graphics_step = STEP_##x, .media_step = STEP_##x

static const struct intel_step_info skl_revids[] = {
	[0x6] = { COMMON_STEP(G0) },
	[0x7] = { COMMON_STEP(H0) },
	[0x9] = { COMMON_STEP(J0) },
	[0xA] = { COMMON_STEP(I1) },
};

static const struct intel_step_info kbl_revids[] = {
	[1] = { COMMON_GT_MEDIA_STEP(B0), .display_step = STEP_B0 },
	[2] = { COMMON_GT_MEDIA_STEP(C0), .display_step = STEP_B0 },
	[3] = { COMMON_GT_MEDIA_STEP(D0), .display_step = STEP_B0 },
	[4] = { COMMON_GT_MEDIA_STEP(F0), .display_step = STEP_C0 },
	[5] = { COMMON_GT_MEDIA_STEP(C0), .display_step = STEP_B1 },
	[6] = { COMMON_GT_MEDIA_STEP(D1), .display_step = STEP_B1 },
	[7] = { COMMON_GT_MEDIA_STEP(G0), .display_step = STEP_C0 },
};

static const struct intel_step_info bxt_revids[] = {
	[0xA] = { COMMON_STEP(C0) },
	[0xB] = { COMMON_STEP(C0) },
	[0xC] = { COMMON_STEP(D0) },
	[0xD] = { COMMON_STEP(E0) },
};

static const struct intel_step_info glk_revids[] = {
	[3] = { COMMON_STEP(B0) },
};

static const struct intel_step_info icl_revids[] = {
	[7] = { COMMON_STEP(D0) },
};

static const struct intel_step_info jsl_ehl_revids[] = {
	[0] = { COMMON_STEP(A0) },
	[1] = { COMMON_STEP(B0) },
};

static const struct intel_step_info tgl_uy_revids[] = {
	[0] = { COMMON_GT_MEDIA_STEP(A0), .display_step = STEP_A0 },
	[1] = { COMMON_GT_MEDIA_STEP(B0), .display_step = STEP_C0 },
	[2] = { COMMON_GT_MEDIA_STEP(B1), .display_step = STEP_C0 },
	[3] = { COMMON_GT_MEDIA_STEP(C0), .display_step = STEP_D0 },
};

/* Same GT stepping between tgl_uy_revids and tgl_revids don't mean the same HW */
static const struct intel_step_info tgl_revids[] = {
	[0] = { COMMON_GT_MEDIA_STEP(A0), .display_step = STEP_B0 },
	[1] = { COMMON_GT_MEDIA_STEP(B0), .display_step = STEP_D0 },
};

static const struct intel_step_info rkl_revids[] = {
	[0] = { COMMON_STEP(A0) },
	[1] = { COMMON_STEP(B0) },
	[4] = { COMMON_STEP(C0) },
};

static const struct intel_step_info dg1_revids[] = {
	[0] = { COMMON_STEP(A0) },
	[1] = { COMMON_STEP(B0) },
};

static const struct intel_step_info adls_revids[] = {
	[0x0] = { COMMON_GT_MEDIA_STEP(A0), .display_step = STEP_A0 },
	[0x1] = { COMMON_GT_MEDIA_STEP(A0), .display_step = STEP_A2 },
	[0x4] = { COMMON_GT_MEDIA_STEP(B0), .display_step = STEP_B0 },
	[0x8] = { COMMON_GT_MEDIA_STEP(C0), .display_step = STEP_B0 },
	[0xC] = { COMMON_GT_MEDIA_STEP(D0), .display_step = STEP_C0 },
};

static const struct intel_step_info adlp_revids[] = {
	[0x0] = { COMMON_GT_MEDIA_STEP(A0), .display_step = STEP_A0 },
	[0x4] = { COMMON_GT_MEDIA_STEP(B0), .display_step = STEP_B0 },
	[0x8] = { COMMON_GT_MEDIA_STEP(C0), .display_step = STEP_C0 },
	[0xC] = { COMMON_GT_MEDIA_STEP(C0), .display_step = STEP_D0 },
};

static const struct intel_step_info xehpsdv_revids[] = {
	[0x0] = { COMMON_GT_MEDIA_STEP(A0) },
	[0x1] = { COMMON_GT_MEDIA_STEP(A1) },
	[0x4] = { COMMON_GT_MEDIA_STEP(B0) },
	[0x8] = { COMMON_GT_MEDIA_STEP(C0) },
};

static const struct intel_step_info dg2_g10_revid_step_tbl[] = {
	[0x0] = { COMMON_GT_MEDIA_STEP(A0), .display_step = STEP_A0 },
	[0x1] = { COMMON_GT_MEDIA_STEP(A1), .display_step = STEP_A0 },
	[0x4] = { COMMON_GT_MEDIA_STEP(B0), .display_step = STEP_B0 },
	[0x8] = { COMMON_GT_MEDIA_STEP(C0), .display_step = STEP_C0 },
};

static const struct intel_step_info dg2_g11_revid_step_tbl[] = {
	[0x0] = { COMMON_GT_MEDIA_STEP(A0), .display_step = STEP_B0 },
	[0x4] = { COMMON_GT_MEDIA_STEP(B0), .display_step = STEP_C0 },
	[0x5] = { COMMON_GT_MEDIA_STEP(B1), .display_step = STEP_C0 },
};

static const struct intel_step_info dg2_g12_revid_step_tbl[] = {
	[0x0] = { COMMON_GT_MEDIA_STEP(A0), .display_step = STEP_C0 },
	[0x1] = { COMMON_GT_MEDIA_STEP(A1), .display_step = STEP_C0 },
};

static const struct intel_step_info adls_rpls_revids[] = {
	[0x4] = { COMMON_GT_MEDIA_STEP(D0), .display_step = STEP_D0 },
	[0xC] = { COMMON_GT_MEDIA_STEP(D0), .display_step = STEP_C0 },
};

static const struct intel_step_info adlp_rplp_revids[] = {
	[0x4] = { COMMON_GT_MEDIA_STEP(C0), .display_step = STEP_E0 },
};

static const struct intel_step_info adlp_n_revids[] = {
	[0x0] = { COMMON_GT_MEDIA_STEP(A0), .display_step = STEP_D0 },
};

static u8 gmd_to_intel_step(struct drm_i915_private *i915,
			    struct intel_ip_version *gmd)
{
	u8 step = gmd->step + STEP_A0;

	if (step >= STEP_FUTURE) {
		drm_dbg(&i915->drm, "Using future steppings\n");
		return STEP_FUTURE;
	}

	return step;
}

static void pvc_step_init(struct drm_i915_private *i915, int pci_revid);

void intel_step_init(struct drm_i915_private *i915)
{
	const struct intel_step_info *revids = NULL;
	int size = 0;
	int revid = INTEL_REVID(i915);
	struct intel_step_info step = {};

	if (HAS_GMD_ID(i915)) {
		step.graphics_step = gmd_to_intel_step(i915,
						       &RUNTIME_INFO(i915)->graphics.ip);
		step.media_step = gmd_to_intel_step(i915,
						    &RUNTIME_INFO(i915)->media.ip);
		step.display_step = STEP_A0 + DISPLAY_RUNTIME_INFO(i915)->ip.step;
		if (step.display_step >= STEP_FUTURE) {
			drm_dbg(&i915->drm, "Using future display steppings\n");
			step.display_step = STEP_FUTURE;
		}

		RUNTIME_INFO(i915)->step = step;

		return;
	}

	if (IS_PONTEVECCHIO(i915)) {
		pvc_step_init(i915, revid);
		return;
	} else if (IS_DG2_G10(i915)) {
		revids = dg2_g10_revid_step_tbl;
		size = ARRAY_SIZE(dg2_g10_revid_step_tbl);
	} else if (IS_DG2_G11(i915)) {
		revids = dg2_g11_revid_step_tbl;
		size = ARRAY_SIZE(dg2_g11_revid_step_tbl);
	} else if (IS_DG2_G12(i915)) {
		revids = dg2_g12_revid_step_tbl;
		size = ARRAY_SIZE(dg2_g12_revid_step_tbl);
	} else if (IS_XEHPSDV(i915)) {
		revids = xehpsdv_revids;
		size = ARRAY_SIZE(xehpsdv_revids);
	} else if (IS_ALDERLAKE_P_N(i915)) {
		revids = adlp_n_revids;
		size = ARRAY_SIZE(adlp_n_revids);
	} else if (IS_RAPTORLAKE_P(i915)) {
		revids = adlp_rplp_revids;
		size = ARRAY_SIZE(adlp_rplp_revids);
	} else if (IS_ALDERLAKE_P(i915)) {
		revids = adlp_revids;
		size = ARRAY_SIZE(adlp_revids);
	} else if (IS_RAPTORLAKE_S(i915)) {
		revids = adls_rpls_revids;
		size = ARRAY_SIZE(adls_rpls_revids);
	} else if (IS_ALDERLAKE_S(i915)) {
		revids = adls_revids;
		size = ARRAY_SIZE(adls_revids);
	} else if (IS_DG1(i915)) {
		revids = dg1_revids;
		size = ARRAY_SIZE(dg1_revids);
	} else if (IS_ROCKETLAKE(i915)) {
		revids = rkl_revids;
		size = ARRAY_SIZE(rkl_revids);
	} else if (IS_TIGERLAKE_UY(i915)) {
		revids = tgl_uy_revids;
		size = ARRAY_SIZE(tgl_uy_revids);
	} else if (IS_TIGERLAKE(i915)) {
		revids = tgl_revids;
		size = ARRAY_SIZE(tgl_revids);
	} else if (IS_JASPERLAKE(i915) || IS_ELKHARTLAKE(i915)) {
		revids = jsl_ehl_revids;
		size = ARRAY_SIZE(jsl_ehl_revids);
	} else if (IS_ICELAKE(i915)) {
		revids = icl_revids;
		size = ARRAY_SIZE(icl_revids);
	} else if (IS_GEMINILAKE(i915)) {
		revids = glk_revids;
		size = ARRAY_SIZE(glk_revids);
	} else if (IS_BROXTON(i915)) {
		revids = bxt_revids;
		size = ARRAY_SIZE(bxt_revids);
	} else if (IS_KABYLAKE(i915)) {
		revids = kbl_revids;
		size = ARRAY_SIZE(kbl_revids);
	} else if (IS_SKYLAKE(i915)) {
		revids = skl_revids;
		size = ARRAY_SIZE(skl_revids);
	}

	/* Not using the stepping scheme for the platform yet. */
	if (!revids)
		return;

	if (revid < size && revids[revid].graphics_step != STEP_NONE) {
		step = revids[revid];
	} else {
		drm_warn(&i915->drm, "Unknown revid 0x%02x\n", revid);

		/*
		 * If we hit a gap in the revid array, use the information for
		 * the next revid.
		 *
		 * This may be wrong in all sorts of ways, especially if the
		 * steppings in the array are not monotonically increasing, but
		 * it's better than defaulting to 0.
		 */
		while (revid < size && revids[revid].graphics_step == STEP_NONE)
			revid++;

		if (revid < size) {
			drm_dbg(&i915->drm, "Using steppings for revid 0x%02x\n",
				revid);
			step = revids[revid];
		} else {
			drm_dbg(&i915->drm, "Using future steppings\n");
			step.graphics_step = STEP_FUTURE;
			step.display_step = STEP_FUTURE;
		}
	}

	if (drm_WARN_ON(&i915->drm, step.graphics_step == STEP_NONE))
		return;

	RUNTIME_INFO(i915)->step = step;
}

#define PVC_BD_REVID	GENMASK(5, 3)
#define PVC_CT_REVID	GENMASK(2, 0)

static const int pvc_bd_subids[] = {
	[0x0] = STEP_A0,
	[0x3] = STEP_B0,
	[0x4] = STEP_B1,
	[0x5] = STEP_B3,
};

static const int pvc_ct_subids[] = {
	[0x3] = STEP_A0,
	[0x5] = STEP_B0,
	[0x6] = STEP_B1,
	[0x7] = STEP_C0,
};

static int
pvc_step_lookup(struct drm_i915_private *i915, const char *type,
		const int *table, int size, int subid)
{
	if (subid < size && table[subid] != STEP_NONE)
		return table[subid];

	drm_warn(&i915->drm, "Unknown %s id 0x%02x\n", type, subid);

	/*
	 * As on other platforms, try to use the next higher ID if we land on a
	 * gap in the table.
	 */
	while (subid < size && table[subid] == STEP_NONE)
		subid++;

	if (subid < size) {
		drm_dbg(&i915->drm, "Using steppings for %s id 0x%02x\n",
			type, subid);
		return table[subid];
	}

	drm_dbg(&i915->drm, "Using future steppings\n");
	return STEP_FUTURE;
}

/*
 * PVC needs special handling since we don't lookup the
 * revid in a table, but rather specific bitfields within
 * the revid for various components.
 */
static void pvc_step_init(struct drm_i915_private *i915, int pci_revid)
{
	int ct_subid, bd_subid;

	bd_subid = FIELD_GET(PVC_BD_REVID, pci_revid);
	ct_subid = FIELD_GET(PVC_CT_REVID, pci_revid);

	RUNTIME_INFO(i915)->step.basedie_step =
		pvc_step_lookup(i915, "Base Die", pvc_bd_subids,
				ARRAY_SIZE(pvc_bd_subids), bd_subid);
	RUNTIME_INFO(i915)->step.graphics_step =
		pvc_step_lookup(i915, "Compute Tile", pvc_ct_subids,
				ARRAY_SIZE(pvc_ct_subids), ct_subid);
}

#define STEP_NAME_CASE(name)	\
	case STEP_##name:	\
		return #name;

const char *intel_step_name(enum intel_step step)
{
	switch (step) {
	STEP_NAME_LIST(STEP_NAME_CASE);

	default:
		return "**";
	}
}

const char *intel_display_step_name(struct drm_i915_private *i915)
{
	return intel_step_name(RUNTIME_INFO(i915)->step.display_step);
}