ac/debug: Support multiple trace ids for nested IBs.
Signed-off-by: Bas Nieuwenhuizen <basni@google.com> Reviewed-by: Dave Airlie <airlied@redhat.com>
This commit is contained in:
@@ -56,7 +56,8 @@ struct ac_ib_parser {
|
|||||||
FILE *f;
|
FILE *f;
|
||||||
uint32_t *ib;
|
uint32_t *ib;
|
||||||
unsigned num_dw;
|
unsigned num_dw;
|
||||||
int trace_id;
|
const int *trace_ids;
|
||||||
|
unsigned trace_id_count;
|
||||||
enum chip_class chip_class;
|
enum chip_class chip_class;
|
||||||
ac_debug_addr_callback addr_callback;
|
ac_debug_addr_callback addr_callback;
|
||||||
void *addr_callback_data;
|
void *addr_callback_data;
|
||||||
@@ -196,7 +197,8 @@ static void ac_parse_set_reg_packet(FILE *f, unsigned count, unsigned reg_offset
|
|||||||
ac_dump_reg(f, reg + i*4, ac_ib_get(ib), ~0);
|
ac_dump_reg(f, reg + i*4, ac_ib_get(ib), ~0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ac_parse_packet3(FILE *f, uint32_t header, struct ac_ib_parser *ib)
|
static void ac_parse_packet3(FILE *f, uint32_t header, struct ac_ib_parser *ib,
|
||||||
|
int *current_trace_id)
|
||||||
{
|
{
|
||||||
unsigned first_dw = ib->cur_dw;
|
unsigned first_dw = ib->cur_dw;
|
||||||
int count = PKT_COUNT_G(header);
|
int count = PKT_COUNT_G(header);
|
||||||
@@ -391,6 +393,14 @@ static void ac_parse_packet3(FILE *f, uint32_t header, struct ac_ib_parser *ib)
|
|||||||
ib_recurse.ib = data;
|
ib_recurse.ib = data;
|
||||||
ib_recurse.num_dw = G_3F2_IB_SIZE(control_dw);
|
ib_recurse.num_dw = G_3F2_IB_SIZE(control_dw);
|
||||||
ib_recurse.cur_dw = 0;
|
ib_recurse.cur_dw = 0;
|
||||||
|
if(ib_recurse.trace_id_count) {
|
||||||
|
if (*current_trace_id == *ib->trace_ids) {
|
||||||
|
++ib_recurse.trace_ids;
|
||||||
|
--ib_recurse.trace_id_count;
|
||||||
|
} else {
|
||||||
|
ib_recurse.trace_id_count = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fprintf(f, "\n\035>------------------ nested begin ------------------\n");
|
fprintf(f, "\n\035>------------------ nested begin ------------------\n");
|
||||||
ac_do_parse_ib(f, &ib_recurse);
|
ac_do_parse_ib(f, &ib_recurse);
|
||||||
@@ -411,20 +421,22 @@ static void ac_parse_packet3(FILE *f, uint32_t header, struct ac_ib_parser *ib)
|
|||||||
print_spaces(f, INDENT_PKT);
|
print_spaces(f, INDENT_PKT);
|
||||||
fprintf(f, COLOR_RED "Trace point ID: %u\n", packet_id);
|
fprintf(f, COLOR_RED "Trace point ID: %u\n", packet_id);
|
||||||
|
|
||||||
if (ib->trace_id == -1)
|
if (!ib->trace_id_count)
|
||||||
break; /* tracing was disabled */
|
break; /* tracing was disabled */
|
||||||
|
|
||||||
|
*current_trace_id = packet_id;
|
||||||
|
|
||||||
print_spaces(f, INDENT_PKT);
|
print_spaces(f, INDENT_PKT);
|
||||||
if (packet_id < ib->trace_id)
|
if (packet_id < *ib->trace_ids)
|
||||||
fprintf(f, COLOR_RED
|
fprintf(f, COLOR_RED
|
||||||
"This trace point was reached by the CP."
|
"This trace point was reached by the CP."
|
||||||
COLOR_RESET "\n");
|
COLOR_RESET "\n");
|
||||||
else if (packet_id == ib->trace_id)
|
else if (packet_id == *ib->trace_ids)
|
||||||
fprintf(f, COLOR_RED
|
fprintf(f, COLOR_RED
|
||||||
"!!!!! This is the last trace point that "
|
"!!!!! This is the last trace point that "
|
||||||
"was reached by the CP !!!!!"
|
"was reached by the CP !!!!!"
|
||||||
COLOR_RESET "\n");
|
COLOR_RESET "\n");
|
||||||
else if (packet_id+1 == ib->trace_id)
|
else if (packet_id+1 == *ib->trace_ids)
|
||||||
fprintf(f, COLOR_RED
|
fprintf(f, COLOR_RED
|
||||||
"!!!!! This is the first trace point that "
|
"!!!!! This is the first trace point that "
|
||||||
"was NOT been reached by the CP !!!!!"
|
"was NOT been reached by the CP !!!!!"
|
||||||
@@ -453,13 +465,15 @@ static void ac_parse_packet3(FILE *f, uint32_t header, struct ac_ib_parser *ib)
|
|||||||
*/
|
*/
|
||||||
static void ac_do_parse_ib(FILE *f, struct ac_ib_parser *ib)
|
static void ac_do_parse_ib(FILE *f, struct ac_ib_parser *ib)
|
||||||
{
|
{
|
||||||
|
int current_trace_id = -1;
|
||||||
|
|
||||||
while (ib->cur_dw < ib->num_dw) {
|
while (ib->cur_dw < ib->num_dw) {
|
||||||
uint32_t header = ac_ib_get(ib);
|
uint32_t header = ac_ib_get(ib);
|
||||||
unsigned type = PKT_TYPE_G(header);
|
unsigned type = PKT_TYPE_G(header);
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 3:
|
case 3:
|
||||||
ac_parse_packet3(f, header, ib);
|
ac_parse_packet3(f, header, ib, ¤t_trace_id);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
/* type-2 nop */
|
/* type-2 nop */
|
||||||
@@ -519,20 +533,22 @@ static void format_ib_output(FILE *f, char *out)
|
|||||||
* \param ib_ptr IB
|
* \param ib_ptr IB
|
||||||
* \param num_dw size of the IB
|
* \param num_dw size of the IB
|
||||||
* \param chip_class chip class
|
* \param chip_class chip class
|
||||||
* \param trace_id the last trace ID that is known to have been reached
|
* \param trace_ids the last trace IDs that are known to have been reached
|
||||||
* and executed by the CP, typically read from a buffer
|
* and executed by the CP, typically read from a buffer
|
||||||
|
* \param trace_id_count The number of entries in the trace_ids array.
|
||||||
* \param addr_callback Get a mapped pointer of the IB at a given address. Can
|
* \param addr_callback Get a mapped pointer of the IB at a given address. Can
|
||||||
* be NULL.
|
* be NULL.
|
||||||
* \param addr_callback_data user data for addr_callback
|
* \param addr_callback_data user data for addr_callback
|
||||||
*/
|
*/
|
||||||
void ac_parse_ib_chunk(FILE *f, uint32_t *ib_ptr, int num_dw, int trace_id,
|
void ac_parse_ib_chunk(FILE *f, uint32_t *ib_ptr, int num_dw, const int *trace_ids,
|
||||||
enum chip_class chip_class,
|
unsigned trace_id_count, enum chip_class chip_class,
|
||||||
ac_debug_addr_callback addr_callback, void *addr_callback_data)
|
ac_debug_addr_callback addr_callback, void *addr_callback_data)
|
||||||
{
|
{
|
||||||
struct ac_ib_parser ib = {};
|
struct ac_ib_parser ib = {};
|
||||||
ib.ib = ib_ptr;
|
ib.ib = ib_ptr;
|
||||||
ib.num_dw = num_dw;
|
ib.num_dw = num_dw;
|
||||||
ib.trace_id = trace_id;
|
ib.trace_ids = trace_ids;
|
||||||
|
ib.trace_id_count = trace_id_count;
|
||||||
ib.chip_class = chip_class;
|
ib.chip_class = chip_class;
|
||||||
ib.addr_callback = addr_callback;
|
ib.addr_callback = addr_callback;
|
||||||
ib.addr_callback_data = addr_callback_data;
|
ib.addr_callback_data = addr_callback_data;
|
||||||
@@ -562,20 +578,22 @@ void ac_parse_ib_chunk(FILE *f, uint32_t *ib_ptr, int num_dw, int trace_id,
|
|||||||
* \param ib IB
|
* \param ib IB
|
||||||
* \param num_dw size of the IB
|
* \param num_dw size of the IB
|
||||||
* \param chip_class chip class
|
* \param chip_class chip class
|
||||||
* \param trace_id the last trace ID that is known to have been reached
|
* \param trace_ids the last trace IDs that are known to have been reached
|
||||||
* and executed by the CP, typically read from a buffer
|
* and executed by the CP, typically read from a buffer
|
||||||
|
* \param trace_id_count The number of entries in the trace_ids array.
|
||||||
* \param addr_callback Get a mapped pointer of the IB at a given address. Can
|
* \param addr_callback Get a mapped pointer of the IB at a given address. Can
|
||||||
* be NULL.
|
* be NULL.
|
||||||
* \param addr_callback_data user data for addr_callback
|
* \param addr_callback_data user data for addr_callback
|
||||||
*/
|
*/
|
||||||
void ac_parse_ib(FILE *f, uint32_t *ib, int num_dw, int trace_id,
|
void ac_parse_ib(FILE *f, uint32_t *ib, int num_dw, const int *trace_ids,
|
||||||
const char *name, enum chip_class chip_class,
|
unsigned trace_id_count, const char *name,
|
||||||
ac_debug_addr_callback addr_callback, void *addr_callback_data)
|
enum chip_class chip_class, ac_debug_addr_callback addr_callback,
|
||||||
|
void *addr_callback_data)
|
||||||
{
|
{
|
||||||
fprintf(f, "------------------ %s begin ------------------\n", name);
|
fprintf(f, "------------------ %s begin ------------------\n", name);
|
||||||
|
|
||||||
ac_parse_ib_chunk(f, ib, num_dw, trace_id, chip_class, addr_callback,
|
ac_parse_ib_chunk(f, ib, num_dw, trace_ids, trace_id_count,
|
||||||
addr_callback_data);
|
chip_class, addr_callback, addr_callback_data);
|
||||||
|
|
||||||
fprintf(f, "------------------- %s end -------------------\n\n", name);
|
fprintf(f, "------------------- %s end -------------------\n\n", name);
|
||||||
}
|
}
|
||||||
|
@@ -39,11 +39,11 @@ typedef void *(*ac_debug_addr_callback)(void *data, uint64_t addr);
|
|||||||
|
|
||||||
void ac_dump_reg(FILE *file, unsigned offset, uint32_t value,
|
void ac_dump_reg(FILE *file, unsigned offset, uint32_t value,
|
||||||
uint32_t field_mask);
|
uint32_t field_mask);
|
||||||
void ac_parse_ib_chunk(FILE *f, uint32_t *ib, int num_dw, int trace_id,
|
void ac_parse_ib_chunk(FILE *f, uint32_t *ib, int num_dw, const int *trace_ids,
|
||||||
enum chip_class chip_class,
|
unsigned trace_id_count, enum chip_class chip_class,
|
||||||
ac_debug_addr_callback addr_callback, void *addr_callback_data);
|
ac_debug_addr_callback addr_callback, void *addr_callback_data);
|
||||||
void ac_parse_ib(FILE *f, uint32_t *ib, int num_dw, int trace_id,
|
void ac_parse_ib(FILE *f, uint32_t *ib, int num_dw, const int *trace_ids,
|
||||||
const char *name, enum chip_class chip_class,
|
unsigned trace_id_count, const char *name, enum chip_class chip_class,
|
||||||
ac_debug_addr_callback addr_callback, void *addr_callback_data);
|
ac_debug_addr_callback addr_callback, void *addr_callback_data);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -998,8 +998,8 @@ static void radv_amdgpu_winsys_cs_dump(struct radeon_winsys_cs *_cs,
|
|||||||
num_dw = cs->ib.size;
|
num_dw = cs->ib.size;
|
||||||
}
|
}
|
||||||
assert(ib);
|
assert(ib);
|
||||||
ac_parse_ib(file, ib, num_dw, trace_id, "main IB", cs->ws->info.chip_class,
|
ac_parse_ib(file, ib, num_dw, (const int*)&trace_id, 1, "main IB",
|
||||||
radv_amdgpu_winsys_get_cpu_addr, cs);
|
cs->ws->info.chip_class, radv_amdgpu_winsys_get_cpu_addr, cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct radeon_winsys_ctx *radv_amdgpu_ctx_create(struct radeon_winsys *_ws)
|
static struct radeon_winsys_ctx *radv_amdgpu_ctx_create(struct radeon_winsys *_ws)
|
||||||
|
@@ -285,8 +285,8 @@ static void si_log_chunk_type_cs_destroy(void *data)
|
|||||||
|
|
||||||
static void si_parse_current_ib(FILE *f, struct radeon_winsys_cs *cs,
|
static void si_parse_current_ib(FILE *f, struct radeon_winsys_cs *cs,
|
||||||
unsigned begin, unsigned end,
|
unsigned begin, unsigned end,
|
||||||
unsigned last_trace_id, const char *name,
|
int *last_trace_id, unsigned trace_id_count,
|
||||||
enum chip_class chip_class)
|
const char *name, enum chip_class chip_class)
|
||||||
{
|
{
|
||||||
unsigned orig_end = end;
|
unsigned orig_end = end;
|
||||||
|
|
||||||
@@ -301,7 +301,8 @@ static void si_parse_current_ib(FILE *f, struct radeon_winsys_cs *cs,
|
|||||||
if (begin < chunk->cdw) {
|
if (begin < chunk->cdw) {
|
||||||
ac_parse_ib_chunk(f, chunk->buf + begin,
|
ac_parse_ib_chunk(f, chunk->buf + begin,
|
||||||
MIN2(end, chunk->cdw) - begin,
|
MIN2(end, chunk->cdw) - begin,
|
||||||
last_trace_id, chip_class, NULL, NULL);
|
last_trace_id, trace_id_count,
|
||||||
|
chip_class, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (end <= chunk->cdw)
|
if (end <= chunk->cdw)
|
||||||
@@ -318,7 +319,7 @@ static void si_parse_current_ib(FILE *f, struct radeon_winsys_cs *cs,
|
|||||||
assert(end <= cs->current.cdw);
|
assert(end <= cs->current.cdw);
|
||||||
|
|
||||||
ac_parse_ib_chunk(f, cs->current.buf + begin, end - begin, last_trace_id,
|
ac_parse_ib_chunk(f, cs->current.buf + begin, end - begin, last_trace_id,
|
||||||
chip_class, NULL, NULL);
|
trace_id_count, chip_class, NULL, NULL);
|
||||||
|
|
||||||
fprintf(f, "------------------- %s end (dw = %u) -------------------\n\n",
|
fprintf(f, "------------------- %s end (dw = %u) -------------------\n\n",
|
||||||
name, orig_end);
|
name, orig_end);
|
||||||
@@ -346,25 +347,25 @@ static void si_log_chunk_type_cs_print(void *data, FILE *f)
|
|||||||
if (chunk->gfx_begin == 0) {
|
if (chunk->gfx_begin == 0) {
|
||||||
if (ctx->init_config)
|
if (ctx->init_config)
|
||||||
ac_parse_ib(f, ctx->init_config->pm4, ctx->init_config->ndw,
|
ac_parse_ib(f, ctx->init_config->pm4, ctx->init_config->ndw,
|
||||||
-1, "IB2: Init config", ctx->b.chip_class,
|
NULL, 0, "IB2: Init config", ctx->b.chip_class,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
|
|
||||||
if (ctx->init_config_gs_rings)
|
if (ctx->init_config_gs_rings)
|
||||||
ac_parse_ib(f, ctx->init_config_gs_rings->pm4,
|
ac_parse_ib(f, ctx->init_config_gs_rings->pm4,
|
||||||
ctx->init_config_gs_rings->ndw,
|
ctx->init_config_gs_rings->ndw,
|
||||||
-1, "IB2: Init GS rings", ctx->b.chip_class,
|
NULL, 0, "IB2: Init GS rings", ctx->b.chip_class,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scs->flushed) {
|
if (scs->flushed) {
|
||||||
ac_parse_ib(f, scs->gfx.ib + chunk->gfx_begin,
|
ac_parse_ib(f, scs->gfx.ib + chunk->gfx_begin,
|
||||||
chunk->gfx_end - chunk->gfx_begin,
|
chunk->gfx_end - chunk->gfx_begin,
|
||||||
last_trace_id, "IB", ctx->b.chip_class,
|
&last_trace_id, map ? 1 : 0, "IB", ctx->b.chip_class,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
} else {
|
} else {
|
||||||
si_parse_current_ib(f, ctx->b.gfx.cs, chunk->gfx_begin,
|
si_parse_current_ib(f, ctx->b.gfx.cs, chunk->gfx_begin,
|
||||||
chunk->gfx_end, last_trace_id, "IB",
|
chunk->gfx_end, &last_trace_id, map ? 1 : 0,
|
||||||
ctx->b.chip_class);
|
"IB", ctx->b.chip_class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user