Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/intel/dev/intel_device_info.c
7080 views
1
/*
2
* Copyright © 2013 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
#include <assert.h>
25
#include <stdbool.h>
26
#include <stdio.h>
27
#include <stdlib.h>
28
#include <string.h>
29
#include <unistd.h>
30
#include "intel_device_info.h"
31
#include "compiler/shader_enums.h"
32
#include "intel/common/intel_gem.h"
33
#include "util/bitscan.h"
34
#include "util/log.h"
35
#include "util/macros.h"
36
37
#include "drm-uapi/i915_drm.h"
38
39
static const struct {
40
const char *name;
41
int pci_id;
42
} name_map[] = {
43
{ "lpt", 0x27a2 },
44
{ "brw", 0x2a02 },
45
{ "g4x", 0x2a42 },
46
{ "ilk", 0x0042 },
47
{ "snb", 0x0126 },
48
{ "ivb", 0x016a },
49
{ "hsw", 0x0d2e },
50
{ "byt", 0x0f33 },
51
{ "bdw", 0x162e },
52
{ "chv", 0x22B3 },
53
{ "skl", 0x1912 },
54
{ "bxt", 0x5A85 },
55
{ "kbl", 0x5912 },
56
{ "aml", 0x591C },
57
{ "glk", 0x3185 },
58
{ "cfl", 0x3E9B },
59
{ "whl", 0x3EA1 },
60
{ "cml", 0x9b41 },
61
{ "icl", 0x8a52 },
62
{ "ehl", 0x4500 },
63
{ "jsl", 0x4E71 },
64
{ "tgl", 0x9a49 },
65
{ "rkl", 0x4c8a },
66
{ "dg1", 0x4905 },
67
{ "adl", 0x4680 },
68
};
69
70
/**
71
* Get the PCI ID for the device name.
72
*
73
* Returns -1 if the device is not known.
74
*/
75
int
76
intel_device_name_to_pci_device_id(const char *name)
77
{
78
for (unsigned i = 0; i < ARRAY_SIZE(name_map); i++) {
79
if (!strcmp(name_map[i].name, name))
80
return name_map[i].pci_id;
81
}
82
83
return -1;
84
}
85
86
static const struct intel_device_info intel_device_info_gfx3 = {
87
.ver = 3,
88
.simulator_id = -1,
89
.cs_prefetch_size = 512,
90
};
91
92
static const struct intel_device_info intel_device_info_i965 = {
93
.ver = 4,
94
.has_negative_rhw_bug = true,
95
.num_slices = 1,
96
.num_subslices = { 1, },
97
.num_eu_per_subslice = 8,
98
.num_thread_per_eu = 4,
99
.max_vs_threads = 16,
100
.max_gs_threads = 2,
101
.max_wm_threads = 8 * 4,
102
.urb = {
103
.size = 256,
104
},
105
.timestamp_frequency = 12500000,
106
.simulator_id = -1,
107
.cs_prefetch_size = 512,
108
};
109
110
static const struct intel_device_info intel_device_info_g4x = {
111
.ver = 4,
112
.verx10 = 45,
113
.has_pln = true,
114
.has_compr4 = true,
115
.has_surface_tile_offset = true,
116
.is_g4x = true,
117
.num_slices = 1,
118
.num_subslices = { 1, },
119
.num_eu_per_subslice = 10,
120
.num_thread_per_eu = 5,
121
.max_vs_threads = 32,
122
.max_gs_threads = 2,
123
.max_wm_threads = 10 * 5,
124
.urb = {
125
.size = 384,
126
},
127
.timestamp_frequency = 12500000,
128
.simulator_id = -1,
129
.cs_prefetch_size = 512,
130
};
131
132
static const struct intel_device_info intel_device_info_ilk = {
133
.ver = 5,
134
.has_pln = true,
135
.has_compr4 = true,
136
.has_surface_tile_offset = true,
137
.num_slices = 1,
138
.num_subslices = { 1, },
139
.num_eu_per_subslice = 12,
140
.num_thread_per_eu = 6,
141
.max_vs_threads = 72,
142
.max_gs_threads = 32,
143
.max_wm_threads = 12 * 6,
144
.urb = {
145
.size = 1024,
146
},
147
.timestamp_frequency = 12500000,
148
.simulator_id = -1,
149
.cs_prefetch_size = 512,
150
};
151
152
static const struct intel_device_info intel_device_info_snb_gt1 = {
153
.ver = 6,
154
.gt = 1,
155
.has_hiz_and_separate_stencil = true,
156
.has_llc = true,
157
.has_pln = true,
158
.has_surface_tile_offset = true,
159
.needs_unlit_centroid_workaround = true,
160
.num_slices = 1,
161
.num_subslices = { 1, },
162
.num_eu_per_subslice = 6,
163
.num_thread_per_eu = 6, /* Not confirmed */
164
.max_vs_threads = 24,
165
.max_gs_threads = 21, /* conservative; 24 if rendering disabled. */
166
.max_wm_threads = 40,
167
.urb = {
168
.size = 32,
169
.min_entries = {
170
[MESA_SHADER_VERTEX] = 24,
171
},
172
.max_entries = {
173
[MESA_SHADER_VERTEX] = 256,
174
[MESA_SHADER_GEOMETRY] = 256,
175
},
176
},
177
.timestamp_frequency = 12500000,
178
.simulator_id = -1,
179
.cs_prefetch_size = 512,
180
};
181
182
static const struct intel_device_info intel_device_info_snb_gt2 = {
183
.ver = 6,
184
.gt = 2,
185
.has_hiz_and_separate_stencil = true,
186
.has_llc = true,
187
.has_pln = true,
188
.has_surface_tile_offset = true,
189
.needs_unlit_centroid_workaround = true,
190
.num_slices = 1,
191
.num_subslices = { 1, },
192
.num_eu_per_subslice = 12,
193
.num_thread_per_eu = 6, /* Not confirmed */
194
.max_vs_threads = 60,
195
.max_gs_threads = 60,
196
.max_wm_threads = 80,
197
.urb = {
198
.size = 64,
199
.min_entries = {
200
[MESA_SHADER_VERTEX] = 24,
201
},
202
.max_entries = {
203
[MESA_SHADER_VERTEX] = 256,
204
[MESA_SHADER_GEOMETRY] = 256,
205
},
206
},
207
.timestamp_frequency = 12500000,
208
.simulator_id = -1,
209
.cs_prefetch_size = 512,
210
};
211
212
#define GFX7_FEATURES \
213
.ver = 7, \
214
.has_hiz_and_separate_stencil = true, \
215
.must_use_separate_stencil = true, \
216
.has_llc = true, \
217
.has_pln = true, \
218
.has_64bit_float = true, \
219
.has_surface_tile_offset = true, \
220
.timestamp_frequency = 12500000, \
221
.cs_prefetch_size = 512
222
223
static const struct intel_device_info intel_device_info_ivb_gt1 = {
224
GFX7_FEATURES, .is_ivybridge = true, .gt = 1,
225
.num_slices = 1,
226
.num_subslices = { 1, },
227
.num_eu_per_subslice = 6,
228
.num_thread_per_eu = 6,
229
.l3_banks = 2,
230
.max_vs_threads = 36,
231
.max_tcs_threads = 36,
232
.max_tes_threads = 36,
233
.max_gs_threads = 36,
234
.max_wm_threads = 48,
235
.max_cs_threads = 36,
236
.urb = {
237
.min_entries = {
238
[MESA_SHADER_VERTEX] = 32,
239
[MESA_SHADER_TESS_EVAL] = 10,
240
},
241
.max_entries = {
242
[MESA_SHADER_VERTEX] = 512,
243
[MESA_SHADER_TESS_CTRL] = 32,
244
[MESA_SHADER_TESS_EVAL] = 288,
245
[MESA_SHADER_GEOMETRY] = 192,
246
},
247
},
248
.simulator_id = 7,
249
};
250
251
static const struct intel_device_info intel_device_info_ivb_gt2 = {
252
GFX7_FEATURES, .is_ivybridge = true, .gt = 2,
253
.num_slices = 1,
254
.num_subslices = { 1, },
255
.num_eu_per_subslice = 12,
256
.num_thread_per_eu = 8, /* Not sure why this isn't a multiple of
257
* @max_wm_threads ... */
258
.l3_banks = 4,
259
.max_vs_threads = 128,
260
.max_tcs_threads = 128,
261
.max_tes_threads = 128,
262
.max_gs_threads = 128,
263
.max_wm_threads = 172,
264
.max_cs_threads = 64,
265
.urb = {
266
.min_entries = {
267
[MESA_SHADER_VERTEX] = 32,
268
[MESA_SHADER_TESS_EVAL] = 10,
269
},
270
.max_entries = {
271
[MESA_SHADER_VERTEX] = 704,
272
[MESA_SHADER_TESS_CTRL] = 64,
273
[MESA_SHADER_TESS_EVAL] = 448,
274
[MESA_SHADER_GEOMETRY] = 320,
275
},
276
},
277
.simulator_id = 7,
278
};
279
280
static const struct intel_device_info intel_device_info_byt = {
281
GFX7_FEATURES, .is_baytrail = true, .gt = 1,
282
.num_slices = 1,
283
.num_subslices = { 1, },
284
.num_eu_per_subslice = 4,
285
.num_thread_per_eu = 8,
286
.l3_banks = 1,
287
.has_llc = false,
288
.max_vs_threads = 36,
289
.max_tcs_threads = 36,
290
.max_tes_threads = 36,
291
.max_gs_threads = 36,
292
.max_wm_threads = 48,
293
.max_cs_threads = 32,
294
.urb = {
295
.min_entries = {
296
[MESA_SHADER_VERTEX] = 32,
297
[MESA_SHADER_TESS_EVAL] = 10,
298
},
299
.max_entries = {
300
[MESA_SHADER_VERTEX] = 512,
301
[MESA_SHADER_TESS_CTRL] = 32,
302
[MESA_SHADER_TESS_EVAL] = 288,
303
[MESA_SHADER_GEOMETRY] = 192,
304
},
305
},
306
.simulator_id = 10,
307
};
308
309
#define HSW_FEATURES \
310
GFX7_FEATURES, \
311
.is_haswell = true, \
312
.verx10 = 75, \
313
.supports_simd16_3src = true
314
315
static const struct intel_device_info intel_device_info_hsw_gt1 = {
316
HSW_FEATURES, .gt = 1,
317
.num_slices = 1,
318
.num_subslices = { 1, },
319
.num_eu_per_subslice = 10,
320
.num_thread_per_eu = 7,
321
.l3_banks = 2,
322
.max_vs_threads = 70,
323
.max_tcs_threads = 70,
324
.max_tes_threads = 70,
325
.max_gs_threads = 70,
326
.max_wm_threads = 102,
327
.max_cs_threads = 70,
328
.urb = {
329
.min_entries = {
330
[MESA_SHADER_VERTEX] = 32,
331
[MESA_SHADER_TESS_EVAL] = 10,
332
},
333
.max_entries = {
334
[MESA_SHADER_VERTEX] = 640,
335
[MESA_SHADER_TESS_CTRL] = 64,
336
[MESA_SHADER_TESS_EVAL] = 384,
337
[MESA_SHADER_GEOMETRY] = 256,
338
},
339
},
340
.simulator_id = 9,
341
};
342
343
static const struct intel_device_info intel_device_info_hsw_gt2 = {
344
HSW_FEATURES, .gt = 2,
345
.num_slices = 1,
346
.num_subslices = { 2, },
347
.num_eu_per_subslice = 10,
348
.num_thread_per_eu = 7,
349
.l3_banks = 4,
350
.max_vs_threads = 280,
351
.max_tcs_threads = 256,
352
.max_tes_threads = 280,
353
.max_gs_threads = 256,
354
.max_wm_threads = 204,
355
.max_cs_threads = 70,
356
.urb = {
357
.min_entries = {
358
[MESA_SHADER_VERTEX] = 64,
359
[MESA_SHADER_TESS_EVAL] = 10,
360
},
361
.max_entries = {
362
[MESA_SHADER_VERTEX] = 1664,
363
[MESA_SHADER_TESS_CTRL] = 128,
364
[MESA_SHADER_TESS_EVAL] = 960,
365
[MESA_SHADER_GEOMETRY] = 640,
366
},
367
},
368
.simulator_id = 9,
369
};
370
371
static const struct intel_device_info intel_device_info_hsw_gt3 = {
372
HSW_FEATURES, .gt = 3,
373
.num_slices = 2,
374
.num_subslices = { 2, },
375
.num_eu_per_subslice = 10,
376
.num_thread_per_eu = 7,
377
.l3_banks = 8,
378
.max_vs_threads = 280,
379
.max_tcs_threads = 256,
380
.max_tes_threads = 280,
381
.max_gs_threads = 256,
382
.max_wm_threads = 408,
383
.max_cs_threads = 70,
384
.urb = {
385
.min_entries = {
386
[MESA_SHADER_VERTEX] = 64,
387
[MESA_SHADER_TESS_EVAL] = 10,
388
},
389
.max_entries = {
390
[MESA_SHADER_VERTEX] = 1664,
391
[MESA_SHADER_TESS_CTRL] = 128,
392
[MESA_SHADER_TESS_EVAL] = 960,
393
[MESA_SHADER_GEOMETRY] = 640,
394
},
395
},
396
.simulator_id = 9,
397
};
398
399
/* It's unclear how well supported sampling from the hiz buffer is on GFX8,
400
* so keep things conservative for now and set has_sample_with_hiz = false.
401
*/
402
#define GFX8_FEATURES \
403
.ver = 8, \
404
.has_hiz_and_separate_stencil = true, \
405
.must_use_separate_stencil = true, \
406
.has_llc = true, \
407
.has_sample_with_hiz = false, \
408
.has_pln = true, \
409
.has_integer_dword_mul = true, \
410
.has_64bit_float = true, \
411
.has_64bit_int = true, \
412
.supports_simd16_3src = true, \
413
.has_surface_tile_offset = true, \
414
.num_thread_per_eu = 7, \
415
.max_vs_threads = 504, \
416
.max_tcs_threads = 504, \
417
.max_tes_threads = 504, \
418
.max_gs_threads = 504, \
419
.max_wm_threads = 384, \
420
.timestamp_frequency = 12500000, \
421
.cs_prefetch_size = 512
422
423
static const struct intel_device_info intel_device_info_bdw_gt1 = {
424
GFX8_FEATURES, .gt = 1,
425
.is_broadwell = true,
426
.num_slices = 1,
427
.num_subslices = { 2, },
428
.num_eu_per_subslice = 6,
429
.l3_banks = 2,
430
.max_cs_threads = 42,
431
.urb = {
432
.min_entries = {
433
[MESA_SHADER_VERTEX] = 64,
434
[MESA_SHADER_TESS_EVAL] = 34,
435
},
436
.max_entries = {
437
[MESA_SHADER_VERTEX] = 2560,
438
[MESA_SHADER_TESS_CTRL] = 504,
439
[MESA_SHADER_TESS_EVAL] = 1536,
440
/* Reduced from 960, seems to be similar to the bug on Gfx9 GT1. */
441
[MESA_SHADER_GEOMETRY] = 690,
442
},
443
},
444
.simulator_id = 11,
445
};
446
447
static const struct intel_device_info intel_device_info_bdw_gt2 = {
448
GFX8_FEATURES, .gt = 2,
449
.is_broadwell = true,
450
.num_slices = 1,
451
.num_subslices = { 3, },
452
.num_eu_per_subslice = 8,
453
.l3_banks = 4,
454
.max_cs_threads = 56,
455
.urb = {
456
.min_entries = {
457
[MESA_SHADER_VERTEX] = 64,
458
[MESA_SHADER_TESS_EVAL] = 34,
459
},
460
.max_entries = {
461
[MESA_SHADER_VERTEX] = 2560,
462
[MESA_SHADER_TESS_CTRL] = 504,
463
[MESA_SHADER_TESS_EVAL] = 1536,
464
[MESA_SHADER_GEOMETRY] = 960,
465
},
466
},
467
.simulator_id = 11,
468
};
469
470
static const struct intel_device_info intel_device_info_bdw_gt3 = {
471
GFX8_FEATURES, .gt = 3,
472
.is_broadwell = true,
473
.num_slices = 2,
474
.num_subslices = { 3, 3, },
475
.num_eu_per_subslice = 8,
476
.l3_banks = 8,
477
.max_cs_threads = 56,
478
.urb = {
479
.min_entries = {
480
[MESA_SHADER_VERTEX] = 64,
481
[MESA_SHADER_TESS_EVAL] = 34,
482
},
483
.max_entries = {
484
[MESA_SHADER_VERTEX] = 2560,
485
[MESA_SHADER_TESS_CTRL] = 504,
486
[MESA_SHADER_TESS_EVAL] = 1536,
487
[MESA_SHADER_GEOMETRY] = 960,
488
},
489
},
490
.simulator_id = 11,
491
};
492
493
static const struct intel_device_info intel_device_info_chv = {
494
GFX8_FEATURES, .is_cherryview = 1, .gt = 1,
495
.has_llc = false,
496
.has_integer_dword_mul = false,
497
.num_slices = 1,
498
.num_subslices = { 2, },
499
.num_eu_per_subslice = 8,
500
.l3_banks = 2,
501
.max_vs_threads = 80,
502
.max_tcs_threads = 80,
503
.max_tes_threads = 80,
504
.max_gs_threads = 80,
505
.max_wm_threads = 128,
506
.max_cs_threads = 6 * 7,
507
.urb = {
508
.min_entries = {
509
[MESA_SHADER_VERTEX] = 34,
510
[MESA_SHADER_TESS_EVAL] = 34,
511
},
512
.max_entries = {
513
[MESA_SHADER_VERTEX] = 640,
514
[MESA_SHADER_TESS_CTRL] = 80,
515
[MESA_SHADER_TESS_EVAL] = 384,
516
[MESA_SHADER_GEOMETRY] = 256,
517
},
518
},
519
.simulator_id = 13,
520
};
521
522
#define GFX9_HW_INFO \
523
.ver = 9, \
524
.max_vs_threads = 336, \
525
.max_gs_threads = 336, \
526
.max_tcs_threads = 336, \
527
.max_tes_threads = 336, \
528
.max_cs_threads = 56, \
529
.timestamp_frequency = 12000000, \
530
.cs_prefetch_size = 512, \
531
.urb = { \
532
.min_entries = { \
533
[MESA_SHADER_VERTEX] = 64, \
534
[MESA_SHADER_TESS_EVAL] = 34, \
535
}, \
536
.max_entries = { \
537
[MESA_SHADER_VERTEX] = 1856, \
538
[MESA_SHADER_TESS_CTRL] = 672, \
539
[MESA_SHADER_TESS_EVAL] = 1120, \
540
[MESA_SHADER_GEOMETRY] = 640, \
541
}, \
542
}
543
544
#define GFX9_LP_FEATURES \
545
GFX8_FEATURES, \
546
GFX9_HW_INFO, \
547
.has_integer_dword_mul = false, \
548
.gt = 1, \
549
.has_llc = false, \
550
.has_sample_with_hiz = true, \
551
.num_slices = 1, \
552
.num_thread_per_eu = 6, \
553
.max_vs_threads = 112, \
554
.max_tcs_threads = 112, \
555
.max_tes_threads = 112, \
556
.max_gs_threads = 112, \
557
.max_cs_threads = 6 * 6, \
558
.timestamp_frequency = 19200000, \
559
.urb = { \
560
.min_entries = { \
561
[MESA_SHADER_VERTEX] = 34, \
562
[MESA_SHADER_TESS_EVAL] = 34, \
563
}, \
564
.max_entries = { \
565
[MESA_SHADER_VERTEX] = 704, \
566
[MESA_SHADER_TESS_CTRL] = 256, \
567
[MESA_SHADER_TESS_EVAL] = 416, \
568
[MESA_SHADER_GEOMETRY] = 256, \
569
}, \
570
}
571
572
#define GFX9_LP_FEATURES_3X6 \
573
GFX9_LP_FEATURES, \
574
.num_subslices = { 3, }, \
575
.num_eu_per_subslice = 6
576
577
#define GFX9_LP_FEATURES_2X6 \
578
GFX9_LP_FEATURES, \
579
.num_subslices = { 2, }, \
580
.num_eu_per_subslice = 6, \
581
.max_vs_threads = 56, \
582
.max_tcs_threads = 56, \
583
.max_tes_threads = 56, \
584
.max_gs_threads = 56, \
585
.max_cs_threads = 6 * 6, \
586
.urb = { \
587
.min_entries = { \
588
[MESA_SHADER_VERTEX] = 34, \
589
[MESA_SHADER_TESS_EVAL] = 34, \
590
}, \
591
.max_entries = { \
592
[MESA_SHADER_VERTEX] = 352, \
593
[MESA_SHADER_TESS_CTRL] = 128, \
594
[MESA_SHADER_TESS_EVAL] = 208, \
595
[MESA_SHADER_GEOMETRY] = 128, \
596
}, \
597
}
598
599
#define GFX9_FEATURES \
600
GFX8_FEATURES, \
601
GFX9_HW_INFO, \
602
.has_sample_with_hiz = true
603
604
static const struct intel_device_info intel_device_info_skl_gt1 = {
605
GFX9_FEATURES, .gt = 1,
606
.is_skylake = true,
607
.num_slices = 1,
608
.num_subslices = { 2, },
609
.num_eu_per_subslice = 6,
610
.l3_banks = 2,
611
/* GT1 seems to have a bug in the top of the pipe (VF/VS?) fixed functions
612
* leading to some vertices to go missing if we use too much URB.
613
*/
614
.urb.max_entries[MESA_SHADER_VERTEX] = 928,
615
.simulator_id = 12,
616
};
617
618
static const struct intel_device_info intel_device_info_skl_gt2 = {
619
GFX9_FEATURES, .gt = 2,
620
.is_skylake = true,
621
.num_slices = 1,
622
.num_subslices = { 3, },
623
.num_eu_per_subslice = 8,
624
.l3_banks = 4,
625
.simulator_id = 12,
626
};
627
628
static const struct intel_device_info intel_device_info_skl_gt3 = {
629
GFX9_FEATURES, .gt = 3,
630
.is_skylake = true,
631
.num_slices = 2,
632
.num_subslices = { 3, 3, },
633
.num_eu_per_subslice = 8,
634
.l3_banks = 8,
635
.simulator_id = 12,
636
};
637
638
static const struct intel_device_info intel_device_info_skl_gt4 = {
639
GFX9_FEATURES, .gt = 4,
640
.is_skylake = true,
641
.num_slices = 3,
642
.num_subslices = { 3, 3, 3, },
643
.num_eu_per_subslice = 8,
644
.l3_banks = 12,
645
/* From the "L3 Allocation and Programming" documentation:
646
*
647
* "URB is limited to 1008KB due to programming restrictions. This is not a
648
* restriction of the L3 implementation, but of the FF and other clients.
649
* Therefore, in a GT4 implementation it is possible for the programmed
650
* allocation of the L3 data array to provide 3*384KB=1152KB for URB, but
651
* only 1008KB of this will be used."
652
*/
653
.simulator_id = 12,
654
};
655
656
static const struct intel_device_info intel_device_info_bxt = {
657
GFX9_LP_FEATURES_3X6,
658
.is_broxton = true,
659
.l3_banks = 2,
660
.simulator_id = 14,
661
};
662
663
static const struct intel_device_info intel_device_info_bxt_2x6 = {
664
GFX9_LP_FEATURES_2X6,
665
.is_broxton = true,
666
.l3_banks = 1,
667
.simulator_id = 14,
668
};
669
/*
670
* Note: for all KBL SKUs, the PRM says SKL for GS entries, not SKL+.
671
* There's no KBL entry. Using the default SKL (GFX9) GS entries value.
672
*/
673
674
static const struct intel_device_info intel_device_info_kbl_gt1 = {
675
GFX9_FEATURES,
676
.is_kabylake = true,
677
.gt = 1,
678
679
.max_cs_threads = 7 * 6,
680
.num_slices = 1,
681
.num_subslices = { 2, },
682
.num_eu_per_subslice = 6,
683
.l3_banks = 2,
684
/* GT1 seems to have a bug in the top of the pipe (VF/VS?) fixed functions
685
* leading to some vertices to go missing if we use too much URB.
686
*/
687
.urb.max_entries[MESA_SHADER_VERTEX] = 928,
688
.urb.max_entries[MESA_SHADER_GEOMETRY] = 256,
689
.simulator_id = 16,
690
};
691
692
static const struct intel_device_info intel_device_info_kbl_gt1_5 = {
693
GFX9_FEATURES,
694
.is_kabylake = true,
695
.gt = 1,
696
697
.max_cs_threads = 7 * 6,
698
.num_slices = 1,
699
.num_subslices = { 3, },
700
.num_eu_per_subslice = 6,
701
.l3_banks = 4,
702
.simulator_id = 16,
703
};
704
705
static const struct intel_device_info intel_device_info_kbl_gt2 = {
706
GFX9_FEATURES,
707
.is_kabylake = true,
708
.gt = 2,
709
710
.num_slices = 1,
711
.num_subslices = { 3, },
712
.num_eu_per_subslice = 8,
713
.l3_banks = 4,
714
.simulator_id = 16,
715
};
716
717
static const struct intel_device_info intel_device_info_kbl_gt3 = {
718
GFX9_FEATURES,
719
.is_kabylake = true,
720
.gt = 3,
721
722
.num_slices = 2,
723
.num_subslices = { 3, 3, },
724
.num_eu_per_subslice = 8,
725
.l3_banks = 8,
726
.simulator_id = 16,
727
};
728
729
static const struct intel_device_info intel_device_info_kbl_gt4 = {
730
GFX9_FEATURES,
731
.is_kabylake = true,
732
.gt = 4,
733
734
/*
735
* From the "L3 Allocation and Programming" documentation:
736
*
737
* "URB is limited to 1008KB due to programming restrictions. This
738
* is not a restriction of the L3 implementation, but of the FF and
739
* other clients. Therefore, in a GT4 implementation it is
740
* possible for the programmed allocation of the L3 data array to
741
* provide 3*384KB=1152KB for URB, but only 1008KB of this
742
* will be used."
743
*/
744
.num_slices = 3,
745
.num_subslices = { 3, 3, 3, },
746
.num_eu_per_subslice = 8,
747
.l3_banks = 12,
748
.simulator_id = 16,
749
};
750
751
static const struct intel_device_info intel_device_info_glk = {
752
GFX9_LP_FEATURES_3X6,
753
.is_geminilake = true,
754
.l3_banks = 2,
755
.simulator_id = 17,
756
};
757
758
static const struct intel_device_info intel_device_info_glk_2x6 = {
759
GFX9_LP_FEATURES_2X6,
760
.is_geminilake = true,
761
.l3_banks = 2,
762
.simulator_id = 17,
763
};
764
765
static const struct intel_device_info intel_device_info_cfl_gt1 = {
766
GFX9_FEATURES,
767
.is_coffeelake = true,
768
.gt = 1,
769
770
.num_slices = 1,
771
.num_subslices = { 2, },
772
.num_eu_per_subslice = 6,
773
.l3_banks = 2,
774
/* GT1 seems to have a bug in the top of the pipe (VF/VS?) fixed functions
775
* leading to some vertices to go missing if we use too much URB.
776
*/
777
.urb.max_entries[MESA_SHADER_VERTEX] = 928,
778
.urb.max_entries[MESA_SHADER_GEOMETRY] = 256,
779
.simulator_id = 24,
780
};
781
static const struct intel_device_info intel_device_info_cfl_gt2 = {
782
GFX9_FEATURES,
783
.is_coffeelake = true,
784
.gt = 2,
785
786
.num_slices = 1,
787
.num_subslices = { 3, },
788
.num_eu_per_subslice = 8,
789
.l3_banks = 4,
790
.simulator_id = 24,
791
};
792
793
static const struct intel_device_info intel_device_info_cfl_gt3 = {
794
GFX9_FEATURES,
795
.is_coffeelake = true,
796
.gt = 3,
797
798
.num_slices = 2,
799
.num_subslices = { 3, 3, },
800
.num_eu_per_subslice = 8,
801
.l3_banks = 8,
802
.simulator_id = 24,
803
};
804
805
#define subslices(args...) { args, }
806
807
#define GFX11_HW_INFO \
808
.ver = 11, \
809
.has_pln = false, \
810
.max_vs_threads = 364, \
811
.max_gs_threads = 224, \
812
.max_tcs_threads = 224, \
813
.max_tes_threads = 364, \
814
.max_cs_threads = 56, \
815
.cs_prefetch_size = 512
816
817
#define GFX11_FEATURES(_gt, _slices, _subslices, _l3) \
818
GFX8_FEATURES, \
819
GFX11_HW_INFO, \
820
.has_64bit_float = false, \
821
.has_64bit_int = false, \
822
.has_integer_dword_mul = false, \
823
.has_sample_with_hiz = false, \
824
.gt = _gt, .num_slices = _slices, .l3_banks = _l3, \
825
.num_subslices = _subslices, \
826
.num_eu_per_subslice = 8
827
828
#define GFX11_URB_MIN_MAX_ENTRIES \
829
.min_entries = { \
830
[MESA_SHADER_VERTEX] = 64, \
831
[MESA_SHADER_TESS_EVAL] = 34, \
832
}, \
833
.max_entries = { \
834
[MESA_SHADER_VERTEX] = 2384, \
835
[MESA_SHADER_TESS_CTRL] = 1032, \
836
[MESA_SHADER_TESS_EVAL] = 2384, \
837
[MESA_SHADER_GEOMETRY] = 1032, \
838
}
839
840
static const struct intel_device_info intel_device_info_icl_gt2 = {
841
GFX11_FEATURES(2, 1, subslices(8), 8),
842
.urb = {
843
GFX11_URB_MIN_MAX_ENTRIES,
844
},
845
.simulator_id = 19,
846
};
847
848
static const struct intel_device_info intel_device_info_icl_gt1_5 = {
849
GFX11_FEATURES(1, 1, subslices(6), 6),
850
.urb = {
851
GFX11_URB_MIN_MAX_ENTRIES,
852
},
853
.simulator_id = 19,
854
};
855
856
static const struct intel_device_info intel_device_info_icl_gt1 = {
857
GFX11_FEATURES(1, 1, subslices(4), 6),
858
.urb = {
859
GFX11_URB_MIN_MAX_ENTRIES,
860
},
861
.simulator_id = 19,
862
};
863
864
static const struct intel_device_info intel_device_info_icl_gt0_5 = {
865
GFX11_FEATURES(1, 1, subslices(1), 6),
866
.urb = {
867
GFX11_URB_MIN_MAX_ENTRIES,
868
},
869
.simulator_id = 19,
870
};
871
872
#define GFX11_LP_FEATURES \
873
.is_elkhartlake = true, \
874
.urb = { \
875
GFX11_URB_MIN_MAX_ENTRIES, \
876
}, \
877
.disable_ccs_repack = true, \
878
.simulator_id = 28
879
880
static const struct intel_device_info intel_device_info_ehl_4x8 = {
881
GFX11_FEATURES(1, 1, subslices(4), 4),
882
GFX11_LP_FEATURES,
883
};
884
885
static const struct intel_device_info intel_device_info_ehl_4x6 = {
886
GFX11_FEATURES(1, 1, subslices(4), 4),
887
GFX11_LP_FEATURES,
888
.num_eu_per_subslice = 6,
889
};
890
891
static const struct intel_device_info intel_device_info_ehl_4x5 = {
892
GFX11_FEATURES(1, 1, subslices(4), 4),
893
GFX11_LP_FEATURES,
894
.num_eu_per_subslice = 5,
895
};
896
897
static const struct intel_device_info intel_device_info_ehl_4x4 = {
898
GFX11_FEATURES(1, 1, subslices(4), 4),
899
GFX11_LP_FEATURES,
900
.num_eu_per_subslice = 4,
901
};
902
903
static const struct intel_device_info intel_device_info_ehl_2x8 = {
904
GFX11_FEATURES(1, 1, subslices(2), 4),
905
GFX11_LP_FEATURES,
906
};
907
908
static const struct intel_device_info intel_device_info_ehl_2x4 = {
909
GFX11_FEATURES(1, 1, subslices(2), 4),
910
GFX11_LP_FEATURES,
911
.num_eu_per_subslice =4,
912
};
913
914
#define GFX12_URB_MIN_MAX_ENTRIES \
915
.min_entries = { \
916
[MESA_SHADER_VERTEX] = 64, \
917
[MESA_SHADER_TESS_EVAL] = 34, \
918
}, \
919
.max_entries = { \
920
[MESA_SHADER_VERTEX] = 3576, \
921
[MESA_SHADER_TESS_CTRL] = 1548, \
922
[MESA_SHADER_TESS_EVAL] = 3576, \
923
/* Wa_14013840143 */ \
924
[MESA_SHADER_GEOMETRY] = 1536, \
925
}
926
927
#define GFX12_HW_INFO \
928
.ver = 12, \
929
.has_pln = false, \
930
.has_sample_with_hiz = false, \
931
.has_aux_map = true, \
932
.max_vs_threads = 546, \
933
.max_gs_threads = 336, \
934
.max_tcs_threads = 336, \
935
.max_tes_threads = 546, \
936
.max_cs_threads = 112, /* threads per DSS */ \
937
.urb = { \
938
GFX12_URB_MIN_MAX_ENTRIES, \
939
}
940
941
#define GFX12_FEATURES(_gt, _slices, _l3) \
942
GFX8_FEATURES, \
943
GFX12_HW_INFO, \
944
.has_64bit_float = false, \
945
.has_64bit_int = false, \
946
.has_integer_dword_mul = false, \
947
.gt = _gt, .num_slices = _slices, .l3_banks = _l3, \
948
.simulator_id = 22, \
949
.num_eu_per_subslice = 16, \
950
.cs_prefetch_size = 512
951
952
#define dual_subslices(args...) { args, }
953
954
#define GFX12_GT05_FEATURES \
955
GFX12_FEATURES(1, 1, 4), \
956
.num_subslices = dual_subslices(1)
957
958
#define GFX12_GT_FEATURES(_gt) \
959
GFX12_FEATURES(_gt, 1, _gt == 1 ? 4 : 8), \
960
.num_subslices = dual_subslices(_gt == 1 ? 2 : 6)
961
962
static const struct intel_device_info intel_device_info_tgl_gt1 = {
963
GFX12_GT_FEATURES(1),
964
.is_tigerlake = true,
965
};
966
967
static const struct intel_device_info intel_device_info_tgl_gt2 = {
968
GFX12_GT_FEATURES(2),
969
.is_tigerlake = true,
970
};
971
972
static const struct intel_device_info intel_device_info_rkl_gt05 = {
973
GFX12_GT05_FEATURES,
974
.is_rocketlake = true,
975
};
976
977
static const struct intel_device_info intel_device_info_rkl_gt1 = {
978
GFX12_GT_FEATURES(1),
979
.is_rocketlake = true,
980
};
981
982
static const struct intel_device_info intel_device_info_adl_gt05 = {
983
GFX12_GT05_FEATURES,
984
.is_alderlake = true,
985
};
986
987
static const struct intel_device_info intel_device_info_adl_gt1 = {
988
GFX12_GT_FEATURES(1),
989
.is_alderlake = true,
990
};
991
992
static const struct intel_device_info intel_device_info_adl_gt2 = {
993
GFX12_GT_FEATURES(2),
994
.is_alderlake = true,
995
};
996
997
#define GFX12_DG1_FEATURES \
998
GFX12_GT_FEATURES(2), \
999
.is_dg1 = true, \
1000
.has_llc = false, \
1001
.has_local_mem = true, \
1002
.urb.size = 768, \
1003
.simulator_id = 30
1004
1005
UNUSED static const struct intel_device_info intel_device_info_dg1 = {
1006
GFX12_DG1_FEATURES,
1007
};
1008
1009
static void
1010
intel_device_info_set_eu_mask(struct intel_device_info *devinfo,
1011
unsigned slice,
1012
unsigned subslice,
1013
unsigned eu_mask)
1014
{
1015
unsigned subslice_offset = slice * devinfo->eu_slice_stride +
1016
subslice * devinfo->eu_subslice_stride;
1017
1018
for (unsigned b_eu = 0; b_eu < devinfo->eu_subslice_stride; b_eu++) {
1019
devinfo->eu_masks[subslice_offset + b_eu] =
1020
(((1U << devinfo->num_eu_per_subslice) - 1) >> (b_eu * 8)) & 0xff;
1021
}
1022
}
1023
1024
/* Generate slice/subslice/eu masks from number of
1025
* slices/subslices/eu_per_subslices in the per generation/gt intel_device_info
1026
* structure.
1027
*
1028
* These can be overridden with values reported by the kernel either from
1029
* getparam SLICE_MASK/SUBSLICE_MASK values or from the kernel version 4.17+
1030
* through the i915 query uapi.
1031
*/
1032
static void
1033
fill_masks(struct intel_device_info *devinfo)
1034
{
1035
devinfo->slice_masks = (1U << devinfo->num_slices) - 1;
1036
1037
/* Subslice masks */
1038
unsigned max_subslices = 0;
1039
for (int s = 0; s < devinfo->num_slices; s++)
1040
max_subslices = MAX2(devinfo->num_subslices[s], max_subslices);
1041
devinfo->subslice_slice_stride = DIV_ROUND_UP(max_subslices, 8);
1042
1043
for (int s = 0; s < devinfo->num_slices; s++) {
1044
devinfo->subslice_masks[s * devinfo->subslice_slice_stride] =
1045
(1U << devinfo->num_subslices[s]) - 1;
1046
}
1047
1048
/* EU masks */
1049
devinfo->eu_subslice_stride = DIV_ROUND_UP(devinfo->num_eu_per_subslice, 8);
1050
devinfo->eu_slice_stride = max_subslices * devinfo->eu_subslice_stride;
1051
1052
for (int s = 0; s < devinfo->num_slices; s++) {
1053
for (int ss = 0; ss < devinfo->num_subslices[s]; ss++) {
1054
intel_device_info_set_eu_mask(devinfo, s, ss,
1055
(1U << devinfo->num_eu_per_subslice) - 1);
1056
}
1057
}
1058
}
1059
1060
static void
1061
reset_masks(struct intel_device_info *devinfo)
1062
{
1063
devinfo->subslice_slice_stride = 0;
1064
devinfo->eu_subslice_stride = 0;
1065
devinfo->eu_slice_stride = 0;
1066
1067
devinfo->num_slices = 0;
1068
devinfo->num_eu_per_subslice = 0;
1069
memset(devinfo->num_subslices, 0, sizeof(devinfo->num_subslices));
1070
1071
memset(&devinfo->slice_masks, 0, sizeof(devinfo->slice_masks));
1072
memset(devinfo->subslice_masks, 0, sizeof(devinfo->subslice_masks));
1073
memset(devinfo->eu_masks, 0, sizeof(devinfo->eu_masks));
1074
memset(devinfo->ppipe_subslices, 0, sizeof(devinfo->ppipe_subslices));
1075
}
1076
1077
static void
1078
update_from_topology(struct intel_device_info *devinfo,
1079
const struct drm_i915_query_topology_info *topology)
1080
{
1081
reset_masks(devinfo);
1082
1083
devinfo->subslice_slice_stride = topology->subslice_stride;
1084
1085
devinfo->eu_subslice_stride = DIV_ROUND_UP(topology->max_eus_per_subslice, 8);
1086
devinfo->eu_slice_stride = topology->max_subslices * devinfo->eu_subslice_stride;
1087
1088
assert(sizeof(devinfo->slice_masks) >= DIV_ROUND_UP(topology->max_slices, 8));
1089
memcpy(&devinfo->slice_masks, topology->data, DIV_ROUND_UP(topology->max_slices, 8));
1090
devinfo->num_slices = __builtin_popcount(devinfo->slice_masks);
1091
1092
uint32_t subslice_mask_len =
1093
topology->max_slices * topology->subslice_stride;
1094
assert(sizeof(devinfo->subslice_masks) >= subslice_mask_len);
1095
memcpy(devinfo->subslice_masks, &topology->data[topology->subslice_offset],
1096
subslice_mask_len);
1097
1098
uint32_t n_subslices = 0;
1099
for (int s = 0; s < topology->max_slices; s++) {
1100
if ((devinfo->slice_masks & (1 << s)) == 0)
1101
continue;
1102
1103
for (int b = 0; b < devinfo->subslice_slice_stride; b++) {
1104
devinfo->num_subslices[s] +=
1105
__builtin_popcount(devinfo->subslice_masks[s * devinfo->subslice_slice_stride + b]);
1106
}
1107
n_subslices += devinfo->num_subslices[s];
1108
}
1109
assert(n_subslices > 0);
1110
1111
if (devinfo->ver >= 11) {
1112
/* On current ICL+ hardware we only have one slice. */
1113
assert(devinfo->slice_masks == 1);
1114
1115
/* Count the number of subslices on each pixel pipe. Assume that every
1116
* contiguous group of 4 subslices in the mask belong to the same pixel
1117
* pipe. However note that on TGL the kernel returns a mask of enabled
1118
* *dual* subslices instead of actual subslices somewhat confusingly, so
1119
* each pixel pipe only takes 2 bits in the mask even though it's still
1120
* 4 subslices.
1121
*/
1122
const unsigned ppipe_bits = devinfo->ver >= 12 ? 2 : 4;
1123
for (unsigned p = 0; p < INTEL_DEVICE_MAX_PIXEL_PIPES; p++) {
1124
const unsigned ppipe_mask = BITFIELD_RANGE(p * ppipe_bits, ppipe_bits);
1125
devinfo->ppipe_subslices[p] =
1126
__builtin_popcount(devinfo->subslice_masks[0] & ppipe_mask);
1127
}
1128
}
1129
1130
if (devinfo->ver == 12 && devinfo->num_slices == 1) {
1131
if (n_subslices >= 6) {
1132
assert(n_subslices == 6);
1133
devinfo->l3_banks = 8;
1134
} else if (n_subslices > 2) {
1135
devinfo->l3_banks = 6;
1136
} else {
1137
devinfo->l3_banks = 4;
1138
}
1139
}
1140
1141
uint32_t eu_mask_len =
1142
topology->eu_stride * topology->max_subslices * topology->max_slices;
1143
assert(sizeof(devinfo->eu_masks) >= eu_mask_len);
1144
memcpy(devinfo->eu_masks, &topology->data[topology->eu_offset], eu_mask_len);
1145
1146
uint32_t n_eus = 0;
1147
for (int b = 0; b < eu_mask_len; b++)
1148
n_eus += __builtin_popcount(devinfo->eu_masks[b]);
1149
1150
devinfo->num_eu_per_subslice = DIV_ROUND_UP(n_eus, n_subslices);
1151
}
1152
1153
static bool
1154
update_from_masks(struct intel_device_info *devinfo, uint32_t slice_mask,
1155
uint32_t subslice_mask, uint32_t n_eus)
1156
{
1157
struct drm_i915_query_topology_info *topology;
1158
1159
assert((slice_mask & 0xff) == slice_mask);
1160
1161
size_t data_length = 100;
1162
1163
topology = calloc(1, sizeof(*topology) + data_length);
1164
if (!topology)
1165
return false;
1166
1167
topology->max_slices = util_last_bit(slice_mask);
1168
topology->max_subslices = util_last_bit(subslice_mask);
1169
1170
topology->subslice_offset = DIV_ROUND_UP(topology->max_slices, 8);
1171
topology->subslice_stride = DIV_ROUND_UP(topology->max_subslices, 8);
1172
1173
uint32_t n_subslices = __builtin_popcount(slice_mask) *
1174
__builtin_popcount(subslice_mask);
1175
uint32_t num_eu_per_subslice = DIV_ROUND_UP(n_eus, n_subslices);
1176
uint32_t eu_mask = (1U << num_eu_per_subslice) - 1;
1177
1178
topology->eu_offset = topology->subslice_offset +
1179
DIV_ROUND_UP(topology->max_subslices, 8);
1180
topology->eu_stride = DIV_ROUND_UP(num_eu_per_subslice, 8);
1181
1182
/* Set slice mask in topology */
1183
for (int b = 0; b < topology->subslice_offset; b++)
1184
topology->data[b] = (slice_mask >> (b * 8)) & 0xff;
1185
1186
for (int s = 0; s < topology->max_slices; s++) {
1187
1188
/* Set subslice mask in topology */
1189
for (int b = 0; b < topology->subslice_stride; b++) {
1190
int subslice_offset = topology->subslice_offset +
1191
s * topology->subslice_stride + b;
1192
1193
topology->data[subslice_offset] = (subslice_mask >> (b * 8)) & 0xff;
1194
}
1195
1196
/* Set eu mask in topology */
1197
for (int ss = 0; ss < topology->max_subslices; ss++) {
1198
for (int b = 0; b < topology->eu_stride; b++) {
1199
int eu_offset = topology->eu_offset +
1200
(s * topology->max_subslices + ss) * topology->eu_stride + b;
1201
1202
topology->data[eu_offset] = (eu_mask >> (b * 8)) & 0xff;
1203
}
1204
}
1205
}
1206
1207
update_from_topology(devinfo, topology);
1208
free(topology);
1209
1210
return true;
1211
}
1212
1213
static bool
1214
getparam(int fd, uint32_t param, int *value)
1215
{
1216
int tmp;
1217
1218
struct drm_i915_getparam gp = {
1219
.param = param,
1220
.value = &tmp,
1221
};
1222
1223
int ret = intel_ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
1224
if (ret != 0)
1225
return false;
1226
1227
*value = tmp;
1228
return true;
1229
}
1230
1231
bool
1232
intel_get_device_info_from_pci_id(int pci_id,
1233
struct intel_device_info *devinfo)
1234
{
1235
switch (pci_id) {
1236
#undef CHIPSET
1237
#define CHIPSET(id, family, fam_str, name) \
1238
case id: *devinfo = intel_device_info_##family; break;
1239
#include "pci_ids/i965_pci_ids.h"
1240
#include "pci_ids/iris_pci_ids.h"
1241
1242
#undef CHIPSET
1243
#define CHIPSET(id, fam_str, name) \
1244
case id: *devinfo = intel_device_info_gfx3; break;
1245
#include "pci_ids/i915_pci_ids.h"
1246
1247
default:
1248
mesa_logw("Driver does not support the 0x%x PCI ID.", pci_id);
1249
return false;
1250
}
1251
1252
fill_masks(devinfo);
1253
1254
/* From the Skylake PRM, 3DSTATE_PS::Scratch Space Base Pointer:
1255
*
1256
* "Scratch Space per slice is computed based on 4 sub-slices. SW must
1257
* allocate scratch space enough so that each slice has 4 slices allowed."
1258
*
1259
* The equivalent internal documentation says that this programming note
1260
* applies to all Gfx9+ platforms.
1261
*
1262
* The hardware typically calculates the scratch space pointer by taking
1263
* the base address, and adding per-thread-scratch-space * thread ID.
1264
* Extra padding can be necessary depending how the thread IDs are
1265
* calculated for a particular shader stage.
1266
*/
1267
1268
switch(devinfo->ver) {
1269
case 9:
1270
devinfo->max_wm_threads = 64 /* threads-per-PSD */
1271
* devinfo->num_slices
1272
* 4; /* effective subslices per slice */
1273
break;
1274
case 11:
1275
case 12:
1276
devinfo->max_wm_threads = 128 /* threads-per-PSD */
1277
* devinfo->num_slices
1278
* 8; /* subslices per slice */
1279
break;
1280
default:
1281
assert(devinfo->ver < 9);
1282
break;
1283
}
1284
1285
assert(devinfo->num_slices <= ARRAY_SIZE(devinfo->num_subslices));
1286
1287
if (devinfo->verx10 == 0)
1288
devinfo->verx10 = devinfo->ver * 10;
1289
1290
devinfo->chipset_id = pci_id;
1291
return true;
1292
}
1293
1294
const char *
1295
intel_get_device_name(int devid)
1296
{
1297
switch (devid) {
1298
#undef CHIPSET
1299
#define CHIPSET(id, family, fam_str, name) case id: return name " (" fam_str ")"; break;
1300
#include "pci_ids/i965_pci_ids.h"
1301
#include "pci_ids/iris_pci_ids.h"
1302
default:
1303
return NULL;
1304
}
1305
}
1306
1307
/**
1308
* for gfx8/gfx9, SLICE_MASK/SUBSLICE_MASK can be used to compute the topology
1309
* (kernel 4.13+)
1310
*/
1311
static bool
1312
getparam_topology(struct intel_device_info *devinfo, int fd)
1313
{
1314
int slice_mask = 0;
1315
if (!getparam(fd, I915_PARAM_SLICE_MASK, &slice_mask))
1316
goto maybe_warn;
1317
1318
int n_eus;
1319
if (!getparam(fd, I915_PARAM_EU_TOTAL, &n_eus))
1320
goto maybe_warn;
1321
1322
int subslice_mask = 0;
1323
if (!getparam(fd, I915_PARAM_SUBSLICE_MASK, &subslice_mask))
1324
goto maybe_warn;
1325
1326
return update_from_masks(devinfo, slice_mask, subslice_mask, n_eus);
1327
1328
maybe_warn:
1329
/* Only with Gfx8+ are we starting to see devices with fusing that can only
1330
* be detected at runtime.
1331
*/
1332
if (devinfo->ver >= 8)
1333
mesa_logw("Kernel 4.1 required to properly query GPU properties.");
1334
1335
return false;
1336
}
1337
1338
/**
1339
* preferred API for updating the topology in devinfo (kernel 4.17+)
1340
*/
1341
static bool
1342
query_topology(struct intel_device_info *devinfo, int fd)
1343
{
1344
struct drm_i915_query_item item = {
1345
.query_id = DRM_I915_QUERY_TOPOLOGY_INFO,
1346
};
1347
struct drm_i915_query query = {
1348
.num_items = 1,
1349
.items_ptr = (uintptr_t) &item,
1350
};
1351
1352
if (intel_ioctl(fd, DRM_IOCTL_I915_QUERY, &query))
1353
return false;
1354
1355
if (item.length < 0)
1356
return false;
1357
1358
struct drm_i915_query_topology_info *topo_info =
1359
(struct drm_i915_query_topology_info *) calloc(1, item.length);
1360
item.data_ptr = (uintptr_t) topo_info;
1361
1362
if (intel_ioctl(fd, DRM_IOCTL_I915_QUERY, &query) ||
1363
item.length <= 0)
1364
return false;
1365
1366
update_from_topology(devinfo, topo_info);
1367
1368
free(topo_info);
1369
1370
return true;
1371
1372
}
1373
1374
int
1375
intel_get_aperture_size(int fd, uint64_t *size)
1376
{
1377
struct drm_i915_gem_get_aperture aperture = { 0 };
1378
1379
int ret = intel_ioctl(fd, DRM_IOCTL_I915_GEM_GET_APERTURE, &aperture);
1380
if (ret == 0 && size)
1381
*size = aperture.aper_size;
1382
1383
return ret;
1384
}
1385
1386
static bool
1387
has_get_tiling(int fd)
1388
{
1389
int ret;
1390
1391
struct drm_i915_gem_create gem_create = {
1392
.size = 4096,
1393
};
1394
1395
if (intel_ioctl(fd, DRM_IOCTL_I915_GEM_CREATE, &gem_create)) {
1396
unreachable("Failed to create GEM BO");
1397
return false;
1398
}
1399
1400
struct drm_i915_gem_get_tiling get_tiling = {
1401
.handle = gem_create.handle,
1402
};
1403
ret = intel_ioctl(fd, DRM_IOCTL_I915_GEM_SET_TILING, &get_tiling);
1404
1405
struct drm_gem_close close = {
1406
.handle = gem_create.handle,
1407
};
1408
intel_ioctl(fd, DRM_IOCTL_GEM_CLOSE, &close);
1409
1410
return ret == 0;
1411
}
1412
1413
bool
1414
intel_get_device_info_from_fd(int fd, struct intel_device_info *devinfo)
1415
{
1416
int devid = 0;
1417
1418
const char *devid_override = getenv("INTEL_DEVID_OVERRIDE");
1419
if (devid_override && strlen(devid_override) > 0) {
1420
if (geteuid() == getuid()) {
1421
devid = intel_device_name_to_pci_device_id(devid_override);
1422
/* Fallback to PCI ID. */
1423
if (devid <= 0)
1424
devid = strtol(devid_override, NULL, 0);
1425
if (devid <= 0) {
1426
mesa_loge("Invalid INTEL_DEVID_OVERRIDE=\"%s\". "
1427
"Use a valid numeric PCI ID or one of the supported "
1428
"platform names:", devid_override);
1429
for (unsigned i = 0; i < ARRAY_SIZE(name_map); i++)
1430
mesa_loge(" %s", name_map[i].name);
1431
return false;
1432
}
1433
} else {
1434
mesa_logi("Ignoring INTEL_DEVID_OVERRIDE=\"%s\" because "
1435
"real and effective user ID don't match.", devid_override);
1436
}
1437
}
1438
1439
if (devid > 0) {
1440
if (!intel_get_device_info_from_pci_id(devid, devinfo))
1441
return false;
1442
devinfo->no_hw = true;
1443
} else {
1444
/* query the device id */
1445
if (!getparam(fd, I915_PARAM_CHIPSET_ID, &devid))
1446
return false;
1447
if (!intel_get_device_info_from_pci_id(devid, devinfo))
1448
return false;
1449
devinfo->no_hw = false;
1450
}
1451
1452
if (devinfo->ver == 10) {
1453
mesa_loge("Gfx10 support is redacted.");
1454
return false;
1455
}
1456
1457
/* remaining initializion queries the kernel for device info */
1458
if (devinfo->no_hw)
1459
return true;
1460
1461
int timestamp_frequency;
1462
if (getparam(fd, I915_PARAM_CS_TIMESTAMP_FREQUENCY,
1463
&timestamp_frequency))
1464
devinfo->timestamp_frequency = timestamp_frequency;
1465
else if (devinfo->ver >= 10) {
1466
mesa_loge("Kernel 4.15 required to read the CS timestamp frequency.");
1467
return false;
1468
}
1469
1470
if (!getparam(fd, I915_PARAM_REVISION, &devinfo->revision))
1471
devinfo->revision = 0;
1472
1473
if (!query_topology(devinfo, fd)) {
1474
if (devinfo->ver >= 10) {
1475
/* topology uAPI required for CNL+ (kernel 4.17+) */
1476
return false;
1477
}
1478
1479
/* else use the kernel 4.13+ api for gfx8+. For older kernels, topology
1480
* will be wrong, affecting GPU metrics. In this case, fail silently.
1481
*/
1482
getparam_topology(devinfo, fd);
1483
}
1484
1485
intel_get_aperture_size(fd, &devinfo->aperture_bytes);
1486
devinfo->has_tiling_uapi = has_get_tiling(fd);
1487
1488
return true;
1489
}
1490
1491