From d71cd245d7445121342a4933cc6ed8ce3fc6e568 Mon Sep 17 00:00:00 2001 From: Andreas Baierl Date: Thu, 19 Dec 2019 22:17:45 +0100 Subject: [PATCH] lima: Rotate dump files after each finished pp frame This rotates the dump files like the mali-syscall-tracker does. After each finished pp frame a new file is generated. They are numbered like lima.dump.0000, lima.dump.0001 ... The filename and path can be given with the new environment variable LIMA_DUMP_FILE. Reviewed-by: Vasily Khoruzhick Signed-off-by: Andreas Baierl Tested-by: Marge Bot Part-of: --- src/gallium/drivers/lima/lima_draw.c | 2 ++ src/gallium/drivers/lima/lima_screen.c | 16 +++-------- src/gallium/drivers/lima/lima_screen.h | 1 - src/gallium/drivers/lima/lima_util.c | 37 ++++++++++++++++++++++++++ src/gallium/drivers/lima/lima_util.h | 5 ++++ 5 files changed, 48 insertions(+), 13 deletions(-) diff --git a/src/gallium/drivers/lima/lima_draw.c b/src/gallium/drivers/lima/lima_draw.c index 2f35d9a3db3..5b86cce4d0d 100644 --- a/src/gallium/drivers/lima/lima_draw.c +++ b/src/gallium/drivers/lima/lima_draw.c @@ -1710,6 +1710,8 @@ _lima_flush(struct lima_context *ctx, bool end_of_frame) } ctx->pp_max_stack_size = 0; + + lima_dump_file_next(); } void diff --git a/src/gallium/drivers/lima/lima_screen.c b/src/gallium/drivers/lima/lima_screen.c index 768a6106c8d..4dc1fc652b8 100644 --- a/src/gallium/drivers/lima/lima_screen.c +++ b/src/gallium/drivers/lima/lima_screen.c @@ -39,6 +39,7 @@ #include "lima_bo.h" #include "lima_fence.h" #include "lima_format.h" +#include "lima_util.h" #include "ir/lima_ir.h" #include "xf86drm.h" @@ -50,10 +51,7 @@ lima_screen_destroy(struct pipe_screen *pscreen) { struct lima_screen *screen = lima_screen(pscreen); - if (lima_dump_command_stream) { - fclose(lima_dump_command_stream); - lima_dump_command_stream = NULL; - } + lima_dump_file_close(); slab_destroy_parent(&screen->transfer_pool); @@ -446,14 +444,8 @@ lima_screen_parse_env(void) { lima_debug = debug_get_option_lima_debug(); - if (lima_debug & LIMA_DEBUG_DUMP) { - const char *dump_command = "lima.dump"; - printf("lima: dump command stream to file %s\n", dump_command); - lima_dump_command_stream = fopen(dump_command, "w"); - if (!lima_dump_command_stream) - fprintf(stderr, "lima: fail to open command stream log file %s\n", - dump_command); - } + if (lima_debug & LIMA_DEBUG_DUMP) + lima_dump_file_open(); lima_ctx_num_plb = debug_get_num_option("LIMA_CTX_NUM_PLB", LIMA_CTX_PLB_DEF_NUM); if (lima_ctx_num_plb > LIMA_CTX_PLB_MAX_NUM || diff --git a/src/gallium/drivers/lima/lima_screen.h b/src/gallium/drivers/lima/lima_screen.h index 144f5a2e163..426f8e956c1 100644 --- a/src/gallium/drivers/lima/lima_screen.h +++ b/src/gallium/drivers/lima/lima_screen.h @@ -41,7 +41,6 @@ #define LIMA_DEBUG_BO_CACHE (1 << 5) extern uint32_t lima_debug; -extern FILE *lima_dump_command_stream; extern int lima_ctx_num_plb; extern int lima_plb_max_blk; extern int lima_ppir_force_spilling; diff --git a/src/gallium/drivers/lima/lima_util.c b/src/gallium/drivers/lima/lima_util.c index e162b4c556f..65e3114ed5f 100644 --- a/src/gallium/drivers/lima/lima_util.c +++ b/src/gallium/drivers/lima/lima_util.c @@ -27,10 +27,13 @@ #include +#include "util/u_debug.h" + #include "lima_util.h" #include "lima_parser.h" FILE *lima_dump_command_stream = NULL; +int lima_dump_frame_count = 0; bool lima_get_absolute_timeout(uint64_t *timeout) { @@ -98,6 +101,40 @@ lima_dump_texture_descriptor(void *data, int size, uint32_t start, uint32_t offs lima_parse_texture_descriptor(lima_dump_command_stream, (uint32_t *)data, size, start, offset); } +void +lima_dump_file_open(void) +{ + if (lima_dump_command_stream) + return; + + char buffer[1024]; + const char *dump_command = debug_get_option("LIMA_DUMP_FILE", "lima.dump"); + snprintf(buffer, sizeof(buffer), "%s.%04d", dump_command, lima_dump_frame_count); + + printf("lima: dump command stream to file %s\n", buffer); + lima_dump_command_stream = fopen(buffer, "w"); + if (!lima_dump_command_stream) + fprintf(stderr, "lima: failed to open command stream log file %s\n", + buffer); +} + +void +lima_dump_file_close(void) +{ + if (lima_dump_command_stream) { + fclose(lima_dump_command_stream); + lima_dump_command_stream = NULL; + } +} + +void +lima_dump_file_next(void) +{ + lima_dump_file_close(); + lima_dump_frame_count++; + lima_dump_file_open(); +} + void lima_dump_command_stream_print(void *data, int size, bool is_float, const char *fmt, ...) diff --git a/src/gallium/drivers/lima/lima_util.h b/src/gallium/drivers/lima/lima_util.h index 36b6aaacabc..9a050f8f028 100644 --- a/src/gallium/drivers/lima/lima_util.h +++ b/src/gallium/drivers/lima/lima_util.h @@ -29,7 +29,12 @@ #define LIMA_PAGE_SIZE 4096 +FILE *lima_dump_command_stream; + bool lima_get_absolute_timeout(uint64_t *timeout); +void lima_dump_file_open(void); +void lima_dump_file_next(void); +void lima_dump_file_close(void); void lima_dump_blob(FILE *fp, void *data, int size, bool is_float); void lima_dump_vs_command_stream_print(void *data, int size, uint32_t start); void lima_dump_plbu_command_stream_print(void *data, int size, uint32_t start); -- 2.30.2