summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBas Nieuwenhuizen <[email protected]>2017-03-17 01:25:00 +0100
committerBas Nieuwenhuizen <[email protected]>2017-08-29 23:05:59 +0200
commit46dd30d08f4c788449f36fce9a53424008693cd0 (patch)
tree7d39b072776fe915f9111f8314aa519dd50b6a15 /src
parent43eb761cad8a7941788735d2d7a5f10a36a25148 (diff)
ac/debug: Support multiple trace ids for nested IBs.
Signed-off-by: Bas Nieuwenhuizen <[email protected]> Reviewed-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/amd/common/ac_debug.c54
-rw-r--r--src/amd/common/ac_debug.h8
-rw-r--r--src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c4
-rw-r--r--src/gallium/drivers/radeonsi/si_debug.c19
4 files changed, 52 insertions, 33 deletions
diff --git a/src/amd/common/ac_debug.c b/src/amd/common/ac_debug.c
index 3daa556f5dd..d46fc27a9e1 100644
--- a/src/amd/common/ac_debug.c
+++ b/src/amd/common/ac_debug.c
@@ -56,7 +56,8 @@ struct ac_ib_parser {
FILE *f;
uint32_t *ib;
unsigned num_dw;
- int trace_id;
+ const int *trace_ids;
+ unsigned trace_id_count;
enum chip_class chip_class;
ac_debug_addr_callback addr_callback;
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);
}
-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;
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.num_dw = G_3F2_IB_SIZE(control_dw);
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");
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);
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 */
+ *current_trace_id = packet_id;
+
print_spaces(f, INDENT_PKT);
- if (packet_id < ib->trace_id)
+ if (packet_id < *ib->trace_ids)
fprintf(f, COLOR_RED
"This trace point was reached by the CP."
COLOR_RESET "\n");
- else if (packet_id == ib->trace_id)
+ else if (packet_id == *ib->trace_ids)
fprintf(f, COLOR_RED
"!!!!! This is the last trace point that "
"was reached by the CP !!!!!"
COLOR_RESET "\n");
- else if (packet_id+1 == ib->trace_id)
+ else if (packet_id+1 == *ib->trace_ids)
fprintf(f, COLOR_RED
"!!!!! This is the first trace point that "
"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)
{
+ int current_trace_id = -1;
+
while (ib->cur_dw < ib->num_dw) {
uint32_t header = ac_ib_get(ib);
unsigned type = PKT_TYPE_G(header);
switch (type) {
case 3:
- ac_parse_packet3(f, header, ib);
+ ac_parse_packet3(f, header, ib, &current_trace_id);
break;
case 2:
/* type-2 nop */
@@ -519,20 +533,22 @@ static void format_ib_output(FILE *f, char *out)
* \param ib_ptr IB
* \param num_dw size of the IB
* \param chip_class chip class
- * \param trace_id the last trace ID that is known to have been reached
- * and executed by the CP, typically read from a buffer
+ * \param trace_ids the last trace IDs that are known to have been reached
+ * 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
* be NULL.
* \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,
- enum chip_class chip_class,
+void ac_parse_ib_chunk(FILE *f, uint32_t *ib_ptr, int num_dw, const int *trace_ids,
+ unsigned trace_id_count, enum chip_class chip_class,
ac_debug_addr_callback addr_callback, void *addr_callback_data)
{
struct ac_ib_parser ib = {};
ib.ib = ib_ptr;
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.addr_callback = addr_callback;
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 num_dw size of the IB
* \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
+ * \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
* be NULL.
* \param addr_callback_data user data for addr_callback
*/
-void ac_parse_ib(FILE *f, uint32_t *ib, int num_dw, int trace_id,
- const char *name, enum chip_class chip_class,
- ac_debug_addr_callback addr_callback, void *addr_callback_data)
+void ac_parse_ib(FILE *f, uint32_t *ib, int num_dw, const int *trace_ids,
+ unsigned trace_id_count, const char *name,
+ enum chip_class chip_class, ac_debug_addr_callback addr_callback,
+ void *addr_callback_data)
{
fprintf(f, "------------------ %s begin ------------------\n", name);
- ac_parse_ib_chunk(f, ib, num_dw, trace_id, chip_class, addr_callback,
- addr_callback_data);
+ ac_parse_ib_chunk(f, ib, num_dw, trace_ids, trace_id_count,
+ chip_class, addr_callback, addr_callback_data);
fprintf(f, "------------------- %s end -------------------\n\n", name);
}
diff --git a/src/amd/common/ac_debug.h b/src/amd/common/ac_debug.h
index 872420d2b9d..a37acd20296 100644
--- a/src/amd/common/ac_debug.h
+++ b/src/amd/common/ac_debug.h
@@ -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,
uint32_t field_mask);
-void ac_parse_ib_chunk(FILE *f, uint32_t *ib, int num_dw, int trace_id,
- enum chip_class chip_class,
+void ac_parse_ib_chunk(FILE *f, uint32_t *ib, int num_dw, const int *trace_ids,
+ unsigned trace_id_count, enum chip_class chip_class,
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,
- const char *name, enum chip_class chip_class,
+void ac_parse_ib(FILE *f, uint32_t *ib, int num_dw, const int *trace_ids,
+ unsigned trace_id_count, const char *name, enum chip_class chip_class,
ac_debug_addr_callback addr_callback, void *addr_callback_data);
#endif
diff --git a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c
index adb855f97de..49c9c909466 100644
--- a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c
+++ b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c
@@ -998,8 +998,8 @@ static void radv_amdgpu_winsys_cs_dump(struct radeon_winsys_cs *_cs,
num_dw = cs->ib.size;
}
assert(ib);
- ac_parse_ib(file, ib, num_dw, trace_id, "main IB", cs->ws->info.chip_class,
- radv_amdgpu_winsys_get_cpu_addr, cs);
+ ac_parse_ib(file, ib, num_dw, (const int*)&trace_id, 1, "main IB",
+ 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)
diff --git a/src/gallium/drivers/radeonsi/si_debug.c b/src/gallium/drivers/radeonsi/si_debug.c
index c2242a6deab..1b97ea40970 100644
--- a/src/gallium/drivers/radeonsi/si_debug.c
+++ b/src/gallium/drivers/radeonsi/si_debug.c
@@ -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,
unsigned begin, unsigned end,
- unsigned last_trace_id, const char *name,
- enum chip_class chip_class)
+ int *last_trace_id, unsigned trace_id_count,
+ const char *name, enum chip_class chip_class)
{
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) {
ac_parse_ib_chunk(f, chunk->buf + 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)
@@ -318,7 +319,7 @@ static void si_parse_current_ib(FILE *f, struct radeon_winsys_cs *cs,
assert(end <= cs->current.cdw);
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",
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 (ctx->init_config)
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);
if (ctx->init_config_gs_rings)
ac_parse_ib(f, ctx->init_config_gs_rings->pm4,
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);
}
if (scs->flushed) {
ac_parse_ib(f, scs->gfx.ib + 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);
} else {
si_parse_current_ib(f, ctx->b.gfx.cs, chunk->gfx_begin,
- chunk->gfx_end, last_trace_id, "IB",
- ctx->b.chip_class);
+ chunk->gfx_end, &last_trace_id, map ? 1 : 0,
+ "IB", ctx->b.chip_class);
}
}