1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Copyright 2015 Advanced Micro Devices, Inc.
3bf215546Sopenharmony_ci * All Rights Reserved.
4bf215546Sopenharmony_ci *
5bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
6bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
7bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation
8bf215546Sopenharmony_ci * on the rights to use, copy, modify, merge, publish, distribute, sub
9bf215546Sopenharmony_ci * license, and/or sell copies of the Software, and to permit persons to whom
10bf215546Sopenharmony_ci * the Software is furnished to do so, subject to the following conditions:
11bf215546Sopenharmony_ci *
12bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next
13bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the
14bf215546Sopenharmony_ci * Software.
15bf215546Sopenharmony_ci *
16bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19bf215546Sopenharmony_ci * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
20bf215546Sopenharmony_ci * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21bf215546Sopenharmony_ci * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22bf215546Sopenharmony_ci * USE OR OTHER DEALINGS IN THE SOFTWARE.
23bf215546Sopenharmony_ci */
24bf215546Sopenharmony_ci
25bf215546Sopenharmony_ci#include "ac_gpu_info.h"
26bf215546Sopenharmony_ci#include "ac_perfcounter.h"
27bf215546Sopenharmony_ci
28bf215546Sopenharmony_ci#include "util/u_memory.h"
29bf215546Sopenharmony_ci#include "macros.h"
30bf215546Sopenharmony_ci
31bf215546Sopenharmony_ci/* cik_CB */
32bf215546Sopenharmony_cistatic unsigned cik_CB_select0[] = {
33bf215546Sopenharmony_ci   R_037004_CB_PERFCOUNTER0_SELECT,
34bf215546Sopenharmony_ci   R_03700C_CB_PERFCOUNTER1_SELECT,
35bf215546Sopenharmony_ci   R_037010_CB_PERFCOUNTER2_SELECT,
36bf215546Sopenharmony_ci   R_037014_CB_PERFCOUNTER3_SELECT,
37bf215546Sopenharmony_ci};
38bf215546Sopenharmony_cistatic unsigned cik_CB_select1[] = {
39bf215546Sopenharmony_ci   R_037008_CB_PERFCOUNTER0_SELECT1,
40bf215546Sopenharmony_ci};
41bf215546Sopenharmony_cistatic struct ac_pc_block_base cik_CB = {
42bf215546Sopenharmony_ci   .gpu_block = CB,
43bf215546Sopenharmony_ci   .name = "CB",
44bf215546Sopenharmony_ci   .num_counters = 4,
45bf215546Sopenharmony_ci   .flags = AC_PC_BLOCK_SE | AC_PC_BLOCK_INSTANCE_GROUPS,
46bf215546Sopenharmony_ci
47bf215546Sopenharmony_ci   .select0 = cik_CB_select0,
48bf215546Sopenharmony_ci   .select1 = cik_CB_select1,
49bf215546Sopenharmony_ci   .counter0_lo = R_035018_CB_PERFCOUNTER0_LO,
50bf215546Sopenharmony_ci
51bf215546Sopenharmony_ci   .num_spm_counters = 1,
52bf215546Sopenharmony_ci   .num_spm_wires = 2,
53bf215546Sopenharmony_ci   .spm_block_select = 0x0,
54bf215546Sopenharmony_ci};
55bf215546Sopenharmony_ci
56bf215546Sopenharmony_ci/* cik_CPC */
57bf215546Sopenharmony_cistatic unsigned cik_CPC_select0[] = {
58bf215546Sopenharmony_ci   R_036024_CPC_PERFCOUNTER0_SELECT,
59bf215546Sopenharmony_ci   R_03600C_CPC_PERFCOUNTER1_SELECT,
60bf215546Sopenharmony_ci};
61bf215546Sopenharmony_cistatic unsigned cik_CPC_select1[] = {
62bf215546Sopenharmony_ci   R_036010_CPC_PERFCOUNTER0_SELECT1,
63bf215546Sopenharmony_ci};
64bf215546Sopenharmony_cistatic unsigned cik_CPC_counters[] = {
65bf215546Sopenharmony_ci   R_034018_CPC_PERFCOUNTER0_LO,
66bf215546Sopenharmony_ci   R_034010_CPC_PERFCOUNTER1_LO,
67bf215546Sopenharmony_ci};
68bf215546Sopenharmony_cistatic struct ac_pc_block_base cik_CPC = {
69bf215546Sopenharmony_ci   .gpu_block = CPC,
70bf215546Sopenharmony_ci   .name = "CPC",
71bf215546Sopenharmony_ci   .num_counters = 2,
72bf215546Sopenharmony_ci
73bf215546Sopenharmony_ci   .select0 = cik_CPC_select0,
74bf215546Sopenharmony_ci   .select1 = cik_CPC_select1,
75bf215546Sopenharmony_ci   .counters = cik_CPC_counters,
76bf215546Sopenharmony_ci
77bf215546Sopenharmony_ci   .num_spm_counters = 1,
78bf215546Sopenharmony_ci   .num_spm_wires = 2,
79bf215546Sopenharmony_ci   .spm_block_select = 0x1,
80bf215546Sopenharmony_ci};
81bf215546Sopenharmony_ci
82bf215546Sopenharmony_ci/* cik_CPF */
83bf215546Sopenharmony_cistatic unsigned cik_CPF_select0[] = {
84bf215546Sopenharmony_ci   R_03601C_CPF_PERFCOUNTER0_SELECT,
85bf215546Sopenharmony_ci   R_036014_CPF_PERFCOUNTER1_SELECT,
86bf215546Sopenharmony_ci};
87bf215546Sopenharmony_cistatic unsigned cik_CPF_select1[] = {
88bf215546Sopenharmony_ci   R_036018_CPF_PERFCOUNTER0_SELECT1,
89bf215546Sopenharmony_ci};
90bf215546Sopenharmony_cistatic unsigned cik_CPF_counters[] = {
91bf215546Sopenharmony_ci   R_034028_CPF_PERFCOUNTER0_LO,
92bf215546Sopenharmony_ci   R_034020_CPF_PERFCOUNTER1_LO,
93bf215546Sopenharmony_ci};
94bf215546Sopenharmony_cistatic struct ac_pc_block_base cik_CPF = {
95bf215546Sopenharmony_ci   .gpu_block = CPF,
96bf215546Sopenharmony_ci   .name = "CPF",
97bf215546Sopenharmony_ci   .num_counters = 2,
98bf215546Sopenharmony_ci
99bf215546Sopenharmony_ci   .select0 = cik_CPF_select0,
100bf215546Sopenharmony_ci   .select1 = cik_CPF_select1,
101bf215546Sopenharmony_ci   .counters = cik_CPF_counters,
102bf215546Sopenharmony_ci
103bf215546Sopenharmony_ci   .num_spm_counters = 1,
104bf215546Sopenharmony_ci   .num_spm_wires = 2,
105bf215546Sopenharmony_ci   .spm_block_select = 0x2,
106bf215546Sopenharmony_ci};
107bf215546Sopenharmony_ci
108bf215546Sopenharmony_ci/* cik_CPG */
109bf215546Sopenharmony_cistatic unsigned cik_CPG_select0[] = {
110bf215546Sopenharmony_ci   R_036008_CPG_PERFCOUNTER0_SELECT,
111bf215546Sopenharmony_ci   R_036000_CPG_PERFCOUNTER1_SELECT,
112bf215546Sopenharmony_ci};
113bf215546Sopenharmony_cistatic unsigned cik_CPG_select1[] = {
114bf215546Sopenharmony_ci   R_036004_CPG_PERFCOUNTER0_SELECT1
115bf215546Sopenharmony_ci};
116bf215546Sopenharmony_cistatic unsigned cik_CPG_counters[] = {
117bf215546Sopenharmony_ci   R_034008_CPG_PERFCOUNTER0_LO,
118bf215546Sopenharmony_ci   R_034000_CPG_PERFCOUNTER1_LO,
119bf215546Sopenharmony_ci};
120bf215546Sopenharmony_cistatic struct ac_pc_block_base cik_CPG = {
121bf215546Sopenharmony_ci   .gpu_block = CPG,
122bf215546Sopenharmony_ci   .name = "CPG",
123bf215546Sopenharmony_ci   .num_counters = 2,
124bf215546Sopenharmony_ci
125bf215546Sopenharmony_ci   .select0 = cik_CPG_select0,
126bf215546Sopenharmony_ci   .select1 = cik_CPG_select1,
127bf215546Sopenharmony_ci   .counters = cik_CPG_counters,
128bf215546Sopenharmony_ci
129bf215546Sopenharmony_ci   .num_spm_counters = 1,
130bf215546Sopenharmony_ci   .num_spm_wires = 2,
131bf215546Sopenharmony_ci   .spm_block_select = 0x0,
132bf215546Sopenharmony_ci};
133bf215546Sopenharmony_ci
134bf215546Sopenharmony_ci/* cik_DB */
135bf215546Sopenharmony_cistatic unsigned cik_DB_select0[] = {
136bf215546Sopenharmony_ci   R_037100_DB_PERFCOUNTER0_SELECT,
137bf215546Sopenharmony_ci   R_037108_DB_PERFCOUNTER1_SELECT,
138bf215546Sopenharmony_ci   R_037110_DB_PERFCOUNTER2_SELECT,
139bf215546Sopenharmony_ci   R_037118_DB_PERFCOUNTER3_SELECT,
140bf215546Sopenharmony_ci};
141bf215546Sopenharmony_cistatic unsigned cik_DB_select1[] = {
142bf215546Sopenharmony_ci   R_037104_DB_PERFCOUNTER0_SELECT1,
143bf215546Sopenharmony_ci   R_03710C_DB_PERFCOUNTER1_SELECT1,
144bf215546Sopenharmony_ci};
145bf215546Sopenharmony_cistatic struct ac_pc_block_base cik_DB = {
146bf215546Sopenharmony_ci   .gpu_block = DB,
147bf215546Sopenharmony_ci   .name = "DB",
148bf215546Sopenharmony_ci   .num_counters = 4,
149bf215546Sopenharmony_ci   .flags = AC_PC_BLOCK_SE | AC_PC_BLOCK_INSTANCE_GROUPS,
150bf215546Sopenharmony_ci
151bf215546Sopenharmony_ci   .select0 = cik_DB_select0,
152bf215546Sopenharmony_ci   .select1 = cik_DB_select1,
153bf215546Sopenharmony_ci   .counter0_lo = R_035100_DB_PERFCOUNTER0_LO,
154bf215546Sopenharmony_ci
155bf215546Sopenharmony_ci   .num_spm_counters = 2,
156bf215546Sopenharmony_ci   .num_spm_wires = 3,
157bf215546Sopenharmony_ci   .spm_block_select = 0x1,
158bf215546Sopenharmony_ci};
159bf215546Sopenharmony_ci
160bf215546Sopenharmony_ci/* cik_GDS */
161bf215546Sopenharmony_cistatic unsigned cik_GDS_select0[] = {
162bf215546Sopenharmony_ci   R_036A00_GDS_PERFCOUNTER0_SELECT,
163bf215546Sopenharmony_ci   R_036A04_GDS_PERFCOUNTER1_SELECT,
164bf215546Sopenharmony_ci   R_036A08_GDS_PERFCOUNTER2_SELECT,
165bf215546Sopenharmony_ci   R_036A0C_GDS_PERFCOUNTER3_SELECT,
166bf215546Sopenharmony_ci};
167bf215546Sopenharmony_cistatic unsigned cik_GDS_select1[] = {
168bf215546Sopenharmony_ci   R_036A10_GDS_PERFCOUNTER0_SELECT1,
169bf215546Sopenharmony_ci};
170bf215546Sopenharmony_cistatic struct ac_pc_block_base cik_GDS = {
171bf215546Sopenharmony_ci   .gpu_block = GDS,
172bf215546Sopenharmony_ci   .name = "GDS",
173bf215546Sopenharmony_ci   .num_counters = 4,
174bf215546Sopenharmony_ci
175bf215546Sopenharmony_ci   .select0 = cik_GDS_select0,
176bf215546Sopenharmony_ci   .select1 = cik_GDS_select1,
177bf215546Sopenharmony_ci   .counter0_lo = R_034A00_GDS_PERFCOUNTER0_LO,
178bf215546Sopenharmony_ci
179bf215546Sopenharmony_ci   .num_spm_counters = 1,
180bf215546Sopenharmony_ci   .num_spm_wires = 2,
181bf215546Sopenharmony_ci   .spm_block_select = 0x3,
182bf215546Sopenharmony_ci};
183bf215546Sopenharmony_ci
184bf215546Sopenharmony_ci/* cik_GRBM */
185bf215546Sopenharmony_cistatic unsigned cik_GRBM_select0[] = {
186bf215546Sopenharmony_ci   R_036100_GRBM_PERFCOUNTER0_SELECT,
187bf215546Sopenharmony_ci   R_036104_GRBM_PERFCOUNTER1_SELECT,
188bf215546Sopenharmony_ci};
189bf215546Sopenharmony_cistatic unsigned cik_GRBM_counters[] = {
190bf215546Sopenharmony_ci   R_034100_GRBM_PERFCOUNTER0_LO,
191bf215546Sopenharmony_ci   R_03410C_GRBM_PERFCOUNTER1_LO,
192bf215546Sopenharmony_ci};
193bf215546Sopenharmony_cistatic struct ac_pc_block_base cik_GRBM = {
194bf215546Sopenharmony_ci   .gpu_block = GRBM,
195bf215546Sopenharmony_ci   .name = "GRBM",
196bf215546Sopenharmony_ci   .num_counters = 2,
197bf215546Sopenharmony_ci
198bf215546Sopenharmony_ci   .select0 = cik_GRBM_select0,
199bf215546Sopenharmony_ci   .counters = cik_GRBM_counters,
200bf215546Sopenharmony_ci};
201bf215546Sopenharmony_ci
202bf215546Sopenharmony_ci/* cik_GRBMSE */
203bf215546Sopenharmony_cistatic unsigned cik_GRBMSE_select0[] = {
204bf215546Sopenharmony_ci   R_036108_GRBM_SE0_PERFCOUNTER_SELECT,
205bf215546Sopenharmony_ci   R_03610C_GRBM_SE1_PERFCOUNTER_SELECT,
206bf215546Sopenharmony_ci   R_036110_GRBM_SE2_PERFCOUNTER_SELECT,
207bf215546Sopenharmony_ci   R_036114_GRBM_SE3_PERFCOUNTER_SELECT,
208bf215546Sopenharmony_ci};
209bf215546Sopenharmony_cistatic struct ac_pc_block_base cik_GRBMSE = {
210bf215546Sopenharmony_ci   .gpu_block = GRBMSE,
211bf215546Sopenharmony_ci   .name = "GRBMSE",
212bf215546Sopenharmony_ci   .num_counters = 4,
213bf215546Sopenharmony_ci
214bf215546Sopenharmony_ci   .select0 = cik_GRBMSE_select0,
215bf215546Sopenharmony_ci   .counter0_lo = R_034114_GRBM_SE0_PERFCOUNTER_LO,
216bf215546Sopenharmony_ci};
217bf215546Sopenharmony_ci
218bf215546Sopenharmony_ci/* cik_IA */
219bf215546Sopenharmony_cistatic unsigned cik_IA_select0[] = {
220bf215546Sopenharmony_ci   R_036210_IA_PERFCOUNTER0_SELECT,
221bf215546Sopenharmony_ci   R_036214_IA_PERFCOUNTER1_SELECT,
222bf215546Sopenharmony_ci   R_036218_IA_PERFCOUNTER2_SELECT,
223bf215546Sopenharmony_ci   R_03621C_IA_PERFCOUNTER3_SELECT,
224bf215546Sopenharmony_ci};
225bf215546Sopenharmony_cistatic unsigned cik_IA_select1[] = {
226bf215546Sopenharmony_ci   R_036220_IA_PERFCOUNTER0_SELECT1,
227bf215546Sopenharmony_ci};
228bf215546Sopenharmony_cistatic struct ac_pc_block_base cik_IA = {
229bf215546Sopenharmony_ci   .gpu_block = IA,
230bf215546Sopenharmony_ci   .name = "IA",
231bf215546Sopenharmony_ci   .num_counters = 4,
232bf215546Sopenharmony_ci
233bf215546Sopenharmony_ci   .select0 = cik_IA_select0,
234bf215546Sopenharmony_ci   .select1 = cik_IA_select1,
235bf215546Sopenharmony_ci   .counter0_lo = R_034220_IA_PERFCOUNTER0_LO,
236bf215546Sopenharmony_ci
237bf215546Sopenharmony_ci   .num_spm_counters = 1,
238bf215546Sopenharmony_ci   .num_spm_wires = 2,
239bf215546Sopenharmony_ci   .spm_block_select = 0x6,
240bf215546Sopenharmony_ci};
241bf215546Sopenharmony_ci
242bf215546Sopenharmony_ci/* cik_PA_SC */
243bf215546Sopenharmony_cistatic unsigned cik_PA_SC_select0[] = {
244bf215546Sopenharmony_ci   R_036500_PA_SC_PERFCOUNTER0_SELECT,
245bf215546Sopenharmony_ci   R_036508_PA_SC_PERFCOUNTER1_SELECT,
246bf215546Sopenharmony_ci   R_03650C_PA_SC_PERFCOUNTER2_SELECT,
247bf215546Sopenharmony_ci   R_036510_PA_SC_PERFCOUNTER3_SELECT,
248bf215546Sopenharmony_ci   R_036514_PA_SC_PERFCOUNTER4_SELECT,
249bf215546Sopenharmony_ci   R_036518_PA_SC_PERFCOUNTER5_SELECT,
250bf215546Sopenharmony_ci   R_03651C_PA_SC_PERFCOUNTER6_SELECT,
251bf215546Sopenharmony_ci   R_036520_PA_SC_PERFCOUNTER7_SELECT,
252bf215546Sopenharmony_ci};
253bf215546Sopenharmony_cistatic unsigned cik_PA_SC_select1[] = {
254bf215546Sopenharmony_ci   R_036504_PA_SC_PERFCOUNTER0_SELECT1,
255bf215546Sopenharmony_ci};
256bf215546Sopenharmony_cistatic struct ac_pc_block_base cik_PA_SC = {
257bf215546Sopenharmony_ci   .gpu_block = PA_SC,
258bf215546Sopenharmony_ci   .name = "PA_SC",
259bf215546Sopenharmony_ci   .num_counters = 8,
260bf215546Sopenharmony_ci   .flags = AC_PC_BLOCK_SE,
261bf215546Sopenharmony_ci
262bf215546Sopenharmony_ci   .select0 = cik_PA_SC_select0,
263bf215546Sopenharmony_ci   .select1 = cik_PA_SC_select1,
264bf215546Sopenharmony_ci   .counter0_lo = R_034500_PA_SC_PERFCOUNTER0_LO,
265bf215546Sopenharmony_ci
266bf215546Sopenharmony_ci   .num_spm_counters = 1,
267bf215546Sopenharmony_ci   .num_spm_wires = 2,
268bf215546Sopenharmony_ci   .spm_block_select = 0x4,
269bf215546Sopenharmony_ci};
270bf215546Sopenharmony_ci
271bf215546Sopenharmony_ci/* cik_PA_SU */
272bf215546Sopenharmony_cistatic unsigned cik_PA_SU_select0[] = {
273bf215546Sopenharmony_ci   R_036400_PA_SU_PERFCOUNTER0_SELECT,
274bf215546Sopenharmony_ci   R_036408_PA_SU_PERFCOUNTER1_SELECT,
275bf215546Sopenharmony_ci   R_036410_PA_SU_PERFCOUNTER2_SELECT,
276bf215546Sopenharmony_ci   R_036414_PA_SU_PERFCOUNTER3_SELECT,
277bf215546Sopenharmony_ci};
278bf215546Sopenharmony_cistatic unsigned cik_PA_SU_select1[] = {
279bf215546Sopenharmony_ci   R_036404_PA_SU_PERFCOUNTER0_SELECT1,
280bf215546Sopenharmony_ci   R_03640C_PA_SU_PERFCOUNTER1_SELECT1,
281bf215546Sopenharmony_ci};
282bf215546Sopenharmony_ci/* According to docs, PA_SU counters are only 48 bits wide. */
283bf215546Sopenharmony_cistatic struct ac_pc_block_base cik_PA_SU = {
284bf215546Sopenharmony_ci   .gpu_block = PA_SU,
285bf215546Sopenharmony_ci   .name = "PA_SU",
286bf215546Sopenharmony_ci   .num_counters = 4,
287bf215546Sopenharmony_ci   .flags = AC_PC_BLOCK_SE,
288bf215546Sopenharmony_ci
289bf215546Sopenharmony_ci   .select0 = cik_PA_SU_select0,
290bf215546Sopenharmony_ci   .select1 = cik_PA_SU_select1,
291bf215546Sopenharmony_ci   .counter0_lo = R_034400_PA_SU_PERFCOUNTER0_LO,
292bf215546Sopenharmony_ci
293bf215546Sopenharmony_ci   .num_spm_counters = 2,
294bf215546Sopenharmony_ci   .num_spm_wires = 3,
295bf215546Sopenharmony_ci   .spm_block_select = 0x2,
296bf215546Sopenharmony_ci};
297bf215546Sopenharmony_ci
298bf215546Sopenharmony_ci/* cik_SPI */
299bf215546Sopenharmony_cistatic unsigned cik_SPI_select0[] = {
300bf215546Sopenharmony_ci   R_036600_SPI_PERFCOUNTER0_SELECT,
301bf215546Sopenharmony_ci   R_036604_SPI_PERFCOUNTER1_SELECT,
302bf215546Sopenharmony_ci   R_036608_SPI_PERFCOUNTER2_SELECT,
303bf215546Sopenharmony_ci   R_03660C_SPI_PERFCOUNTER3_SELECT,
304bf215546Sopenharmony_ci   R_036620_SPI_PERFCOUNTER4_SELECT,
305bf215546Sopenharmony_ci   R_036624_SPI_PERFCOUNTER5_SELECT,
306bf215546Sopenharmony_ci};
307bf215546Sopenharmony_cistatic unsigned cik_SPI_select1[] = {
308bf215546Sopenharmony_ci   R_036610_SPI_PERFCOUNTER0_SELECT1,
309bf215546Sopenharmony_ci   R_036614_SPI_PERFCOUNTER1_SELECT1,
310bf215546Sopenharmony_ci   R_036618_SPI_PERFCOUNTER2_SELECT1,
311bf215546Sopenharmony_ci   R_03661C_SPI_PERFCOUNTER3_SELECT1
312bf215546Sopenharmony_ci};
313bf215546Sopenharmony_cistatic struct ac_pc_block_base cik_SPI = {
314bf215546Sopenharmony_ci   .gpu_block = SPI,
315bf215546Sopenharmony_ci   .name = "SPI",
316bf215546Sopenharmony_ci   .num_counters = 6,
317bf215546Sopenharmony_ci   .flags = AC_PC_BLOCK_SE,
318bf215546Sopenharmony_ci
319bf215546Sopenharmony_ci   .select0 = cik_SPI_select0,
320bf215546Sopenharmony_ci   .select1 = cik_SPI_select1,
321bf215546Sopenharmony_ci   .counter0_lo = R_034604_SPI_PERFCOUNTER0_LO,
322bf215546Sopenharmony_ci
323bf215546Sopenharmony_ci   .num_spm_counters = 4,
324bf215546Sopenharmony_ci   .num_spm_wires = 8,
325bf215546Sopenharmony_ci   .spm_block_select = 0x8,
326bf215546Sopenharmony_ci};
327bf215546Sopenharmony_ci
328bf215546Sopenharmony_ci/* cik_SQ */
329bf215546Sopenharmony_cistatic unsigned cik_SQ_select0[] = {
330bf215546Sopenharmony_ci   R_036700_SQ_PERFCOUNTER0_SELECT,
331bf215546Sopenharmony_ci   R_036704_SQ_PERFCOUNTER1_SELECT,
332bf215546Sopenharmony_ci   R_036708_SQ_PERFCOUNTER2_SELECT,
333bf215546Sopenharmony_ci   R_03670C_SQ_PERFCOUNTER3_SELECT,
334bf215546Sopenharmony_ci   R_036710_SQ_PERFCOUNTER4_SELECT,
335bf215546Sopenharmony_ci   R_036714_SQ_PERFCOUNTER5_SELECT,
336bf215546Sopenharmony_ci   R_036718_SQ_PERFCOUNTER6_SELECT,
337bf215546Sopenharmony_ci   R_03671C_SQ_PERFCOUNTER7_SELECT,
338bf215546Sopenharmony_ci   R_036720_SQ_PERFCOUNTER8_SELECT,
339bf215546Sopenharmony_ci   R_036724_SQ_PERFCOUNTER9_SELECT,
340bf215546Sopenharmony_ci   R_036728_SQ_PERFCOUNTER10_SELECT,
341bf215546Sopenharmony_ci   R_03672C_SQ_PERFCOUNTER11_SELECT,
342bf215546Sopenharmony_ci   R_036730_SQ_PERFCOUNTER12_SELECT,
343bf215546Sopenharmony_ci   R_036734_SQ_PERFCOUNTER13_SELECT,
344bf215546Sopenharmony_ci   R_036738_SQ_PERFCOUNTER14_SELECT,
345bf215546Sopenharmony_ci   R_03673C_SQ_PERFCOUNTER15_SELECT,
346bf215546Sopenharmony_ci};
347bf215546Sopenharmony_cistatic struct ac_pc_block_base cik_SQ = {
348bf215546Sopenharmony_ci   .gpu_block = SQ,
349bf215546Sopenharmony_ci   .name = "SQ",
350bf215546Sopenharmony_ci   .num_counters = 16,
351bf215546Sopenharmony_ci   .flags = AC_PC_BLOCK_SE | AC_PC_BLOCK_SHADER,
352bf215546Sopenharmony_ci
353bf215546Sopenharmony_ci   .select0 = cik_SQ_select0,
354bf215546Sopenharmony_ci   .select_or = S_036700_SQC_BANK_MASK(15) | S_036700_SQC_CLIENT_MASK(15) | S_036700_SIMD_MASK(15),
355bf215546Sopenharmony_ci   .counter0_lo = R_034700_SQ_PERFCOUNTER0_LO,
356bf215546Sopenharmony_ci
357bf215546Sopenharmony_ci   .num_spm_wires = 8,
358bf215546Sopenharmony_ci   .spm_block_select = 0x9,
359bf215546Sopenharmony_ci};
360bf215546Sopenharmony_ci
361bf215546Sopenharmony_ci/* cik_SX */
362bf215546Sopenharmony_cistatic unsigned cik_SX_select0[] = {
363bf215546Sopenharmony_ci   R_036900_SX_PERFCOUNTER0_SELECT,
364bf215546Sopenharmony_ci   R_036904_SX_PERFCOUNTER1_SELECT,
365bf215546Sopenharmony_ci   R_036908_SX_PERFCOUNTER2_SELECT,
366bf215546Sopenharmony_ci   R_03690C_SX_PERFCOUNTER3_SELECT,
367bf215546Sopenharmony_ci};
368bf215546Sopenharmony_cistatic unsigned cik_SX_select1[] = {
369bf215546Sopenharmony_ci   R_036910_SX_PERFCOUNTER0_SELECT1,
370bf215546Sopenharmony_ci   R_036914_SX_PERFCOUNTER1_SELECT1,
371bf215546Sopenharmony_ci};
372bf215546Sopenharmony_cistatic struct ac_pc_block_base cik_SX = {
373bf215546Sopenharmony_ci   .gpu_block = SX,
374bf215546Sopenharmony_ci   .name = "SX",
375bf215546Sopenharmony_ci   .num_counters = 4,
376bf215546Sopenharmony_ci   .flags = AC_PC_BLOCK_SE,
377bf215546Sopenharmony_ci
378bf215546Sopenharmony_ci   .select0 = cik_SX_select0,
379bf215546Sopenharmony_ci   .select1 = cik_SX_select1,
380bf215546Sopenharmony_ci   .counter0_lo = R_034900_SX_PERFCOUNTER0_LO,
381bf215546Sopenharmony_ci
382bf215546Sopenharmony_ci   .num_spm_counters = 2,
383bf215546Sopenharmony_ci   .num_spm_wires = 4,
384bf215546Sopenharmony_ci   .spm_block_select = 0x3,
385bf215546Sopenharmony_ci};
386bf215546Sopenharmony_ci
387bf215546Sopenharmony_ci/* cik_TA */
388bf215546Sopenharmony_cistatic unsigned cik_TA_select0[] = {
389bf215546Sopenharmony_ci   R_036B00_TA_PERFCOUNTER0_SELECT,
390bf215546Sopenharmony_ci   R_036B08_TA_PERFCOUNTER1_SELECT,
391bf215546Sopenharmony_ci};
392bf215546Sopenharmony_cistatic unsigned cik_TA_select1[] = {
393bf215546Sopenharmony_ci   R_036B04_TA_PERFCOUNTER0_SELECT1,
394bf215546Sopenharmony_ci};
395bf215546Sopenharmony_cistatic struct ac_pc_block_base cik_TA = {
396bf215546Sopenharmony_ci   .gpu_block = TA,
397bf215546Sopenharmony_ci   .name = "TA",
398bf215546Sopenharmony_ci   .num_counters = 2,
399bf215546Sopenharmony_ci   .flags = AC_PC_BLOCK_SE | AC_PC_BLOCK_INSTANCE_GROUPS | AC_PC_BLOCK_SHADER_WINDOWED,
400bf215546Sopenharmony_ci
401bf215546Sopenharmony_ci   .select0 = cik_TA_select0,
402bf215546Sopenharmony_ci   .select1 = cik_TA_select1,
403bf215546Sopenharmony_ci   .counter0_lo = R_034B00_TA_PERFCOUNTER0_LO,
404bf215546Sopenharmony_ci
405bf215546Sopenharmony_ci   .num_spm_counters = 1,
406bf215546Sopenharmony_ci   .num_spm_wires = 2,
407bf215546Sopenharmony_ci   .spm_block_select = 0x5,
408bf215546Sopenharmony_ci};
409bf215546Sopenharmony_ci
410bf215546Sopenharmony_ci/* cik_TD */
411bf215546Sopenharmony_cistatic unsigned cik_TD_select0[] = {
412bf215546Sopenharmony_ci   R_036C00_TD_PERFCOUNTER0_SELECT,
413bf215546Sopenharmony_ci   R_036C08_TD_PERFCOUNTER1_SELECT,
414bf215546Sopenharmony_ci};
415bf215546Sopenharmony_cistatic unsigned cik_TD_select1[] = {
416bf215546Sopenharmony_ci   R_036C04_TD_PERFCOUNTER0_SELECT1,
417bf215546Sopenharmony_ci};
418bf215546Sopenharmony_cistatic struct ac_pc_block_base cik_TD = {
419bf215546Sopenharmony_ci   .gpu_block = TD,
420bf215546Sopenharmony_ci   .name = "TD",
421bf215546Sopenharmony_ci   .num_counters = 2,
422bf215546Sopenharmony_ci   .flags = AC_PC_BLOCK_SE | AC_PC_BLOCK_INSTANCE_GROUPS | AC_PC_BLOCK_SHADER_WINDOWED,
423bf215546Sopenharmony_ci
424bf215546Sopenharmony_ci   .select0 = cik_TD_select0,
425bf215546Sopenharmony_ci   .select1 = cik_TD_select1,
426bf215546Sopenharmony_ci   .counter0_lo = R_034C00_TD_PERFCOUNTER0_LO,
427bf215546Sopenharmony_ci
428bf215546Sopenharmony_ci   .num_spm_counters = 1,
429bf215546Sopenharmony_ci   .num_spm_wires = 2,
430bf215546Sopenharmony_ci   .spm_block_select = 0x6,
431bf215546Sopenharmony_ci};
432bf215546Sopenharmony_ci
433bf215546Sopenharmony_ci/* cik_TCA */
434bf215546Sopenharmony_cistatic unsigned cik_TCA_select0[] = {
435bf215546Sopenharmony_ci   R_036E40_TCA_PERFCOUNTER0_SELECT,
436bf215546Sopenharmony_ci   R_036E48_TCA_PERFCOUNTER1_SELECT,
437bf215546Sopenharmony_ci   R_036E50_TCA_PERFCOUNTER2_SELECT,
438bf215546Sopenharmony_ci   R_036E54_TCA_PERFCOUNTER3_SELECT,
439bf215546Sopenharmony_ci};
440bf215546Sopenharmony_cistatic unsigned cik_TCA_select1[] = {
441bf215546Sopenharmony_ci   R_036E44_TCA_PERFCOUNTER0_SELECT1,
442bf215546Sopenharmony_ci   R_036E4C_TCA_PERFCOUNTER1_SELECT1,
443bf215546Sopenharmony_ci};
444bf215546Sopenharmony_cistatic struct ac_pc_block_base cik_TCA = {
445bf215546Sopenharmony_ci   .gpu_block = TCA,
446bf215546Sopenharmony_ci   .name = "TCA",
447bf215546Sopenharmony_ci   .num_counters = 4,
448bf215546Sopenharmony_ci   .flags = AC_PC_BLOCK_INSTANCE_GROUPS,
449bf215546Sopenharmony_ci
450bf215546Sopenharmony_ci   .select0 = cik_TCA_select0,
451bf215546Sopenharmony_ci   .select1 = cik_TCA_select1,
452bf215546Sopenharmony_ci   .counter0_lo = R_034E40_TCA_PERFCOUNTER0_LO,
453bf215546Sopenharmony_ci
454bf215546Sopenharmony_ci   .num_spm_counters = 2,
455bf215546Sopenharmony_ci   .num_spm_wires = 4,
456bf215546Sopenharmony_ci   .spm_block_select = 0x5,
457bf215546Sopenharmony_ci};
458bf215546Sopenharmony_ci
459bf215546Sopenharmony_ci/* cik_TCC */
460bf215546Sopenharmony_cistatic unsigned cik_TCC_select0[] = {
461bf215546Sopenharmony_ci   R_036E00_TCC_PERFCOUNTER0_SELECT,
462bf215546Sopenharmony_ci   R_036E08_TCC_PERFCOUNTER1_SELECT,
463bf215546Sopenharmony_ci   R_036E10_TCC_PERFCOUNTER2_SELECT,
464bf215546Sopenharmony_ci   R_036E14_TCC_PERFCOUNTER3_SELECT,
465bf215546Sopenharmony_ci};
466bf215546Sopenharmony_cistatic unsigned cik_TCC_select1[] = {
467bf215546Sopenharmony_ci   R_036E04_TCC_PERFCOUNTER0_SELECT1,
468bf215546Sopenharmony_ci   R_036E0C_TCC_PERFCOUNTER1_SELECT1,
469bf215546Sopenharmony_ci};
470bf215546Sopenharmony_cistatic struct ac_pc_block_base cik_TCC = {
471bf215546Sopenharmony_ci   .gpu_block = TCC,
472bf215546Sopenharmony_ci   .name = "TCC",
473bf215546Sopenharmony_ci   .num_counters = 4,
474bf215546Sopenharmony_ci   .flags = AC_PC_BLOCK_INSTANCE_GROUPS,
475bf215546Sopenharmony_ci
476bf215546Sopenharmony_ci   .select0 = cik_TCC_select0,
477bf215546Sopenharmony_ci   .select1 = cik_TCC_select1,
478bf215546Sopenharmony_ci   .counter0_lo = R_034E00_TCC_PERFCOUNTER0_LO,
479bf215546Sopenharmony_ci
480bf215546Sopenharmony_ci   .num_spm_counters = 2,
481bf215546Sopenharmony_ci   .num_spm_wires = 4,
482bf215546Sopenharmony_ci   .spm_block_select = 0x4,
483bf215546Sopenharmony_ci};
484bf215546Sopenharmony_ci
485bf215546Sopenharmony_ci/* cik_TCP */
486bf215546Sopenharmony_cistatic unsigned cik_TCP_select0[] = {
487bf215546Sopenharmony_ci   R_036D00_TCP_PERFCOUNTER0_SELECT,
488bf215546Sopenharmony_ci   R_036D08_TCP_PERFCOUNTER1_SELECT,
489bf215546Sopenharmony_ci   R_036D10_TCP_PERFCOUNTER2_SELECT,
490bf215546Sopenharmony_ci   R_036D14_TCP_PERFCOUNTER3_SELECT,
491bf215546Sopenharmony_ci};
492bf215546Sopenharmony_cistatic unsigned cik_TCP_select1[] = {
493bf215546Sopenharmony_ci   R_036D04_TCP_PERFCOUNTER0_SELECT1,
494bf215546Sopenharmony_ci   R_036D0C_TCP_PERFCOUNTER1_SELECT1,
495bf215546Sopenharmony_ci};
496bf215546Sopenharmony_cistatic struct ac_pc_block_base cik_TCP = {
497bf215546Sopenharmony_ci   .gpu_block = TCP,
498bf215546Sopenharmony_ci   .name = "TCP",
499bf215546Sopenharmony_ci   .num_counters = 4,
500bf215546Sopenharmony_ci   .flags = AC_PC_BLOCK_SE | AC_PC_BLOCK_INSTANCE_GROUPS | AC_PC_BLOCK_SHADER_WINDOWED,
501bf215546Sopenharmony_ci
502bf215546Sopenharmony_ci   .select0 = cik_TCP_select0,
503bf215546Sopenharmony_ci   .select1 = cik_TCP_select1,
504bf215546Sopenharmony_ci   .counter0_lo = R_034D00_TCP_PERFCOUNTER0_LO,
505bf215546Sopenharmony_ci
506bf215546Sopenharmony_ci   .num_spm_counters = 2,
507bf215546Sopenharmony_ci   .num_spm_wires = 3,
508bf215546Sopenharmony_ci   .spm_block_select = 0x7,
509bf215546Sopenharmony_ci};
510bf215546Sopenharmony_ci
511bf215546Sopenharmony_ci/* cik_VGT */
512bf215546Sopenharmony_cistatic unsigned cik_VGT_select0[] = {
513bf215546Sopenharmony_ci   R_036230_VGT_PERFCOUNTER0_SELECT,
514bf215546Sopenharmony_ci   R_036234_VGT_PERFCOUNTER1_SELECT,
515bf215546Sopenharmony_ci   R_036238_VGT_PERFCOUNTER2_SELECT,
516bf215546Sopenharmony_ci   R_03623C_VGT_PERFCOUNTER3_SELECT,
517bf215546Sopenharmony_ci};
518bf215546Sopenharmony_cistatic unsigned cik_VGT_select1[] = {
519bf215546Sopenharmony_ci   R_036240_VGT_PERFCOUNTER0_SELECT1,
520bf215546Sopenharmony_ci   R_036244_VGT_PERFCOUNTER1_SELECT1,
521bf215546Sopenharmony_ci};
522bf215546Sopenharmony_cistatic struct ac_pc_block_base cik_VGT = {
523bf215546Sopenharmony_ci   .gpu_block = VGT,
524bf215546Sopenharmony_ci   .name = "VGT",
525bf215546Sopenharmony_ci   .num_counters = 4,
526bf215546Sopenharmony_ci   .flags = AC_PC_BLOCK_SE,
527bf215546Sopenharmony_ci
528bf215546Sopenharmony_ci   .select0 = cik_VGT_select0,
529bf215546Sopenharmony_ci   .select1 = cik_VGT_select1,
530bf215546Sopenharmony_ci   .counter0_lo = R_034240_VGT_PERFCOUNTER0_LO,
531bf215546Sopenharmony_ci
532bf215546Sopenharmony_ci   .num_spm_counters = 2,
533bf215546Sopenharmony_ci   .num_spm_wires = 3,
534bf215546Sopenharmony_ci   .spm_block_select = 0xa,
535bf215546Sopenharmony_ci};
536bf215546Sopenharmony_ci
537bf215546Sopenharmony_ci/* cik_WD */
538bf215546Sopenharmony_cistatic unsigned cik_WD_select0[] = {
539bf215546Sopenharmony_ci   R_036200_WD_PERFCOUNTER0_SELECT,
540bf215546Sopenharmony_ci   R_036204_WD_PERFCOUNTER1_SELECT,
541bf215546Sopenharmony_ci   R_036208_WD_PERFCOUNTER2_SELECT,
542bf215546Sopenharmony_ci   R_03620C_WD_PERFCOUNTER3_SELECT,
543bf215546Sopenharmony_ci};
544bf215546Sopenharmony_cistatic struct ac_pc_block_base cik_WD = {
545bf215546Sopenharmony_ci   .gpu_block = WD,
546bf215546Sopenharmony_ci   .name = "WD",
547bf215546Sopenharmony_ci   .num_counters = 4,
548bf215546Sopenharmony_ci
549bf215546Sopenharmony_ci   .select0 = cik_WD_select0,
550bf215546Sopenharmony_ci   .counter0_lo = R_034200_WD_PERFCOUNTER0_LO,
551bf215546Sopenharmony_ci};
552bf215546Sopenharmony_ci
553bf215546Sopenharmony_ci/* cik_MC */
554bf215546Sopenharmony_cistatic struct ac_pc_block_base cik_MC = {
555bf215546Sopenharmony_ci   .gpu_block = MC,
556bf215546Sopenharmony_ci   .name = "MC",
557bf215546Sopenharmony_ci   .num_counters = 4,
558bf215546Sopenharmony_ci};
559bf215546Sopenharmony_ci
560bf215546Sopenharmony_ci/* cik_SRBM */
561bf215546Sopenharmony_cistatic struct ac_pc_block_base cik_SRBM = {
562bf215546Sopenharmony_ci   .gpu_block = SRBM,
563bf215546Sopenharmony_ci   .name = "SRBM",
564bf215546Sopenharmony_ci   .num_counters = 2,
565bf215546Sopenharmony_ci};
566bf215546Sopenharmony_ci
567bf215546Sopenharmony_ci/* gfx10_CHA */
568bf215546Sopenharmony_cistatic unsigned gfx10_CHA_select0[] = {
569bf215546Sopenharmony_ci   R_037780_CHA_PERFCOUNTER0_SELECT,
570bf215546Sopenharmony_ci   R_037788_CHA_PERFCOUNTER1_SELECT,
571bf215546Sopenharmony_ci   R_03778C_CHA_PERFCOUNTER2_SELECT,
572bf215546Sopenharmony_ci   R_037790_CHA_PERFCOUNTER3_SELECT,
573bf215546Sopenharmony_ci};
574bf215546Sopenharmony_cistatic unsigned gfx10_CHA_select1[] = {
575bf215546Sopenharmony_ci   R_037784_CHA_PERFCOUNTER0_SELECT1,
576bf215546Sopenharmony_ci};
577bf215546Sopenharmony_cistatic struct ac_pc_block_base gfx10_CHA = {
578bf215546Sopenharmony_ci   .gpu_block = CHA,
579bf215546Sopenharmony_ci   .name = "CHA",
580bf215546Sopenharmony_ci   .num_counters = 4,
581bf215546Sopenharmony_ci
582bf215546Sopenharmony_ci   .select0 = gfx10_CHA_select0,
583bf215546Sopenharmony_ci   .select1 = gfx10_CHA_select1,
584bf215546Sopenharmony_ci   .counter0_lo = R_035800_CHA_PERFCOUNTER0_LO,
585bf215546Sopenharmony_ci
586bf215546Sopenharmony_ci   .num_spm_counters = 1,
587bf215546Sopenharmony_ci   .num_spm_wires = 2,
588bf215546Sopenharmony_ci   .spm_block_select = 0xc,
589bf215546Sopenharmony_ci};
590bf215546Sopenharmony_ci
591bf215546Sopenharmony_ci/* gfx10_CHCG */
592bf215546Sopenharmony_cistatic unsigned gfx10_CHCG_select0[] = {
593bf215546Sopenharmony_ci   R_036F18_CHCG_PERFCOUNTER0_SELECT,
594bf215546Sopenharmony_ci   R_036F20_CHCG_PERFCOUNTER1_SELECT,
595bf215546Sopenharmony_ci   R_036F24_CHCG_PERFCOUNTER2_SELECT,
596bf215546Sopenharmony_ci   R_036F28_CHCG_PERFCOUNTER3_SELECT,
597bf215546Sopenharmony_ci};
598bf215546Sopenharmony_cistatic unsigned gfx10_CHCG_select1[] = {
599bf215546Sopenharmony_ci   R_036F1C_CHCG_PERFCOUNTER0_SELECT1,
600bf215546Sopenharmony_ci};
601bf215546Sopenharmony_cistatic struct ac_pc_block_base gfx10_CHCG = {
602bf215546Sopenharmony_ci   .gpu_block = CHCG,
603bf215546Sopenharmony_ci   .name = "CHCG",
604bf215546Sopenharmony_ci   .num_counters = 4,
605bf215546Sopenharmony_ci
606bf215546Sopenharmony_ci   .select0 = gfx10_CHCG_select0,
607bf215546Sopenharmony_ci   .select1 = gfx10_CHCG_select1,
608bf215546Sopenharmony_ci   .counter0_lo = R_034F20_CHCG_PERFCOUNTER0_LO,
609bf215546Sopenharmony_ci
610bf215546Sopenharmony_ci   .num_spm_counters = 1,
611bf215546Sopenharmony_ci   .num_spm_wires = 2,
612bf215546Sopenharmony_ci   .spm_block_select = 0xe,
613bf215546Sopenharmony_ci};
614bf215546Sopenharmony_ci
615bf215546Sopenharmony_ci/* gfx10_CHC */
616bf215546Sopenharmony_cistatic unsigned gfx10_CHC_select0[] = {
617bf215546Sopenharmony_ci   R_036F00_CHC_PERFCOUNTER0_SELECT,
618bf215546Sopenharmony_ci   R_036F08_CHC_PERFCOUNTER1_SELECT,
619bf215546Sopenharmony_ci   R_036F0C_CHC_PERFCOUNTER2_SELECT,
620bf215546Sopenharmony_ci   R_036F10_CHC_PERFCOUNTER3_SELECT,
621bf215546Sopenharmony_ci};
622bf215546Sopenharmony_cistatic unsigned gfx10_CHC_select1[] = {
623bf215546Sopenharmony_ci   R_036F04_CHC_PERFCOUNTER0_SELECT1,
624bf215546Sopenharmony_ci};
625bf215546Sopenharmony_cistatic struct ac_pc_block_base gfx10_CHC = {
626bf215546Sopenharmony_ci   .gpu_block = CHC,
627bf215546Sopenharmony_ci   .name = "CHC",
628bf215546Sopenharmony_ci   .num_counters = 4,
629bf215546Sopenharmony_ci
630bf215546Sopenharmony_ci   .select0 = gfx10_CHC_select0,
631bf215546Sopenharmony_ci   .select1 = gfx10_CHC_select1,
632bf215546Sopenharmony_ci   .counter0_lo = R_034F00_CHC_PERFCOUNTER0_LO,
633bf215546Sopenharmony_ci
634bf215546Sopenharmony_ci   .num_spm_counters = 1,
635bf215546Sopenharmony_ci   .num_spm_wires = 2,
636bf215546Sopenharmony_ci   .spm_block_select = 0xd,
637bf215546Sopenharmony_ci};
638bf215546Sopenharmony_ci
639bf215546Sopenharmony_ci/* gfx10_DB */
640bf215546Sopenharmony_cistatic struct ac_pc_block_base gfx10_DB = {
641bf215546Sopenharmony_ci   .gpu_block = DB,
642bf215546Sopenharmony_ci   .name = "DB",
643bf215546Sopenharmony_ci   .num_counters = 4,
644bf215546Sopenharmony_ci   .flags = AC_PC_BLOCK_SE | AC_PC_BLOCK_INSTANCE_GROUPS,
645bf215546Sopenharmony_ci
646bf215546Sopenharmony_ci   .select0 = cik_DB_select0,
647bf215546Sopenharmony_ci   .select1 = cik_DB_select1,
648bf215546Sopenharmony_ci   .counter0_lo = R_035100_DB_PERFCOUNTER0_LO,
649bf215546Sopenharmony_ci
650bf215546Sopenharmony_ci   .num_spm_counters = 2,
651bf215546Sopenharmony_ci   .num_spm_wires = 4,
652bf215546Sopenharmony_ci   .spm_block_select = 0x1,
653bf215546Sopenharmony_ci};
654bf215546Sopenharmony_ci
655bf215546Sopenharmony_ci/* gfx10_GCR */
656bf215546Sopenharmony_cistatic unsigned gfx10_GCR_select0[] = {
657bf215546Sopenharmony_ci   R_037580_GCR_PERFCOUNTER0_SELECT,
658bf215546Sopenharmony_ci   R_037588_GCR_PERFCOUNTER1_SELECT,
659bf215546Sopenharmony_ci};
660bf215546Sopenharmony_cistatic unsigned gfx10_GCR_select1[] = {
661bf215546Sopenharmony_ci   R_037584_GCR_PERFCOUNTER0_SELECT1,
662bf215546Sopenharmony_ci};
663bf215546Sopenharmony_cistatic struct ac_pc_block_base gfx10_GCR = {
664bf215546Sopenharmony_ci   .gpu_block = GCR,
665bf215546Sopenharmony_ci   .name = "GCR",
666bf215546Sopenharmony_ci   .num_counters = 2,
667bf215546Sopenharmony_ci
668bf215546Sopenharmony_ci   .select0 = gfx10_GCR_select0,
669bf215546Sopenharmony_ci   .select1 = gfx10_GCR_select1,
670bf215546Sopenharmony_ci   .counter0_lo = R_035480_GCR_PERFCOUNTER0_LO,
671bf215546Sopenharmony_ci
672bf215546Sopenharmony_ci   .num_spm_counters = 1,
673bf215546Sopenharmony_ci   .num_spm_wires = 2,
674bf215546Sopenharmony_ci   .spm_block_select = 0x4,
675bf215546Sopenharmony_ci};
676bf215546Sopenharmony_ci
677bf215546Sopenharmony_ci/* gfx10_GE */
678bf215546Sopenharmony_cistatic unsigned gfx10_GE_select0[] = {
679bf215546Sopenharmony_ci   R_036200_GE_PERFCOUNTER0_SELECT,
680bf215546Sopenharmony_ci   R_036208_GE_PERFCOUNTER1_SELECT,
681bf215546Sopenharmony_ci   R_036210_GE_PERFCOUNTER2_SELECT,
682bf215546Sopenharmony_ci   R_036218_GE_PERFCOUNTER3_SELECT,
683bf215546Sopenharmony_ci   R_036220_GE_PERFCOUNTER4_SELECT,
684bf215546Sopenharmony_ci   R_036228_GE_PERFCOUNTER5_SELECT,
685bf215546Sopenharmony_ci   R_036230_GE_PERFCOUNTER6_SELECT,
686bf215546Sopenharmony_ci   R_036238_GE_PERFCOUNTER7_SELECT,
687bf215546Sopenharmony_ci   R_036240_GE_PERFCOUNTER8_SELECT,
688bf215546Sopenharmony_ci   R_036248_GE_PERFCOUNTER9_SELECT,
689bf215546Sopenharmony_ci   R_036250_GE_PERFCOUNTER10_SELECT,
690bf215546Sopenharmony_ci   R_036258_GE_PERFCOUNTER11_SELECT,
691bf215546Sopenharmony_ci};
692bf215546Sopenharmony_cistatic unsigned gfx10_GE_select1[] = {
693bf215546Sopenharmony_ci   R_036204_GE_PERFCOUNTER0_SELECT1,
694bf215546Sopenharmony_ci   R_03620C_GE_PERFCOUNTER1_SELECT1,
695bf215546Sopenharmony_ci   R_036214_GE_PERFCOUNTER2_SELECT1,
696bf215546Sopenharmony_ci   R_03621C_GE_PERFCOUNTER3_SELECT1,
697bf215546Sopenharmony_ci};
698bf215546Sopenharmony_cistatic struct ac_pc_block_base gfx10_GE = {
699bf215546Sopenharmony_ci   .gpu_block = GE,
700bf215546Sopenharmony_ci   .name = "GE",
701bf215546Sopenharmony_ci   .num_counters = 12,
702bf215546Sopenharmony_ci
703bf215546Sopenharmony_ci   .select0 = gfx10_GE_select0,
704bf215546Sopenharmony_ci   .select1 = gfx10_GE_select1,
705bf215546Sopenharmony_ci   .counter0_lo = R_034200_GE_PERFCOUNTER0_LO,
706bf215546Sopenharmony_ci
707bf215546Sopenharmony_ci   .num_spm_counters = 4,
708bf215546Sopenharmony_ci   .num_spm_wires = 8,
709bf215546Sopenharmony_ci   .spm_block_select = 0x6,
710bf215546Sopenharmony_ci};
711bf215546Sopenharmony_ci
712bf215546Sopenharmony_ci/* gfx10_GL1A */
713bf215546Sopenharmony_cistatic unsigned gfx10_GL1A_select0[] = {
714bf215546Sopenharmony_ci   R_037700_GL1A_PERFCOUNTER0_SELECT,
715bf215546Sopenharmony_ci   R_037708_GL1A_PERFCOUNTER1_SELECT,
716bf215546Sopenharmony_ci   R_03770C_GL1A_PERFCOUNTER2_SELECT,
717bf215546Sopenharmony_ci   R_037710_GL1A_PERFCOUNTER3_SELECT,
718bf215546Sopenharmony_ci};
719bf215546Sopenharmony_cistatic unsigned gfx10_GL1A_select1[] = {
720bf215546Sopenharmony_ci   R_037704_GL1A_PERFCOUNTER0_SELECT1,
721bf215546Sopenharmony_ci};
722bf215546Sopenharmony_cistatic struct ac_pc_block_base gfx10_GL1A = {
723bf215546Sopenharmony_ci   .gpu_block = GL1A,
724bf215546Sopenharmony_ci   .name = "GL1A",
725bf215546Sopenharmony_ci   .num_counters = 4,
726bf215546Sopenharmony_ci   .flags = AC_PC_BLOCK_SE | AC_PC_BLOCK_SHADER_WINDOWED,
727bf215546Sopenharmony_ci
728bf215546Sopenharmony_ci   .select0 = gfx10_GL1A_select0,
729bf215546Sopenharmony_ci   .select1 = gfx10_GL1A_select1,
730bf215546Sopenharmony_ci   .counter0_lo = R_035700_GL1A_PERFCOUNTER0_LO,
731bf215546Sopenharmony_ci
732bf215546Sopenharmony_ci   .num_spm_counters = 1,
733bf215546Sopenharmony_ci   .num_spm_wires = 2,
734bf215546Sopenharmony_ci   .spm_block_select = 0xa,
735bf215546Sopenharmony_ci};
736bf215546Sopenharmony_ci
737bf215546Sopenharmony_ci/* gfx10_GL1C */
738bf215546Sopenharmony_cistatic unsigned gfx10_GL1C_select0[] = {
739bf215546Sopenharmony_ci   R_036E80_GL1C_PERFCOUNTER0_SELECT,
740bf215546Sopenharmony_ci   R_036E88_GL1C_PERFCOUNTER1_SELECT,
741bf215546Sopenharmony_ci   R_036E8C_GL1C_PERFCOUNTER2_SELECT,
742bf215546Sopenharmony_ci   R_036E90_GL1C_PERFCOUNTER3_SELECT,
743bf215546Sopenharmony_ci};
744bf215546Sopenharmony_cistatic unsigned gfx10_GL1C_select1[] = {
745bf215546Sopenharmony_ci   R_036E84_GL1C_PERFCOUNTER0_SELECT1,
746bf215546Sopenharmony_ci};
747bf215546Sopenharmony_cistatic struct ac_pc_block_base gfx10_GL1C = {
748bf215546Sopenharmony_ci   .gpu_block = GL1C,
749bf215546Sopenharmony_ci   .name = "GL1C",
750bf215546Sopenharmony_ci   .num_counters = 4,
751bf215546Sopenharmony_ci   .flags = AC_PC_BLOCK_SE | AC_PC_BLOCK_SHADER_WINDOWED,
752bf215546Sopenharmony_ci
753bf215546Sopenharmony_ci   .select0 = gfx10_GL1C_select0,
754bf215546Sopenharmony_ci   .select1 = gfx10_GL1C_select1,
755bf215546Sopenharmony_ci   .counter0_lo = R_034E80_GL1C_PERFCOUNTER0_LO,
756bf215546Sopenharmony_ci
757bf215546Sopenharmony_ci   .num_spm_counters = 1,
758bf215546Sopenharmony_ci   .num_spm_wires = 2,
759bf215546Sopenharmony_ci   .spm_block_select = 0xc
760bf215546Sopenharmony_ci};
761bf215546Sopenharmony_ci
762bf215546Sopenharmony_ci/* gfx10_GL2A */
763bf215546Sopenharmony_cistatic unsigned gfx10_GL2A_select0[] = {
764bf215546Sopenharmony_ci   R_036E40_GL2A_PERFCOUNTER0_SELECT,
765bf215546Sopenharmony_ci   R_036E48_GL2A_PERFCOUNTER1_SELECT,
766bf215546Sopenharmony_ci   R_036E50_GL2A_PERFCOUNTER2_SELECT,
767bf215546Sopenharmony_ci   R_036E54_GL2A_PERFCOUNTER3_SELECT,
768bf215546Sopenharmony_ci};
769bf215546Sopenharmony_cistatic unsigned gfx10_GL2A_select1[] = {
770bf215546Sopenharmony_ci   R_036E44_GL2A_PERFCOUNTER0_SELECT1,
771bf215546Sopenharmony_ci   R_036E4C_GL2A_PERFCOUNTER1_SELECT1,
772bf215546Sopenharmony_ci};
773bf215546Sopenharmony_cistatic struct ac_pc_block_base gfx10_GL2A = {
774bf215546Sopenharmony_ci   .gpu_block = GL2A,
775bf215546Sopenharmony_ci   .name = "GL2A",
776bf215546Sopenharmony_ci   .num_counters = 4,
777bf215546Sopenharmony_ci
778bf215546Sopenharmony_ci   .select0 = gfx10_GL2A_select0,
779bf215546Sopenharmony_ci   .select1 = gfx10_GL2A_select1,
780bf215546Sopenharmony_ci   .counter0_lo = R_034E40_GL2A_PERFCOUNTER0_LO,
781bf215546Sopenharmony_ci
782bf215546Sopenharmony_ci   .num_spm_counters = 2,
783bf215546Sopenharmony_ci   .num_spm_wires = 4,
784bf215546Sopenharmony_ci   .spm_block_select = 0x7,
785bf215546Sopenharmony_ci};
786bf215546Sopenharmony_ci
787bf215546Sopenharmony_ci/* gfx10_GL2C */
788bf215546Sopenharmony_cistatic unsigned gfx10_GL2C_select0[] = {
789bf215546Sopenharmony_ci   R_036E00_GL2C_PERFCOUNTER0_SELECT,
790bf215546Sopenharmony_ci   R_036E08_GL2C_PERFCOUNTER1_SELECT,
791bf215546Sopenharmony_ci   R_036E10_GL2C_PERFCOUNTER2_SELECT,
792bf215546Sopenharmony_ci   R_036E14_GL2C_PERFCOUNTER3_SELECT,
793bf215546Sopenharmony_ci};
794bf215546Sopenharmony_cistatic unsigned gfx10_GL2C_select1[] = {
795bf215546Sopenharmony_ci   R_036E04_GL2C_PERFCOUNTER0_SELECT1,
796bf215546Sopenharmony_ci   R_036E0C_GL2C_PERFCOUNTER1_SELECT1,
797bf215546Sopenharmony_ci};
798bf215546Sopenharmony_cistatic struct ac_pc_block_base gfx10_GL2C = {
799bf215546Sopenharmony_ci   .gpu_block = GL2C,
800bf215546Sopenharmony_ci   .name = "GL2C",
801bf215546Sopenharmony_ci   .num_counters = 4,
802bf215546Sopenharmony_ci
803bf215546Sopenharmony_ci   .select0 = gfx10_GL2C_select0,
804bf215546Sopenharmony_ci   .select1 = gfx10_GL2C_select1,
805bf215546Sopenharmony_ci   .counter0_lo = R_034E00_GL2C_PERFCOUNTER0_LO,
806bf215546Sopenharmony_ci
807bf215546Sopenharmony_ci   .num_spm_counters = 2,
808bf215546Sopenharmony_ci   .num_spm_wires = 4,
809bf215546Sopenharmony_ci   .spm_block_select = 0x8,
810bf215546Sopenharmony_ci};
811bf215546Sopenharmony_ci
812bf215546Sopenharmony_ci/* gfx10_PA_PH */
813bf215546Sopenharmony_cistatic unsigned gfx10_PA_PH_select0[] = {
814bf215546Sopenharmony_ci   R_037600_PA_PH_PERFCOUNTER0_SELECT,
815bf215546Sopenharmony_ci   R_037608_PA_PH_PERFCOUNTER1_SELECT,
816bf215546Sopenharmony_ci   R_03760C_PA_PH_PERFCOUNTER2_SELECT,
817bf215546Sopenharmony_ci   R_037610_PA_PH_PERFCOUNTER3_SELECT,
818bf215546Sopenharmony_ci   R_037614_PA_PH_PERFCOUNTER4_SELECT,
819bf215546Sopenharmony_ci   R_037618_PA_PH_PERFCOUNTER5_SELECT,
820bf215546Sopenharmony_ci   R_03761C_PA_PH_PERFCOUNTER6_SELECT,
821bf215546Sopenharmony_ci   R_037620_PA_PH_PERFCOUNTER7_SELECT,
822bf215546Sopenharmony_ci};
823bf215546Sopenharmony_cistatic unsigned gfx10_PA_PH_select1[] = {
824bf215546Sopenharmony_ci   R_037604_PA_PH_PERFCOUNTER0_SELECT1,
825bf215546Sopenharmony_ci   R_037640_PA_PH_PERFCOUNTER1_SELECT1,
826bf215546Sopenharmony_ci   R_037644_PA_PH_PERFCOUNTER2_SELECT1,
827bf215546Sopenharmony_ci   R_037648_PA_PH_PERFCOUNTER3_SELECT1,
828bf215546Sopenharmony_ci};
829bf215546Sopenharmony_cistatic struct ac_pc_block_base gfx10_PA_PH = {
830bf215546Sopenharmony_ci   .gpu_block = PA_PH,
831bf215546Sopenharmony_ci   .name = "PA_PH",
832bf215546Sopenharmony_ci   .num_counters = 8,
833bf215546Sopenharmony_ci   .flags = AC_PC_BLOCK_SE,
834bf215546Sopenharmony_ci
835bf215546Sopenharmony_ci   .select0 = gfx10_PA_PH_select0,
836bf215546Sopenharmony_ci   .select1 = gfx10_PA_PH_select1,
837bf215546Sopenharmony_ci   .counter0_lo = R_035600_PA_PH_PERFCOUNTER0_LO,
838bf215546Sopenharmony_ci
839bf215546Sopenharmony_ci   .num_spm_counters = 4,
840bf215546Sopenharmony_ci   .num_spm_wires = 8,
841bf215546Sopenharmony_ci   .spm_block_select = 0x5,
842bf215546Sopenharmony_ci};
843bf215546Sopenharmony_ci
844bf215546Sopenharmony_ci/* gfx10_PA_SU */
845bf215546Sopenharmony_cistatic unsigned gfx10_PA_SU_select0[] = {
846bf215546Sopenharmony_ci   R_036400_PA_SU_PERFCOUNTER0_SELECT,
847bf215546Sopenharmony_ci   R_036408_PA_SU_PERFCOUNTER1_SELECT,
848bf215546Sopenharmony_ci   R_036410_PA_SU_PERFCOUNTER2_SELECT,
849bf215546Sopenharmony_ci   R_036418_PA_SU_PERFCOUNTER3_SELECT,
850bf215546Sopenharmony_ci};
851bf215546Sopenharmony_cistatic unsigned gfx10_PA_SU_select1[] = {
852bf215546Sopenharmony_ci   R_036404_PA_SU_PERFCOUNTER0_SELECT1,
853bf215546Sopenharmony_ci   R_03640C_PA_SU_PERFCOUNTER1_SELECT1,
854bf215546Sopenharmony_ci   R_036414_PA_SU_PERFCOUNTER2_SELECT1,
855bf215546Sopenharmony_ci   R_03641C_PA_SU_PERFCOUNTER3_SELECT1,
856bf215546Sopenharmony_ci};
857bf215546Sopenharmony_cistatic struct ac_pc_block_base gfx10_PA_SU = {
858bf215546Sopenharmony_ci   .gpu_block = PA_SU,
859bf215546Sopenharmony_ci   .name = "PA_SU",
860bf215546Sopenharmony_ci   .num_counters = 4,
861bf215546Sopenharmony_ci   .flags = AC_PC_BLOCK_SE,
862bf215546Sopenharmony_ci
863bf215546Sopenharmony_ci   .select0 = gfx10_PA_SU_select0,
864bf215546Sopenharmony_ci   .select1 = gfx10_PA_SU_select1,
865bf215546Sopenharmony_ci   .counter0_lo = R_034400_PA_SU_PERFCOUNTER0_LO,
866bf215546Sopenharmony_ci
867bf215546Sopenharmony_ci   .num_spm_counters = 4,
868bf215546Sopenharmony_ci   .num_spm_wires = 8,
869bf215546Sopenharmony_ci   .spm_block_select = 0x2,
870bf215546Sopenharmony_ci};
871bf215546Sopenharmony_ci
872bf215546Sopenharmony_ci/* gfx10_RLC */
873bf215546Sopenharmony_cistatic unsigned gfx10_RLC_select0[] = {
874bf215546Sopenharmony_ci   R_037304_RLC_PERFCOUNTER0_SELECT,
875bf215546Sopenharmony_ci   R_037308_RLC_PERFCOUNTER1_SELECT,
876bf215546Sopenharmony_ci};
877bf215546Sopenharmony_cistatic struct ac_pc_block_base gfx10_RLC = {
878bf215546Sopenharmony_ci   .gpu_block = RLC,
879bf215546Sopenharmony_ci   .name = "RLC",
880bf215546Sopenharmony_ci   .num_counters = 2,
881bf215546Sopenharmony_ci
882bf215546Sopenharmony_ci   .select0 = gfx10_RLC_select0,
883bf215546Sopenharmony_ci   .counter0_lo = R_035200_RLC_PERFCOUNTER0_LO,
884bf215546Sopenharmony_ci   .num_spm_counters = 0,
885bf215546Sopenharmony_ci};
886bf215546Sopenharmony_ci
887bf215546Sopenharmony_ci/* gfx10_RMI */
888bf215546Sopenharmony_cistatic unsigned gfx10_RMI_select0[] = {
889bf215546Sopenharmony_ci   R_037400_RMI_PERFCOUNTER0_SELECT,
890bf215546Sopenharmony_ci   R_037408_RMI_PERFCOUNTER1_SELECT,
891bf215546Sopenharmony_ci   R_03740C_RMI_PERFCOUNTER2_SELECT,
892bf215546Sopenharmony_ci   R_037414_RMI_PERFCOUNTER3_SELECT,
893bf215546Sopenharmony_ci};
894bf215546Sopenharmony_cistatic unsigned gfx10_RMI_select1[] = {
895bf215546Sopenharmony_ci   R_037404_RMI_PERFCOUNTER0_SELECT1,
896bf215546Sopenharmony_ci   R_037410_RMI_PERFCOUNTER2_SELECT1,
897bf215546Sopenharmony_ci};
898bf215546Sopenharmony_cistatic struct ac_pc_block_base gfx10_RMI = {
899bf215546Sopenharmony_ci   .gpu_block = RMI,
900bf215546Sopenharmony_ci   .name = "RMI",
901bf215546Sopenharmony_ci   .num_counters = 4,
902bf215546Sopenharmony_ci   .flags = AC_PC_BLOCK_SE | AC_PC_BLOCK_INSTANCE_GROUPS,
903bf215546Sopenharmony_ci
904bf215546Sopenharmony_ci   .select0 = gfx10_RMI_select0,
905bf215546Sopenharmony_ci   .select1 = gfx10_RMI_select1,
906bf215546Sopenharmony_ci   .counter0_lo = R_035300_RMI_PERFCOUNTER0_LO,
907bf215546Sopenharmony_ci
908bf215546Sopenharmony_ci   .num_spm_counters = 2,
909bf215546Sopenharmony_ci   .num_spm_wires = 2,
910bf215546Sopenharmony_ci   .spm_block_select = 0xb,
911bf215546Sopenharmony_ci};
912bf215546Sopenharmony_ci
913bf215546Sopenharmony_ci/* gfx10_SQ */
914bf215546Sopenharmony_cistatic struct ac_pc_block_base gfx10_SQ = {
915bf215546Sopenharmony_ci   .gpu_block = SQ,
916bf215546Sopenharmony_ci   .name = "SQ",
917bf215546Sopenharmony_ci   .num_counters = 16,
918bf215546Sopenharmony_ci   .flags = AC_PC_BLOCK_SE | AC_PC_BLOCK_SHADER,
919bf215546Sopenharmony_ci
920bf215546Sopenharmony_ci   .select0 = cik_SQ_select0,
921bf215546Sopenharmony_ci   .select_or = S_036700_SQC_BANK_MASK(15),
922bf215546Sopenharmony_ci   .counter0_lo = R_034700_SQ_PERFCOUNTER0_LO,
923bf215546Sopenharmony_ci
924bf215546Sopenharmony_ci   .num_spm_wires = 16,
925bf215546Sopenharmony_ci   .spm_block_select = 0x9,
926bf215546Sopenharmony_ci};
927bf215546Sopenharmony_ci
928bf215546Sopenharmony_ci/* gfx10_TCP */
929bf215546Sopenharmony_cistatic struct ac_pc_block_base gfx10_TCP = {
930bf215546Sopenharmony_ci   .gpu_block = TCP,
931bf215546Sopenharmony_ci   .name = "TCP",
932bf215546Sopenharmony_ci   .num_counters = 4,
933bf215546Sopenharmony_ci   .flags = AC_PC_BLOCK_SE | AC_PC_BLOCK_INSTANCE_GROUPS | AC_PC_BLOCK_SHADER_WINDOWED,
934bf215546Sopenharmony_ci
935bf215546Sopenharmony_ci   .select0 = cik_TCP_select0,
936bf215546Sopenharmony_ci   .select1 = cik_TCP_select1,
937bf215546Sopenharmony_ci   .counter0_lo = R_034D00_TCP_PERFCOUNTER0_LO,
938bf215546Sopenharmony_ci
939bf215546Sopenharmony_ci   .num_spm_counters = 2,
940bf215546Sopenharmony_ci   .num_spm_wires = 4,
941bf215546Sopenharmony_ci   .spm_block_select = 0x7,
942bf215546Sopenharmony_ci};
943bf215546Sopenharmony_ci
944bf215546Sopenharmony_ci/* gfx10_UTCL1 */
945bf215546Sopenharmony_cistatic unsigned gfx10_UTCL1_select0[] = {
946bf215546Sopenharmony_ci   R_03758C_UTCL1_PERFCOUNTER0_SELECT,
947bf215546Sopenharmony_ci   R_037590_UTCL1_PERFCOUNTER1_SELECT,
948bf215546Sopenharmony_ci};
949bf215546Sopenharmony_cistatic struct ac_pc_block_base gfx10_UTCL1 = {
950bf215546Sopenharmony_ci   .gpu_block = UTCL1,
951bf215546Sopenharmony_ci   .name = "UTCL1",
952bf215546Sopenharmony_ci   .num_counters = 2,
953bf215546Sopenharmony_ci   .flags = AC_PC_BLOCK_SE | AC_PC_BLOCK_SHADER_WINDOWED,
954bf215546Sopenharmony_ci
955bf215546Sopenharmony_ci   .select0 = gfx10_UTCL1_select0,
956bf215546Sopenharmony_ci   .counter0_lo = R_035470_UTCL1_PERFCOUNTER0_LO,
957bf215546Sopenharmony_ci   .num_spm_counters = 0,
958bf215546Sopenharmony_ci};
959bf215546Sopenharmony_ci
960bf215546Sopenharmony_ci/* Both the number of instances and selectors varies between chips of the same
961bf215546Sopenharmony_ci * class. We only differentiate by class here and simply expose the maximum
962bf215546Sopenharmony_ci * number over all chips in a class.
963bf215546Sopenharmony_ci *
964bf215546Sopenharmony_ci * Unfortunately, GPUPerfStudio uses the order of performance counter groups
965bf215546Sopenharmony_ci * blindly once it believes it has identified the hardware, so the order of
966bf215546Sopenharmony_ci * blocks here matters.
967bf215546Sopenharmony_ci */
968bf215546Sopenharmony_cistatic struct ac_pc_block_gfxdescr groups_CIK[] = {
969bf215546Sopenharmony_ci   {&cik_CB, 226},     {&cik_CPF, 17},    {&cik_DB, 257},  {&cik_GRBM, 34},   {&cik_GRBMSE, 15},
970bf215546Sopenharmony_ci   {&cik_PA_SU, 153},  {&cik_PA_SC, 395}, {&cik_SPI, 186}, {&cik_SQ, 252},    {&cik_SX, 32},
971bf215546Sopenharmony_ci   {&cik_TA, 111},     {&cik_TCA, 39, 2}, {&cik_TCC, 160}, {&cik_TD, 55},     {&cik_TCP, 154},
972bf215546Sopenharmony_ci   {&cik_GDS, 121},    {&cik_VGT, 140},   {&cik_IA, 22},   {&cik_MC, 22},     {&cik_SRBM, 19},
973bf215546Sopenharmony_ci   {&cik_WD, 22},      {&cik_CPG, 46},    {&cik_CPC, 22},
974bf215546Sopenharmony_ci
975bf215546Sopenharmony_ci};
976bf215546Sopenharmony_ci
977bf215546Sopenharmony_cistatic struct ac_pc_block_gfxdescr groups_VI[] = {
978bf215546Sopenharmony_ci   {&cik_CB, 405},     {&cik_CPF, 19},    {&cik_DB, 257},  {&cik_GRBM, 34},   {&cik_GRBMSE, 15},
979bf215546Sopenharmony_ci   {&cik_PA_SU, 154},  {&cik_PA_SC, 397}, {&cik_SPI, 197}, {&cik_SQ, 273},    {&cik_SX, 34},
980bf215546Sopenharmony_ci   {&cik_TA, 119},     {&cik_TCA, 35, 2}, {&cik_TCC, 192}, {&cik_TD, 55},     {&cik_TCP, 180},
981bf215546Sopenharmony_ci   {&cik_GDS, 121},    {&cik_VGT, 147},   {&cik_IA, 24},   {&cik_MC, 22},     {&cik_SRBM, 27},
982bf215546Sopenharmony_ci   {&cik_WD, 37},      {&cik_CPG, 48},    {&cik_CPC, 24},
983bf215546Sopenharmony_ci
984bf215546Sopenharmony_ci};
985bf215546Sopenharmony_ci
986bf215546Sopenharmony_cistatic struct ac_pc_block_gfxdescr groups_gfx9[] = {
987bf215546Sopenharmony_ci   {&cik_CB, 438},     {&cik_CPF, 32},    {&cik_DB, 328},  {&cik_GRBM, 38},   {&cik_GRBMSE, 16},
988bf215546Sopenharmony_ci   {&cik_PA_SU, 292},  {&cik_PA_SC, 491}, {&cik_SPI, 196}, {&cik_SQ, 374},    {&cik_SX, 208},
989bf215546Sopenharmony_ci   {&cik_TA, 119},     {&cik_TCA, 35, 2}, {&cik_TCC, 256}, {&cik_TD, 57},     {&cik_TCP, 85},
990bf215546Sopenharmony_ci   {&cik_GDS, 121},    {&cik_VGT, 148},   {&cik_IA, 32},   {&cik_WD, 58},     {&cik_CPG, 59},
991bf215546Sopenharmony_ci   {&cik_CPC, 35},
992bf215546Sopenharmony_ci};
993bf215546Sopenharmony_ci
994bf215546Sopenharmony_cistatic struct ac_pc_block_gfxdescr groups_gfx10[] = {
995bf215546Sopenharmony_ci   {&cik_CB, 461},
996bf215546Sopenharmony_ci   {&gfx10_CHA, 45},
997bf215546Sopenharmony_ci   {&gfx10_CHCG, 35},
998bf215546Sopenharmony_ci   {&gfx10_CHC, 35},
999bf215546Sopenharmony_ci   {&cik_CPC, 47},
1000bf215546Sopenharmony_ci   {&cik_CPF, 40},
1001bf215546Sopenharmony_ci   {&cik_CPG, 82},
1002bf215546Sopenharmony_ci   {&gfx10_DB, 370},
1003bf215546Sopenharmony_ci   {&gfx10_GCR, 94},
1004bf215546Sopenharmony_ci   {&cik_GDS, 123},
1005bf215546Sopenharmony_ci   {&gfx10_GE, 315},
1006bf215546Sopenharmony_ci   {&gfx10_GL1A, 36},
1007bf215546Sopenharmony_ci   {&gfx10_GL1C, 64},
1008bf215546Sopenharmony_ci   {&gfx10_GL2A, 91},
1009bf215546Sopenharmony_ci   {&gfx10_GL2C, 235},
1010bf215546Sopenharmony_ci   {&cik_GRBM, 47},
1011bf215546Sopenharmony_ci   {&cik_GRBMSE, 19},
1012bf215546Sopenharmony_ci   {&gfx10_PA_PH, 960},
1013bf215546Sopenharmony_ci   {&cik_PA_SC, 552},
1014bf215546Sopenharmony_ci   {&gfx10_PA_SU, 266},
1015bf215546Sopenharmony_ci   {&gfx10_RLC, 7},
1016bf215546Sopenharmony_ci   {&gfx10_RMI, 258},
1017bf215546Sopenharmony_ci   {&cik_SPI, 329},
1018bf215546Sopenharmony_ci   {&gfx10_SQ, 509},
1019bf215546Sopenharmony_ci   {&cik_SX, 225},
1020bf215546Sopenharmony_ci   {&cik_TA, 226},
1021bf215546Sopenharmony_ci   {&gfx10_TCP, 77},
1022bf215546Sopenharmony_ci   {&cik_TD, 61},
1023bf215546Sopenharmony_ci   {&gfx10_UTCL1, 15},
1024bf215546Sopenharmony_ci};
1025bf215546Sopenharmony_ci
1026bf215546Sopenharmony_cistruct ac_pc_block *ac_lookup_counter(const struct ac_perfcounters *pc,
1027bf215546Sopenharmony_ci                                      unsigned index, unsigned *base_gid,
1028bf215546Sopenharmony_ci                                      unsigned *sub_index)
1029bf215546Sopenharmony_ci{
1030bf215546Sopenharmony_ci   struct ac_pc_block *block = pc->blocks;
1031bf215546Sopenharmony_ci   unsigned bid;
1032bf215546Sopenharmony_ci
1033bf215546Sopenharmony_ci   *base_gid = 0;
1034bf215546Sopenharmony_ci   for (bid = 0; bid < pc->num_blocks; ++bid, ++block) {
1035bf215546Sopenharmony_ci      unsigned total = block->num_groups * block->b->selectors;
1036bf215546Sopenharmony_ci
1037bf215546Sopenharmony_ci      if (index < total) {
1038bf215546Sopenharmony_ci         *sub_index = index;
1039bf215546Sopenharmony_ci         return block;
1040bf215546Sopenharmony_ci      }
1041bf215546Sopenharmony_ci
1042bf215546Sopenharmony_ci      index -= total;
1043bf215546Sopenharmony_ci      *base_gid += block->num_groups;
1044bf215546Sopenharmony_ci   }
1045bf215546Sopenharmony_ci
1046bf215546Sopenharmony_ci   return NULL;
1047bf215546Sopenharmony_ci}
1048bf215546Sopenharmony_ci
1049bf215546Sopenharmony_cistruct ac_pc_block *ac_lookup_group(const struct ac_perfcounters *pc,
1050bf215546Sopenharmony_ci                                    unsigned *index)
1051bf215546Sopenharmony_ci{
1052bf215546Sopenharmony_ci   unsigned bid;
1053bf215546Sopenharmony_ci   struct ac_pc_block *block = pc->blocks;
1054bf215546Sopenharmony_ci
1055bf215546Sopenharmony_ci   for (bid = 0; bid < pc->num_blocks; ++bid, ++block) {
1056bf215546Sopenharmony_ci      if (*index < block->num_groups)
1057bf215546Sopenharmony_ci         return block;
1058bf215546Sopenharmony_ci      *index -= block->num_groups;
1059bf215546Sopenharmony_ci   }
1060bf215546Sopenharmony_ci
1061bf215546Sopenharmony_ci   return NULL;
1062bf215546Sopenharmony_ci}
1063bf215546Sopenharmony_ci
1064bf215546Sopenharmony_cibool ac_init_block_names(const struct radeon_info *info,
1065bf215546Sopenharmony_ci                         const struct ac_perfcounters *pc,
1066bf215546Sopenharmony_ci                         struct ac_pc_block *block)
1067bf215546Sopenharmony_ci{
1068bf215546Sopenharmony_ci   bool per_instance_groups = ac_pc_block_has_per_instance_groups(pc, block);
1069bf215546Sopenharmony_ci   bool per_se_groups = ac_pc_block_has_per_se_groups(pc, block);
1070bf215546Sopenharmony_ci   unsigned i, j, k;
1071bf215546Sopenharmony_ci   unsigned groups_shader = 1, groups_se = 1, groups_instance = 1;
1072bf215546Sopenharmony_ci   unsigned namelen;
1073bf215546Sopenharmony_ci   char *groupname;
1074bf215546Sopenharmony_ci   char *p;
1075bf215546Sopenharmony_ci
1076bf215546Sopenharmony_ci   if (per_instance_groups)
1077bf215546Sopenharmony_ci      groups_instance = block->num_instances;
1078bf215546Sopenharmony_ci   if (per_se_groups)
1079bf215546Sopenharmony_ci      groups_se = info->max_se;
1080bf215546Sopenharmony_ci   if (block->b->b->flags & AC_PC_BLOCK_SHADER)
1081bf215546Sopenharmony_ci      groups_shader = ARRAY_SIZE(ac_pc_shader_type_bits);
1082bf215546Sopenharmony_ci
1083bf215546Sopenharmony_ci   namelen = strlen(block->b->b->name);
1084bf215546Sopenharmony_ci   block->group_name_stride = namelen + 1;
1085bf215546Sopenharmony_ci   if (block->b->b->flags & AC_PC_BLOCK_SHADER)
1086bf215546Sopenharmony_ci      block->group_name_stride += 3;
1087bf215546Sopenharmony_ci   if (per_se_groups) {
1088bf215546Sopenharmony_ci      assert(groups_se <= 10);
1089bf215546Sopenharmony_ci      block->group_name_stride += 1;
1090bf215546Sopenharmony_ci
1091bf215546Sopenharmony_ci      if (per_instance_groups)
1092bf215546Sopenharmony_ci         block->group_name_stride += 1;
1093bf215546Sopenharmony_ci   }
1094bf215546Sopenharmony_ci   if (per_instance_groups) {
1095bf215546Sopenharmony_ci      assert(groups_instance <= 100);
1096bf215546Sopenharmony_ci      block->group_name_stride += 2;
1097bf215546Sopenharmony_ci   }
1098bf215546Sopenharmony_ci
1099bf215546Sopenharmony_ci   block->group_names = MALLOC(block->num_groups * block->group_name_stride);
1100bf215546Sopenharmony_ci   if (!block->group_names)
1101bf215546Sopenharmony_ci      return false;
1102bf215546Sopenharmony_ci
1103bf215546Sopenharmony_ci   groupname = block->group_names;
1104bf215546Sopenharmony_ci   for (i = 0; i < groups_shader; ++i) {
1105bf215546Sopenharmony_ci      const char *shader_suffix = ac_pc_shader_type_suffixes[i];
1106bf215546Sopenharmony_ci      unsigned shaderlen = strlen(shader_suffix);
1107bf215546Sopenharmony_ci      for (j = 0; j < groups_se; ++j) {
1108bf215546Sopenharmony_ci         for (k = 0; k < groups_instance; ++k) {
1109bf215546Sopenharmony_ci            strcpy(groupname, block->b->b->name);
1110bf215546Sopenharmony_ci            p = groupname + namelen;
1111bf215546Sopenharmony_ci
1112bf215546Sopenharmony_ci            if (block->b->b->flags & AC_PC_BLOCK_SHADER) {
1113bf215546Sopenharmony_ci               strcpy(p, shader_suffix);
1114bf215546Sopenharmony_ci               p += shaderlen;
1115bf215546Sopenharmony_ci            }
1116bf215546Sopenharmony_ci
1117bf215546Sopenharmony_ci            if (per_se_groups) {
1118bf215546Sopenharmony_ci               p += sprintf(p, "%d", j);
1119bf215546Sopenharmony_ci               if (per_instance_groups)
1120bf215546Sopenharmony_ci                  *p++ = '_';
1121bf215546Sopenharmony_ci            }
1122bf215546Sopenharmony_ci
1123bf215546Sopenharmony_ci            if (per_instance_groups)
1124bf215546Sopenharmony_ci               p += sprintf(p, "%d", k);
1125bf215546Sopenharmony_ci
1126bf215546Sopenharmony_ci            groupname += block->group_name_stride;
1127bf215546Sopenharmony_ci         }
1128bf215546Sopenharmony_ci      }
1129bf215546Sopenharmony_ci   }
1130bf215546Sopenharmony_ci
1131bf215546Sopenharmony_ci   assert(block->b->selectors <= 1000);
1132bf215546Sopenharmony_ci   block->selector_name_stride = block->group_name_stride + 4;
1133bf215546Sopenharmony_ci   block->selector_names =
1134bf215546Sopenharmony_ci      MALLOC(block->num_groups * block->b->selectors * block->selector_name_stride);
1135bf215546Sopenharmony_ci   if (!block->selector_names)
1136bf215546Sopenharmony_ci      return false;
1137bf215546Sopenharmony_ci
1138bf215546Sopenharmony_ci   groupname = block->group_names;
1139bf215546Sopenharmony_ci   p = block->selector_names;
1140bf215546Sopenharmony_ci   for (i = 0; i < block->num_groups; ++i) {
1141bf215546Sopenharmony_ci      for (j = 0; j < block->b->selectors; ++j) {
1142bf215546Sopenharmony_ci         sprintf(p, "%s_%03d", groupname, j);
1143bf215546Sopenharmony_ci         p += block->selector_name_stride;
1144bf215546Sopenharmony_ci      }
1145bf215546Sopenharmony_ci      groupname += block->group_name_stride;
1146bf215546Sopenharmony_ci   }
1147bf215546Sopenharmony_ci
1148bf215546Sopenharmony_ci   return true;
1149bf215546Sopenharmony_ci}
1150bf215546Sopenharmony_ci
1151bf215546Sopenharmony_cibool ac_init_perfcounters(const struct radeon_info *info,
1152bf215546Sopenharmony_ci                          bool separate_se,
1153bf215546Sopenharmony_ci                          bool separate_instance,
1154bf215546Sopenharmony_ci                          struct ac_perfcounters *pc)
1155bf215546Sopenharmony_ci{
1156bf215546Sopenharmony_ci   const struct ac_pc_block_gfxdescr *blocks;
1157bf215546Sopenharmony_ci   unsigned num_blocks;
1158bf215546Sopenharmony_ci
1159bf215546Sopenharmony_ci   switch (info->gfx_level) {
1160bf215546Sopenharmony_ci   case GFX7:
1161bf215546Sopenharmony_ci      blocks = groups_CIK;
1162bf215546Sopenharmony_ci      num_blocks = ARRAY_SIZE(groups_CIK);
1163bf215546Sopenharmony_ci      break;
1164bf215546Sopenharmony_ci   case GFX8:
1165bf215546Sopenharmony_ci      blocks = groups_VI;
1166bf215546Sopenharmony_ci      num_blocks = ARRAY_SIZE(groups_VI);
1167bf215546Sopenharmony_ci      break;
1168bf215546Sopenharmony_ci   case GFX9:
1169bf215546Sopenharmony_ci      blocks = groups_gfx9;
1170bf215546Sopenharmony_ci      num_blocks = ARRAY_SIZE(groups_gfx9);
1171bf215546Sopenharmony_ci      break;
1172bf215546Sopenharmony_ci   case GFX10:
1173bf215546Sopenharmony_ci   case GFX10_3:
1174bf215546Sopenharmony_ci      blocks = groups_gfx10;
1175bf215546Sopenharmony_ci      num_blocks = ARRAY_SIZE(groups_gfx10);
1176bf215546Sopenharmony_ci      break;
1177bf215546Sopenharmony_ci   case GFX6:
1178bf215546Sopenharmony_ci   default:
1179bf215546Sopenharmony_ci      return false; /* not implemented */
1180bf215546Sopenharmony_ci   }
1181bf215546Sopenharmony_ci
1182bf215546Sopenharmony_ci   pc->separate_se = separate_se;
1183bf215546Sopenharmony_ci   pc->separate_instance = separate_instance;
1184bf215546Sopenharmony_ci
1185bf215546Sopenharmony_ci   pc->blocks = CALLOC(num_blocks, sizeof(struct ac_pc_block));
1186bf215546Sopenharmony_ci   if (!pc->blocks)
1187bf215546Sopenharmony_ci      return false;
1188bf215546Sopenharmony_ci   pc->num_blocks = num_blocks;
1189bf215546Sopenharmony_ci
1190bf215546Sopenharmony_ci   for (unsigned i = 0; i < num_blocks; i++) {
1191bf215546Sopenharmony_ci      struct ac_pc_block *block = &pc->blocks[i];
1192bf215546Sopenharmony_ci
1193bf215546Sopenharmony_ci      block->b = &blocks[i];
1194bf215546Sopenharmony_ci      block->num_instances = MAX2(1, block->b->instances);
1195bf215546Sopenharmony_ci
1196bf215546Sopenharmony_ci      if (!strcmp(block->b->b->name, "CB") ||
1197bf215546Sopenharmony_ci          !strcmp(block->b->b->name, "DB") ||
1198bf215546Sopenharmony_ci          !strcmp(block->b->b->name, "RMI"))
1199bf215546Sopenharmony_ci         block->num_instances = info->max_se;
1200bf215546Sopenharmony_ci      else if (!strcmp(block->b->b->name, "TCC"))
1201bf215546Sopenharmony_ci         block->num_instances = info->max_tcc_blocks;
1202bf215546Sopenharmony_ci      else if (!strcmp(block->b->b->name, "IA"))
1203bf215546Sopenharmony_ci         block->num_instances = MAX2(1, info->max_se / 2);
1204bf215546Sopenharmony_ci      else if (!strcmp(block->b->b->name, "TA") ||
1205bf215546Sopenharmony_ci               !strcmp(block->b->b->name, "TCP") ||
1206bf215546Sopenharmony_ci               !strcmp(block->b->b->name, "TD")) {
1207bf215546Sopenharmony_ci         block->num_instances = MAX2(1, info->max_good_cu_per_sa);
1208bf215546Sopenharmony_ci      }
1209bf215546Sopenharmony_ci
1210bf215546Sopenharmony_ci      if (ac_pc_block_has_per_instance_groups(pc, block)) {
1211bf215546Sopenharmony_ci         block->num_groups = block->num_instances;
1212bf215546Sopenharmony_ci      } else {
1213bf215546Sopenharmony_ci         block->num_groups = 1;
1214bf215546Sopenharmony_ci      }
1215bf215546Sopenharmony_ci
1216bf215546Sopenharmony_ci      if (ac_pc_block_has_per_se_groups(pc, block))
1217bf215546Sopenharmony_ci         block->num_groups *= info->max_se;
1218bf215546Sopenharmony_ci      if (block->b->b->flags & AC_PC_BLOCK_SHADER)
1219bf215546Sopenharmony_ci         block->num_groups *= ARRAY_SIZE(ac_pc_shader_type_bits);
1220bf215546Sopenharmony_ci
1221bf215546Sopenharmony_ci      pc->num_groups += block->num_groups;
1222bf215546Sopenharmony_ci   }
1223bf215546Sopenharmony_ci
1224bf215546Sopenharmony_ci   return true;
1225bf215546Sopenharmony_ci}
1226bf215546Sopenharmony_ci
1227bf215546Sopenharmony_civoid ac_destroy_perfcounters(struct ac_perfcounters *pc)
1228bf215546Sopenharmony_ci{
1229bf215546Sopenharmony_ci   if (!pc)
1230bf215546Sopenharmony_ci      return;
1231bf215546Sopenharmony_ci
1232bf215546Sopenharmony_ci   for (unsigned i = 0; i < pc->num_blocks; ++i) {
1233bf215546Sopenharmony_ci      FREE(pc->blocks[i].group_names);
1234bf215546Sopenharmony_ci      FREE(pc->blocks[i].selector_names);
1235bf215546Sopenharmony_ci   }
1236bf215546Sopenharmony_ci   FREE(pc->blocks);
1237bf215546Sopenharmony_ci}
1238bf215546Sopenharmony_ci
1239bf215546Sopenharmony_cistruct ac_pc_block *ac_pc_get_block(const struct ac_perfcounters *pc,
1240bf215546Sopenharmony_ci                                    enum ac_pc_gpu_block gpu_block)
1241bf215546Sopenharmony_ci{
1242bf215546Sopenharmony_ci   for (unsigned i = 0; i < pc->num_blocks; i++) {
1243bf215546Sopenharmony_ci      struct ac_pc_block *block = &pc->blocks[i];
1244bf215546Sopenharmony_ci      if (block->b->b->gpu_block == gpu_block) {
1245bf215546Sopenharmony_ci         return block;
1246bf215546Sopenharmony_ci      }
1247bf215546Sopenharmony_ci   }
1248bf215546Sopenharmony_ci   return NULL;
1249bf215546Sopenharmony_ci}
1250