2
2
* Copyright 2015 Advanced Micro Devices, Inc.
4
* Permission is hereby granted, free of charge, to any person obtaining a
5
* copy of this software and associated documentation files (the "Software"),
6
* to deal in the Software without restriction, including without limitation
7
* on the rights to use, copy, modify, merge, publish, distribute, sub
8
* license, and/or sell copies of the Software, and to permit persons to whom
9
* the Software is furnished to do so, subject to the following conditions:
11
* The above copyright notice and this permission notice (including the next
12
* paragraph) shall be included in all copies or substantial portions of the
15
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18
* THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21
* USE OR OTHER DEALINGS IN THE SOFTWARE.
4
* SPDX-License-Identifier: MIT
24
7
#include "ac_debug.h"
259
265
unsigned index = reg_dw >> 28;
263
print_spaces(f, INDENT_PKT);
264
fprintf(f, "INDEX = %u\n", index);
269
print_named_value(f, "INDEX", index, 32);
267
271
for (i = 0; i < count; i++)
268
272
ac_dump_reg(f, ib->gfx_level, ib->family, reg + i * 4, ac_ib_get(ib), ~0);
275
static void ac_parse_set_reg_pairs_packed_packet(FILE *f, unsigned count, unsigned reg_base,
276
struct ac_ib_parser *ib)
278
unsigned reg_offset0 = 0, reg_offset1 = 0;
280
print_named_value(f, "REG_COUNT", ac_ib_get(ib), 32);
282
for (unsigned i = 0; i < count; i++) {
284
unsigned tmp = ac_ib_get(ib);
285
reg_offset0 = ((tmp & 0xffff) << 2) + reg_base;
286
reg_offset1 = ((tmp >> 16) << 2) + reg_base;
287
} else if (i % 3 == 1) {
288
ac_dump_reg(f, ib->gfx_level, ib->family, reg_offset0, ac_ib_get(ib), ~0);
290
ac_dump_reg(f, ib->gfx_level, ib->family, reg_offset1, ac_ib_get(ib), ~0);
271
295
static void ac_parse_packet3(FILE *f, uint32_t header, struct ac_ib_parser *ib,
272
296
int *current_trace_id)
274
298
unsigned first_dw = ib->cur_dw;
275
299
int count = PKT_COUNT_G(header);
276
300
unsigned op = PKT3_IT_OPCODE_G(header);
277
const char *predicate = PKT3_PREDICATE(header) ? "(predicate)" : "";
301
const char *shader_type = PKT3_SHADER_TYPE_G(header) ? "(shader_type=compute)" : "";
302
const char *predicated = PKT3_PREDICATE(header) ? "(predicated)" : "";
303
const char *reset_filter_cam = PKT3_RESET_FILTER_CAM_G(header) ? "(reset_filter_cam)" : "";
280
307
/* Print the name first. */
281
308
for (i = 0; i < ARRAY_SIZE(packet3_table); i++)
282
309
if (packet3_table[i].op == op)
285
if (i < ARRAY_SIZE(packet3_table)) {
286
const char *name = sid_strings + packet3_table[i].name_offset;
288
if (op == PKT3_SET_CONTEXT_REG || op == PKT3_SET_CONFIG_REG || op == PKT3_SET_UCONFIG_REG ||
289
op == PKT3_SET_UCONFIG_REG_INDEX || op == PKT3_SET_SH_REG || op == PKT3_SET_SH_REG_INDEX)
290
fprintf(f, "%s%s%s%s:\n", O_COLOR_CYAN, name, predicate, O_COLOR_RESET);
292
fprintf(f, "%s%s%s%s:\n", O_COLOR_GREEN, name, predicate, O_COLOR_RESET);
294
fprintf(f, "%sPKT3_UNKNOWN 0x%x%s%s:\n", O_COLOR_RED, op, predicate, O_COLOR_RESET);
312
const char *pkt_name = i < ARRAY_SIZE(packet3_table) ? sid_strings + packet3_table[i].name_offset
316
if (strstr(pkt_name, "DRAW") || strstr(pkt_name, "DISPATCH"))
317
color = O_COLOR_PURPLE;
318
else if (strstr(pkt_name, "SET") == pkt_name && strstr(pkt_name, "REG"))
319
color = O_COLOR_CYAN;
320
else if (i >= ARRAY_SIZE(packet3_table))
323
color = O_COLOR_GREEN;
325
fprintf(f, "%s%s%s%s%s%s:\n", color, pkt_name, O_COLOR_RESET,
326
shader_type, predicated, reset_filter_cam);
296
328
/* Print the contents. */
309
341
case PKT3_SET_SH_REG_INDEX:
310
342
ac_parse_set_reg_packet(f, count, SI_SH_REG_OFFSET, ib);
344
case PKT3_SET_CONTEXT_REG_PAIRS_PACKED:
345
ac_parse_set_reg_pairs_packed_packet(f, count, SI_CONTEXT_REG_OFFSET, ib);
347
case PKT3_SET_SH_REG_PAIRS_PACKED:
348
case PKT3_SET_SH_REG_PAIRS_PACKED_N:
349
ac_parse_set_reg_pairs_packed_packet(f, count, SI_SH_REG_OFFSET, ib);
312
351
case PKT3_ACQUIRE_MEM:
313
if (ib->gfx_level >= GFX11 && G_585_PWS_ENA(ib->ib[ib->cur_dw + 5])) {
314
ac_dump_reg(f, ib->gfx_level, ib->family, R_580_ACQUIRE_MEM_PWS_2, ac_ib_get(ib), ~0);
315
print_named_value(f, "GCR_SIZE", ac_ib_get(ib), 32);
316
print_named_value(f, "GCR_SIZE_HI", ac_ib_get(ib), 25);
317
print_named_value(f, "GCR_BASE_LO", ac_ib_get(ib), 32);
318
print_named_value(f, "GCR_BASE_HI", ac_ib_get(ib), 32);
319
ac_dump_reg(f, ib->gfx_level, ib->family, R_585_ACQUIRE_MEM_PWS_7, ac_ib_get(ib), ~0);
320
ac_dump_reg(f, ib->gfx_level, ib->family, R_586_GCR_CNTL, ac_ib_get(ib), ~0);
352
if (ib->gfx_level >= GFX11) {
353
if (G_585_PWS_ENA(ib->ib[ib->cur_dw + 5])) {
354
ac_dump_reg(f, ib->gfx_level, ib->family, R_580_ACQUIRE_MEM_PWS_2, ac_ib_get(ib), ~0);
355
print_named_value(f, "GCR_SIZE", ac_ib_get(ib), 32);
356
print_named_value(f, "GCR_SIZE_HI", ac_ib_get(ib), 25);
357
print_named_value(f, "GCR_BASE_LO", ac_ib_get(ib), 32);
358
print_named_value(f, "GCR_BASE_HI", ac_ib_get(ib), 32);
359
ac_dump_reg(f, ib->gfx_level, ib->family, R_585_ACQUIRE_MEM_PWS_7, ac_ib_get(ib), ~0);
360
ac_dump_reg(f, ib->gfx_level, ib->family, R_586_GCR_CNTL, ac_ib_get(ib), ~0);
362
print_string_value(f, "ENGINE_SEL", ac_ib_get(ib) & 0x80000000 ? "ME" : "PFP");
363
print_named_value(f, "GCR_SIZE", ac_ib_get(ib), 32);
364
print_named_value(f, "GCR_SIZE_HI", ac_ib_get(ib), 25);
365
print_named_value(f, "GCR_BASE_LO", ac_ib_get(ib), 32);
366
print_named_value(f, "GCR_BASE_HI", ac_ib_get(ib), 32);
367
print_named_value(f, "POLL_INTERVAL", ac_ib_get(ib), 16);
368
ac_dump_reg(f, ib->gfx_level, ib->family, R_586_GCR_CNTL, ac_ib_get(ib), ~0);
372
ac_dump_reg(f, ib->gfx_level, ib->family, R_0301F0_CP_COHER_CNTL, tmp, 0x7fffffff);
373
print_string_value(f, "ENGINE_SEL", tmp & 0x80000000 ? "ME" : "PFP");
374
ac_dump_reg(f, ib->gfx_level, ib->family, R_0301F4_CP_COHER_SIZE, ac_ib_get(ib), ~0);
375
ac_dump_reg(f, ib->gfx_level, ib->family, R_030230_CP_COHER_SIZE_HI, ac_ib_get(ib), ~0);
376
ac_dump_reg(f, ib->gfx_level, ib->family, R_0301F8_CP_COHER_BASE, ac_ib_get(ib), ~0);
377
ac_dump_reg(f, ib->gfx_level, ib->family, R_0301E4_CP_COHER_BASE_HI, ac_ib_get(ib), ~0);
378
print_named_value(f, "POLL_INTERVAL", ac_ib_get(ib), 16);
379
if (ib->gfx_level >= GFX10)
380
ac_dump_reg(f, ib->gfx_level, ib->family, R_586_GCR_CNTL, ac_ib_get(ib), ~0);
323
ac_dump_reg(f, ib->gfx_level, ib->family, R_0301F0_CP_COHER_CNTL, ac_ib_get(ib), ~0);
324
ac_dump_reg(f, ib->gfx_level, ib->family, R_0301F4_CP_COHER_SIZE, ac_ib_get(ib), ~0);
325
ac_dump_reg(f, ib->gfx_level, ib->family, R_030230_CP_COHER_SIZE_HI, ac_ib_get(ib), ~0);
326
ac_dump_reg(f, ib->gfx_level, ib->family, R_0301F8_CP_COHER_BASE, ac_ib_get(ib), ~0);
327
ac_dump_reg(f, ib->gfx_level, ib->family, R_0301E4_CP_COHER_BASE_HI, ac_ib_get(ib), ~0);
328
print_named_value(f, "POLL_INTERVAL", ac_ib_get(ib), 16);
329
if (ib->gfx_level >= GFX10)
330
ac_dump_reg(f, ib->gfx_level, ib->family, R_586_GCR_CNTL, ac_ib_get(ib), ~0);
332
383
case PKT3_SURFACE_SYNC:
333
384
if (ib->gfx_level >= GFX7) {
584
case PKT3_DISPATCH_DIRECT:
585
ac_dump_reg(f, ib->gfx_level, ib->family, R_00B804_COMPUTE_DIM_X, ac_ib_get(ib), ~0);
586
ac_dump_reg(f, ib->gfx_level, ib->family, R_00B808_COMPUTE_DIM_Y, ac_ib_get(ib), ~0);
587
ac_dump_reg(f, ib->gfx_level, ib->family, R_00B80C_COMPUTE_DIM_Z, ac_ib_get(ib), ~0);
588
ac_dump_reg(f, ib->gfx_level, ib->family, R_00B800_COMPUTE_DISPATCH_INITIATOR,
591
case PKT3_DISPATCH_INDIRECT:
592
print_named_value(f, "DATA_OFFSET", ac_ib_get(ib), 32);
593
ac_dump_reg(f, ib->gfx_level, ib->family, R_00B800_COMPUTE_DISPATCH_INITIATOR,
598
print_string_value(f, "BASE_INDEX", tmp == 1 ? "INDIRECT_BASE" : COLOR_RED "UNKNOWN" COLOR_RESET);
534
602
/* print additional dwords */