summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/i915/i915_oa_hsw.c
blob: 4ddf756add31b82635b0bb2534d8b0d6ccb02e8b (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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
/*
 * Autogenerated file, DO NOT EDIT manually!
 *
 * Copyright (c) 2015 Intel Corporation
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 *
 */

#include <linux/sysfs.h>

#include "i915_drv.h"
#include "i915_oa_hsw.h"

enum metric_set_id {
	METRIC_SET_ID_RENDER_BASIC = 1,
	METRIC_SET_ID_COMPUTE_BASIC,
	METRIC_SET_ID_COMPUTE_EXTENDED,
	METRIC_SET_ID_MEMORY_READS,
	METRIC_SET_ID_MEMORY_WRITES,
	METRIC_SET_ID_SAMPLER_BALANCE,
};

int i915_oa_n_builtin_metric_sets_hsw = 6;

static const struct i915_oa_reg b_counter_config_render_basic[] = {
	{ _MMIO(0x2724), 0x00800000 },
	{ _MMIO(0x2720), 0x00000000 },
	{ _MMIO(0x2714), 0x00800000 },
	{ _MMIO(0x2710), 0x00000000 },
};

static const struct i915_oa_reg mux_config_render_basic[] = {
	{ _MMIO(0x253a4), 0x01600000 },
	{ _MMIO(0x25440), 0x00100000 },
	{ _MMIO(0x25128), 0x00000000 },
	{ _MMIO(0x2691c), 0x00000800 },
	{ _MMIO(0x26aa0), 0x01500000 },
	{ _MMIO(0x26b9c), 0x00006000 },
	{ _MMIO(0x2791c), 0x00000800 },
	{ _MMIO(0x27aa0), 0x01500000 },
	{ _MMIO(0x27b9c), 0x00006000 },
	{ _MMIO(0x2641c), 0x00000400 },
	{ _MMIO(0x25380), 0x00000010 },
	{ _MMIO(0x2538c), 0x00000000 },
	{ _MMIO(0x25384), 0x0800aaaa },
	{ _MMIO(0x25400), 0x00000004 },
	{ _MMIO(0x2540c), 0x06029000 },
	{ _MMIO(0x25410), 0x00000002 },
	{ _MMIO(0x25404), 0x5c30ffff },
	{ _MMIO(0x25100), 0x00000016 },
	{ _MMIO(0x25110), 0x00000400 },
	{ _MMIO(0x25104), 0x00000000 },
	{ _MMIO(0x26804), 0x00001211 },
	{ _MMIO(0x26884), 0x00000100 },
	{ _MMIO(0x26900), 0x00000002 },
	{ _MMIO(0x26908), 0x00700000 },
	{ _MMIO(0x26904), 0x00000000 },
	{ _MMIO(0x26984), 0x00001022 },
	{ _MMIO(0x26a04), 0x00000011 },
	{ _MMIO(0x26a80), 0x00000006 },
	{ _MMIO(0x26a88), 0x00000c02 },
	{ _MMIO(0x26a84), 0x00000000 },
	{ _MMIO(0x26b04), 0x00001000 },
	{ _MMIO(0x26b80), 0x00000002 },
	{ _MMIO(0x26b8c), 0x00000007 },
	{ _MMIO(0x26b84), 0x00000000 },
	{ _MMIO(0x27804), 0x00004844 },
	{ _MMIO(0x27884), 0x00000400 },
	{ _MMIO(0x27900), 0x00000002 },
	{ _MMIO(0x27908), 0x0e000000 },
	{ _MMIO(0x27904), 0x00000000 },
	{ _MMIO(0x27984), 0x00004088 },
	{ _MMIO(0x27a04), 0x00000044 },
	{ _MMIO(0x27a80), 0x00000006 },
	{ _MMIO(0x27a88), 0x00018040 },
	{ _MMIO(0x27a84), 0x00000000 },
	{ _MMIO(0x27b04), 0x00004000 },
	{ _MMIO(0x27b80), 0x00000002 },
	{ _MMIO(0x27b8c), 0x000000e0 },
	{ _MMIO(0x27b84), 0x00000000 },
	{ _MMIO(0x26104), 0x00002222 },
	{ _MMIO(0x26184), 0x0c006666 },
	{ _MMIO(0x26284), 0x04000000 },
	{ _MMIO(0x26304), 0x04000000 },
	{ _MMIO(0x26400), 0x00000002 },
	{ _MMIO(0x26410), 0x000000a0 },
	{ _MMIO(0x26404), 0x00000000 },
	{ _MMIO(0x25420), 0x04108020 },
	{ _MMIO(0x25424), 0x1284a420 },
	{ _MMIO(0x2541c), 0x00000000 },
	{ _MMIO(0x25428), 0x00042049 },
};

static const struct i915_oa_reg *
get_render_basic_mux_config(struct drm_i915_private *dev_priv,
			    int *len)
{
	*len = ARRAY_SIZE(mux_config_render_basic);
	return mux_config_render_basic;
}

static const struct i915_oa_reg b_counter_config_compute_basic[] = {
	{ _MMIO(0x2710), 0x00000000 },
	{ _MMIO(0x2714), 0x00800000 },
	{ _MMIO(0x2718), 0xaaaaaaaa },
	{ _MMIO(0x271c), 0xaaaaaaaa },
	{ _MMIO(0x2720), 0x00000000 },
	{ _MMIO(0x2724), 0x00800000 },
	{ _MMIO(0x2728), 0xaaaaaaaa },
	{ _MMIO(0x272c), 0xaaaaaaaa },
	{ _MMIO(0x2740), 0x00000000 },
	{ _MMIO(0x2744), 0x00000000 },
	{ _MMIO(0x2748), 0x00000000 },
	{ _MMIO(0x274c), 0x00000000 },
	{ _MMIO(0x2750), 0x00000000 },
	{ _MMIO(0x2754), 0x00000000 },
	{ _MMIO(0x2758), 0x00000000 },
	{ _MMIO(0x275c), 0x00000000 },
	{ _MMIO(0x236c), 0x00000000 },
};

static const struct i915_oa_reg mux_config_compute_basic[] = {
	{ _MMIO(0x253a4), 0x00000000 },
	{ _MMIO(0x2681c), 0x01f00800 },
	{ _MMIO(0x26820), 0x00001000 },
	{ _MMIO(0x2781c), 0x01f00800 },
	{ _MMIO(0x26520), 0x00000007 },
	{ _MMIO(0x265a0), 0x00000007 },
	{ _MMIO(0x25380), 0x00000010 },
	{ _MMIO(0x2538c), 0x00300000 },
	{ _MMIO(0x25384), 0xaa8aaaaa },
	{ _MMIO(0x25404), 0xffffffff },
	{ _MMIO(0x26800), 0x00004202 },
	{ _MMIO(0x26808), 0x00605817 },
	{ _MMIO(0x2680c), 0x10001005 },
	{ _MMIO(0x26804), 0x00000000 },
	{ _MMIO(0x27800), 0x00000102 },
	{ _MMIO(0x27808), 0x0c0701e0 },
	{ _MMIO(0x2780c), 0x000200a0 },
	{ _MMIO(0x27804), 0x00000000 },
	{ _MMIO(0x26484), 0x44000000 },
	{ _MMIO(0x26704), 0x44000000 },
	{ _MMIO(0x26500), 0x00000006 },
	{ _MMIO(0x26510), 0x00000001 },
	{ _MMIO(0x26504), 0x88000000 },
	{ _MMIO(0x26580), 0x00000006 },
	{ _MMIO(0x26590), 0x00000020 },
	{ _MMIO(0x26584), 0x00000000 },
	{ _MMIO(0x26104), 0x55822222 },
	{ _MMIO(0x26184), 0xaa866666 },
	{ _MMIO(0x25420), 0x08320c83 },
	{ _MMIO(0x25424), 0x06820c83 },
	{ _MMIO(0x2541c), 0x00000000 },
	{ _MMIO(0x25428), 0x00000c03 },
};

static const struct i915_oa_reg *
get_compute_basic_mux_config(struct drm_i915_private *dev_priv,
			     int *len)
{
	*len = ARRAY_SIZE(mux_config_compute_basic);
	return mux_config_compute_basic;
}

static const struct i915_oa_reg b_counter_config_compute_extended[] = {
	{ _MMIO(0x2724), 0xf0800000 },
	{ _MMIO(0x2720), 0x00000000 },
	{ _MMIO(0x2714), 0xf0800000 },
	{ _MMIO(0x2710), 0x00000000 },
	{ _MMIO(0x2770), 0x0007fe2a },
	{ _MMIO(0x2774), 0x0000ff00 },
	{ _MMIO(0x2778), 0x0007fe6a },
	{ _MMIO(0x277c), 0x0000ff00 },
	{ _MMIO(0x2780), 0x0007fe92 },
	{ _MMIO(0x2784), 0x0000ff00 },
	{ _MMIO(0x2788), 0x0007fea2 },
	{ _MMIO(0x278c), 0x0000ff00 },
	{ _MMIO(0x2790), 0x0007fe32 },
	{ _MMIO(0x2794), 0x0000ff00 },
	{ _MMIO(0x2798), 0x0007fe9a },
	{ _MMIO(0x279c), 0x0000ff00 },
	{ _MMIO(0x27a0), 0x0007ff23 },
	{ _MMIO(0x27a4), 0x0000ff00 },
	{ _MMIO(0x27a8), 0x0007fff3 },
	{ _MMIO(0x27ac), 0x0000fffe },
};

static const struct i915_oa_reg mux_config_compute_extended[] = {
	{ _MMIO(0x2681c), 0x3eb00800 },
	{ _MMIO(0x26820), 0x00900000 },
	{ _MMIO(0x25384), 0x02aaaaaa },
	{ _MMIO(0x25404), 0x03ffffff },
	{ _MMIO(0x26800), 0x00142284 },
	{ _MMIO(0x26808), 0x0e629062 },
	{ _MMIO(0x2680c), 0x3f6f55cb },
	{ _MMIO(0x26810), 0x00000014 },
	{ _MMIO(0x26804), 0x00000000 },
	{ _MMIO(0x26104), 0x02aaaaaa },
	{ _MMIO(0x26184), 0x02aaaaaa },
	{ _MMIO(0x25420), 0x00000000 },
	{ _MMIO(0x25424), 0x00000000 },
	{ _MMIO(0x2541c), 0x00000000 },
	{ _MMIO(0x25428), 0x00000000 },
};

static const struct i915_oa_reg *
get_compute_extended_mux_config(struct drm_i915_private *dev_priv,
				int *len)
{
	*len = ARRAY_SIZE(mux_config_compute_extended);
	return mux_config_compute_extended;
}

static const struct i915_oa_reg b_counter_config_memory_reads[] = {
	{ _MMIO(0x2724), 0xf0800000 },
	{ _MMIO(0x2720), 0x00000000 },
	{ _MMIO(0x2714), 0xf0800000 },
	{ _MMIO(0x2710), 0x00000000 },
	{ _MMIO(0x274c), 0x76543298 },
	{ _MMIO(0x2748), 0x98989898 },
	{ _MMIO(0x2744), 0x000000e4 },
	{ _MMIO(0x2740), 0x00000000 },
	{ _MMIO(0x275c), 0x98a98a98 },
	{ _MMIO(0x2758), 0x88888888 },
	{ _MMIO(0x2754), 0x000c5500 },
	{ _MMIO(0x2750), 0x00000000 },
	{ _MMIO(0x2770), 0x0007f81a },
	{ _MMIO(0x2774), 0x0000fc00 },
	{ _MMIO(0x2778), 0x0007f82a },
	{ _MMIO(0x277c), 0x0000fc00 },
	{ _MMIO(0x2780), 0x0007f872 },
	{ _MMIO(0x2784), 0x0000fc00 },
	{ _MMIO(0x2788), 0x0007f8ba },
	{ _MMIO(0x278c), 0x0000fc00 },
	{ _MMIO(0x2790), 0x0007f87a },
	{ _MMIO(0x2794), 0x0000fc00 },
	{ _MMIO(0x2798), 0x0007f8ea },
	{ _MMIO(0x279c), 0x0000fc00 },
	{ _MMIO(0x27a0), 0x0007f8e2 },
	{ _MMIO(0x27a4), 0x0000fc00 },
	{ _MMIO(0x27a8), 0x0007f8f2 },
	{ _MMIO(0x27ac), 0x0000fc00 },
};

static const struct i915_oa_reg mux_config_memory_reads[] = {
	{ _MMIO(0x253a4), 0x34300000 },
	{ _MMIO(0x25440), 0x2d800000 },
	{ _MMIO(0x25444), 0x00000008 },
	{ _MMIO(0x25128), 0x0e600000 },
	{ _MMIO(0x25380), 0x00000450 },
	{ _MMIO(0x25390), 0x00052c43 },
	{ _MMIO(0x25384), 0x00000000 },
	{ _MMIO(0x25400), 0x00006144 },
	{ _MMIO(0x25408), 0x0a418820 },
	{ _MMIO(0x2540c), 0x000820e6 },
	{ _MMIO(0x25404), 0xff500000 },
	{ _MMIO(0x25100), 0x000005d6 },
	{ _MMIO(0x2510c), 0x0ef00000 },
	{ _MMIO(0x25104), 0x00000000 },
	{ _MMIO(0x25420), 0x02108421 },
	{ _MMIO(0x25424), 0x00008421 },
	{ _MMIO(0x2541c), 0x00000000 },
	{ _MMIO(0x25428), 0x00000000 },
};

static const struct i915_oa_reg *
get_memory_reads_mux_config(struct drm_i915_private *dev_priv,
			    int *len)
{
	*len = ARRAY_SIZE(mux_config_memory_reads);
	return mux_config_memory_reads;
}

static const struct i915_oa_reg b_counter_config_memory_writes[] = {
	{ _MMIO(0x2724), 0xf0800000 },
	{ _MMIO(0x2720), 0x00000000 },
	{ _MMIO(0x2714), 0xf0800000 },
	{ _MMIO(0x2710), 0x00000000 },
	{ _MMIO(0x274c), 0x76543298 },
	{ _MMIO(0x2748), 0x98989898 },
	{ _MMIO(0x2744), 0x000000e4 },
	{ _MMIO(0x2740), 0x00000000 },
	{ _MMIO(0x275c), 0xbabababa },
	{ _MMIO(0x2758), 0x88888888 },
	{ _MMIO(0x2754), 0x000c5500 },
	{ _MMIO(0x2750), 0x00000000 },
	{ _MMIO(0x2770), 0x0007f81a },
	{ _MMIO(0x2774), 0x0000fc00 },
	{ _MMIO(0x2778), 0x0007f82a },
	{ _MMIO(0x277c), 0x0000fc00 },
	{ _MMIO(0x2780), 0x0007f822 },
	{ _MMIO(0x2784), 0x0000fc00 },
	{ _MMIO(0x2788), 0x0007f8ba },
	{ _MMIO(0x278c), 0x0000fc00 },
	{ _MMIO(0x2790), 0x0007f87a },
	{ _MMIO(0x2794), 0x0000fc00 },
	{ _MMIO(0x2798), 0x0007f8ea },
	{ _MMIO(0x279c), 0x0000fc00 },
	{ _MMIO(0x27a0), 0x0007f8e2 },
	{ _MMIO(0x27a4), 0x0000fc00 },
	{ _MMIO(0x27a8), 0x0007f8f2 },
	{ _MMIO(0x27ac), 0x0000fc00 },
};

static const struct i915_oa_reg mux_config_memory_writes[] = {
	{ _MMIO(0x253a4), 0x34300000 },
	{ _MMIO(0x25440), 0x01500000 },
	{ _MMIO(0x25444), 0x00000120 },
	{ _MMIO(0x25128), 0x0c200000 },
	{ _MMIO(0x25380), 0x00000450 },
	{ _MMIO(0x25390), 0x00052c43 },
	{ _MMIO(0x25384), 0x00000000 },
	{ _MMIO(0x25400), 0x00007184 },
	{ _MMIO(0x25408), 0x0a418820 },
	{ _MMIO(0x2540c), 0x000820e6 },
	{ _MMIO(0x25404), 0xff500000 },
	{ _MMIO(0x25100), 0x000005d6 },
	{ _MMIO(0x2510c), 0x1e700000 },
	{ _MMIO(0x25104), 0x00000000 },
	{ _MMIO(0x25420), 0x02108421 },
	{ _MMIO(0x25424), 0x00008421 },
	{ _MMIO(0x2541c), 0x00000000 },
	{ _MMIO(0x25428), 0x00000000 },
};

static const struct i915_oa_reg *
get_memory_writes_mux_config(struct drm_i915_private *dev_priv,
			     int *len)
{
	*len = ARRAY_SIZE(mux_config_memory_writes);
	return mux_config_memory_writes;
}

static const struct i915_oa_reg b_counter_config_sampler_balance[] = {
	{ _MMIO(0x2740), 0x00000000 },
	{ _MMIO(0x2744), 0x00800000 },
	{ _MMIO(0x2710), 0x00000000 },
	{ _MMIO(0x2714), 0x00800000 },
	{ _MMIO(0x2720), 0x00000000 },
	{ _MMIO(0x2724), 0x00800000 },
};

static const struct i915_oa_reg mux_config_sampler_balance[] = {
	{ _MMIO(0x2eb9c), 0x01906400 },
	{ _MMIO(0x2fb9c), 0x01906400 },
	{ _MMIO(0x253a4), 0x00000000 },
	{ _MMIO(0x26b9c), 0x01906400 },
	{ _MMIO(0x27b9c), 0x01906400 },
	{ _MMIO(0x27104), 0x00a00000 },
	{ _MMIO(0x27184), 0x00a50000 },
	{ _MMIO(0x2e804), 0x00500000 },
	{ _MMIO(0x2e984), 0x00500000 },
	{ _MMIO(0x2eb04), 0x00500000 },
	{ _MMIO(0x2eb80), 0x00000084 },
	{ _MMIO(0x2eb8c), 0x14200000 },
	{ _MMIO(0x2eb84), 0x00000000 },
	{ _MMIO(0x2f804), 0x00050000 },
	{ _MMIO(0x2f984), 0x00050000 },
	{ _MMIO(0x2fb04), 0x00050000 },
	{ _MMIO(0x2fb80), 0x00000084 },
	{ _MMIO(0x2fb8c), 0x00050800 },
	{ _MMIO(0x2fb84), 0x00000000 },
	{ _MMIO(0x25380), 0x00000010 },
	{ _MMIO(0x2538c), 0x000000c0 },
	{ _MMIO(0x25384), 0xaa550000 },
	{ _MMIO(0x25404), 0xffffc000 },
	{ _MMIO(0x26804), 0x50000000 },
	{ _MMIO(0x26984), 0x50000000 },
	{ _MMIO(0x26b04), 0x50000000 },
	{ _MMIO(0x26b80), 0x00000084 },
	{ _MMIO(0x26b90), 0x00050800 },
	{ _MMIO(0x26b84), 0x00000000 },
	{ _MMIO(0x27804), 0x05000000 },
	{ _MMIO(0x27984), 0x05000000 },
	{ _MMIO(0x27b04), 0x05000000 },
	{ _MMIO(0x27b80), 0x00000084 },
	{ _MMIO(0x27b90), 0x00000142 },
	{ _MMIO(0x27b84), 0x00000000 },
	{ _MMIO(0x26104), 0xa0000000 },
	{ _MMIO(0x26184), 0xa5000000 },
	{ _MMIO(0x25424), 0x00008620 },
	{ _MMIO(0x2541c), 0x00000000 },
	{ _MMIO(0x25428), 0x0004a54a },
};

static const struct i915_oa_reg *
get_sampler_balance_mux_config(struct drm_i915_private *dev_priv,
			       int *len)
{
	*len = ARRAY_SIZE(mux_config_sampler_balance);
	return mux_config_sampler_balance;
}

int i915_oa_select_metric_set_hsw(struct drm_i915_private *dev_priv)
{
	dev_priv->perf.oa.mux_regs = NULL;
	dev_priv->perf.oa.mux_regs_len = 0;
	dev_priv->perf.oa.b_counter_regs = NULL;
	dev_priv->perf.oa.b_counter_regs_len = 0;

	switch (dev_priv->perf.oa.metrics_set) {
	case METRIC_SET_ID_RENDER_BASIC:
		dev_priv->perf.oa.mux_regs =
			get_render_basic_mux_config(dev_priv,
						    &dev_priv->perf.oa.mux_regs_len);
		if (!dev_priv->perf.oa.mux_regs) {
			DRM_DEBUG_DRIVER("No suitable MUX config for \"RENDER_BASIC\" metric set");

			/* EINVAL because *_register_sysfs already checked this
			 * and so it wouldn't have been advertised so userspace and
			 * so shouldn't have been requested
			 */
			return -EINVAL;
		}

		dev_priv->perf.oa.b_counter_regs =
			b_counter_config_render_basic;
		dev_priv->perf.oa.b_counter_regs_len =
			ARRAY_SIZE(b_counter_config_render_basic);

		return 0;
	case METRIC_SET_ID_COMPUTE_BASIC:
		dev_priv->perf.oa.mux_regs =
			get_compute_basic_mux_config(dev_priv,
						     &dev_priv->perf.oa.mux_regs_len);
		if (!dev_priv->perf.oa.mux_regs) {
			DRM_DEBUG_DRIVER("No suitable MUX config for \"COMPUTE_BASIC\" metric set");

			/* EINVAL because *_register_sysfs already checked this
			 * and so it wouldn't have been advertised so userspace and
			 * so shouldn't have been requested
			 */
			return -EINVAL;
		}

		dev_priv->perf.oa.b_counter_regs =
			b_counter_config_compute_basic;
		dev_priv->perf.oa.b_counter_regs_len =
			ARRAY_SIZE(b_counter_config_compute_basic);

		return 0;
	case METRIC_SET_ID_COMPUTE_EXTENDED:
		dev_priv->perf.oa.mux_regs =
			get_compute_extended_mux_config(dev_priv,
							&dev_priv->perf.oa.mux_regs_len);
		if (!dev_priv->perf.oa.mux_regs) {
			DRM_DEBUG_DRIVER("No suitable MUX config for \"COMPUTE_EXTENDED\" metric set");

			/* EINVAL because *_register_sysfs already checked this
			 * and so it wouldn't have been advertised so userspace and
			 * so shouldn't have been requested
			 */
			return -EINVAL;
		}

		dev_priv->perf.oa.b_counter_regs =
			b_counter_config_compute_extended;
		dev_priv->perf.oa.b_counter_regs_len =
			ARRAY_SIZE(b_counter_config_compute_extended);

		return 0;
	case METRIC_SET_ID_MEMORY_READS:
		dev_priv->perf.oa.mux_regs =
			get_memory_reads_mux_config(dev_priv,
						    &dev_priv->perf.oa.mux_regs_len);
		if (!dev_priv->perf.oa.mux_regs) {
			DRM_DEBUG_DRIVER("No suitable MUX config for \"MEMORY_READS\" metric set");

			/* EINVAL because *_register_sysfs already checked this
			 * and so it wouldn't have been advertised so userspace and
			 * so shouldn't have been requested
			 */
			return -EINVAL;
		}

		dev_priv->perf.oa.b_counter_regs =
			b_counter_config_memory_reads;
		dev_priv->perf.oa.b_counter_regs_len =
			ARRAY_SIZE(b_counter_config_memory_reads);

		return 0;
	case METRIC_SET_ID_MEMORY_WRITES:
		dev_priv->perf.oa.mux_regs =
			get_memory_writes_mux_config(dev_priv,
						     &dev_priv->perf.oa.mux_regs_len);
		if (!dev_priv->perf.oa.mux_regs) {
			DRM_DEBUG_DRIVER("No suitable MUX config for \"MEMORY_WRITES\" metric set");

			/* EINVAL because *_register_sysfs already checked this
			 * and so it wouldn't have been advertised so userspace and
			 * so shouldn't have been requested
			 */
			return -EINVAL;
		}

		dev_priv->perf.oa.b_counter_regs =
			b_counter_config_memory_writes;
		dev_priv->perf.oa.b_counter_regs_len =
			ARRAY_SIZE(b_counter_config_memory_writes);

		return 0;
	case METRIC_SET_ID_SAMPLER_BALANCE:
		dev_priv->perf.oa.mux_regs =
			get_sampler_balance_mux_config(dev_priv,
						       &dev_priv->perf.oa.mux_regs_len);
		if (!dev_priv->perf.oa.mux_regs) {
			DRM_DEBUG_DRIVER("No suitable MUX config for \"SAMPLER_BALANCE\" metric set");

			/* EINVAL because *_register_sysfs already checked this
			 * and so it wouldn't have been advertised so userspace and
			 * so shouldn't have been requested
			 */
			return -EINVAL;
		}

		dev_priv->perf.oa.b_counter_regs =
			b_counter_config_sampler_balance;
		dev_priv->perf.oa.b_counter_regs_len =
			ARRAY_SIZE(b_counter_config_sampler_balance);

		return 0;
	default:
		return -ENODEV;
	}
}

static ssize_t
show_render_basic_id(struct device *kdev, struct device_attribute *attr, char *buf)
{
	return sprintf(buf, "%d\n", METRIC_SET_ID_RENDER_BASIC);
}

static struct device_attribute dev_attr_render_basic_id = {
	.attr = { .name = "id", .mode = 0444 },
	.show = show_render_basic_id,
	.store = NULL,
};

static struct attribute *attrs_render_basic[] = {
	&dev_attr_render_basic_id.attr,
	NULL,
};

static struct attribute_group group_render_basic = {
	.name = "403d8832-1a27-4aa6-a64e-f5389ce7b212",
	.attrs =  attrs_render_basic,
};

static ssize_t
show_compute_basic_id(struct device *kdev, struct device_attribute *attr, char *buf)
{
	return sprintf(buf, "%d\n", METRIC_SET_ID_COMPUTE_BASIC);
}

static struct device_attribute dev_attr_compute_basic_id = {
	.attr = { .name = "id", .mode = 0444 },
	.show = show_compute_basic_id,
	.store = NULL,
};

static struct attribute *attrs_compute_basic[] = {
	&dev_attr_compute_basic_id.attr,
	NULL,
};

static struct attribute_group group_compute_basic = {
	.name = "39ad14bc-2380-45c4-91eb-fbcb3aa7ae7b",
	.attrs =  attrs_compute_basic,
};

static ssize_t
show_compute_extended_id(struct device *kdev, struct device_attribute *attr, char *buf)
{
	return sprintf(buf, "%d\n", METRIC_SET_ID_COMPUTE_EXTENDED);
}

static struct device_attribute dev_attr_compute_extended_id = {
	.attr = { .name = "id", .mode = 0444 },
	.show = show_compute_extended_id,
	.store = NULL,
};

static struct attribute *attrs_compute_extended[] = {
	&dev_attr_compute_extended_id.attr,
	NULL,
};

static struct attribute_group group_compute_extended = {
	.name = "3865be28-6982-49fe-9494-e4d1b4795413",
	.attrs =  attrs_compute_extended,
};

static ssize_t
show_memory_reads_id(struct device *kdev, struct device_attribute *attr, char *buf)
{
	return sprintf(buf, "%d\n", METRIC_SET_ID_MEMORY_READS);
}

static struct device_attribute dev_attr_memory_reads_id = {
	.attr = { .name = "id", .mode = 0444 },
	.show = show_memory_reads_id,
	.store = NULL,
};

static struct attribute *attrs_memory_reads[] = {
	&dev_attr_memory_reads_id.attr,
	NULL,
};

static struct attribute_group group_memory_reads = {
	.name = "bb5ed49b-2497-4095-94f6-26ba294db88a",
	.attrs =  attrs_memory_reads,
};

static ssize_t
show_memory_writes_id(struct device *kdev, struct device_attribute *attr, char *buf)
{
	return sprintf(buf, "%d\n", METRIC_SET_ID_MEMORY_WRITES);
}

static struct device_attribute dev_attr_memory_writes_id = {
	.attr = { .name = "id", .mode = 0444 },
	.show = show_memory_writes_id,
	.store = NULL,
};

static struct attribute *attrs_memory_writes[] = {
	&dev_attr_memory_writes_id.attr,
	NULL,
};

static struct attribute_group group_memory_writes = {
	.name = "3358d639-9b5f-45ab-976d-9b08cbfc6240",
	.attrs =  attrs_memory_writes,
};

static ssize_t
show_sampler_balance_id(struct device *kdev, struct device_attribute *attr, char *buf)
{
	return sprintf(buf, "%d\n", METRIC_SET_ID_SAMPLER_BALANCE);
}

static struct device_attribute dev_attr_sampler_balance_id = {
	.attr = { .name = "id", .mode = 0444 },
	.show = show_sampler_balance_id,
	.store = NULL,
};

static struct attribute *attrs_sampler_balance[] = {
	&dev_attr_sampler_balance_id.attr,
	NULL,
};

static struct attribute_group group_sampler_balance = {
	.name = "bc274488-b4b6-40c7-90da-b77d7ad16189",
	.attrs =  attrs_sampler_balance,
};

int
i915_perf_register_sysfs_hsw(struct drm_i915_private *dev_priv)
{
	int mux_len;
	int ret = 0;

	if (get_render_basic_mux_config(dev_priv, &mux_len)) {
		ret = sysfs_create_group(dev_priv->perf.metrics_kobj, &group_render_basic);
		if (ret)
			goto error_render_basic;
	}
	if (get_compute_basic_mux_config(dev_priv, &mux_len)) {
		ret = sysfs_create_group(dev_priv->perf.metrics_kobj, &group_compute_basic);
		if (ret)
			goto error_compute_basic;
	}
	if (get_compute_extended_mux_config(dev_priv, &mux_len)) {
		ret = sysfs_create_group(dev_priv->perf.metrics_kobj, &group_compute_extended);
		if (ret)
			goto error_compute_extended;
	}
	if (get_memory_reads_mux_config(dev_priv, &mux_len)) {
		ret = sysfs_create_group(dev_priv->perf.metrics_kobj, &group_memory_reads);
		if (ret)
			goto error_memory_reads;
	}
	if (get_memory_writes_mux_config(dev_priv, &mux_len)) {
		ret = sysfs_create_group(dev_priv->perf.metrics_kobj, &group_memory_writes);
		if (ret)
			goto error_memory_writes;
	}
	if (get_sampler_balance_mux_config(dev_priv, &mux_len)) {
		ret = sysfs_create_group(dev_priv->perf.metrics_kobj, &group_sampler_balance);
		if (ret)
			goto error_sampler_balance;
	}

	return 0;

error_sampler_balance:
	if (get_sampler_balance_mux_config(dev_priv, &mux_len))
		sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_memory_writes);
error_memory_writes:
	if (get_sampler_balance_mux_config(dev_priv, &mux_len))
		sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_memory_reads);
error_memory_reads:
	if (get_sampler_balance_mux_config(dev_priv, &mux_len))
		sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_compute_extended);
error_compute_extended:
	if (get_sampler_balance_mux_config(dev_priv, &mux_len))
		sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_compute_basic);
error_compute_basic:
	if (get_sampler_balance_mux_config(dev_priv, &mux_len))
		sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_render_basic);
error_render_basic:
	return ret;
}

void
i915_perf_unregister_sysfs_hsw(struct drm_i915_private *dev_priv)
{
	int mux_len;

	if (get_render_basic_mux_config(dev_priv, &mux_len))
		sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_render_basic);
	if (get_compute_basic_mux_config(dev_priv, &mux_len))
		sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_compute_basic);
	if (get_compute_extended_mux_config(dev_priv, &mux_len))
		sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_compute_extended);
	if (get_memory_reads_mux_config(dev_priv, &mux_len))
		sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_memory_reads);
	if (get_memory_writes_mux_config(dev_priv, &mux_len))
		sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_memory_writes);
	if (get_sampler_balance_mux_config(dev_priv, &mux_len))
		sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_sampler_balance);
}