Merge tag 'hisi-fixes-for-4.14' of git://github.com/hisilicon/linux-hisi into next...
[sfrench/cifs-2.6.git] / drivers / gpu / drm / i915 / i915_oa_kblgt3.c
1 /*
2  * Autogenerated file by GPU Top : https://github.com/rib/gputop
3  * DO NOT EDIT manually!
4  *
5  *
6  * Copyright (c) 2015 Intel Corporation
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a
9  * copy of this software and associated documentation files (the "Software"),
10  * to deal in the Software without restriction, including without limitation
11  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12  * and/or sell copies of the Software, and to permit persons to whom the
13  * Software is furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice (including the next
16  * paragraph) shall be included in all copies or substantial portions of the
17  * Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
22  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25  * IN THE SOFTWARE.
26  *
27  */
28
29 #include <linux/sysfs.h>
30
31 #include "i915_drv.h"
32 #include "i915_oa_kblgt3.h"
33
34 enum metric_set_id {
35         METRIC_SET_ID_RENDER_BASIC = 1,
36         METRIC_SET_ID_COMPUTE_BASIC,
37         METRIC_SET_ID_RENDER_PIPE_PROFILE,
38         METRIC_SET_ID_MEMORY_READS,
39         METRIC_SET_ID_MEMORY_WRITES,
40         METRIC_SET_ID_COMPUTE_EXTENDED,
41         METRIC_SET_ID_COMPUTE_L3_CACHE,
42         METRIC_SET_ID_HDC_AND_SF,
43         METRIC_SET_ID_L3_1,
44         METRIC_SET_ID_L3_2,
45         METRIC_SET_ID_L3_3,
46         METRIC_SET_ID_RASTERIZER_AND_PIXEL_BACKEND,
47         METRIC_SET_ID_SAMPLER,
48         METRIC_SET_ID_TDL_1,
49         METRIC_SET_ID_TDL_2,
50         METRIC_SET_ID_COMPUTE_EXTRA,
51         METRIC_SET_ID_VME_PIPE,
52         METRIC_SET_ID_TEST_OA,
53 };
54
55 int i915_oa_n_builtin_metric_sets_kblgt3 = 18;
56
57 static const struct i915_oa_reg b_counter_config_render_basic[] = {
58         { _MMIO(0x2710), 0x00000000 },
59         { _MMIO(0x2714), 0x00800000 },
60         { _MMIO(0x2720), 0x00000000 },
61         { _MMIO(0x2724), 0x00800000 },
62         { _MMIO(0x2740), 0x00000000 },
63 };
64
65 static const struct i915_oa_reg flex_eu_config_render_basic[] = {
66         { _MMIO(0xe458), 0x00005004 },
67         { _MMIO(0xe558), 0x00010003 },
68         { _MMIO(0xe658), 0x00012011 },
69         { _MMIO(0xe758), 0x00015014 },
70         { _MMIO(0xe45c), 0x00051050 },
71         { _MMIO(0xe55c), 0x00053052 },
72         { _MMIO(0xe65c), 0x00055054 },
73 };
74
75 static const struct i915_oa_reg mux_config_render_basic[] = {
76         { _MMIO(0x9888), 0x166c01e0 },
77         { _MMIO(0x9888), 0x12170280 },
78         { _MMIO(0x9888), 0x12370280 },
79         { _MMIO(0x9888), 0x16ec01e0 },
80         { _MMIO(0x9888), 0x11930317 },
81         { _MMIO(0x9888), 0x159303df },
82         { _MMIO(0x9888), 0x3f900003 },
83         { _MMIO(0x9888), 0x1a4e0380 },
84         { _MMIO(0x9888), 0x0a6c0053 },
85         { _MMIO(0x9888), 0x106c0000 },
86         { _MMIO(0x9888), 0x1c6c0000 },
87         { _MMIO(0x9888), 0x0a1b4000 },
88         { _MMIO(0x9888), 0x1c1c0001 },
89         { _MMIO(0x9888), 0x002f1000 },
90         { _MMIO(0x9888), 0x042f1000 },
91         { _MMIO(0x9888), 0x004c4000 },
92         { _MMIO(0x9888), 0x0a4c8400 },
93         { _MMIO(0x9888), 0x0c4c0002 },
94         { _MMIO(0x9888), 0x000d2000 },
95         { _MMIO(0x9888), 0x060d8000 },
96         { _MMIO(0x9888), 0x080da000 },
97         { _MMIO(0x9888), 0x0a0da000 },
98         { _MMIO(0x9888), 0x0c0f0400 },
99         { _MMIO(0x9888), 0x0e0f6600 },
100         { _MMIO(0x9888), 0x100f0001 },
101         { _MMIO(0x9888), 0x002c8000 },
102         { _MMIO(0x9888), 0x162ca200 },
103         { _MMIO(0x9888), 0x062d8000 },
104         { _MMIO(0x9888), 0x082d8000 },
105         { _MMIO(0x9888), 0x00133000 },
106         { _MMIO(0x9888), 0x08133000 },
107         { _MMIO(0x9888), 0x00170020 },
108         { _MMIO(0x9888), 0x08170021 },
109         { _MMIO(0x9888), 0x10170000 },
110         { _MMIO(0x9888), 0x0633c000 },
111         { _MMIO(0x9888), 0x0833c000 },
112         { _MMIO(0x9888), 0x06370800 },
113         { _MMIO(0x9888), 0x08370840 },
114         { _MMIO(0x9888), 0x10370000 },
115         { _MMIO(0x9888), 0x1ace0200 },
116         { _MMIO(0x9888), 0x0aec5300 },
117         { _MMIO(0x9888), 0x10ec0000 },
118         { _MMIO(0x9888), 0x1cec0000 },
119         { _MMIO(0x9888), 0x0a9b8000 },
120         { _MMIO(0x9888), 0x1c9c0002 },
121         { _MMIO(0x9888), 0x0ccc0002 },
122         { _MMIO(0x9888), 0x0a8d8000 },
123         { _MMIO(0x9888), 0x108f0001 },
124         { _MMIO(0x9888), 0x16ac8000 },
125         { _MMIO(0x9888), 0x0d933031 },
126         { _MMIO(0x9888), 0x0f933e3f },
127         { _MMIO(0x9888), 0x01933d00 },
128         { _MMIO(0x9888), 0x0393073c },
129         { _MMIO(0x9888), 0x0593000e },
130         { _MMIO(0x9888), 0x1d930000 },
131         { _MMIO(0x9888), 0x19930000 },
132         { _MMIO(0x9888), 0x1b930000 },
133         { _MMIO(0x9888), 0x1d900157 },
134         { _MMIO(0x9888), 0x1f900158 },
135         { _MMIO(0x9888), 0x35900000 },
136         { _MMIO(0x9888), 0x2b908000 },
137         { _MMIO(0x9888), 0x2d908000 },
138         { _MMIO(0x9888), 0x2f908000 },
139         { _MMIO(0x9888), 0x31908000 },
140         { _MMIO(0x9888), 0x15908000 },
141         { _MMIO(0x9888), 0x17908000 },
142         { _MMIO(0x9888), 0x19908000 },
143         { _MMIO(0x9888), 0x1b908000 },
144         { _MMIO(0x9888), 0x1190003f },
145         { _MMIO(0x9888), 0x51902240 },
146         { _MMIO(0x9888), 0x41900c00 },
147         { _MMIO(0x9888), 0x55900242 },
148         { _MMIO(0x9888), 0x45900084 },
149         { _MMIO(0x9888), 0x47901400 },
150         { _MMIO(0x9888), 0x57902220 },
151         { _MMIO(0x9888), 0x49900c60 },
152         { _MMIO(0x9888), 0x37900000 },
153         { _MMIO(0x9888), 0x33900000 },
154         { _MMIO(0x9888), 0x4b900063 },
155         { _MMIO(0x9888), 0x59900002 },
156         { _MMIO(0x9888), 0x43900c63 },
157         { _MMIO(0x9888), 0x53902222 },
158 };
159
160 static int
161 get_render_basic_mux_config(struct drm_i915_private *dev_priv,
162                             const struct i915_oa_reg **regs,
163                             int *lens)
164 {
165         int n = 0;
166
167         BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs) < 1);
168         BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs_lens) < 1);
169
170         regs[n] = mux_config_render_basic;
171         lens[n] = ARRAY_SIZE(mux_config_render_basic);
172         n++;
173
174         return n;
175 }
176
177 static const struct i915_oa_reg b_counter_config_compute_basic[] = {
178         { _MMIO(0x2710), 0x00000000 },
179         { _MMIO(0x2714), 0x00800000 },
180         { _MMIO(0x2720), 0x00000000 },
181         { _MMIO(0x2724), 0x00800000 },
182         { _MMIO(0x2740), 0x00000000 },
183 };
184
185 static const struct i915_oa_reg flex_eu_config_compute_basic[] = {
186         { _MMIO(0xe458), 0x00005004 },
187         { _MMIO(0xe558), 0x00000003 },
188         { _MMIO(0xe658), 0x00002001 },
189         { _MMIO(0xe758), 0x00778008 },
190         { _MMIO(0xe45c), 0x00088078 },
191         { _MMIO(0xe55c), 0x00808708 },
192         { _MMIO(0xe65c), 0x00a08908 },
193 };
194
195 static const struct i915_oa_reg mux_config_compute_basic[] = {
196         { _MMIO(0x9888), 0x104f00e0 },
197         { _MMIO(0x9888), 0x124f1c00 },
198         { _MMIO(0x9888), 0x106c00e0 },
199         { _MMIO(0x9888), 0x37906800 },
200         { _MMIO(0x9888), 0x3f900003 },
201         { _MMIO(0x9888), 0x004e8000 },
202         { _MMIO(0x9888), 0x1a4e0820 },
203         { _MMIO(0x9888), 0x1c4e0002 },
204         { _MMIO(0x9888), 0x064f0900 },
205         { _MMIO(0x9888), 0x084f0032 },
206         { _MMIO(0x9888), 0x0a4f1891 },
207         { _MMIO(0x9888), 0x0c4f0e00 },
208         { _MMIO(0x9888), 0x0e4f003c },
209         { _MMIO(0x9888), 0x004f0d80 },
210         { _MMIO(0x9888), 0x024f003b },
211         { _MMIO(0x9888), 0x006c0002 },
212         { _MMIO(0x9888), 0x086c0100 },
213         { _MMIO(0x9888), 0x0c6c000c },
214         { _MMIO(0x9888), 0x0e6c0b00 },
215         { _MMIO(0x9888), 0x186c0000 },
216         { _MMIO(0x9888), 0x1c6c0000 },
217         { _MMIO(0x9888), 0x1e6c0000 },
218         { _MMIO(0x9888), 0x001b4000 },
219         { _MMIO(0x9888), 0x081b8000 },
220         { _MMIO(0x9888), 0x0c1b4000 },
221         { _MMIO(0x9888), 0x0e1b8000 },
222         { _MMIO(0x9888), 0x101c8000 },
223         { _MMIO(0x9888), 0x1a1c8000 },
224         { _MMIO(0x9888), 0x1c1c0024 },
225         { _MMIO(0x9888), 0x065b8000 },
226         { _MMIO(0x9888), 0x085b4000 },
227         { _MMIO(0x9888), 0x0a5bc000 },
228         { _MMIO(0x9888), 0x0c5b8000 },
229         { _MMIO(0x9888), 0x0e5b4000 },
230         { _MMIO(0x9888), 0x005b8000 },
231         { _MMIO(0x9888), 0x025b4000 },
232         { _MMIO(0x9888), 0x1a5c6000 },
233         { _MMIO(0x9888), 0x1c5c001b },
234         { _MMIO(0x9888), 0x125c8000 },
235         { _MMIO(0x9888), 0x145c8000 },
236         { _MMIO(0x9888), 0x004c8000 },
237         { _MMIO(0x9888), 0x0a4c2000 },
238         { _MMIO(0x9888), 0x0c4c0208 },
239         { _MMIO(0x9888), 0x000da000 },
240         { _MMIO(0x9888), 0x060d8000 },
241         { _MMIO(0x9888), 0x080da000 },
242         { _MMIO(0x9888), 0x0a0da000 },
243         { _MMIO(0x9888), 0x0c0da000 },
244         { _MMIO(0x9888), 0x0e0da000 },
245         { _MMIO(0x9888), 0x020d2000 },
246         { _MMIO(0x9888), 0x0c0f5400 },
247         { _MMIO(0x9888), 0x0e0f5500 },
248         { _MMIO(0x9888), 0x100f0155 },
249         { _MMIO(0x9888), 0x002c8000 },
250         { _MMIO(0x9888), 0x0e2cc000 },
251         { _MMIO(0x9888), 0x162cfb00 },
252         { _MMIO(0x9888), 0x182c00be },
253         { _MMIO(0x9888), 0x022cc000 },
254         { _MMIO(0x9888), 0x042cc000 },
255         { _MMIO(0x9888), 0x19900157 },
256         { _MMIO(0x9888), 0x1b900158 },
257         { _MMIO(0x9888), 0x1d900105 },
258         { _MMIO(0x9888), 0x1f900103 },
259         { _MMIO(0x9888), 0x35900000 },
260         { _MMIO(0x9888), 0x11900fff },
261         { _MMIO(0x9888), 0x51900000 },
262         { _MMIO(0x9888), 0x41900800 },
263         { _MMIO(0x9888), 0x55900000 },
264         { _MMIO(0x9888), 0x45900821 },
265         { _MMIO(0x9888), 0x47900802 },
266         { _MMIO(0x9888), 0x57900000 },
267         { _MMIO(0x9888), 0x49900802 },
268         { _MMIO(0x9888), 0x33900000 },
269         { _MMIO(0x9888), 0x4b900002 },
270         { _MMIO(0x9888), 0x59900000 },
271         { _MMIO(0x9888), 0x43900422 },
272         { _MMIO(0x9888), 0x53904444 },
273 };
274
275 static int
276 get_compute_basic_mux_config(struct drm_i915_private *dev_priv,
277                              const struct i915_oa_reg **regs,
278                              int *lens)
279 {
280         int n = 0;
281
282         BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs) < 1);
283         BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs_lens) < 1);
284
285         regs[n] = mux_config_compute_basic;
286         lens[n] = ARRAY_SIZE(mux_config_compute_basic);
287         n++;
288
289         return n;
290 }
291
292 static const struct i915_oa_reg b_counter_config_render_pipe_profile[] = {
293         { _MMIO(0x2724), 0xf0800000 },
294         { _MMIO(0x2720), 0x00000000 },
295         { _MMIO(0x2714), 0xf0800000 },
296         { _MMIO(0x2710), 0x00000000 },
297         { _MMIO(0x2740), 0x00000000 },
298         { _MMIO(0x2770), 0x0007ffea },
299         { _MMIO(0x2774), 0x00007ffc },
300         { _MMIO(0x2778), 0x0007affa },
301         { _MMIO(0x277c), 0x0000f5fd },
302         { _MMIO(0x2780), 0x00079ffa },
303         { _MMIO(0x2784), 0x0000f3fb },
304         { _MMIO(0x2788), 0x0007bf7a },
305         { _MMIO(0x278c), 0x0000f7e7 },
306         { _MMIO(0x2790), 0x0007fefa },
307         { _MMIO(0x2794), 0x0000f7cf },
308         { _MMIO(0x2798), 0x00077ffa },
309         { _MMIO(0x279c), 0x0000efdf },
310         { _MMIO(0x27a0), 0x0006fffa },
311         { _MMIO(0x27a4), 0x0000cfbf },
312         { _MMIO(0x27a8), 0x0003fffa },
313         { _MMIO(0x27ac), 0x00005f7f },
314 };
315
316 static const struct i915_oa_reg flex_eu_config_render_pipe_profile[] = {
317         { _MMIO(0xe458), 0x00005004 },
318         { _MMIO(0xe558), 0x00015014 },
319         { _MMIO(0xe658), 0x00025024 },
320         { _MMIO(0xe758), 0x00035034 },
321         { _MMIO(0xe45c), 0x00045044 },
322         { _MMIO(0xe55c), 0x00055054 },
323         { _MMIO(0xe65c), 0x00065064 },
324 };
325
326 static const struct i915_oa_reg mux_config_render_pipe_profile[] = {
327         { _MMIO(0x9888), 0x0c0e001f },
328         { _MMIO(0x9888), 0x0a0f0000 },
329         { _MMIO(0x9888), 0x10116800 },
330         { _MMIO(0x9888), 0x178a03e0 },
331         { _MMIO(0x9888), 0x11824c00 },
332         { _MMIO(0x9888), 0x11830020 },
333         { _MMIO(0x9888), 0x13840020 },
334         { _MMIO(0x9888), 0x11850019 },
335         { _MMIO(0x9888), 0x11860007 },
336         { _MMIO(0x9888), 0x01870c40 },
337         { _MMIO(0x9888), 0x17880000 },
338         { _MMIO(0x9888), 0x022f4000 },
339         { _MMIO(0x9888), 0x0a4c0040 },
340         { _MMIO(0x9888), 0x0c0d8000 },
341         { _MMIO(0x9888), 0x040d4000 },
342         { _MMIO(0x9888), 0x060d2000 },
343         { _MMIO(0x9888), 0x020e5400 },
344         { _MMIO(0x9888), 0x000e0000 },
345         { _MMIO(0x9888), 0x080f0040 },
346         { _MMIO(0x9888), 0x000f0000 },
347         { _MMIO(0x9888), 0x100f0000 },
348         { _MMIO(0x9888), 0x0e0f0040 },
349         { _MMIO(0x9888), 0x0c2c8000 },
350         { _MMIO(0x9888), 0x06104000 },
351         { _MMIO(0x9888), 0x06110012 },
352         { _MMIO(0x9888), 0x06131000 },
353         { _MMIO(0x9888), 0x01898000 },
354         { _MMIO(0x9888), 0x0d890100 },
355         { _MMIO(0x9888), 0x03898000 },
356         { _MMIO(0x9888), 0x09808000 },
357         { _MMIO(0x9888), 0x0b808000 },
358         { _MMIO(0x9888), 0x0380c000 },
359         { _MMIO(0x9888), 0x0f8a0075 },
360         { _MMIO(0x9888), 0x1d8a0000 },
361         { _MMIO(0x9888), 0x118a8000 },
362         { _MMIO(0x9888), 0x1b8a4000 },
363         { _MMIO(0x9888), 0x138a8000 },
364         { _MMIO(0x9888), 0x1d81a000 },
365         { _MMIO(0x9888), 0x15818000 },
366         { _MMIO(0x9888), 0x17818000 },
367         { _MMIO(0x9888), 0x0b820030 },
368         { _MMIO(0x9888), 0x07828000 },
369         { _MMIO(0x9888), 0x0d824000 },
370         { _MMIO(0x9888), 0x0f828000 },
371         { _MMIO(0x9888), 0x05824000 },
372         { _MMIO(0x9888), 0x0d830003 },
373         { _MMIO(0x9888), 0x0583000c },
374         { _MMIO(0x9888), 0x09830000 },
375         { _MMIO(0x9888), 0x03838000 },
376         { _MMIO(0x9888), 0x07838000 },
377         { _MMIO(0x9888), 0x0b840980 },
378         { _MMIO(0x9888), 0x03844d80 },
379         { _MMIO(0x9888), 0x11840000 },
380         { _MMIO(0x9888), 0x09848000 },
381         { _MMIO(0x9888), 0x09850080 },
382         { _MMIO(0x9888), 0x03850003 },
383         { _MMIO(0x9888), 0x01850000 },
384         { _MMIO(0x9888), 0x07860000 },
385         { _MMIO(0x9888), 0x0f860400 },
386         { _MMIO(0x9888), 0x09870032 },
387         { _MMIO(0x9888), 0x01888052 },
388         { _MMIO(0x9888), 0x11880000 },
389         { _MMIO(0x9888), 0x09884000 },
390         { _MMIO(0x9888), 0x1b931001 },
391         { _MMIO(0x9888), 0x1d930001 },
392         { _MMIO(0x9888), 0x19934000 },
393         { _MMIO(0x9888), 0x1b958000 },
394         { _MMIO(0x9888), 0x1d950094 },
395         { _MMIO(0x9888), 0x19958000 },
396         { _MMIO(0x9888), 0x09e58000 },
397         { _MMIO(0x9888), 0x0be58000 },
398         { _MMIO(0x9888), 0x03e5c000 },
399         { _MMIO(0x9888), 0x0592c000 },
400         { _MMIO(0x9888), 0x0b928000 },
401         { _MMIO(0x9888), 0x0d924000 },
402         { _MMIO(0x9888), 0x0f924000 },
403         { _MMIO(0x9888), 0x11928000 },
404         { _MMIO(0x9888), 0x1392c000 },
405         { _MMIO(0x9888), 0x09924000 },
406         { _MMIO(0x9888), 0x01985000 },
407         { _MMIO(0x9888), 0x07988000 },
408         { _MMIO(0x9888), 0x09981000 },
409         { _MMIO(0x9888), 0x0b982000 },
410         { _MMIO(0x9888), 0x0d982000 },
411         { _MMIO(0x9888), 0x0f989000 },
412         { _MMIO(0x9888), 0x05982000 },
413         { _MMIO(0x9888), 0x13904000 },
414         { _MMIO(0x9888), 0x21904000 },
415         { _MMIO(0x9888), 0x23904000 },
416         { _MMIO(0x9888), 0x25908000 },
417         { _MMIO(0x9888), 0x27904000 },
418         { _MMIO(0x9888), 0x29908000 },
419         { _MMIO(0x9888), 0x2b904000 },
420         { _MMIO(0x9888), 0x2f904000 },
421         { _MMIO(0x9888), 0x31904000 },
422         { _MMIO(0x9888), 0x15904000 },
423         { _MMIO(0x9888), 0x17908000 },
424         { _MMIO(0x9888), 0x19908000 },
425         { _MMIO(0x9888), 0x1b904000 },
426         { _MMIO(0x9888), 0x1190c080 },
427         { _MMIO(0x9888), 0x51900000 },
428         { _MMIO(0x9888), 0x41900440 },
429         { _MMIO(0x9888), 0x55900000 },
430         { _MMIO(0x9888), 0x45900400 },
431         { _MMIO(0x9888), 0x47900c21 },
432         { _MMIO(0x9888), 0x57900400 },
433         { _MMIO(0x9888), 0x49900042 },
434         { _MMIO(0x9888), 0x37900000 },
435         { _MMIO(0x9888), 0x33900000 },
436         { _MMIO(0x9888), 0x4b900024 },
437         { _MMIO(0x9888), 0x59900000 },
438         { _MMIO(0x9888), 0x43900841 },
439         { _MMIO(0x9888), 0x53900400 },
440 };
441
442 static int
443 get_render_pipe_profile_mux_config(struct drm_i915_private *dev_priv,
444                                    const struct i915_oa_reg **regs,
445                                    int *lens)
446 {
447         int n = 0;
448
449         BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs) < 1);
450         BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs_lens) < 1);
451
452         regs[n] = mux_config_render_pipe_profile;
453         lens[n] = ARRAY_SIZE(mux_config_render_pipe_profile);
454         n++;
455
456         return n;
457 }
458
459 static const struct i915_oa_reg b_counter_config_memory_reads[] = {
460         { _MMIO(0x272c), 0xffffffff },
461         { _MMIO(0x2728), 0xffffffff },
462         { _MMIO(0x2724), 0xf0800000 },
463         { _MMIO(0x2720), 0x00000000 },
464         { _MMIO(0x271c), 0xffffffff },
465         { _MMIO(0x2718), 0xffffffff },
466         { _MMIO(0x2714), 0xf0800000 },
467         { _MMIO(0x2710), 0x00000000 },
468         { _MMIO(0x274c), 0x86543210 },
469         { _MMIO(0x2748), 0x86543210 },
470         { _MMIO(0x2744), 0x00006667 },
471         { _MMIO(0x2740), 0x00000000 },
472         { _MMIO(0x275c), 0x86543210 },
473         { _MMIO(0x2758), 0x86543210 },
474         { _MMIO(0x2754), 0x00006465 },
475         { _MMIO(0x2750), 0x00000000 },
476         { _MMIO(0x2770), 0x0007f81a },
477         { _MMIO(0x2774), 0x0000fe00 },
478         { _MMIO(0x2778), 0x0007f82a },
479         { _MMIO(0x277c), 0x0000fe00 },
480         { _MMIO(0x2780), 0x0007f872 },
481         { _MMIO(0x2784), 0x0000fe00 },
482         { _MMIO(0x2788), 0x0007f8ba },
483         { _MMIO(0x278c), 0x0000fe00 },
484         { _MMIO(0x2790), 0x0007f87a },
485         { _MMIO(0x2794), 0x0000fe00 },
486         { _MMIO(0x2798), 0x0007f8ea },
487         { _MMIO(0x279c), 0x0000fe00 },
488         { _MMIO(0x27a0), 0x0007f8e2 },
489         { _MMIO(0x27a4), 0x0000fe00 },
490         { _MMIO(0x27a8), 0x0007f8f2 },
491         { _MMIO(0x27ac), 0x0000fe00 },
492 };
493
494 static const struct i915_oa_reg flex_eu_config_memory_reads[] = {
495         { _MMIO(0xe458), 0x00005004 },
496         { _MMIO(0xe558), 0x00015014 },
497         { _MMIO(0xe658), 0x00025024 },
498         { _MMIO(0xe758), 0x00035034 },
499         { _MMIO(0xe45c), 0x00045044 },
500         { _MMIO(0xe55c), 0x00055054 },
501         { _MMIO(0xe65c), 0x00065064 },
502 };
503
504 static const struct i915_oa_reg mux_config_memory_reads[] = {
505         { _MMIO(0x9888), 0x11810c00 },
506         { _MMIO(0x9888), 0x1381001a },
507         { _MMIO(0x9888), 0x37906800 },
508         { _MMIO(0x9888), 0x3f900064 },
509         { _MMIO(0x9888), 0x03811300 },
510         { _MMIO(0x9888), 0x05811b12 },
511         { _MMIO(0x9888), 0x0781001a },
512         { _MMIO(0x9888), 0x1f810000 },
513         { _MMIO(0x9888), 0x17810000 },
514         { _MMIO(0x9888), 0x19810000 },
515         { _MMIO(0x9888), 0x1b810000 },
516         { _MMIO(0x9888), 0x1d810000 },
517         { _MMIO(0x9888), 0x1b930055 },
518         { _MMIO(0x9888), 0x03e58000 },
519         { _MMIO(0x9888), 0x05e5c000 },
520         { _MMIO(0x9888), 0x07e54000 },
521         { _MMIO(0x9888), 0x13900150 },
522         { _MMIO(0x9888), 0x21900151 },
523         { _MMIO(0x9888), 0x23900152 },
524         { _MMIO(0x9888), 0x25900153 },
525         { _MMIO(0x9888), 0x27900154 },
526         { _MMIO(0x9888), 0x29900155 },
527         { _MMIO(0x9888), 0x2b900156 },
528         { _MMIO(0x9888), 0x2d900157 },
529         { _MMIO(0x9888), 0x2f90015f },
530         { _MMIO(0x9888), 0x31900105 },
531         { _MMIO(0x9888), 0x15900103 },
532         { _MMIO(0x9888), 0x17900101 },
533         { _MMIO(0x9888), 0x35900000 },
534         { _MMIO(0x9888), 0x19908000 },
535         { _MMIO(0x9888), 0x1b908000 },
536         { _MMIO(0x9888), 0x1d908000 },
537         { _MMIO(0x9888), 0x1f908000 },
538         { _MMIO(0x9888), 0x11900000 },
539         { _MMIO(0x9888), 0x51900000 },
540         { _MMIO(0x9888), 0x41900c60 },
541         { _MMIO(0x9888), 0x55900000 },
542         { _MMIO(0x9888), 0x45900c00 },
543         { _MMIO(0x9888), 0x47900c63 },
544         { _MMIO(0x9888), 0x57900000 },
545         { _MMIO(0x9888), 0x49900c63 },
546         { _MMIO(0x9888), 0x33900000 },
547         { _MMIO(0x9888), 0x4b900063 },
548         { _MMIO(0x9888), 0x59900000 },
549         { _MMIO(0x9888), 0x43900003 },
550         { _MMIO(0x9888), 0x53900000 },
551 };
552
553 static int
554 get_memory_reads_mux_config(struct drm_i915_private *dev_priv,
555                             const struct i915_oa_reg **regs,
556                             int *lens)
557 {
558         int n = 0;
559
560         BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs) < 1);
561         BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs_lens) < 1);
562
563         regs[n] = mux_config_memory_reads;
564         lens[n] = ARRAY_SIZE(mux_config_memory_reads);
565         n++;
566
567         return n;
568 }
569
570 static const struct i915_oa_reg b_counter_config_memory_writes[] = {
571         { _MMIO(0x272c), 0xffffffff },
572         { _MMIO(0x2728), 0xffffffff },
573         { _MMIO(0x2724), 0xf0800000 },
574         { _MMIO(0x2720), 0x00000000 },
575         { _MMIO(0x271c), 0xffffffff },
576         { _MMIO(0x2718), 0xffffffff },
577         { _MMIO(0x2714), 0xf0800000 },
578         { _MMIO(0x2710), 0x00000000 },
579         { _MMIO(0x274c), 0x86543210 },
580         { _MMIO(0x2748), 0x86543210 },
581         { _MMIO(0x2744), 0x00006667 },
582         { _MMIO(0x2740), 0x00000000 },
583         { _MMIO(0x275c), 0x86543210 },
584         { _MMIO(0x2758), 0x86543210 },
585         { _MMIO(0x2754), 0x00006465 },
586         { _MMIO(0x2750), 0x00000000 },
587         { _MMIO(0x2770), 0x0007f81a },
588         { _MMIO(0x2774), 0x0000fe00 },
589         { _MMIO(0x2778), 0x0007f82a },
590         { _MMIO(0x277c), 0x0000fe00 },
591         { _MMIO(0x2780), 0x0007f822 },
592         { _MMIO(0x2784), 0x0000fe00 },
593         { _MMIO(0x2788), 0x0007f8ba },
594         { _MMIO(0x278c), 0x0000fe00 },
595         { _MMIO(0x2790), 0x0007f87a },
596         { _MMIO(0x2794), 0x0000fe00 },
597         { _MMIO(0x2798), 0x0007f8ea },
598         { _MMIO(0x279c), 0x0000fe00 },
599         { _MMIO(0x27a0), 0x0007f8e2 },
600         { _MMIO(0x27a4), 0x0000fe00 },
601         { _MMIO(0x27a8), 0x0007f8f2 },
602         { _MMIO(0x27ac), 0x0000fe00 },
603 };
604
605 static const struct i915_oa_reg flex_eu_config_memory_writes[] = {
606         { _MMIO(0xe458), 0x00005004 },
607         { _MMIO(0xe558), 0x00015014 },
608         { _MMIO(0xe658), 0x00025024 },
609         { _MMIO(0xe758), 0x00035034 },
610         { _MMIO(0xe45c), 0x00045044 },
611         { _MMIO(0xe55c), 0x00055054 },
612         { _MMIO(0xe65c), 0x00065064 },
613 };
614
615 static const struct i915_oa_reg mux_config_memory_writes[] = {
616         { _MMIO(0x9888), 0x11810c00 },
617         { _MMIO(0x9888), 0x1381001a },
618         { _MMIO(0x9888), 0x37906800 },
619         { _MMIO(0x9888), 0x3f901000 },
620         { _MMIO(0x9888), 0x03811300 },
621         { _MMIO(0x9888), 0x05811b12 },
622         { _MMIO(0x9888), 0x0781001a },
623         { _MMIO(0x9888), 0x1f810000 },
624         { _MMIO(0x9888), 0x17810000 },
625         { _MMIO(0x9888), 0x19810000 },
626         { _MMIO(0x9888), 0x1b810000 },
627         { _MMIO(0x9888), 0x1d810000 },
628         { _MMIO(0x9888), 0x1b930055 },
629         { _MMIO(0x9888), 0x03e58000 },
630         { _MMIO(0x9888), 0x05e5c000 },
631         { _MMIO(0x9888), 0x07e54000 },
632         { _MMIO(0x9888), 0x13900160 },
633         { _MMIO(0x9888), 0x21900161 },
634         { _MMIO(0x9888), 0x23900162 },
635         { _MMIO(0x9888), 0x25900163 },
636         { _MMIO(0x9888), 0x27900164 },
637         { _MMIO(0x9888), 0x29900165 },
638         { _MMIO(0x9888), 0x2b900166 },
639         { _MMIO(0x9888), 0x2d900167 },
640         { _MMIO(0x9888), 0x2f900150 },
641         { _MMIO(0x9888), 0x31900105 },
642         { _MMIO(0x9888), 0x15900103 },
643         { _MMIO(0x9888), 0x17900101 },
644         { _MMIO(0x9888), 0x35900000 },
645         { _MMIO(0x9888), 0x19908000 },
646         { _MMIO(0x9888), 0x1b908000 },
647         { _MMIO(0x9888), 0x1d908000 },
648         { _MMIO(0x9888), 0x1f908000 },
649         { _MMIO(0x9888), 0x11900000 },
650         { _MMIO(0x9888), 0x51900000 },
651         { _MMIO(0x9888), 0x41900c60 },
652         { _MMIO(0x9888), 0x55900000 },
653         { _MMIO(0x9888), 0x45900c00 },
654         { _MMIO(0x9888), 0x47900c63 },
655         { _MMIO(0x9888), 0x57900000 },
656         { _MMIO(0x9888), 0x49900c63 },
657         { _MMIO(0x9888), 0x33900000 },
658         { _MMIO(0x9888), 0x4b900063 },
659         { _MMIO(0x9888), 0x59900000 },
660         { _MMIO(0x9888), 0x43900003 },
661         { _MMIO(0x9888), 0x53900000 },
662 };
663
664 static int
665 get_memory_writes_mux_config(struct drm_i915_private *dev_priv,
666                              const struct i915_oa_reg **regs,
667                              int *lens)
668 {
669         int n = 0;
670
671         BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs) < 1);
672         BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs_lens) < 1);
673
674         regs[n] = mux_config_memory_writes;
675         lens[n] = ARRAY_SIZE(mux_config_memory_writes);
676         n++;
677
678         return n;
679 }
680
681 static const struct i915_oa_reg b_counter_config_compute_extended[] = {
682         { _MMIO(0x2724), 0xf0800000 },
683         { _MMIO(0x2720), 0x00000000 },
684         { _MMIO(0x2714), 0xf0800000 },
685         { _MMIO(0x2710), 0x00000000 },
686         { _MMIO(0x2740), 0x00000000 },
687         { _MMIO(0x2770), 0x0007fc2a },
688         { _MMIO(0x2774), 0x0000bf00 },
689         { _MMIO(0x2778), 0x0007fc6a },
690         { _MMIO(0x277c), 0x0000bf00 },
691         { _MMIO(0x2780), 0x0007fc92 },
692         { _MMIO(0x2784), 0x0000bf00 },
693         { _MMIO(0x2788), 0x0007fca2 },
694         { _MMIO(0x278c), 0x0000bf00 },
695         { _MMIO(0x2790), 0x0007fc32 },
696         { _MMIO(0x2794), 0x0000bf00 },
697         { _MMIO(0x2798), 0x0007fc9a },
698         { _MMIO(0x279c), 0x0000bf00 },
699         { _MMIO(0x27a0), 0x0007fe6a },
700         { _MMIO(0x27a4), 0x0000bf00 },
701         { _MMIO(0x27a8), 0x0007fe7a },
702         { _MMIO(0x27ac), 0x0000bf00 },
703 };
704
705 static const struct i915_oa_reg flex_eu_config_compute_extended[] = {
706         { _MMIO(0xe458), 0x00005004 },
707         { _MMIO(0xe558), 0x00000003 },
708         { _MMIO(0xe658), 0x00002001 },
709         { _MMIO(0xe758), 0x00778008 },
710         { _MMIO(0xe45c), 0x00088078 },
711         { _MMIO(0xe55c), 0x00808708 },
712         { _MMIO(0xe65c), 0x00a08908 },
713 };
714
715 static const struct i915_oa_reg mux_config_compute_extended[] = {
716         { _MMIO(0x9888), 0x106c00e0 },
717         { _MMIO(0x9888), 0x141c8160 },
718         { _MMIO(0x9888), 0x161c8015 },
719         { _MMIO(0x9888), 0x181c0120 },
720         { _MMIO(0x9888), 0x004e8000 },
721         { _MMIO(0x9888), 0x0e4e8000 },
722         { _MMIO(0x9888), 0x184e8000 },
723         { _MMIO(0x9888), 0x1a4eaaa0 },
724         { _MMIO(0x9888), 0x1c4e0002 },
725         { _MMIO(0x9888), 0x024e8000 },
726         { _MMIO(0x9888), 0x044e8000 },
727         { _MMIO(0x9888), 0x064e8000 },
728         { _MMIO(0x9888), 0x084e8000 },
729         { _MMIO(0x9888), 0x0a4e8000 },
730         { _MMIO(0x9888), 0x0e6c0b01 },
731         { _MMIO(0x9888), 0x006c0200 },
732         { _MMIO(0x9888), 0x026c000c },
733         { _MMIO(0x9888), 0x1c6c0000 },
734         { _MMIO(0x9888), 0x1e6c0000 },
735         { _MMIO(0x9888), 0x1a6c0000 },
736         { _MMIO(0x9888), 0x0e1bc000 },
737         { _MMIO(0x9888), 0x001b8000 },
738         { _MMIO(0x9888), 0x021bc000 },
739         { _MMIO(0x9888), 0x001c0041 },
740         { _MMIO(0x9888), 0x061c4200 },
741         { _MMIO(0x9888), 0x081c4443 },
742         { _MMIO(0x9888), 0x0a1c4645 },
743         { _MMIO(0x9888), 0x0c1c7647 },
744         { _MMIO(0x9888), 0x041c7357 },
745         { _MMIO(0x9888), 0x1c1c0030 },
746         { _MMIO(0x9888), 0x101c0000 },
747         { _MMIO(0x9888), 0x1a1c0000 },
748         { _MMIO(0x9888), 0x121c8000 },
749         { _MMIO(0x9888), 0x004c8000 },
750         { _MMIO(0x9888), 0x0a4caa2a },
751         { _MMIO(0x9888), 0x0c4c02aa },
752         { _MMIO(0x9888), 0x084ca000 },
753         { _MMIO(0x9888), 0x000da000 },
754         { _MMIO(0x9888), 0x060d8000 },
755         { _MMIO(0x9888), 0x080da000 },
756         { _MMIO(0x9888), 0x0a0da000 },
757         { _MMIO(0x9888), 0x0c0da000 },
758         { _MMIO(0x9888), 0x0e0da000 },
759         { _MMIO(0x9888), 0x020da000 },
760         { _MMIO(0x9888), 0x040da000 },
761         { _MMIO(0x9888), 0x0c0f5400 },
762         { _MMIO(0x9888), 0x0e0f5515 },
763         { _MMIO(0x9888), 0x100f0155 },
764         { _MMIO(0x9888), 0x002c8000 },
765         { _MMIO(0x9888), 0x0e2c8000 },
766         { _MMIO(0x9888), 0x162caa00 },
767         { _MMIO(0x9888), 0x182c00aa },
768         { _MMIO(0x9888), 0x022c8000 },
769         { _MMIO(0x9888), 0x042c8000 },
770         { _MMIO(0x9888), 0x062c8000 },
771         { _MMIO(0x9888), 0x082c8000 },
772         { _MMIO(0x9888), 0x0a2c8000 },
773         { _MMIO(0x9888), 0x11907fff },
774         { _MMIO(0x9888), 0x51900000 },
775         { _MMIO(0x9888), 0x41900040 },
776         { _MMIO(0x9888), 0x55900000 },
777         { _MMIO(0x9888), 0x45900802 },
778         { _MMIO(0x9888), 0x47900842 },
779         { _MMIO(0x9888), 0x57900000 },
780         { _MMIO(0x9888), 0x49900842 },
781         { _MMIO(0x9888), 0x37900000 },
782         { _MMIO(0x9888), 0x33900000 },
783         { _MMIO(0x9888), 0x4b900000 },
784         { _MMIO(0x9888), 0x59900000 },
785         { _MMIO(0x9888), 0x43900800 },
786         { _MMIO(0x9888), 0x53900000 },
787 };
788
789 static int
790 get_compute_extended_mux_config(struct drm_i915_private *dev_priv,
791                                 const struct i915_oa_reg **regs,
792                                 int *lens)
793 {
794         int n = 0;
795
796         BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs) < 1);
797         BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs_lens) < 1);
798
799         regs[n] = mux_config_compute_extended;
800         lens[n] = ARRAY_SIZE(mux_config_compute_extended);
801         n++;
802
803         return n;
804 }
805
806 static const struct i915_oa_reg b_counter_config_compute_l3_cache[] = {
807         { _MMIO(0x2710), 0x00000000 },
808         { _MMIO(0x2714), 0x30800000 },
809         { _MMIO(0x2720), 0x00000000 },
810         { _MMIO(0x2724), 0x30800000 },
811         { _MMIO(0x2740), 0x00000000 },
812         { _MMIO(0x2770), 0x0007fffa },
813         { _MMIO(0x2774), 0x0000fefe },
814         { _MMIO(0x2778), 0x0007fffa },
815         { _MMIO(0x277c), 0x0000fefd },
816         { _MMIO(0x2790), 0x0007fffa },
817         { _MMIO(0x2794), 0x0000fbef },
818         { _MMIO(0x2798), 0x0007fffa },
819         { _MMIO(0x279c), 0x0000fbdf },
820 };
821
822 static const struct i915_oa_reg flex_eu_config_compute_l3_cache[] = {
823         { _MMIO(0xe458), 0x00005004 },
824         { _MMIO(0xe558), 0x00000003 },
825         { _MMIO(0xe658), 0x00002001 },
826         { _MMIO(0xe758), 0x00101100 },
827         { _MMIO(0xe45c), 0x00201200 },
828         { _MMIO(0xe55c), 0x00301300 },
829         { _MMIO(0xe65c), 0x00401400 },
830 };
831
832 static const struct i915_oa_reg mux_config_compute_l3_cache[] = {
833         { _MMIO(0x9888), 0x166c0760 },
834         { _MMIO(0x9888), 0x1593001e },
835         { _MMIO(0x9888), 0x3f900003 },
836         { _MMIO(0x9888), 0x004e8000 },
837         { _MMIO(0x9888), 0x0e4e8000 },
838         { _MMIO(0x9888), 0x184e8000 },
839         { _MMIO(0x9888), 0x1a4e8020 },
840         { _MMIO(0x9888), 0x1c4e0002 },
841         { _MMIO(0x9888), 0x006c0051 },
842         { _MMIO(0x9888), 0x066c5000 },
843         { _MMIO(0x9888), 0x086c5c5d },
844         { _MMIO(0x9888), 0x0e6c5e5f },
845         { _MMIO(0x9888), 0x106c0000 },
846         { _MMIO(0x9888), 0x186c0000 },
847         { _MMIO(0x9888), 0x1c6c0000 },
848         { _MMIO(0x9888), 0x1e6c0000 },
849         { _MMIO(0x9888), 0x001b4000 },
850         { _MMIO(0x9888), 0x061b8000 },
851         { _MMIO(0x9888), 0x081bc000 },
852         { _MMIO(0x9888), 0x0e1bc000 },
853         { _MMIO(0x9888), 0x101c8000 },
854         { _MMIO(0x9888), 0x1a1ce000 },
855         { _MMIO(0x9888), 0x1c1c0030 },
856         { _MMIO(0x9888), 0x004c8000 },
857         { _MMIO(0x9888), 0x0a4c2a00 },
858         { _MMIO(0x9888), 0x0c4c0280 },
859         { _MMIO(0x9888), 0x000d2000 },
860         { _MMIO(0x9888), 0x060d8000 },
861         { _MMIO(0x9888), 0x080da000 },
862         { _MMIO(0x9888), 0x0e0da000 },
863         { _MMIO(0x9888), 0x0c0f0400 },
864         { _MMIO(0x9888), 0x0e0f1500 },
865         { _MMIO(0x9888), 0x100f0140 },
866         { _MMIO(0x9888), 0x002c8000 },
867         { _MMIO(0x9888), 0x0e2c8000 },
868         { _MMIO(0x9888), 0x162c0a00 },
869         { _MMIO(0x9888), 0x182c00a0 },
870         { _MMIO(0x9888), 0x03933300 },
871         { _MMIO(0x9888), 0x05930032 },
872         { _MMIO(0x9888), 0x11930000 },
873         { _MMIO(0x9888), 0x1b930000 },
874         { _MMIO(0x9888), 0x1d900157 },
875         { _MMIO(0x9888), 0x1f900158 },
876         { _MMIO(0x9888), 0x35900000 },
877         { _MMIO(0x9888), 0x19908000 },
878         { _MMIO(0x9888), 0x1b908000 },
879         { _MMIO(0x9888), 0x1190030f },
880         { _MMIO(0x9888), 0x51900000 },
881         { _MMIO(0x9888), 0x41900000 },
882         { _MMIO(0x9888), 0x55900000 },
883         { _MMIO(0x9888), 0x45900021 },
884         { _MMIO(0x9888), 0x47900000 },
885         { _MMIO(0x9888), 0x37900000 },
886         { _MMIO(0x9888), 0x33900000 },
887         { _MMIO(0x9888), 0x57900000 },
888         { _MMIO(0x9888), 0x4b900000 },
889         { _MMIO(0x9888), 0x59900000 },
890         { _MMIO(0x9888), 0x53904444 },
891         { _MMIO(0x9888), 0x43900000 },
892 };
893
894 static int
895 get_compute_l3_cache_mux_config(struct drm_i915_private *dev_priv,
896                                 const struct i915_oa_reg **regs,
897                                 int *lens)
898 {
899         int n = 0;
900
901         BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs) < 1);
902         BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs_lens) < 1);
903
904         regs[n] = mux_config_compute_l3_cache;
905         lens[n] = ARRAY_SIZE(mux_config_compute_l3_cache);
906         n++;
907
908         return n;
909 }
910
911 static const struct i915_oa_reg b_counter_config_hdc_and_sf[] = {
912         { _MMIO(0x2740), 0x00000000 },
913         { _MMIO(0x2744), 0x00800000 },
914         { _MMIO(0x2710), 0x00000000 },
915         { _MMIO(0x2714), 0x10800000 },
916         { _MMIO(0x2740), 0x00000000 },
917         { _MMIO(0x2720), 0x00000000 },
918         { _MMIO(0x2724), 0x00800000 },
919         { _MMIO(0x2770), 0x00000002 },
920         { _MMIO(0x2774), 0x0000fdff },
921 };
922
923 static const struct i915_oa_reg flex_eu_config_hdc_and_sf[] = {
924         { _MMIO(0xe458), 0x00005004 },
925         { _MMIO(0xe558), 0x00010003 },
926         { _MMIO(0xe658), 0x00012011 },
927         { _MMIO(0xe758), 0x00015014 },
928         { _MMIO(0xe45c), 0x00051050 },
929         { _MMIO(0xe55c), 0x00053052 },
930         { _MMIO(0xe65c), 0x00055054 },
931 };
932
933 static const struct i915_oa_reg mux_config_hdc_and_sf[] = {
934         { _MMIO(0x9888), 0x104f0232 },
935         { _MMIO(0x9888), 0x124f4640 },
936         { _MMIO(0x9888), 0x106c0232 },
937         { _MMIO(0x9888), 0x11834400 },
938         { _MMIO(0x9888), 0x0a4e8000 },
939         { _MMIO(0x9888), 0x0c4e8000 },
940         { _MMIO(0x9888), 0x004f1880 },
941         { _MMIO(0x9888), 0x024f08bb },
942         { _MMIO(0x9888), 0x044f001b },
943         { _MMIO(0x9888), 0x046c0100 },
944         { _MMIO(0x9888), 0x066c000b },
945         { _MMIO(0x9888), 0x1a6c0000 },
946         { _MMIO(0x9888), 0x041b8000 },
947         { _MMIO(0x9888), 0x061b4000 },
948         { _MMIO(0x9888), 0x1a1c1800 },
949         { _MMIO(0x9888), 0x005b8000 },
950         { _MMIO(0x9888), 0x025bc000 },
951         { _MMIO(0x9888), 0x045b4000 },
952         { _MMIO(0x9888), 0x125c8000 },
953         { _MMIO(0x9888), 0x145c8000 },
954         { _MMIO(0x9888), 0x165c8000 },
955         { _MMIO(0x9888), 0x185c8000 },
956         { _MMIO(0x9888), 0x0a4c00a0 },
957         { _MMIO(0x9888), 0x000d8000 },
958         { _MMIO(0x9888), 0x020da000 },
959         { _MMIO(0x9888), 0x040da000 },
960         { _MMIO(0x9888), 0x060d2000 },
961         { _MMIO(0x9888), 0x0c0f5000 },
962         { _MMIO(0x9888), 0x0e0f0055 },
963         { _MMIO(0x9888), 0x022cc000 },
964         { _MMIO(0x9888), 0x042cc000 },
965         { _MMIO(0x9888), 0x062cc000 },
966         { _MMIO(0x9888), 0x082cc000 },
967         { _MMIO(0x9888), 0x0a2c8000 },
968         { _MMIO(0x9888), 0x0c2c8000 },
969         { _MMIO(0x9888), 0x0f828000 },
970         { _MMIO(0x9888), 0x0f8305c0 },
971         { _MMIO(0x9888), 0x09830000 },
972         { _MMIO(0x9888), 0x07830000 },
973         { _MMIO(0x9888), 0x1d950080 },
974         { _MMIO(0x9888), 0x13928000 },
975         { _MMIO(0x9888), 0x0f988000 },
976         { _MMIO(0x9888), 0x31904000 },
977         { _MMIO(0x9888), 0x1190fc00 },
978         { _MMIO(0x9888), 0x37900000 },
979         { _MMIO(0x9888), 0x59900000 },
980         { _MMIO(0x9888), 0x4b900040 },
981         { _MMIO(0x9888), 0x51900000 },
982         { _MMIO(0x9888), 0x41900800 },
983         { _MMIO(0x9888), 0x43900842 },
984         { _MMIO(0x9888), 0x53900000 },
985         { _MMIO(0x9888), 0x45900000 },
986         { _MMIO(0x9888), 0x33900000 },
987 };
988
989 static int
990 get_hdc_and_sf_mux_config(struct drm_i915_private *dev_priv,
991                           const struct i915_oa_reg **regs,
992                           int *lens)
993 {
994         int n = 0;
995
996         BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs) < 1);
997         BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs_lens) < 1);
998
999         regs[n] = mux_config_hdc_and_sf;
1000         lens[n] = ARRAY_SIZE(mux_config_hdc_and_sf);
1001         n++;
1002
1003         return n;
1004 }
1005
1006 static const struct i915_oa_reg b_counter_config_l3_1[] = {
1007         { _MMIO(0x2740), 0x00000000 },
1008         { _MMIO(0x2744), 0x00800000 },
1009         { _MMIO(0x2710), 0x00000000 },
1010         { _MMIO(0x2714), 0xf0800000 },
1011         { _MMIO(0x2720), 0x00000000 },
1012         { _MMIO(0x2724), 0xf0800000 },
1013         { _MMIO(0x2770), 0x00100070 },
1014         { _MMIO(0x2774), 0x0000fff1 },
1015         { _MMIO(0x2778), 0x00014002 },
1016         { _MMIO(0x277c), 0x0000c3ff },
1017         { _MMIO(0x2780), 0x00010002 },
1018         { _MMIO(0x2784), 0x0000c7ff },
1019         { _MMIO(0x2788), 0x00004002 },
1020         { _MMIO(0x278c), 0x0000d3ff },
1021         { _MMIO(0x2790), 0x00100700 },
1022         { _MMIO(0x2794), 0x0000ff1f },
1023         { _MMIO(0x2798), 0x00001402 },
1024         { _MMIO(0x279c), 0x0000fc3f },
1025         { _MMIO(0x27a0), 0x00001002 },
1026         { _MMIO(0x27a4), 0x0000fc7f },
1027         { _MMIO(0x27a8), 0x00000402 },
1028         { _MMIO(0x27ac), 0x0000fd3f },
1029 };
1030
1031 static const struct i915_oa_reg flex_eu_config_l3_1[] = {
1032         { _MMIO(0xe458), 0x00005004 },
1033         { _MMIO(0xe558), 0x00010003 },
1034         { _MMIO(0xe658), 0x00012011 },
1035         { _MMIO(0xe758), 0x00015014 },
1036         { _MMIO(0xe45c), 0x00051050 },
1037         { _MMIO(0xe55c), 0x00053052 },
1038         { _MMIO(0xe65c), 0x00055054 },
1039 };
1040
1041 static const struct i915_oa_reg mux_config_l3_1[] = {
1042         { _MMIO(0x9888), 0x126c7b40 },
1043         { _MMIO(0x9888), 0x166c0020 },
1044         { _MMIO(0x9888), 0x0a603444 },
1045         { _MMIO(0x9888), 0x0a613400 },
1046         { _MMIO(0x9888), 0x1a4ea800 },
1047         { _MMIO(0x9888), 0x1c4e0002 },
1048         { _MMIO(0x9888), 0x024e8000 },
1049         { _MMIO(0x9888), 0x044e8000 },
1050         { _MMIO(0x9888), 0x064e8000 },
1051         { _MMIO(0x9888), 0x084e8000 },
1052         { _MMIO(0x9888), 0x0a4e8000 },
1053         { _MMIO(0x9888), 0x064f4000 },
1054         { _MMIO(0x9888), 0x0c6c5327 },
1055         { _MMIO(0x9888), 0x0e6c5425 },
1056         { _MMIO(0x9888), 0x006c2a00 },
1057         { _MMIO(0x9888), 0x026c285b },
1058         { _MMIO(0x9888), 0x046c005c },
1059         { _MMIO(0x9888), 0x106c0000 },
1060         { _MMIO(0x9888), 0x1c6c0000 },
1061         { _MMIO(0x9888), 0x1e6c0000 },
1062         { _MMIO(0x9888), 0x1a6c0800 },
1063         { _MMIO(0x9888), 0x0c1bc000 },
1064         { _MMIO(0x9888), 0x0e1bc000 },
1065         { _MMIO(0x9888), 0x001b8000 },
1066         { _MMIO(0x9888), 0x021bc000 },
1067         { _MMIO(0x9888), 0x041bc000 },
1068         { _MMIO(0x9888), 0x1c1c003c },
1069         { _MMIO(0x9888), 0x121c8000 },
1070         { _MMIO(0x9888), 0x141c8000 },
1071         { _MMIO(0x9888), 0x161c8000 },
1072         { _MMIO(0x9888), 0x181c8000 },
1073         { _MMIO(0x9888), 0x1a1c0800 },
1074         { _MMIO(0x9888), 0x065b4000 },
1075         { _MMIO(0x9888), 0x1a5c1000 },
1076         { _MMIO(0x9888), 0x10600000 },
1077         { _MMIO(0x9888), 0x04600000 },
1078         { _MMIO(0x9888), 0x0c610044 },
1079         { _MMIO(0x9888), 0x10610000 },
1080         { _MMIO(0x9888), 0x06610000 },
1081         { _MMIO(0x9888), 0x0c4c02a8 },
1082         { _MMIO(0x9888), 0x084ca000 },
1083         { _MMIO(0x9888), 0x0a4c002a },
1084         { _MMIO(0x9888), 0x0c0da000 },
1085         { _MMIO(0x9888), 0x0e0da000 },
1086         { _MMIO(0x9888), 0x000d8000 },
1087         { _MMIO(0x9888), 0x020da000 },
1088         { _MMIO(0x9888), 0x040da000 },
1089         { _MMIO(0x9888), 0x060d2000 },
1090         { _MMIO(0x9888), 0x100f0154 },
1091         { _MMIO(0x9888), 0x0c0f5000 },
1092         { _MMIO(0x9888), 0x0e0f0055 },
1093         { _MMIO(0x9888), 0x182c00aa },
1094         { _MMIO(0x9888), 0x022c8000 },
1095         { _MMIO(0x9888), 0x042c8000 },
1096         { _MMIO(0x9888), 0x062c8000 },
1097         { _MMIO(0x9888), 0x082c8000 },
1098         { _MMIO(0x9888), 0x0a2c8000 },
1099         { _MMIO(0x9888), 0x0c2cc000 },
1100         { _MMIO(0x9888), 0x1190ffc0 },
1101         { _MMIO(0x9888), 0x57900000 },
1102         { _MMIO(0x9888), 0x49900420 },
1103         { _MMIO(0x9888), 0x37900000 },
1104         { _MMIO(0x9888), 0x33900000 },
1105         { _MMIO(0x9888), 0x4b900021 },
1106         { _MMIO(0x9888), 0x59900000 },
1107         { _MMIO(0x9888), 0x51900000 },
1108         { _MMIO(0x9888), 0x41900400 },
1109         { _MMIO(0x9888), 0x43900421 },
1110         { _MMIO(0x9888), 0x53900000 },
1111         { _MMIO(0x9888), 0x45900040 },
1112 };
1113
1114 static int
1115 get_l3_1_mux_config(struct drm_i915_private *dev_priv,
1116                     const struct i915_oa_reg **regs,
1117                     int *lens)
1118 {
1119         int n = 0;
1120
1121         BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs) < 1);
1122         BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs_lens) < 1);
1123
1124         regs[n] = mux_config_l3_1;
1125         lens[n] = ARRAY_SIZE(mux_config_l3_1);
1126         n++;
1127
1128         return n;
1129 }
1130
1131 static const struct i915_oa_reg b_counter_config_l3_2[] = {
1132         { _MMIO(0x2740), 0x00000000 },
1133         { _MMIO(0x2744), 0x00800000 },
1134         { _MMIO(0x2710), 0x00000000 },
1135         { _MMIO(0x2714), 0xf0800000 },
1136         { _MMIO(0x2720), 0x00000000 },
1137         { _MMIO(0x2724), 0x00800000 },
1138         { _MMIO(0x2770), 0x00100070 },
1139         { _MMIO(0x2774), 0x0000fff1 },
1140         { _MMIO(0x2778), 0x00028002 },
1141         { _MMIO(0x277c), 0x000087ff },
1142         { _MMIO(0x2780), 0x00020002 },
1143         { _MMIO(0x2784), 0x00008fff },
1144         { _MMIO(0x2788), 0x00008002 },
1145         { _MMIO(0x278c), 0x0000a7ff },
1146 };
1147
1148 static const struct i915_oa_reg flex_eu_config_l3_2[] = {
1149         { _MMIO(0xe458), 0x00005004 },
1150         { _MMIO(0xe558), 0x00010003 },
1151         { _MMIO(0xe658), 0x00012011 },
1152         { _MMIO(0xe758), 0x00015014 },
1153         { _MMIO(0xe45c), 0x00051050 },
1154         { _MMIO(0xe55c), 0x00053052 },
1155         { _MMIO(0xe65c), 0x00055054 },
1156 };
1157
1158 static const struct i915_oa_reg mux_config_l3_2[] = {
1159         { _MMIO(0x9888), 0x126c02e0 },
1160         { _MMIO(0x9888), 0x146c0001 },
1161         { _MMIO(0x9888), 0x0a623400 },
1162         { _MMIO(0x9888), 0x044e8000 },
1163         { _MMIO(0x9888), 0x064e8000 },
1164         { _MMIO(0x9888), 0x084e8000 },
1165         { _MMIO(0x9888), 0x0a4e8000 },
1166         { _MMIO(0x9888), 0x064f4000 },
1167         { _MMIO(0x9888), 0x026c3324 },
1168         { _MMIO(0x9888), 0x046c3422 },
1169         { _MMIO(0x9888), 0x106c0000 },
1170         { _MMIO(0x9888), 0x1a6c0000 },
1171         { _MMIO(0x9888), 0x021bc000 },
1172         { _MMIO(0x9888), 0x041bc000 },
1173         { _MMIO(0x9888), 0x141c8000 },
1174         { _MMIO(0x9888), 0x161c8000 },
1175         { _MMIO(0x9888), 0x181c8000 },
1176         { _MMIO(0x9888), 0x1a1c0800 },
1177         { _MMIO(0x9888), 0x065b4000 },
1178         { _MMIO(0x9888), 0x1a5c1000 },
1179         { _MMIO(0x9888), 0x06614000 },
1180         { _MMIO(0x9888), 0x0c620044 },
1181         { _MMIO(0x9888), 0x10620000 },
1182         { _MMIO(0x9888), 0x06620000 },
1183         { _MMIO(0x9888), 0x084c8000 },
1184         { _MMIO(0x9888), 0x0a4c002a },
1185         { _MMIO(0x9888), 0x020da000 },
1186         { _MMIO(0x9888), 0x040da000 },
1187         { _MMIO(0x9888), 0x060d2000 },
1188         { _MMIO(0x9888), 0x0c0f4000 },
1189         { _MMIO(0x9888), 0x0e0f0055 },
1190         { _MMIO(0x9888), 0x042c8000 },
1191         { _MMIO(0x9888), 0x062c8000 },
1192         { _MMIO(0x9888), 0x082c8000 },
1193         { _MMIO(0x9888), 0x0a2c8000 },
1194         { _MMIO(0x9888), 0x0c2cc000 },
1195         { _MMIO(0x9888), 0x1190f800 },
1196         { _MMIO(0x9888), 0x37900000 },
1197         { _MMIO(0x9888), 0x51900000 },
1198         { _MMIO(0x9888), 0x43900000 },
1199         { _MMIO(0x9888), 0x53900000 },
1200         { _MMIO(0x9888), 0x45900000 },
1201         { _MMIO(0x9888), 0x33900000 },
1202 };
1203
1204 static int
1205 get_l3_2_mux_config(struct drm_i915_private *dev_priv,
1206                     const struct i915_oa_reg **regs,
1207                     int *lens)
1208 {
1209         int n = 0;
1210
1211         BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs) < 1);
1212         BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs_lens) < 1);
1213
1214         regs[n] = mux_config_l3_2;
1215         lens[n] = ARRAY_SIZE(mux_config_l3_2);
1216         n++;
1217
1218         return n;
1219 }
1220
1221 static const struct i915_oa_reg b_counter_config_l3_3[] = {
1222         { _MMIO(0x2740), 0x00000000 },
1223         { _MMIO(0x2744), 0x00800000 },
1224         { _MMIO(0x2710), 0x00000000 },
1225         { _MMIO(0x2714), 0xf0800000 },
1226         { _MMIO(0x2720), 0x00000000 },
1227         { _MMIO(0x2724), 0x00800000 },
1228         { _MMIO(0x2770), 0x00100070 },
1229         { _MMIO(0x2774), 0x0000fff1 },
1230         { _MMIO(0x2778), 0x00028002 },
1231         { _MMIO(0x277c), 0x000087ff },
1232         { _MMIO(0x2780), 0x00020002 },
1233         { _MMIO(0x2784), 0x00008fff },
1234         { _MMIO(0x2788), 0x00008002 },
1235         { _MMIO(0x278c), 0x0000a7ff },
1236 };
1237
1238 static const struct i915_oa_reg flex_eu_config_l3_3[] = {
1239         { _MMIO(0xe458), 0x00005004 },
1240         { _MMIO(0xe558), 0x00010003 },
1241         { _MMIO(0xe658), 0x00012011 },
1242         { _MMIO(0xe758), 0x00015014 },
1243         { _MMIO(0xe45c), 0x00051050 },
1244         { _MMIO(0xe55c), 0x00053052 },
1245         { _MMIO(0xe65c), 0x00055054 },
1246 };
1247
1248 static const struct i915_oa_reg mux_config_l3_3[] = {
1249         { _MMIO(0x9888), 0x126c4e80 },
1250         { _MMIO(0x9888), 0x146c0000 },
1251         { _MMIO(0x9888), 0x0a633400 },
1252         { _MMIO(0x9888), 0x044e8000 },
1253         { _MMIO(0x9888), 0x064e8000 },
1254         { _MMIO(0x9888), 0x084e8000 },
1255         { _MMIO(0x9888), 0x0a4e8000 },
1256         { _MMIO(0x9888), 0x0c4e8000 },
1257         { _MMIO(0x9888), 0x026c3321 },
1258         { _MMIO(0x9888), 0x046c342f },
1259         { _MMIO(0x9888), 0x106c0000 },
1260         { _MMIO(0x9888), 0x1a6c2000 },
1261         { _MMIO(0x9888), 0x021bc000 },
1262         { _MMIO(0x9888), 0x041bc000 },
1263         { _MMIO(0x9888), 0x061b4000 },
1264         { _MMIO(0x9888), 0x141c8000 },
1265         { _MMIO(0x9888), 0x161c8000 },
1266         { _MMIO(0x9888), 0x181c8000 },
1267         { _MMIO(0x9888), 0x1a1c1800 },
1268         { _MMIO(0x9888), 0x06604000 },
1269         { _MMIO(0x9888), 0x0c630044 },
1270         { _MMIO(0x9888), 0x10630000 },
1271         { _MMIO(0x9888), 0x06630000 },
1272         { _MMIO(0x9888), 0x084c8000 },
1273         { _MMIO(0x9888), 0x0a4c00aa },
1274         { _MMIO(0x9888), 0x020da000 },
1275         { _MMIO(0x9888), 0x040da000 },
1276         { _MMIO(0x9888), 0x060d2000 },
1277         { _MMIO(0x9888), 0x0c0f4000 },
1278         { _MMIO(0x9888), 0x0e0f0055 },
1279         { _MMIO(0x9888), 0x042c8000 },
1280         { _MMIO(0x9888), 0x062c8000 },
1281         { _MMIO(0x9888), 0x082c8000 },
1282         { _MMIO(0x9888), 0x0a2c8000 },
1283         { _MMIO(0x9888), 0x0c2c8000 },
1284         { _MMIO(0x9888), 0x1190f800 },
1285         { _MMIO(0x9888), 0x37900000 },
1286         { _MMIO(0x9888), 0x51900000 },
1287         { _MMIO(0x9888), 0x43900842 },
1288         { _MMIO(0x9888), 0x53900000 },
1289         { _MMIO(0x9888), 0x45900002 },
1290         { _MMIO(0x9888), 0x33900000 },
1291 };
1292
1293 static int
1294 get_l3_3_mux_config(struct drm_i915_private *dev_priv,
1295                     const struct i915_oa_reg **regs,
1296                     int *lens)
1297 {
1298         int n = 0;
1299
1300         BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs) < 1);
1301         BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs_lens) < 1);
1302
1303         regs[n] = mux_config_l3_3;
1304         lens[n] = ARRAY_SIZE(mux_config_l3_3);
1305         n++;
1306
1307         return n;
1308 }
1309
1310 static const struct i915_oa_reg b_counter_config_rasterizer_and_pixel_backend[] = {
1311         { _MMIO(0x2740), 0x00000000 },
1312         { _MMIO(0x2744), 0x00800000 },
1313         { _MMIO(0x2710), 0x00000000 },
1314         { _MMIO(0x2714), 0x30800000 },
1315         { _MMIO(0x2720), 0x00000000 },
1316         { _MMIO(0x2724), 0x00800000 },
1317         { _MMIO(0x2770), 0x00000002 },
1318         { _MMIO(0x2774), 0x0000efff },
1319         { _MMIO(0x2778), 0x00006000 },
1320         { _MMIO(0x277c), 0x0000f3ff },
1321 };
1322
1323 static const struct i915_oa_reg flex_eu_config_rasterizer_and_pixel_backend[] = {
1324         { _MMIO(0xe458), 0x00005004 },
1325         { _MMIO(0xe558), 0x00010003 },
1326         { _MMIO(0xe658), 0x00012011 },
1327         { _MMIO(0xe758), 0x00015014 },
1328         { _MMIO(0xe45c), 0x00051050 },
1329         { _MMIO(0xe55c), 0x00053052 },
1330         { _MMIO(0xe65c), 0x00055054 },
1331 };
1332
1333 static const struct i915_oa_reg mux_config_rasterizer_and_pixel_backend[] = {
1334         { _MMIO(0x9888), 0x102f3800 },
1335         { _MMIO(0x9888), 0x144d0500 },
1336         { _MMIO(0x9888), 0x120d03c0 },
1337         { _MMIO(0x9888), 0x140d03cf },
1338         { _MMIO(0x9888), 0x0c0f0004 },
1339         { _MMIO(0x9888), 0x0c4e4000 },
1340         { _MMIO(0x9888), 0x042f0480 },
1341         { _MMIO(0x9888), 0x082f0000 },
1342         { _MMIO(0x9888), 0x022f0000 },
1343         { _MMIO(0x9888), 0x0a4c0090 },
1344         { _MMIO(0x9888), 0x064d0027 },
1345         { _MMIO(0x9888), 0x004d0000 },
1346         { _MMIO(0x9888), 0x000d0d40 },
1347         { _MMIO(0x9888), 0x020d803f },
1348         { _MMIO(0x9888), 0x040d8023 },
1349         { _MMIO(0x9888), 0x100d0000 },
1350         { _MMIO(0x9888), 0x060d2000 },
1351         { _MMIO(0x9888), 0x020f0010 },
1352         { _MMIO(0x9888), 0x000f0000 },
1353         { _MMIO(0x9888), 0x0e0f0050 },
1354         { _MMIO(0x9888), 0x0a2c8000 },
1355         { _MMIO(0x9888), 0x0c2c8000 },
1356         { _MMIO(0x9888), 0x1190fc00 },
1357         { _MMIO(0x9888), 0x37900000 },
1358         { _MMIO(0x9888), 0x51900000 },
1359         { _MMIO(0x9888), 0x41901400 },
1360         { _MMIO(0x9888), 0x43901485 },
1361         { _MMIO(0x9888), 0x53900000 },
1362         { _MMIO(0x9888), 0x45900001 },
1363         { _MMIO(0x9888), 0x33900000 },
1364 };
1365
1366 static int
1367 get_rasterizer_and_pixel_backend_mux_config(struct drm_i915_private *dev_priv,
1368                                             const struct i915_oa_reg **regs,
1369                                             int *lens)
1370 {
1371         int n = 0;
1372
1373         BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs) < 1);
1374         BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs_lens) < 1);
1375
1376         regs[n] = mux_config_rasterizer_and_pixel_backend;
1377         lens[n] = ARRAY_SIZE(mux_config_rasterizer_and_pixel_backend);
1378         n++;
1379
1380         return n;
1381 }
1382
1383 static const struct i915_oa_reg b_counter_config_sampler[] = {
1384         { _MMIO(0x2740), 0x00000000 },
1385         { _MMIO(0x2744), 0x00800000 },
1386         { _MMIO(0x2710), 0x00000000 },
1387         { _MMIO(0x2714), 0x70800000 },
1388         { _MMIO(0x2720), 0x00000000 },
1389         { _MMIO(0x2724), 0x00800000 },
1390         { _MMIO(0x2770), 0x0000c000 },
1391         { _MMIO(0x2774), 0x0000e7ff },
1392         { _MMIO(0x2778), 0x00003000 },
1393         { _MMIO(0x277c), 0x0000f9ff },
1394         { _MMIO(0x2780), 0x00000c00 },
1395         { _MMIO(0x2784), 0x0000fe7f },
1396 };
1397
1398 static const struct i915_oa_reg flex_eu_config_sampler[] = {
1399         { _MMIO(0xe458), 0x00005004 },
1400         { _MMIO(0xe558), 0x00010003 },
1401         { _MMIO(0xe658), 0x00012011 },
1402         { _MMIO(0xe758), 0x00015014 },
1403         { _MMIO(0xe45c), 0x00051050 },
1404         { _MMIO(0xe55c), 0x00053052 },
1405         { _MMIO(0xe65c), 0x00055054 },
1406 };
1407
1408 static const struct i915_oa_reg mux_config_sampler[] = {
1409         { _MMIO(0x9888), 0x14152c00 },
1410         { _MMIO(0x9888), 0x16150005 },
1411         { _MMIO(0x9888), 0x121600a0 },
1412         { _MMIO(0x9888), 0x14352c00 },
1413         { _MMIO(0x9888), 0x16350005 },
1414         { _MMIO(0x9888), 0x123600a0 },
1415         { _MMIO(0x9888), 0x14552c00 },
1416         { _MMIO(0x9888), 0x16550005 },
1417         { _MMIO(0x9888), 0x125600a0 },
1418         { _MMIO(0x9888), 0x062f6000 },
1419         { _MMIO(0x9888), 0x022f2000 },
1420         { _MMIO(0x9888), 0x0c4c0050 },
1421         { _MMIO(0x9888), 0x0a4c0010 },
1422         { _MMIO(0x9888), 0x0c0d8000 },
1423         { _MMIO(0x9888), 0x0e0da000 },
1424         { _MMIO(0x9888), 0x000d8000 },
1425         { _MMIO(0x9888), 0x020da000 },
1426         { _MMIO(0x9888), 0x040da000 },
1427         { _MMIO(0x9888), 0x060d2000 },
1428         { _MMIO(0x9888), 0x100f0350 },
1429         { _MMIO(0x9888), 0x0c0fb000 },
1430         { _MMIO(0x9888), 0x0e0f00da },
1431         { _MMIO(0x9888), 0x182c0028 },
1432         { _MMIO(0x9888), 0x0a2c8000 },
1433         { _MMIO(0x9888), 0x022dc000 },
1434         { _MMIO(0x9888), 0x042d4000 },
1435         { _MMIO(0x9888), 0x0c138000 },
1436         { _MMIO(0x9888), 0x0e132000 },
1437         { _MMIO(0x9888), 0x0413c000 },
1438         { _MMIO(0x9888), 0x1c140018 },
1439         { _MMIO(0x9888), 0x0c157000 },
1440         { _MMIO(0x9888), 0x0e150078 },
1441         { _MMIO(0x9888), 0x10150000 },
1442         { _MMIO(0x9888), 0x04162180 },
1443         { _MMIO(0x9888), 0x02160000 },
1444         { _MMIO(0x9888), 0x04174000 },
1445         { _MMIO(0x9888), 0x0233a000 },
1446         { _MMIO(0x9888), 0x04333000 },
1447         { _MMIO(0x9888), 0x14348000 },
1448         { _MMIO(0x9888), 0x16348000 },
1449         { _MMIO(0x9888), 0x02357870 },
1450         { _MMIO(0x9888), 0x10350000 },
1451         { _MMIO(0x9888), 0x04360043 },
1452         { _MMIO(0x9888), 0x02360000 },
1453         { _MMIO(0x9888), 0x04371000 },
1454         { _MMIO(0x9888), 0x0e538000 },
1455         { _MMIO(0x9888), 0x00538000 },
1456         { _MMIO(0x9888), 0x06533000 },
1457         { _MMIO(0x9888), 0x1c540020 },
1458         { _MMIO(0x9888), 0x12548000 },
1459         { _MMIO(0x9888), 0x0e557000 },
1460         { _MMIO(0x9888), 0x00557800 },
1461         { _MMIO(0x9888), 0x10550000 },
1462         { _MMIO(0x9888), 0x06560043 },
1463         { _MMIO(0x9888), 0x02560000 },
1464         { _MMIO(0x9888), 0x06571000 },
1465         { _MMIO(0x9888), 0x1190ff80 },
1466         { _MMIO(0x9888), 0x57900000 },
1467         { _MMIO(0x9888), 0x49900000 },
1468         { _MMIO(0x9888), 0x37900000 },
1469         { _MMIO(0x9888), 0x33900000 },
1470         { _MMIO(0x9888), 0x4b900060 },
1471         { _MMIO(0x9888), 0x59900000 },
1472         { _MMIO(0x9888), 0x51900000 },
1473         { _MMIO(0x9888), 0x41900c00 },
1474         { _MMIO(0x9888), 0x43900842 },
1475         { _MMIO(0x9888), 0x53900000 },
1476         { _MMIO(0x9888), 0x45900060 },
1477 };
1478
1479 static int
1480 get_sampler_mux_config(struct drm_i915_private *dev_priv,
1481                        const struct i915_oa_reg **regs,
1482                        int *lens)
1483 {
1484         int n = 0;
1485
1486         BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs) < 1);
1487         BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs_lens) < 1);
1488
1489         regs[n] = mux_config_sampler;
1490         lens[n] = ARRAY_SIZE(mux_config_sampler);
1491         n++;
1492
1493         return n;
1494 }
1495
1496 static const struct i915_oa_reg b_counter_config_tdl_1[] = {
1497         { _MMIO(0x2740), 0x00000000 },
1498         { _MMIO(0x2744), 0x00800000 },
1499         { _MMIO(0x2710), 0x00000000 },
1500         { _MMIO(0x2714), 0xf0800000 },
1501         { _MMIO(0x2720), 0x00000000 },
1502         { _MMIO(0x2724), 0x30800000 },
1503         { _MMIO(0x2770), 0x00000002 },
1504         { _MMIO(0x2774), 0x00007fff },
1505         { _MMIO(0x2778), 0x00000000 },
1506         { _MMIO(0x277c), 0x00009fff },
1507         { _MMIO(0x2780), 0x00000002 },
1508         { _MMIO(0x2784), 0x0000efff },
1509         { _MMIO(0x2788), 0x00000000 },
1510         { _MMIO(0x278c), 0x0000f3ff },
1511         { _MMIO(0x2790), 0x00000002 },
1512         { _MMIO(0x2794), 0x0000fdff },
1513         { _MMIO(0x2798), 0x00000000 },
1514         { _MMIO(0x279c), 0x0000fe7f },
1515 };
1516
1517 static const struct i915_oa_reg flex_eu_config_tdl_1[] = {
1518         { _MMIO(0xe458), 0x00005004 },
1519         { _MMIO(0xe558), 0x00010003 },
1520         { _MMIO(0xe658), 0x00012011 },
1521         { _MMIO(0xe758), 0x00015014 },
1522         { _MMIO(0xe45c), 0x00051050 },
1523         { _MMIO(0xe55c), 0x00053052 },
1524         { _MMIO(0xe65c), 0x00055054 },
1525 };
1526
1527 static const struct i915_oa_reg mux_config_tdl_1[] = {
1528         { _MMIO(0x9888), 0x12120000 },
1529         { _MMIO(0x9888), 0x12320000 },
1530         { _MMIO(0x9888), 0x12520000 },
1531         { _MMIO(0x9888), 0x002f8000 },
1532         { _MMIO(0x9888), 0x022f3000 },
1533         { _MMIO(0x9888), 0x0a4c0015 },
1534         { _MMIO(0x9888), 0x0c0d8000 },
1535         { _MMIO(0x9888), 0x0e0da000 },
1536         { _MMIO(0x9888), 0x000d8000 },
1537         { _MMIO(0x9888), 0x020da000 },
1538         { _MMIO(0x9888), 0x040da000 },
1539         { _MMIO(0x9888), 0x060d2000 },
1540         { _MMIO(0x9888), 0x100f03a0 },
1541         { _MMIO(0x9888), 0x0c0ff000 },
1542         { _MMIO(0x9888), 0x0e0f0095 },
1543         { _MMIO(0x9888), 0x062c8000 },
1544         { _MMIO(0x9888), 0x082c8000 },
1545         { _MMIO(0x9888), 0x0a2c8000 },
1546         { _MMIO(0x9888), 0x0c2d8000 },
1547         { _MMIO(0x9888), 0x0e2d4000 },
1548         { _MMIO(0x9888), 0x062d4000 },
1549         { _MMIO(0x9888), 0x02108000 },
1550         { _MMIO(0x9888), 0x0410c000 },
1551         { _MMIO(0x9888), 0x02118000 },
1552         { _MMIO(0x9888), 0x0411c000 },
1553         { _MMIO(0x9888), 0x02121880 },
1554         { _MMIO(0x9888), 0x041219b5 },
1555         { _MMIO(0x9888), 0x00120000 },
1556         { _MMIO(0x9888), 0x02134000 },
1557         { _MMIO(0x9888), 0x04135000 },
1558         { _MMIO(0x9888), 0x0c308000 },
1559         { _MMIO(0x9888), 0x0e304000 },
1560         { _MMIO(0x9888), 0x06304000 },
1561         { _MMIO(0x9888), 0x0c318000 },
1562         { _MMIO(0x9888), 0x0e314000 },
1563         { _MMIO(0x9888), 0x06314000 },
1564         { _MMIO(0x9888), 0x0c321a80 },
1565         { _MMIO(0x9888), 0x0e320033 },
1566         { _MMIO(0x9888), 0x06320031 },
1567         { _MMIO(0x9888), 0x00320000 },
1568         { _MMIO(0x9888), 0x0c334000 },
1569         { _MMIO(0x9888), 0x0e331000 },
1570         { _MMIO(0x9888), 0x06331000 },
1571         { _MMIO(0x9888), 0x0e508000 },
1572         { _MMIO(0x9888), 0x00508000 },
1573         { _MMIO(0x9888), 0x02504000 },
1574         { _MMIO(0x9888), 0x0e518000 },
1575         { _MMIO(0x9888), 0x00518000 },
1576         { _MMIO(0x9888), 0x02514000 },
1577         { _MMIO(0x9888), 0x0e521880 },
1578         { _MMIO(0x9888), 0x00521a80 },
1579         { _MMIO(0x9888), 0x02520033 },
1580         { _MMIO(0x9888), 0x0e534000 },
1581         { _MMIO(0x9888), 0x00534000 },
1582         { _MMIO(0x9888), 0x02531000 },
1583         { _MMIO(0x9888), 0x1190ff80 },
1584         { _MMIO(0x9888), 0x57900000 },
1585         { _MMIO(0x9888), 0x49900800 },
1586         { _MMIO(0x9888), 0x37900000 },
1587         { _MMIO(0x9888), 0x33900000 },
1588         { _MMIO(0x9888), 0x4b900062 },
1589         { _MMIO(0x9888), 0x59900000 },
1590         { _MMIO(0x9888), 0x51900000 },
1591         { _MMIO(0x9888), 0x41900c00 },
1592         { _MMIO(0x9888), 0x43900003 },
1593         { _MMIO(0x9888), 0x53900000 },
1594         { _MMIO(0x9888), 0x45900040 },
1595 };
1596
1597 static int
1598 get_tdl_1_mux_config(struct drm_i915_private *dev_priv,
1599                      const struct i915_oa_reg **regs,
1600                      int *lens)
1601 {
1602         int n = 0;
1603
1604         BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs) < 1);
1605         BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs_lens) < 1);
1606
1607         regs[n] = mux_config_tdl_1;
1608         lens[n] = ARRAY_SIZE(mux_config_tdl_1);
1609         n++;
1610
1611         return n;
1612 }
1613
1614 static const struct i915_oa_reg b_counter_config_tdl_2[] = {
1615         { _MMIO(0x2740), 0x00000000 },
1616         { _MMIO(0x2744), 0x00800000 },
1617         { _MMIO(0x2710), 0x00000000 },
1618         { _MMIO(0x2714), 0x00800000 },
1619         { _MMIO(0x2720), 0x00000000 },
1620         { _MMIO(0x2724), 0x00800000 },
1621 };
1622
1623 static const struct i915_oa_reg flex_eu_config_tdl_2[] = {
1624         { _MMIO(0xe458), 0x00005004 },
1625         { _MMIO(0xe558), 0x00010003 },
1626         { _MMIO(0xe658), 0x00012011 },
1627         { _MMIO(0xe758), 0x00015014 },
1628         { _MMIO(0xe45c), 0x00051050 },
1629         { _MMIO(0xe55c), 0x00053052 },
1630         { _MMIO(0xe65c), 0x00055054 },
1631 };
1632
1633 static const struct i915_oa_reg mux_config_tdl_2[] = {
1634         { _MMIO(0x9888), 0x12124d60 },
1635         { _MMIO(0x9888), 0x12322e60 },
1636         { _MMIO(0x9888), 0x12524d60 },
1637         { _MMIO(0x9888), 0x022f3000 },
1638         { _MMIO(0x9888), 0x0a4c0014 },
1639         { _MMIO(0x9888), 0x000d8000 },
1640         { _MMIO(0x9888), 0x020da000 },
1641         { _MMIO(0x9888), 0x040da000 },
1642         { _MMIO(0x9888), 0x060d2000 },
1643         { _MMIO(0x9888), 0x0c0fe000 },
1644         { _MMIO(0x9888), 0x0e0f0097 },
1645         { _MMIO(0x9888), 0x082c8000 },
1646         { _MMIO(0x9888), 0x0a2c8000 },
1647         { _MMIO(0x9888), 0x002d8000 },
1648         { _MMIO(0x9888), 0x062d4000 },
1649         { _MMIO(0x9888), 0x0410c000 },
1650         { _MMIO(0x9888), 0x0411c000 },
1651         { _MMIO(0x9888), 0x04121fb7 },
1652         { _MMIO(0x9888), 0x00120000 },
1653         { _MMIO(0x9888), 0x04135000 },
1654         { _MMIO(0x9888), 0x00308000 },
1655         { _MMIO(0x9888), 0x06304000 },
1656         { _MMIO(0x9888), 0x00318000 },
1657         { _MMIO(0x9888), 0x06314000 },
1658         { _MMIO(0x9888), 0x00321b80 },
1659         { _MMIO(0x9888), 0x0632003f },
1660         { _MMIO(0x9888), 0x00334000 },
1661         { _MMIO(0x9888), 0x06331000 },
1662         { _MMIO(0x9888), 0x0250c000 },
1663         { _MMIO(0x9888), 0x0251c000 },
1664         { _MMIO(0x9888), 0x02521fb7 },
1665         { _MMIO(0x9888), 0x00520000 },
1666         { _MMIO(0x9888), 0x02535000 },
1667         { _MMIO(0x9888), 0x1190fc00 },
1668         { _MMIO(0x9888), 0x37900000 },
1669         { _MMIO(0x9888), 0x51900000 },
1670         { _MMIO(0x9888), 0x41900800 },
1671         { _MMIO(0x9888), 0x43900063 },
1672         { _MMIO(0x9888), 0x53900000 },
1673         { _MMIO(0x9888), 0x45900040 },
1674         { _MMIO(0x9888), 0x33900000 },
1675 };
1676
1677 static int
1678 get_tdl_2_mux_config(struct drm_i915_private *dev_priv,
1679                      const struct i915_oa_reg **regs,
1680                      int *lens)
1681 {
1682         int n = 0;
1683
1684         BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs) < 1);
1685         BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs_lens) < 1);
1686
1687         regs[n] = mux_config_tdl_2;
1688         lens[n] = ARRAY_SIZE(mux_config_tdl_2);
1689         n++;
1690
1691         return n;
1692 }
1693
1694 static const struct i915_oa_reg b_counter_config_compute_extra[] = {
1695 };
1696
1697 static const struct i915_oa_reg flex_eu_config_compute_extra[] = {
1698 };
1699
1700 static const struct i915_oa_reg mux_config_compute_extra[] = {
1701         { _MMIO(0x9888), 0x121203e0 },
1702         { _MMIO(0x9888), 0x123203e0 },
1703         { _MMIO(0x9888), 0x125203e0 },
1704         { _MMIO(0x9888), 0x129203e0 },
1705         { _MMIO(0x9888), 0x12b203e0 },
1706         { _MMIO(0x9888), 0x12d203e0 },
1707         { _MMIO(0x9888), 0x024ec000 },
1708         { _MMIO(0x9888), 0x044ec000 },
1709         { _MMIO(0x9888), 0x064ec000 },
1710         { _MMIO(0x9888), 0x022f4000 },
1711         { _MMIO(0x9888), 0x084ca000 },
1712         { _MMIO(0x9888), 0x0a4c0042 },
1713         { _MMIO(0x9888), 0x000d8000 },
1714         { _MMIO(0x9888), 0x020da000 },
1715         { _MMIO(0x9888), 0x040da000 },
1716         { _MMIO(0x9888), 0x060d2000 },
1717         { _MMIO(0x9888), 0x0c0f5000 },
1718         { _MMIO(0x9888), 0x0e0f006d },
1719         { _MMIO(0x9888), 0x022c8000 },
1720         { _MMIO(0x9888), 0x042c8000 },
1721         { _MMIO(0x9888), 0x062c8000 },
1722         { _MMIO(0x9888), 0x0c2c8000 },
1723         { _MMIO(0x9888), 0x042d8000 },
1724         { _MMIO(0x9888), 0x06104000 },
1725         { _MMIO(0x9888), 0x06114000 },
1726         { _MMIO(0x9888), 0x06120033 },
1727         { _MMIO(0x9888), 0x00120000 },
1728         { _MMIO(0x9888), 0x06131000 },
1729         { _MMIO(0x9888), 0x04308000 },
1730         { _MMIO(0x9888), 0x04318000 },
1731         { _MMIO(0x9888), 0x04321980 },
1732         { _MMIO(0x9888), 0x00320000 },
1733         { _MMIO(0x9888), 0x04334000 },
1734         { _MMIO(0x9888), 0x04504000 },
1735         { _MMIO(0x9888), 0x04514000 },
1736         { _MMIO(0x9888), 0x04520033 },
1737         { _MMIO(0x9888), 0x00520000 },
1738         { _MMIO(0x9888), 0x04531000 },
1739         { _MMIO(0x9888), 0x00af8000 },
1740         { _MMIO(0x9888), 0x0acc0001 },
1741         { _MMIO(0x9888), 0x008d8000 },
1742         { _MMIO(0x9888), 0x028da000 },
1743         { _MMIO(0x9888), 0x0c8fb000 },
1744         { _MMIO(0x9888), 0x0e8f0001 },
1745         { _MMIO(0x9888), 0x06ac8000 },
1746         { _MMIO(0x9888), 0x02ad4000 },
1747         { _MMIO(0x9888), 0x02908000 },
1748         { _MMIO(0x9888), 0x02918000 },
1749         { _MMIO(0x9888), 0x02921980 },
1750         { _MMIO(0x9888), 0x00920000 },
1751         { _MMIO(0x9888), 0x02934000 },
1752         { _MMIO(0x9888), 0x02b04000 },
1753         { _MMIO(0x9888), 0x02b14000 },
1754         { _MMIO(0x9888), 0x02b20033 },
1755         { _MMIO(0x9888), 0x00b20000 },
1756         { _MMIO(0x9888), 0x02b31000 },
1757         { _MMIO(0x9888), 0x00d08000 },
1758         { _MMIO(0x9888), 0x00d18000 },
1759         { _MMIO(0x9888), 0x00d21980 },
1760         { _MMIO(0x9888), 0x00d34000 },
1761         { _MMIO(0x9888), 0x1190fc00 },
1762         { _MMIO(0x9888), 0x37900000 },
1763         { _MMIO(0x9888), 0x51900000 },
1764         { _MMIO(0x9888), 0x41900c00 },
1765         { _MMIO(0x9888), 0x43900002 },
1766         { _MMIO(0x9888), 0x53900420 },
1767         { _MMIO(0x9888), 0x459000a1 },
1768         { _MMIO(0x9888), 0x33900000 },
1769 };
1770
1771 static int
1772 get_compute_extra_mux_config(struct drm_i915_private *dev_priv,
1773                              const struct i915_oa_reg **regs,
1774                              int *lens)
1775 {
1776         int n = 0;
1777
1778         BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs) < 1);
1779         BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs_lens) < 1);
1780
1781         regs[n] = mux_config_compute_extra;
1782         lens[n] = ARRAY_SIZE(mux_config_compute_extra);
1783         n++;
1784
1785         return n;
1786 }
1787
1788 static const struct i915_oa_reg b_counter_config_vme_pipe[] = {
1789         { _MMIO(0x2740), 0x00000000 },
1790         { _MMIO(0x2710), 0x00000000 },
1791         { _MMIO(0x2714), 0xf0800000 },
1792         { _MMIO(0x2720), 0x00000000 },
1793         { _MMIO(0x2724), 0x30800000 },
1794         { _MMIO(0x2770), 0x00100030 },
1795         { _MMIO(0x2774), 0x0000fff9 },
1796         { _MMIO(0x2778), 0x00000002 },
1797         { _MMIO(0x277c), 0x0000fffc },
1798         { _MMIO(0x2780), 0x00000002 },
1799         { _MMIO(0x2784), 0x0000fff3 },
1800         { _MMIO(0x2788), 0x00100180 },
1801         { _MMIO(0x278c), 0x0000ffcf },
1802         { _MMIO(0x2790), 0x00000002 },
1803         { _MMIO(0x2794), 0x0000ffcf },
1804         { _MMIO(0x2798), 0x00000002 },
1805         { _MMIO(0x279c), 0x0000ff3f },
1806 };
1807
1808 static const struct i915_oa_reg flex_eu_config_vme_pipe[] = {
1809         { _MMIO(0xe458), 0x00005004 },
1810         { _MMIO(0xe558), 0x00008003 },
1811 };
1812
1813 static const struct i915_oa_reg mux_config_vme_pipe[] = {
1814         { _MMIO(0x9888), 0x141a5800 },
1815         { _MMIO(0x9888), 0x161a00c0 },
1816         { _MMIO(0x9888), 0x12180240 },
1817         { _MMIO(0x9888), 0x14180002 },
1818         { _MMIO(0x9888), 0x149a5800 },
1819         { _MMIO(0x9888), 0x169a00c0 },
1820         { _MMIO(0x9888), 0x12980240 },
1821         { _MMIO(0x9888), 0x14980002 },
1822         { _MMIO(0x9888), 0x1a4e3fc0 },
1823         { _MMIO(0x9888), 0x002f1000 },
1824         { _MMIO(0x9888), 0x022f8000 },
1825         { _MMIO(0x9888), 0x042f3000 },
1826         { _MMIO(0x9888), 0x004c4000 },
1827         { _MMIO(0x9888), 0x0a4c9500 },
1828         { _MMIO(0x9888), 0x0c4c002a },
1829         { _MMIO(0x9888), 0x000d2000 },
1830         { _MMIO(0x9888), 0x060d8000 },
1831         { _MMIO(0x9888), 0x080da000 },
1832         { _MMIO(0x9888), 0x0a0da000 },
1833         { _MMIO(0x9888), 0x0c0da000 },
1834         { _MMIO(0x9888), 0x0c0f0400 },
1835         { _MMIO(0x9888), 0x0e0f5500 },
1836         { _MMIO(0x9888), 0x100f0015 },
1837         { _MMIO(0x9888), 0x002c8000 },
1838         { _MMIO(0x9888), 0x0e2c8000 },
1839         { _MMIO(0x9888), 0x162caa00 },
1840         { _MMIO(0x9888), 0x182c000a },
1841         { _MMIO(0x9888), 0x04193000 },
1842         { _MMIO(0x9888), 0x081a28c1 },
1843         { _MMIO(0x9888), 0x001a0000 },
1844         { _MMIO(0x9888), 0x00133000 },
1845         { _MMIO(0x9888), 0x0613c000 },
1846         { _MMIO(0x9888), 0x0813f000 },
1847         { _MMIO(0x9888), 0x00172000 },
1848         { _MMIO(0x9888), 0x06178000 },
1849         { _MMIO(0x9888), 0x0817a000 },
1850         { _MMIO(0x9888), 0x00180037 },
1851         { _MMIO(0x9888), 0x06180940 },
1852         { _MMIO(0x9888), 0x08180000 },
1853         { _MMIO(0x9888), 0x02180000 },
1854         { _MMIO(0x9888), 0x04183000 },
1855         { _MMIO(0x9888), 0x04afc000 },
1856         { _MMIO(0x9888), 0x06af3000 },
1857         { _MMIO(0x9888), 0x0acc4000 },
1858         { _MMIO(0x9888), 0x0ccc0015 },
1859         { _MMIO(0x9888), 0x0a8da000 },
1860         { _MMIO(0x9888), 0x0c8da000 },
1861         { _MMIO(0x9888), 0x0e8f4000 },
1862         { _MMIO(0x9888), 0x108f0015 },
1863         { _MMIO(0x9888), 0x16aca000 },
1864         { _MMIO(0x9888), 0x18ac000a },
1865         { _MMIO(0x9888), 0x06993000 },
1866         { _MMIO(0x9888), 0x0c9a28c1 },
1867         { _MMIO(0x9888), 0x009a0000 },
1868         { _MMIO(0x9888), 0x0a93f000 },
1869         { _MMIO(0x9888), 0x0c93f000 },
1870         { _MMIO(0x9888), 0x0a97a000 },
1871         { _MMIO(0x9888), 0x0c97a000 },
1872         { _MMIO(0x9888), 0x0a980977 },
1873         { _MMIO(0x9888), 0x08980000 },
1874         { _MMIO(0x9888), 0x04980000 },
1875         { _MMIO(0x9888), 0x06983000 },
1876         { _MMIO(0x9888), 0x119000ff },
1877         { _MMIO(0x9888), 0x51900040 },
1878         { _MMIO(0x9888), 0x41900020 },
1879         { _MMIO(0x9888), 0x55900004 },
1880         { _MMIO(0x9888), 0x45900400 },
1881         { _MMIO(0x9888), 0x479008a5 },
1882         { _MMIO(0x9888), 0x57900000 },
1883         { _MMIO(0x9888), 0x49900002 },
1884         { _MMIO(0x9888), 0x37900000 },
1885         { _MMIO(0x9888), 0x33900000 },
1886 };
1887
1888 static int
1889 get_vme_pipe_mux_config(struct drm_i915_private *dev_priv,
1890                         const struct i915_oa_reg **regs,
1891                         int *lens)
1892 {
1893         int n = 0;
1894
1895         BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs) < 1);
1896         BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs_lens) < 1);
1897
1898         regs[n] = mux_config_vme_pipe;
1899         lens[n] = ARRAY_SIZE(mux_config_vme_pipe);
1900         n++;
1901
1902         return n;
1903 }
1904
1905 static const struct i915_oa_reg b_counter_config_test_oa[] = {
1906         { _MMIO(0x2740), 0x00000000 },
1907         { _MMIO(0x2744), 0x00800000 },
1908         { _MMIO(0x2714), 0xf0800000 },
1909         { _MMIO(0x2710), 0x00000000 },
1910         { _MMIO(0x2724), 0xf0800000 },
1911         { _MMIO(0x2720), 0x00000000 },
1912         { _MMIO(0x2770), 0x00000004 },
1913         { _MMIO(0x2774), 0x00000000 },
1914         { _MMIO(0x2778), 0x00000003 },
1915         { _MMIO(0x277c), 0x00000000 },
1916         { _MMIO(0x2780), 0x00000007 },
1917         { _MMIO(0x2784), 0x00000000 },
1918         { _MMIO(0x2788), 0x00100002 },
1919         { _MMIO(0x278c), 0x0000fff7 },
1920         { _MMIO(0x2790), 0x00100002 },
1921         { _MMIO(0x2794), 0x0000ffcf },
1922         { _MMIO(0x2798), 0x00100082 },
1923         { _MMIO(0x279c), 0x0000ffef },
1924         { _MMIO(0x27a0), 0x001000c2 },
1925         { _MMIO(0x27a4), 0x0000ffe7 },
1926         { _MMIO(0x27a8), 0x00100001 },
1927         { _MMIO(0x27ac), 0x0000ffe7 },
1928 };
1929
1930 static const struct i915_oa_reg flex_eu_config_test_oa[] = {
1931 };
1932
1933 static const struct i915_oa_reg mux_config_test_oa[] = {
1934         { _MMIO(0x9888), 0x11810000 },
1935         { _MMIO(0x9888), 0x07810013 },
1936         { _MMIO(0x9888), 0x1f810000 },
1937         { _MMIO(0x9888), 0x1d810000 },
1938         { _MMIO(0x9888), 0x1b930040 },
1939         { _MMIO(0x9888), 0x07e54000 },
1940         { _MMIO(0x9888), 0x1f908000 },
1941         { _MMIO(0x9888), 0x11900000 },
1942         { _MMIO(0x9888), 0x37900000 },
1943         { _MMIO(0x9888), 0x53900000 },
1944         { _MMIO(0x9888), 0x45900000 },
1945         { _MMIO(0x9888), 0x33900000 },
1946 };
1947
1948 static int
1949 get_test_oa_mux_config(struct drm_i915_private *dev_priv,
1950                        const struct i915_oa_reg **regs,
1951                        int *lens)
1952 {
1953         int n = 0;
1954
1955         BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs) < 1);
1956         BUILD_BUG_ON(ARRAY_SIZE(dev_priv->perf.oa.mux_regs_lens) < 1);
1957
1958         regs[n] = mux_config_test_oa;
1959         lens[n] = ARRAY_SIZE(mux_config_test_oa);
1960         n++;
1961
1962         return n;
1963 }
1964
1965 int i915_oa_select_metric_set_kblgt3(struct drm_i915_private *dev_priv)
1966 {
1967         dev_priv->perf.oa.n_mux_configs = 0;
1968         dev_priv->perf.oa.b_counter_regs = NULL;
1969         dev_priv->perf.oa.b_counter_regs_len = 0;
1970         dev_priv->perf.oa.flex_regs = NULL;
1971         dev_priv->perf.oa.flex_regs_len = 0;
1972
1973         switch (dev_priv->perf.oa.metrics_set) {
1974         case METRIC_SET_ID_RENDER_BASIC:
1975                 dev_priv->perf.oa.n_mux_configs =
1976                         get_render_basic_mux_config(dev_priv,
1977                                                     dev_priv->perf.oa.mux_regs,
1978                                                     dev_priv->perf.oa.mux_regs_lens);
1979                 if (dev_priv->perf.oa.n_mux_configs == 0) {
1980                         DRM_DEBUG_DRIVER("No suitable MUX config for \"RENDER_BASIC\" metric set\n");
1981
1982                         /* EINVAL because *_register_sysfs already checked this
1983                          * and so it wouldn't have been advertised to userspace and
1984                          * so shouldn't have been requested
1985                          */
1986                         return -EINVAL;
1987                 }
1988
1989                 dev_priv->perf.oa.b_counter_regs =
1990                         b_counter_config_render_basic;
1991                 dev_priv->perf.oa.b_counter_regs_len =
1992                         ARRAY_SIZE(b_counter_config_render_basic);
1993
1994                 dev_priv->perf.oa.flex_regs =
1995                         flex_eu_config_render_basic;
1996                 dev_priv->perf.oa.flex_regs_len =
1997                         ARRAY_SIZE(flex_eu_config_render_basic);
1998
1999                 return 0;
2000         case METRIC_SET_ID_COMPUTE_BASIC:
2001                 dev_priv->perf.oa.n_mux_configs =
2002                         get_compute_basic_mux_config(dev_priv,
2003                                                      dev_priv->perf.oa.mux_regs,
2004                                                      dev_priv->perf.oa.mux_regs_lens);
2005                 if (dev_priv->perf.oa.n_mux_configs == 0) {
2006                         DRM_DEBUG_DRIVER("No suitable MUX config for \"COMPUTE_BASIC\" metric set\n");
2007
2008                         /* EINVAL because *_register_sysfs already checked this
2009                          * and so it wouldn't have been advertised to userspace and
2010                          * so shouldn't have been requested
2011                          */
2012                         return -EINVAL;
2013                 }
2014
2015                 dev_priv->perf.oa.b_counter_regs =
2016                         b_counter_config_compute_basic;
2017                 dev_priv->perf.oa.b_counter_regs_len =
2018                         ARRAY_SIZE(b_counter_config_compute_basic);
2019
2020                 dev_priv->perf.oa.flex_regs =
2021                         flex_eu_config_compute_basic;
2022                 dev_priv->perf.oa.flex_regs_len =
2023                         ARRAY_SIZE(flex_eu_config_compute_basic);
2024
2025                 return 0;
2026         case METRIC_SET_ID_RENDER_PIPE_PROFILE:
2027                 dev_priv->perf.oa.n_mux_configs =
2028                         get_render_pipe_profile_mux_config(dev_priv,
2029                                                            dev_priv->perf.oa.mux_regs,
2030                                                            dev_priv->perf.oa.mux_regs_lens);
2031                 if (dev_priv->perf.oa.n_mux_configs == 0) {
2032                         DRM_DEBUG_DRIVER("No suitable MUX config for \"RENDER_PIPE_PROFILE\" metric set\n");
2033
2034                         /* EINVAL because *_register_sysfs already checked this
2035                          * and so it wouldn't have been advertised to userspace and
2036                          * so shouldn't have been requested
2037                          */
2038                         return -EINVAL;
2039                 }
2040
2041                 dev_priv->perf.oa.b_counter_regs =
2042                         b_counter_config_render_pipe_profile;
2043                 dev_priv->perf.oa.b_counter_regs_len =
2044                         ARRAY_SIZE(b_counter_config_render_pipe_profile);
2045
2046                 dev_priv->perf.oa.flex_regs =
2047                         flex_eu_config_render_pipe_profile;
2048                 dev_priv->perf.oa.flex_regs_len =
2049                         ARRAY_SIZE(flex_eu_config_render_pipe_profile);
2050
2051                 return 0;
2052         case METRIC_SET_ID_MEMORY_READS:
2053                 dev_priv->perf.oa.n_mux_configs =
2054                         get_memory_reads_mux_config(dev_priv,
2055                                                     dev_priv->perf.oa.mux_regs,
2056                                                     dev_priv->perf.oa.mux_regs_lens);
2057                 if (dev_priv->perf.oa.n_mux_configs == 0) {
2058                         DRM_DEBUG_DRIVER("No suitable MUX config for \"MEMORY_READS\" metric set\n");
2059
2060                         /* EINVAL because *_register_sysfs already checked this
2061                          * and so it wouldn't have been advertised to userspace and
2062                          * so shouldn't have been requested
2063                          */
2064                         return -EINVAL;
2065                 }
2066
2067                 dev_priv->perf.oa.b_counter_regs =
2068                         b_counter_config_memory_reads;
2069                 dev_priv->perf.oa.b_counter_regs_len =
2070                         ARRAY_SIZE(b_counter_config_memory_reads);
2071
2072                 dev_priv->perf.oa.flex_regs =
2073                         flex_eu_config_memory_reads;
2074                 dev_priv->perf.oa.flex_regs_len =
2075                         ARRAY_SIZE(flex_eu_config_memory_reads);
2076
2077                 return 0;
2078         case METRIC_SET_ID_MEMORY_WRITES:
2079                 dev_priv->perf.oa.n_mux_configs =
2080                         get_memory_writes_mux_config(dev_priv,
2081                                                      dev_priv->perf.oa.mux_regs,
2082                                                      dev_priv->perf.oa.mux_regs_lens);
2083                 if (dev_priv->perf.oa.n_mux_configs == 0) {
2084                         DRM_DEBUG_DRIVER("No suitable MUX config for \"MEMORY_WRITES\" metric set\n");
2085
2086                         /* EINVAL because *_register_sysfs already checked this
2087                          * and so it wouldn't have been advertised to userspace and
2088                          * so shouldn't have been requested
2089                          */
2090                         return -EINVAL;
2091                 }
2092
2093                 dev_priv->perf.oa.b_counter_regs =
2094                         b_counter_config_memory_writes;
2095                 dev_priv->perf.oa.b_counter_regs_len =
2096                         ARRAY_SIZE(b_counter_config_memory_writes);
2097
2098                 dev_priv->perf.oa.flex_regs =
2099                         flex_eu_config_memory_writes;
2100                 dev_priv->perf.oa.flex_regs_len =
2101                         ARRAY_SIZE(flex_eu_config_memory_writes);
2102
2103                 return 0;
2104         case METRIC_SET_ID_COMPUTE_EXTENDED:
2105                 dev_priv->perf.oa.n_mux_configs =
2106                         get_compute_extended_mux_config(dev_priv,
2107                                                         dev_priv->perf.oa.mux_regs,
2108                                                         dev_priv->perf.oa.mux_regs_lens);
2109                 if (dev_priv->perf.oa.n_mux_configs == 0) {
2110                         DRM_DEBUG_DRIVER("No suitable MUX config for \"COMPUTE_EXTENDED\" metric set\n");
2111
2112                         /* EINVAL because *_register_sysfs already checked this
2113                          * and so it wouldn't have been advertised to userspace and
2114                          * so shouldn't have been requested
2115                          */
2116                         return -EINVAL;
2117                 }
2118
2119                 dev_priv->perf.oa.b_counter_regs =
2120                         b_counter_config_compute_extended;
2121                 dev_priv->perf.oa.b_counter_regs_len =
2122                         ARRAY_SIZE(b_counter_config_compute_extended);
2123
2124                 dev_priv->perf.oa.flex_regs =
2125                         flex_eu_config_compute_extended;
2126                 dev_priv->perf.oa.flex_regs_len =
2127                         ARRAY_SIZE(flex_eu_config_compute_extended);
2128
2129                 return 0;
2130         case METRIC_SET_ID_COMPUTE_L3_CACHE:
2131                 dev_priv->perf.oa.n_mux_configs =
2132                         get_compute_l3_cache_mux_config(dev_priv,
2133                                                         dev_priv->perf.oa.mux_regs,
2134                                                         dev_priv->perf.oa.mux_regs_lens);
2135                 if (dev_priv->perf.oa.n_mux_configs == 0) {
2136                         DRM_DEBUG_DRIVER("No suitable MUX config for \"COMPUTE_L3_CACHE\" metric set\n");
2137
2138                         /* EINVAL because *_register_sysfs already checked this
2139                          * and so it wouldn't have been advertised to userspace and
2140                          * so shouldn't have been requested
2141                          */
2142                         return -EINVAL;
2143                 }
2144
2145                 dev_priv->perf.oa.b_counter_regs =
2146                         b_counter_config_compute_l3_cache;
2147                 dev_priv->perf.oa.b_counter_regs_len =
2148                         ARRAY_SIZE(b_counter_config_compute_l3_cache);
2149
2150                 dev_priv->perf.oa.flex_regs =
2151                         flex_eu_config_compute_l3_cache;
2152                 dev_priv->perf.oa.flex_regs_len =
2153                         ARRAY_SIZE(flex_eu_config_compute_l3_cache);
2154
2155                 return 0;
2156         case METRIC_SET_ID_HDC_AND_SF:
2157                 dev_priv->perf.oa.n_mux_configs =
2158                         get_hdc_and_sf_mux_config(dev_priv,
2159                                                   dev_priv->perf.oa.mux_regs,
2160                                                   dev_priv->perf.oa.mux_regs_lens);
2161                 if (dev_priv->perf.oa.n_mux_configs == 0) {
2162                         DRM_DEBUG_DRIVER("No suitable MUX config for \"HDC_AND_SF\" metric set\n");
2163
2164                         /* EINVAL because *_register_sysfs already checked this
2165                          * and so it wouldn't have been advertised to userspace and
2166                          * so shouldn't have been requested
2167                          */
2168                         return -EINVAL;
2169                 }
2170
2171                 dev_priv->perf.oa.b_counter_regs =
2172                         b_counter_config_hdc_and_sf;
2173                 dev_priv->perf.oa.b_counter_regs_len =
2174                         ARRAY_SIZE(b_counter_config_hdc_and_sf);
2175
2176                 dev_priv->perf.oa.flex_regs =
2177                         flex_eu_config_hdc_and_sf;
2178                 dev_priv->perf.oa.flex_regs_len =
2179                         ARRAY_SIZE(flex_eu_config_hdc_and_sf);
2180
2181                 return 0;
2182         case METRIC_SET_ID_L3_1:
2183                 dev_priv->perf.oa.n_mux_configs =
2184                         get_l3_1_mux_config(dev_priv,
2185                                             dev_priv->perf.oa.mux_regs,
2186                                             dev_priv->perf.oa.mux_regs_lens);
2187                 if (dev_priv->perf.oa.n_mux_configs == 0) {
2188                         DRM_DEBUG_DRIVER("No suitable MUX config for \"L3_1\" metric set\n");
2189
2190                         /* EINVAL because *_register_sysfs already checked this
2191                          * and so it wouldn't have been advertised to userspace and
2192                          * so shouldn't have been requested
2193                          */
2194                         return -EINVAL;
2195                 }
2196
2197                 dev_priv->perf.oa.b_counter_regs =
2198                         b_counter_config_l3_1;
2199                 dev_priv->perf.oa.b_counter_regs_len =
2200                         ARRAY_SIZE(b_counter_config_l3_1);
2201
2202                 dev_priv->perf.oa.flex_regs =
2203                         flex_eu_config_l3_1;
2204                 dev_priv->perf.oa.flex_regs_len =
2205                         ARRAY_SIZE(flex_eu_config_l3_1);
2206
2207                 return 0;
2208         case METRIC_SET_ID_L3_2:
2209                 dev_priv->perf.oa.n_mux_configs =
2210                         get_l3_2_mux_config(dev_priv,
2211                                             dev_priv->perf.oa.mux_regs,
2212                                             dev_priv->perf.oa.mux_regs_lens);
2213                 if (dev_priv->perf.oa.n_mux_configs == 0) {
2214                         DRM_DEBUG_DRIVER("No suitable MUX config for \"L3_2\" metric set\n");
2215
2216                         /* EINVAL because *_register_sysfs already checked this
2217                          * and so it wouldn't have been advertised to userspace and
2218                          * so shouldn't have been requested
2219                          */
2220                         return -EINVAL;
2221                 }
2222
2223                 dev_priv->perf.oa.b_counter_regs =
2224                         b_counter_config_l3_2;
2225                 dev_priv->perf.oa.b_counter_regs_len =
2226                         ARRAY_SIZE(b_counter_config_l3_2);
2227
2228                 dev_priv->perf.oa.flex_regs =
2229                         flex_eu_config_l3_2;
2230                 dev_priv->perf.oa.flex_regs_len =
2231                         ARRAY_SIZE(flex_eu_config_l3_2);
2232
2233                 return 0;
2234         case METRIC_SET_ID_L3_3:
2235                 dev_priv->perf.oa.n_mux_configs =
2236                         get_l3_3_mux_config(dev_priv,
2237                                             dev_priv->perf.oa.mux_regs,
2238                                             dev_priv->perf.oa.mux_regs_lens);
2239                 if (dev_priv->perf.oa.n_mux_configs == 0) {
2240                         DRM_DEBUG_DRIVER("No suitable MUX config for \"L3_3\" metric set\n");
2241
2242                         /* EINVAL because *_register_sysfs already checked this
2243                          * and so it wouldn't have been advertised to userspace and
2244                          * so shouldn't have been requested
2245                          */
2246                         return -EINVAL;
2247                 }
2248
2249                 dev_priv->perf.oa.b_counter_regs =
2250                         b_counter_config_l3_3;
2251                 dev_priv->perf.oa.b_counter_regs_len =
2252                         ARRAY_SIZE(b_counter_config_l3_3);
2253
2254                 dev_priv->perf.oa.flex_regs =
2255                         flex_eu_config_l3_3;
2256                 dev_priv->perf.oa.flex_regs_len =
2257                         ARRAY_SIZE(flex_eu_config_l3_3);
2258
2259                 return 0;
2260         case METRIC_SET_ID_RASTERIZER_AND_PIXEL_BACKEND:
2261                 dev_priv->perf.oa.n_mux_configs =
2262                         get_rasterizer_and_pixel_backend_mux_config(dev_priv,
2263                                                                     dev_priv->perf.oa.mux_regs,
2264                                                                     dev_priv->perf.oa.mux_regs_lens);
2265                 if (dev_priv->perf.oa.n_mux_configs == 0) {
2266                         DRM_DEBUG_DRIVER("No suitable MUX config for \"RASTERIZER_AND_PIXEL_BACKEND\" metric set\n");
2267
2268                         /* EINVAL because *_register_sysfs already checked this
2269                          * and so it wouldn't have been advertised to userspace and
2270                          * so shouldn't have been requested
2271                          */
2272                         return -EINVAL;
2273                 }
2274
2275                 dev_priv->perf.oa.b_counter_regs =
2276                         b_counter_config_rasterizer_and_pixel_backend;
2277                 dev_priv->perf.oa.b_counter_regs_len =
2278                         ARRAY_SIZE(b_counter_config_rasterizer_and_pixel_backend);
2279
2280                 dev_priv->perf.oa.flex_regs =
2281                         flex_eu_config_rasterizer_and_pixel_backend;
2282                 dev_priv->perf.oa.flex_regs_len =
2283                         ARRAY_SIZE(flex_eu_config_rasterizer_and_pixel_backend);
2284
2285                 return 0;
2286         case METRIC_SET_ID_SAMPLER:
2287                 dev_priv->perf.oa.n_mux_configs =
2288                         get_sampler_mux_config(dev_priv,
2289                                                dev_priv->perf.oa.mux_regs,
2290                                                dev_priv->perf.oa.mux_regs_lens);
2291                 if (dev_priv->perf.oa.n_mux_configs == 0) {
2292                         DRM_DEBUG_DRIVER("No suitable MUX config for \"SAMPLER\" metric set\n");
2293
2294                         /* EINVAL because *_register_sysfs already checked this
2295                          * and so it wouldn't have been advertised to userspace and
2296                          * so shouldn't have been requested
2297                          */
2298                         return -EINVAL;
2299                 }
2300
2301                 dev_priv->perf.oa.b_counter_regs =
2302                         b_counter_config_sampler;
2303                 dev_priv->perf.oa.b_counter_regs_len =
2304                         ARRAY_SIZE(b_counter_config_sampler);
2305
2306                 dev_priv->perf.oa.flex_regs =
2307                         flex_eu_config_sampler;
2308                 dev_priv->perf.oa.flex_regs_len =
2309                         ARRAY_SIZE(flex_eu_config_sampler);
2310
2311                 return 0;
2312         case METRIC_SET_ID_TDL_1:
2313                 dev_priv->perf.oa.n_mux_configs =
2314                         get_tdl_1_mux_config(dev_priv,
2315                                              dev_priv->perf.oa.mux_regs,
2316                                              dev_priv->perf.oa.mux_regs_lens);
2317                 if (dev_priv->perf.oa.n_mux_configs == 0) {
2318                         DRM_DEBUG_DRIVER("No suitable MUX config for \"TDL_1\" metric set\n");
2319
2320                         /* EINVAL because *_register_sysfs already checked this
2321                          * and so it wouldn't have been advertised to userspace and
2322                          * so shouldn't have been requested
2323                          */
2324                         return -EINVAL;
2325                 }
2326
2327                 dev_priv->perf.oa.b_counter_regs =
2328                         b_counter_config_tdl_1;
2329                 dev_priv->perf.oa.b_counter_regs_len =
2330                         ARRAY_SIZE(b_counter_config_tdl_1);
2331
2332                 dev_priv->perf.oa.flex_regs =
2333                         flex_eu_config_tdl_1;
2334                 dev_priv->perf.oa.flex_regs_len =
2335                         ARRAY_SIZE(flex_eu_config_tdl_1);
2336
2337                 return 0;
2338         case METRIC_SET_ID_TDL_2:
2339                 dev_priv->perf.oa.n_mux_configs =
2340                         get_tdl_2_mux_config(dev_priv,
2341                                              dev_priv->perf.oa.mux_regs,
2342                                              dev_priv->perf.oa.mux_regs_lens);
2343                 if (dev_priv->perf.oa.n_mux_configs == 0) {
2344                         DRM_DEBUG_DRIVER("No suitable MUX config for \"TDL_2\" metric set\n");
2345
2346                         /* EINVAL because *_register_sysfs already checked this
2347                          * and so it wouldn't have been advertised to userspace and
2348                          * so shouldn't have been requested
2349                          */
2350                         return -EINVAL;
2351                 }
2352
2353                 dev_priv->perf.oa.b_counter_regs =
2354                         b_counter_config_tdl_2;
2355                 dev_priv->perf.oa.b_counter_regs_len =
2356                         ARRAY_SIZE(b_counter_config_tdl_2);
2357
2358                 dev_priv->perf.oa.flex_regs =
2359                         flex_eu_config_tdl_2;
2360                 dev_priv->perf.oa.flex_regs_len =
2361                         ARRAY_SIZE(flex_eu_config_tdl_2);
2362
2363                 return 0;
2364         case METRIC_SET_ID_COMPUTE_EXTRA:
2365                 dev_priv->perf.oa.n_mux_configs =
2366                         get_compute_extra_mux_config(dev_priv,
2367                                                      dev_priv->perf.oa.mux_regs,
2368                                                      dev_priv->perf.oa.mux_regs_lens);
2369                 if (dev_priv->perf.oa.n_mux_configs == 0) {
2370                         DRM_DEBUG_DRIVER("No suitable MUX config for \"COMPUTE_EXTRA\" metric set\n");
2371
2372                         /* EINVAL because *_register_sysfs already checked this
2373                          * and so it wouldn't have been advertised to userspace and
2374                          * so shouldn't have been requested
2375                          */
2376                         return -EINVAL;
2377                 }
2378
2379                 dev_priv->perf.oa.b_counter_regs =
2380                         b_counter_config_compute_extra;
2381                 dev_priv->perf.oa.b_counter_regs_len =
2382                         ARRAY_SIZE(b_counter_config_compute_extra);
2383
2384                 dev_priv->perf.oa.flex_regs =
2385                         flex_eu_config_compute_extra;
2386                 dev_priv->perf.oa.flex_regs_len =
2387                         ARRAY_SIZE(flex_eu_config_compute_extra);
2388
2389                 return 0;
2390         case METRIC_SET_ID_VME_PIPE:
2391                 dev_priv->perf.oa.n_mux_configs =
2392                         get_vme_pipe_mux_config(dev_priv,
2393                                                 dev_priv->perf.oa.mux_regs,
2394                                                 dev_priv->perf.oa.mux_regs_lens);
2395                 if (dev_priv->perf.oa.n_mux_configs == 0) {
2396                         DRM_DEBUG_DRIVER("No suitable MUX config for \"VME_PIPE\" metric set\n");
2397
2398                         /* EINVAL because *_register_sysfs already checked this
2399                          * and so it wouldn't have been advertised to userspace and
2400                          * so shouldn't have been requested
2401                          */
2402                         return -EINVAL;
2403                 }
2404
2405                 dev_priv->perf.oa.b_counter_regs =
2406                         b_counter_config_vme_pipe;
2407                 dev_priv->perf.oa.b_counter_regs_len =
2408                         ARRAY_SIZE(b_counter_config_vme_pipe);
2409
2410                 dev_priv->perf.oa.flex_regs =
2411                         flex_eu_config_vme_pipe;
2412                 dev_priv->perf.oa.flex_regs_len =
2413                         ARRAY_SIZE(flex_eu_config_vme_pipe);
2414
2415                 return 0;
2416         case METRIC_SET_ID_TEST_OA:
2417                 dev_priv->perf.oa.n_mux_configs =
2418                         get_test_oa_mux_config(dev_priv,
2419                                                dev_priv->perf.oa.mux_regs,
2420                                                dev_priv->perf.oa.mux_regs_lens);
2421                 if (dev_priv->perf.oa.n_mux_configs == 0) {
2422                         DRM_DEBUG_DRIVER("No suitable MUX config for \"TEST_OA\" metric set\n");
2423
2424                         /* EINVAL because *_register_sysfs already checked this
2425                          * and so it wouldn't have been advertised to userspace and
2426                          * so shouldn't have been requested
2427                          */
2428                         return -EINVAL;
2429                 }
2430
2431                 dev_priv->perf.oa.b_counter_regs =
2432                         b_counter_config_test_oa;
2433                 dev_priv->perf.oa.b_counter_regs_len =
2434                         ARRAY_SIZE(b_counter_config_test_oa);
2435
2436                 dev_priv->perf.oa.flex_regs =
2437                         flex_eu_config_test_oa;
2438                 dev_priv->perf.oa.flex_regs_len =
2439                         ARRAY_SIZE(flex_eu_config_test_oa);
2440
2441                 return 0;
2442         default:
2443                 return -ENODEV;
2444         }
2445 }
2446
2447 static ssize_t
2448 show_render_basic_id(struct device *kdev, struct device_attribute *attr, char *buf)
2449 {
2450         return sprintf(buf, "%d\n", METRIC_SET_ID_RENDER_BASIC);
2451 }
2452
2453 static struct device_attribute dev_attr_render_basic_id = {
2454         .attr = { .name = "id", .mode = 0444 },
2455         .show = show_render_basic_id,
2456         .store = NULL,
2457 };
2458
2459 static struct attribute *attrs_render_basic[] = {
2460         &dev_attr_render_basic_id.attr,
2461         NULL,
2462 };
2463
2464 static struct attribute_group group_render_basic = {
2465         .name = "0286c920-2f6d-493b-b22d-7a5280df43de",
2466         .attrs =  attrs_render_basic,
2467 };
2468
2469 static ssize_t
2470 show_compute_basic_id(struct device *kdev, struct device_attribute *attr, char *buf)
2471 {
2472         return sprintf(buf, "%d\n", METRIC_SET_ID_COMPUTE_BASIC);
2473 }
2474
2475 static struct device_attribute dev_attr_compute_basic_id = {
2476         .attr = { .name = "id", .mode = 0444 },
2477         .show = show_compute_basic_id,
2478         .store = NULL,
2479 };
2480
2481 static struct attribute *attrs_compute_basic[] = {
2482         &dev_attr_compute_basic_id.attr,
2483         NULL,
2484 };
2485
2486 static struct attribute_group group_compute_basic = {
2487         .name = "9823aaa1-b06f-40ce-884b-cd798c79f0c2",
2488         .attrs =  attrs_compute_basic,
2489 };
2490
2491 static ssize_t
2492 show_render_pipe_profile_id(struct device *kdev, struct device_attribute *attr, char *buf)
2493 {
2494         return sprintf(buf, "%d\n", METRIC_SET_ID_RENDER_PIPE_PROFILE);
2495 }
2496
2497 static struct device_attribute dev_attr_render_pipe_profile_id = {
2498         .attr = { .name = "id", .mode = 0444 },
2499         .show = show_render_pipe_profile_id,
2500         .store = NULL,
2501 };
2502
2503 static struct attribute *attrs_render_pipe_profile[] = {
2504         &dev_attr_render_pipe_profile_id.attr,
2505         NULL,
2506 };
2507
2508 static struct attribute_group group_render_pipe_profile = {
2509         .name = "c7c735f3-ce58-45cf-aa04-30b183f1faff",
2510         .attrs =  attrs_render_pipe_profile,
2511 };
2512
2513 static ssize_t
2514 show_memory_reads_id(struct device *kdev, struct device_attribute *attr, char *buf)
2515 {
2516         return sprintf(buf, "%d\n", METRIC_SET_ID_MEMORY_READS);
2517 }
2518
2519 static struct device_attribute dev_attr_memory_reads_id = {
2520         .attr = { .name = "id", .mode = 0444 },
2521         .show = show_memory_reads_id,
2522         .store = NULL,
2523 };
2524
2525 static struct attribute *attrs_memory_reads[] = {
2526         &dev_attr_memory_reads_id.attr,
2527         NULL,
2528 };
2529
2530 static struct attribute_group group_memory_reads = {
2531         .name = "96ec2219-040b-428a-856a-6bc03363a057",
2532         .attrs =  attrs_memory_reads,
2533 };
2534
2535 static ssize_t
2536 show_memory_writes_id(struct device *kdev, struct device_attribute *attr, char *buf)
2537 {
2538         return sprintf(buf, "%d\n", METRIC_SET_ID_MEMORY_WRITES);
2539 }
2540
2541 static struct device_attribute dev_attr_memory_writes_id = {
2542         .attr = { .name = "id", .mode = 0444 },
2543         .show = show_memory_writes_id,
2544         .store = NULL,
2545 };
2546
2547 static struct attribute *attrs_memory_writes[] = {
2548         &dev_attr_memory_writes_id.attr,
2549         NULL,
2550 };
2551
2552 static struct attribute_group group_memory_writes = {
2553         .name = "03372b64-4996-4d3b-aa18-790e75eeb9c2",
2554         .attrs =  attrs_memory_writes,
2555 };
2556
2557 static ssize_t
2558 show_compute_extended_id(struct device *kdev, struct device_attribute *attr, char *buf)
2559 {
2560         return sprintf(buf, "%d\n", METRIC_SET_ID_COMPUTE_EXTENDED);
2561 }
2562
2563 static struct device_attribute dev_attr_compute_extended_id = {
2564         .attr = { .name = "id", .mode = 0444 },
2565         .show = show_compute_extended_id,
2566         .store = NULL,
2567 };
2568
2569 static struct attribute *attrs_compute_extended[] = {
2570         &dev_attr_compute_extended_id.attr,
2571         NULL,
2572 };
2573
2574 static struct attribute_group group_compute_extended = {
2575         .name = "31b4ce5a-bd61-4c1f-bb5d-f2e731412150",
2576         .attrs =  attrs_compute_extended,
2577 };
2578
2579 static ssize_t
2580 show_compute_l3_cache_id(struct device *kdev, struct device_attribute *attr, char *buf)
2581 {
2582         return sprintf(buf, "%d\n", METRIC_SET_ID_COMPUTE_L3_CACHE);
2583 }
2584
2585 static struct device_attribute dev_attr_compute_l3_cache_id = {
2586         .attr = { .name = "id", .mode = 0444 },
2587         .show = show_compute_l3_cache_id,
2588         .store = NULL,
2589 };
2590
2591 static struct attribute *attrs_compute_l3_cache[] = {
2592         &dev_attr_compute_l3_cache_id.attr,
2593         NULL,
2594 };
2595
2596 static struct attribute_group group_compute_l3_cache = {
2597         .name = "2ce0911a-27fc-4887-96f0-11084fa807c3",
2598         .attrs =  attrs_compute_l3_cache,
2599 };
2600
2601 static ssize_t
2602 show_hdc_and_sf_id(struct device *kdev, struct device_attribute *attr, char *buf)
2603 {
2604         return sprintf(buf, "%d\n", METRIC_SET_ID_HDC_AND_SF);
2605 }
2606
2607 static struct device_attribute dev_attr_hdc_and_sf_id = {
2608         .attr = { .name = "id", .mode = 0444 },
2609         .show = show_hdc_and_sf_id,
2610         .store = NULL,
2611 };
2612
2613 static struct attribute *attrs_hdc_and_sf[] = {
2614         &dev_attr_hdc_and_sf_id.attr,
2615         NULL,
2616 };
2617
2618 static struct attribute_group group_hdc_and_sf = {
2619         .name = "546c4c1d-99b8-42fb-a107-5aaabb5314a8",
2620         .attrs =  attrs_hdc_and_sf,
2621 };
2622
2623 static ssize_t
2624 show_l3_1_id(struct device *kdev, struct device_attribute *attr, char *buf)
2625 {
2626         return sprintf(buf, "%d\n", METRIC_SET_ID_L3_1);
2627 }
2628
2629 static struct device_attribute dev_attr_l3_1_id = {
2630         .attr = { .name = "id", .mode = 0444 },
2631         .show = show_l3_1_id,
2632         .store = NULL,
2633 };
2634
2635 static struct attribute *attrs_l3_1[] = {
2636         &dev_attr_l3_1_id.attr,
2637         NULL,
2638 };
2639
2640 static struct attribute_group group_l3_1 = {
2641         .name = "4e93d156-9b39-4268-8544-a8e0480806d7",
2642         .attrs =  attrs_l3_1,
2643 };
2644
2645 static ssize_t
2646 show_l3_2_id(struct device *kdev, struct device_attribute *attr, char *buf)
2647 {
2648         return sprintf(buf, "%d\n", METRIC_SET_ID_L3_2);
2649 }
2650
2651 static struct device_attribute dev_attr_l3_2_id = {
2652         .attr = { .name = "id", .mode = 0444 },
2653         .show = show_l3_2_id,
2654         .store = NULL,
2655 };
2656
2657 static struct attribute *attrs_l3_2[] = {
2658         &dev_attr_l3_2_id.attr,
2659         NULL,
2660 };
2661
2662 static struct attribute_group group_l3_2 = {
2663         .name = "de1bec86-ca92-4b43-89fa-147653221cc0",
2664         .attrs =  attrs_l3_2,
2665 };
2666
2667 static ssize_t
2668 show_l3_3_id(struct device *kdev, struct device_attribute *attr, char *buf)
2669 {
2670         return sprintf(buf, "%d\n", METRIC_SET_ID_L3_3);
2671 }
2672
2673 static struct device_attribute dev_attr_l3_3_id = {
2674         .attr = { .name = "id", .mode = 0444 },
2675         .show = show_l3_3_id,
2676         .store = NULL,
2677 };
2678
2679 static struct attribute *attrs_l3_3[] = {
2680         &dev_attr_l3_3_id.attr,
2681         NULL,
2682 };
2683
2684 static struct attribute_group group_l3_3 = {
2685         .name = "e63537bb-10be-4d4a-92c4-c6b0c65e02ef",
2686         .attrs =  attrs_l3_3,
2687 };
2688
2689 static ssize_t
2690 show_rasterizer_and_pixel_backend_id(struct device *kdev, struct device_attribute *attr, char *buf)
2691 {
2692         return sprintf(buf, "%d\n", METRIC_SET_ID_RASTERIZER_AND_PIXEL_BACKEND);
2693 }
2694
2695 static struct device_attribute dev_attr_rasterizer_and_pixel_backend_id = {
2696         .attr = { .name = "id", .mode = 0444 },
2697         .show = show_rasterizer_and_pixel_backend_id,
2698         .store = NULL,
2699 };
2700
2701 static struct attribute *attrs_rasterizer_and_pixel_backend[] = {
2702         &dev_attr_rasterizer_and_pixel_backend_id.attr,
2703         NULL,
2704 };
2705
2706 static struct attribute_group group_rasterizer_and_pixel_backend = {
2707         .name = "7a03a9f8-ec5e-46bb-8b67-1f0ff1476281",
2708         .attrs =  attrs_rasterizer_and_pixel_backend,
2709 };
2710
2711 static ssize_t
2712 show_sampler_id(struct device *kdev, struct device_attribute *attr, char *buf)
2713 {
2714         return sprintf(buf, "%d\n", METRIC_SET_ID_SAMPLER);
2715 }
2716
2717 static struct device_attribute dev_attr_sampler_id = {
2718         .attr = { .name = "id", .mode = 0444 },
2719         .show = show_sampler_id,
2720         .store = NULL,
2721 };
2722
2723 static struct attribute *attrs_sampler[] = {
2724         &dev_attr_sampler_id.attr,
2725         NULL,
2726 };
2727
2728 static struct attribute_group group_sampler = {
2729         .name = "b25d2ebf-a6e0-4b29-96be-a9b010edeeda",
2730         .attrs =  attrs_sampler,
2731 };
2732
2733 static ssize_t
2734 show_tdl_1_id(struct device *kdev, struct device_attribute *attr, char *buf)
2735 {
2736         return sprintf(buf, "%d\n", METRIC_SET_ID_TDL_1);
2737 }
2738
2739 static struct device_attribute dev_attr_tdl_1_id = {
2740         .attr = { .name = "id", .mode = 0444 },
2741         .show = show_tdl_1_id,
2742         .store = NULL,
2743 };
2744
2745 static struct attribute *attrs_tdl_1[] = {
2746         &dev_attr_tdl_1_id.attr,
2747         NULL,
2748 };
2749
2750 static struct attribute_group group_tdl_1 = {
2751         .name = "469a05e5-e299-46f7-9598-7b05f3c34991",
2752         .attrs =  attrs_tdl_1,
2753 };
2754
2755 static ssize_t
2756 show_tdl_2_id(struct device *kdev, struct device_attribute *attr, char *buf)
2757 {
2758         return sprintf(buf, "%d\n", METRIC_SET_ID_TDL_2);
2759 }
2760
2761 static struct device_attribute dev_attr_tdl_2_id = {
2762         .attr = { .name = "id", .mode = 0444 },
2763         .show = show_tdl_2_id,
2764         .store = NULL,
2765 };
2766
2767 static struct attribute *attrs_tdl_2[] = {
2768         &dev_attr_tdl_2_id.attr,
2769         NULL,
2770 };
2771
2772 static struct attribute_group group_tdl_2 = {
2773         .name = "52f925c6-786a-4ec6-86ce-cba85c83453a",
2774         .attrs =  attrs_tdl_2,
2775 };
2776
2777 static ssize_t
2778 show_compute_extra_id(struct device *kdev, struct device_attribute *attr, char *buf)
2779 {
2780         return sprintf(buf, "%d\n", METRIC_SET_ID_COMPUTE_EXTRA);
2781 }
2782
2783 static struct device_attribute dev_attr_compute_extra_id = {
2784         .attr = { .name = "id", .mode = 0444 },
2785         .show = show_compute_extra_id,
2786         .store = NULL,
2787 };
2788
2789 static struct attribute *attrs_compute_extra[] = {
2790         &dev_attr_compute_extra_id.attr,
2791         NULL,
2792 };
2793
2794 static struct attribute_group group_compute_extra = {
2795         .name = "efc497ac-884e-4ee4-a4a8-15fba22aaf21",
2796         .attrs =  attrs_compute_extra,
2797 };
2798
2799 static ssize_t
2800 show_vme_pipe_id(struct device *kdev, struct device_attribute *attr, char *buf)
2801 {
2802         return sprintf(buf, "%d\n", METRIC_SET_ID_VME_PIPE);
2803 }
2804
2805 static struct device_attribute dev_attr_vme_pipe_id = {
2806         .attr = { .name = "id", .mode = 0444 },
2807         .show = show_vme_pipe_id,
2808         .store = NULL,
2809 };
2810
2811 static struct attribute *attrs_vme_pipe[] = {
2812         &dev_attr_vme_pipe_id.attr,
2813         NULL,
2814 };
2815
2816 static struct attribute_group group_vme_pipe = {
2817         .name = "bfd9764d-2c5b-4c16-bfc1-89de3ca10917",
2818         .attrs =  attrs_vme_pipe,
2819 };
2820
2821 static ssize_t
2822 show_test_oa_id(struct device *kdev, struct device_attribute *attr, char *buf)
2823 {
2824         return sprintf(buf, "%d\n", METRIC_SET_ID_TEST_OA);
2825 }
2826
2827 static struct device_attribute dev_attr_test_oa_id = {
2828         .attr = { .name = "id", .mode = 0444 },
2829         .show = show_test_oa_id,
2830         .store = NULL,
2831 };
2832
2833 static struct attribute *attrs_test_oa[] = {
2834         &dev_attr_test_oa_id.attr,
2835         NULL,
2836 };
2837
2838 static struct attribute_group group_test_oa = {
2839         .name = "f1792f32-6db2-4b50-b4b2-557128f1688d",
2840         .attrs =  attrs_test_oa,
2841 };
2842
2843 int
2844 i915_perf_register_sysfs_kblgt3(struct drm_i915_private *dev_priv)
2845 {
2846         const struct i915_oa_reg *mux_regs[ARRAY_SIZE(dev_priv->perf.oa.mux_regs)];
2847         int mux_lens[ARRAY_SIZE(dev_priv->perf.oa.mux_regs_lens)];
2848         int ret = 0;
2849
2850         if (get_render_basic_mux_config(dev_priv, mux_regs, mux_lens)) {
2851                 ret = sysfs_create_group(dev_priv->perf.metrics_kobj, &group_render_basic);
2852                 if (ret)
2853                         goto error_render_basic;
2854         }
2855         if (get_compute_basic_mux_config(dev_priv, mux_regs, mux_lens)) {
2856                 ret = sysfs_create_group(dev_priv->perf.metrics_kobj, &group_compute_basic);
2857                 if (ret)
2858                         goto error_compute_basic;
2859         }
2860         if (get_render_pipe_profile_mux_config(dev_priv, mux_regs, mux_lens)) {
2861                 ret = sysfs_create_group(dev_priv->perf.metrics_kobj, &group_render_pipe_profile);
2862                 if (ret)
2863                         goto error_render_pipe_profile;
2864         }
2865         if (get_memory_reads_mux_config(dev_priv, mux_regs, mux_lens)) {
2866                 ret = sysfs_create_group(dev_priv->perf.metrics_kobj, &group_memory_reads);
2867                 if (ret)
2868                         goto error_memory_reads;
2869         }
2870         if (get_memory_writes_mux_config(dev_priv, mux_regs, mux_lens)) {
2871                 ret = sysfs_create_group(dev_priv->perf.metrics_kobj, &group_memory_writes);
2872                 if (ret)
2873                         goto error_memory_writes;
2874         }
2875         if (get_compute_extended_mux_config(dev_priv, mux_regs, mux_lens)) {
2876                 ret = sysfs_create_group(dev_priv->perf.metrics_kobj, &group_compute_extended);
2877                 if (ret)
2878                         goto error_compute_extended;
2879         }
2880         if (get_compute_l3_cache_mux_config(dev_priv, mux_regs, mux_lens)) {
2881                 ret = sysfs_create_group(dev_priv->perf.metrics_kobj, &group_compute_l3_cache);
2882                 if (ret)
2883                         goto error_compute_l3_cache;
2884         }
2885         if (get_hdc_and_sf_mux_config(dev_priv, mux_regs, mux_lens)) {
2886                 ret = sysfs_create_group(dev_priv->perf.metrics_kobj, &group_hdc_and_sf);
2887                 if (ret)
2888                         goto error_hdc_and_sf;
2889         }
2890         if (get_l3_1_mux_config(dev_priv, mux_regs, mux_lens)) {
2891                 ret = sysfs_create_group(dev_priv->perf.metrics_kobj, &group_l3_1);
2892                 if (ret)
2893                         goto error_l3_1;
2894         }
2895         if (get_l3_2_mux_config(dev_priv, mux_regs, mux_lens)) {
2896                 ret = sysfs_create_group(dev_priv->perf.metrics_kobj, &group_l3_2);
2897                 if (ret)
2898                         goto error_l3_2;
2899         }
2900         if (get_l3_3_mux_config(dev_priv, mux_regs, mux_lens)) {
2901                 ret = sysfs_create_group(dev_priv->perf.metrics_kobj, &group_l3_3);
2902                 if (ret)
2903                         goto error_l3_3;
2904         }
2905         if (get_rasterizer_and_pixel_backend_mux_config(dev_priv, mux_regs, mux_lens)) {
2906                 ret = sysfs_create_group(dev_priv->perf.metrics_kobj, &group_rasterizer_and_pixel_backend);
2907                 if (ret)
2908                         goto error_rasterizer_and_pixel_backend;
2909         }
2910         if (get_sampler_mux_config(dev_priv, mux_regs, mux_lens)) {
2911                 ret = sysfs_create_group(dev_priv->perf.metrics_kobj, &group_sampler);
2912                 if (ret)
2913                         goto error_sampler;
2914         }
2915         if (get_tdl_1_mux_config(dev_priv, mux_regs, mux_lens)) {
2916                 ret = sysfs_create_group(dev_priv->perf.metrics_kobj, &group_tdl_1);
2917                 if (ret)
2918                         goto error_tdl_1;
2919         }
2920         if (get_tdl_2_mux_config(dev_priv, mux_regs, mux_lens)) {
2921                 ret = sysfs_create_group(dev_priv->perf.metrics_kobj, &group_tdl_2);
2922                 if (ret)
2923                         goto error_tdl_2;
2924         }
2925         if (get_compute_extra_mux_config(dev_priv, mux_regs, mux_lens)) {
2926                 ret = sysfs_create_group(dev_priv->perf.metrics_kobj, &group_compute_extra);
2927                 if (ret)
2928                         goto error_compute_extra;
2929         }
2930         if (get_vme_pipe_mux_config(dev_priv, mux_regs, mux_lens)) {
2931                 ret = sysfs_create_group(dev_priv->perf.metrics_kobj, &group_vme_pipe);
2932                 if (ret)
2933                         goto error_vme_pipe;
2934         }
2935         if (get_test_oa_mux_config(dev_priv, mux_regs, mux_lens)) {
2936                 ret = sysfs_create_group(dev_priv->perf.metrics_kobj, &group_test_oa);
2937                 if (ret)
2938                         goto error_test_oa;
2939         }
2940
2941         return 0;
2942
2943 error_test_oa:
2944         if (get_vme_pipe_mux_config(dev_priv, mux_regs, mux_lens))
2945                 sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_vme_pipe);
2946 error_vme_pipe:
2947         if (get_compute_extra_mux_config(dev_priv, mux_regs, mux_lens))
2948                 sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_compute_extra);
2949 error_compute_extra:
2950         if (get_tdl_2_mux_config(dev_priv, mux_regs, mux_lens))
2951                 sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_tdl_2);
2952 error_tdl_2:
2953         if (get_tdl_1_mux_config(dev_priv, mux_regs, mux_lens))
2954                 sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_tdl_1);
2955 error_tdl_1:
2956         if (get_sampler_mux_config(dev_priv, mux_regs, mux_lens))
2957                 sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_sampler);
2958 error_sampler:
2959         if (get_rasterizer_and_pixel_backend_mux_config(dev_priv, mux_regs, mux_lens))
2960                 sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_rasterizer_and_pixel_backend);
2961 error_rasterizer_and_pixel_backend:
2962         if (get_l3_3_mux_config(dev_priv, mux_regs, mux_lens))
2963                 sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_l3_3);
2964 error_l3_3:
2965         if (get_l3_2_mux_config(dev_priv, mux_regs, mux_lens))
2966                 sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_l3_2);
2967 error_l3_2:
2968         if (get_l3_1_mux_config(dev_priv, mux_regs, mux_lens))
2969                 sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_l3_1);
2970 error_l3_1:
2971         if (get_hdc_and_sf_mux_config(dev_priv, mux_regs, mux_lens))
2972                 sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_hdc_and_sf);
2973 error_hdc_and_sf:
2974         if (get_compute_l3_cache_mux_config(dev_priv, mux_regs, mux_lens))
2975                 sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_compute_l3_cache);
2976 error_compute_l3_cache:
2977         if (get_compute_extended_mux_config(dev_priv, mux_regs, mux_lens))
2978                 sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_compute_extended);
2979 error_compute_extended:
2980         if (get_memory_writes_mux_config(dev_priv, mux_regs, mux_lens))
2981                 sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_memory_writes);
2982 error_memory_writes:
2983         if (get_memory_reads_mux_config(dev_priv, mux_regs, mux_lens))
2984                 sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_memory_reads);
2985 error_memory_reads:
2986         if (get_render_pipe_profile_mux_config(dev_priv, mux_regs, mux_lens))
2987                 sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_render_pipe_profile);
2988 error_render_pipe_profile:
2989         if (get_compute_basic_mux_config(dev_priv, mux_regs, mux_lens))
2990                 sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_compute_basic);
2991 error_compute_basic:
2992         if (get_render_basic_mux_config(dev_priv, mux_regs, mux_lens))
2993                 sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_render_basic);
2994 error_render_basic:
2995         return ret;
2996 }
2997
2998 void
2999 i915_perf_unregister_sysfs_kblgt3(struct drm_i915_private *dev_priv)
3000 {
3001         const struct i915_oa_reg *mux_regs[ARRAY_SIZE(dev_priv->perf.oa.mux_regs)];
3002         int mux_lens[ARRAY_SIZE(dev_priv->perf.oa.mux_regs_lens)];
3003
3004         if (get_render_basic_mux_config(dev_priv, mux_regs, mux_lens))
3005                 sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_render_basic);
3006         if (get_compute_basic_mux_config(dev_priv, mux_regs, mux_lens))
3007                 sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_compute_basic);
3008         if (get_render_pipe_profile_mux_config(dev_priv, mux_regs, mux_lens))
3009                 sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_render_pipe_profile);
3010         if (get_memory_reads_mux_config(dev_priv, mux_regs, mux_lens))
3011                 sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_memory_reads);
3012         if (get_memory_writes_mux_config(dev_priv, mux_regs, mux_lens))
3013                 sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_memory_writes);
3014         if (get_compute_extended_mux_config(dev_priv, mux_regs, mux_lens))
3015                 sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_compute_extended);
3016         if (get_compute_l3_cache_mux_config(dev_priv, mux_regs, mux_lens))
3017                 sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_compute_l3_cache);
3018         if (get_hdc_and_sf_mux_config(dev_priv, mux_regs, mux_lens))
3019                 sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_hdc_and_sf);
3020         if (get_l3_1_mux_config(dev_priv, mux_regs, mux_lens))
3021                 sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_l3_1);
3022         if (get_l3_2_mux_config(dev_priv, mux_regs, mux_lens))
3023                 sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_l3_2);
3024         if (get_l3_3_mux_config(dev_priv, mux_regs, mux_lens))
3025                 sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_l3_3);
3026         if (get_rasterizer_and_pixel_backend_mux_config(dev_priv, mux_regs, mux_lens))
3027                 sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_rasterizer_and_pixel_backend);
3028         if (get_sampler_mux_config(dev_priv, mux_regs, mux_lens))
3029                 sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_sampler);
3030         if (get_tdl_1_mux_config(dev_priv, mux_regs, mux_lens))
3031                 sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_tdl_1);
3032         if (get_tdl_2_mux_config(dev_priv, mux_regs, mux_lens))
3033                 sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_tdl_2);
3034         if (get_compute_extra_mux_config(dev_priv, mux_regs, mux_lens))
3035                 sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_compute_extra);
3036         if (get_vme_pipe_mux_config(dev_priv, mux_regs, mux_lens))
3037                 sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_vme_pipe);
3038         if (get_test_oa_mux_config(dev_priv, mux_regs, mux_lens))
3039                 sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_test_oa);
3040 }