lima: create heap buffer with new interface if available

Newly added heap buffer create interface can create a
large enough buffer whose backup memory can increase
dynamically as needed.

Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com>
Tested-by: Andreas Baierl <ichgeh@imkreisrum.de>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3264>
This commit is contained in:
Qiang Yu
2020-01-01 20:25:45 +08:00
committed by Marge Bot
parent 92465cc999
commit b220aec628
6 changed files with 33 additions and 4 deletions
+6 -1
View File
@@ -246,6 +246,10 @@ lima_bo_cache_put(struct lima_bo *bo)
static struct lima_bo *
lima_bo_cache_get(struct lima_screen *screen, uint32_t size, uint32_t flags)
{
/* we won't cache heap buffer */
if (flags & LIMA_BO_FLAG_HEAP)
return NULL;
struct lima_bo *bo = NULL;
mtx_lock(&screen->bo_cache_lock);
struct list_head *bucket = lima_bo_cache_get_bucket(screen, size);
@@ -314,7 +318,8 @@ struct lima_bo *lima_bo_create(struct lima_screen *screen,
bo->size = req.size;
bo->flags = req.flags;
bo->handle = req.handle;
bo->cacheable = !(lima_debug & LIMA_DEBUG_NO_BO_CACHE);
bo->cacheable = !(lima_debug & LIMA_DEBUG_NO_BO_CACHE ||
flags & LIMA_BO_FLAG_HEAP);
p_atomic_set(&bo->refcnt, 1);
if (!lima_bo_get_info(bo))
+15 -1
View File
@@ -235,11 +235,25 @@ lima_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
ctx->plb_size = screen->plb_max_blk * LIMA_CTX_PLB_BLK_SIZE;
ctx->plb_gp_size = screen->plb_max_blk * 4;
uint32_t heap_flags;
if (screen->has_growable_heap_buffer) {
/* growable size buffer, initially will allocate 32K (by default)
* backup memory in kernel driver, and will allocate more when GP
* get out of memory interrupt. Max to 16M set here.
*/
ctx->gp_tile_heap_size = 0x1000000;
heap_flags = LIMA_BO_FLAG_HEAP;
} else {
/* fix size buffer */
ctx->gp_tile_heap_size = 0x100000;
heap_flags = 0;
}
for (int i = 0; i < lima_ctx_num_plb; i++) {
ctx->plb[i] = lima_bo_create(screen, ctx->plb_size, 0);
if (!ctx->plb[i])
goto err_out;
ctx->gp_tile_heap[i] = lima_bo_create(screen, gp_tile_heap_size, 0);
ctx->gp_tile_heap[i] = lima_bo_create(screen, ctx->gp_tile_heap_size, heap_flags);
if (!ctx->gp_tile_heap[i])
goto err_out;
}
+1 -1
View File
@@ -225,7 +225,7 @@ struct lima_context {
struct lima_bo *plb[LIMA_CTX_PLB_MAX_NUM];
struct lima_bo *gp_tile_heap[LIMA_CTX_PLB_MAX_NUM];
#define gp_tile_heap_size 0x100000
uint32_t gp_tile_heap_size;
struct lima_bo *plb_gp_stream;
struct lima_bo *gp_output;
uint32_t gp_output_varyings_offt;
+1 -1
View File
@@ -1792,7 +1792,7 @@ _lima_flush(struct lima_context *ctx, bool end_of_frame)
gp_frame_reg->plbu_cmd_start = plbu_cmd_va;
gp_frame_reg->plbu_cmd_end = plbu_cmd_va + plbu_cmd_size;
gp_frame_reg->tile_heap_start = ctx->gp_tile_heap[ctx->plb_index]->va;
gp_frame_reg->tile_heap_end = ctx->gp_tile_heap[ctx->plb_index]->va + gp_tile_heap_size;
gp_frame_reg->tile_heap_end = ctx->gp_tile_heap[ctx->plb_index]->va + ctx->gp_tile_heap_size;
lima_dump_command_stream_print(
&gp_frame, sizeof(gp_frame), false, "add gp frame\n");
+9
View File
@@ -388,6 +388,15 @@ lima_screen_set_plb_max_blk(struct lima_screen *screen)
static bool
lima_screen_query_info(struct lima_screen *screen)
{
drmVersionPtr version = drmGetVersion(screen->fd);
if (!version)
return false;
if (version->version_major > 1 || version->version_minor > 0)
screen->has_growable_heap_buffer = true;
drmFreeVersion(version);
struct drm_lima_get_param param;
memset(&param, 0, sizeof(param));
+1
View File
@@ -85,6 +85,7 @@ struct lima_screen {
#define pp_clear_gl_pos_offset 0x0100
#define pp_buffer_size 0x1000
bool has_growable_heap_buffer;
};
static inline struct lima_screen *