From 38c5a5a8b51bdeab1672a8a8ea54caa27ffdafee Mon Sep 17 00:00:00 2001 From: Patrick Lerda Date: Mon, 13 May 2019 00:03:22 +0200 Subject: lima: refactor plb_max_blk Move plb_max_blk to lima_screen, and add a new debug option: LIMA_PLB_MAX_BLK Signed-off-by: Patrick Lerda Reviewed-by: Qiang Yu --- src/gallium/drivers/lima/lima_context.c | 10 +++------- src/gallium/drivers/lima/lima_context.h | 1 - src/gallium/drivers/lima/lima_screen.c | 28 ++++++++++++++++++++++++++-- src/gallium/drivers/lima/lima_screen.h | 2 ++ src/gallium/drivers/lima/lima_state.c | 4 +++- 5 files changed, 34 insertions(+), 11 deletions(-) diff --git a/src/gallium/drivers/lima/lima_context.c b/src/gallium/drivers/lima/lima_context.c index 9a373b96728..558d2346653 100644 --- a/src/gallium/drivers/lima/lima_context.c +++ b/src/gallium/drivers/lima/lima_context.c @@ -214,12 +214,8 @@ lima_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags) util_dynarray_init(&ctx->vs_cmd_array, ctx); util_dynarray_init(&ctx->plbu_cmd_array, ctx); - if (screen->gpu_type == DRM_LIMA_PARAM_GPU_ID_MALI450) - ctx->plb_max_blk = 4096; - else - ctx->plb_max_blk = 512; - ctx->plb_size = ctx->plb_max_blk * LIMA_CTX_PLB_BLK_SIZE; - ctx->plb_gp_size = ctx->plb_max_blk * 4; + ctx->plb_size = screen->plb_max_blk * LIMA_CTX_PLB_BLK_SIZE; + ctx->plb_gp_size = screen->plb_max_blk * 4; for (int i = 0; i < lima_ctx_num_plb; i++) { ctx->plb[i] = lima_bo_create(screen, ctx->plb_size, 0); @@ -241,7 +237,7 @@ lima_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags) /* plb gp stream is static for any framebuffer */ for (int i = 0; i < lima_ctx_num_plb; i++) { uint32_t *plb_gp_stream = ctx->plb_gp_stream->map + i * ctx->plb_gp_size; - for (int j = 0; j < ctx->plb_max_blk; j++) + for (int j = 0; j < screen->plb_max_blk; j++) plb_gp_stream[j] = ctx->plb[i]->va + LIMA_CTX_PLB_BLK_SIZE * j; } diff --git a/src/gallium/drivers/lima/lima_context.h b/src/gallium/drivers/lima/lima_context.h index 4bbe915bcdc..c16baeef0ba 100644 --- a/src/gallium/drivers/lima/lima_context.h +++ b/src/gallium/drivers/lima/lima_context.h @@ -222,7 +222,6 @@ struct lima_context { #define LIMA_CTX_PLB_MAX_NUM 4 #define LIMA_CTX_PLB_DEF_NUM 2 #define LIMA_CTX_PLB_BLK_SIZE 512 - unsigned plb_max_blk; unsigned plb_size; unsigned plb_gp_size; diff --git a/src/gallium/drivers/lima/lima_screen.c b/src/gallium/drivers/lima/lima_screen.c index 29dfc16c7ac..0eb472acebd 100644 --- a/src/gallium/drivers/lima/lima_screen.c +++ b/src/gallium/drivers/lima/lima_screen.c @@ -42,6 +42,8 @@ #include "xf86drm.h" +int lima_plb_max_blk = 0; + static void lima_screen_destroy(struct pipe_screen *pscreen) { @@ -343,6 +345,19 @@ lima_screen_get_compiler_options(struct pipe_screen *pscreen, return lima_program_get_compiler_options(shader); } +static bool +lima_screen_set_plb_max_blk(struct lima_screen *screen) +{ + if (lima_plb_max_blk) + screen->plb_max_blk = lima_plb_max_blk; + else if (screen->gpu_type == DRM_LIMA_PARAM_GPU_ID_MALI450) + screen->plb_max_blk = 4096; + else + screen->plb_max_blk = 512; + + return true; +} + static bool lima_screen_query_info(struct lima_screen *screen) { @@ -369,6 +384,8 @@ lima_screen_query_info(struct lima_screen *screen) screen->num_pp = param.value; + lima_screen_set_plb_max_blk(screen); + return true; } @@ -431,6 +448,13 @@ lima_screen_parse_env(void) lima_ctx_num_plb = LIMA_CTX_PLB_DEF_NUM; } + lima_plb_max_blk = debug_get_num_option("LIMA_PLB_MAX_BLK", 0); + if (lima_plb_max_blk < 0 || lima_plb_max_blk > 65536) { + fprintf(stderr, "lima: LIMA_PLB_MAX_BLK %d out of range [%d %d], " + "reset to default %d\n", lima_plb_max_blk, 0, 65536, 0); + lima_plb_max_blk = 0; + } + lima_ppir_force_spilling = debug_get_num_option("LIMA_PPIR_FORCE_SPILLING", 0); if (lima_ppir_force_spilling < 0) { fprintf(stderr, "lima: LIMA_PPIR_FORCE_SPILLING %d less than 0, " @@ -450,6 +474,8 @@ lima_screen_create(int fd, struct renderonly *ro) screen->fd = fd; + lima_screen_parse_env(); + if (!lima_screen_query_info(screen)) goto err_out0; @@ -532,8 +558,6 @@ lima_screen_create(int fd, struct renderonly *ro) screen->refcnt = 1; - lima_screen_parse_env(); - return &screen->base; err_out2: diff --git a/src/gallium/drivers/lima/lima_screen.h b/src/gallium/drivers/lima/lima_screen.h index af435f71190..7d1f6f82924 100644 --- a/src/gallium/drivers/lima/lima_screen.h +++ b/src/gallium/drivers/lima/lima_screen.h @@ -40,6 +40,7 @@ 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; struct ra_regs; @@ -54,6 +55,7 @@ struct lima_screen { int fd; int gpu_type; int num_pp; + uint32_t plb_max_blk; /* bo table */ mtx_t bo_table_lock; diff --git a/src/gallium/drivers/lima/lima_state.c b/src/gallium/drivers/lima/lima_state.c index 1621618c865..3cb8c57ffc8 100644 --- a/src/gallium/drivers/lima/lima_state.c +++ b/src/gallium/drivers/lima/lima_state.c @@ -58,13 +58,15 @@ lima_set_framebuffer_state(struct pipe_context *pctx, int width = align(framebuffer->width, 16) >> 4; int height = align(framebuffer->height, 16) >> 4; if (fb->tiled_w != width || fb->tiled_h != height) { + struct lima_screen *screen = lima_screen(ctx->base.screen); + fb->tiled_w = width; fb->tiled_h = height; fb->shift_h = 0; fb->shift_w = 0; - int limit = ctx->plb_max_blk; + int limit = screen->plb_max_blk; while ((width * height) > limit) { if (width >= height) { width = (width + 1) >> 1; -- cgit v1.2.3