diff options
author | Jordan Justen <[email protected]> | 2018-04-27 16:35:28 -0700 |
---|---|---|
committer | Jordan Justen <[email protected]> | 2019-10-28 00:09:14 -0700 |
commit | f118ca20758c85da1aaf1792e61aadb298b32a47 (patch) | |
tree | 4c6ecb7a4a50a798176eee1bc904185852a75c62 /src/gallium/drivers/iris/iris_bufmgr.c | |
parent | 6af8a4acc4a4a30608d221b80ac3aa848db309a7 (diff) |
iris/bufmgr: Initialize aux map context for gen12
Reworks:
* free gen_buffer in gen_aux_map_buffer_free. (Rafael)
* lock around aux_map_bos accesses. (Ken)
Signed-off-by: Jordan Justen <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/gallium/drivers/iris/iris_bufmgr.c')
-rw-r--r-- | src/gallium/drivers/iris/iris_bufmgr.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/gallium/drivers/iris/iris_bufmgr.c b/src/gallium/drivers/iris/iris_bufmgr.c index 992bbd90b3a..1624257729a 100644 --- a/src/gallium/drivers/iris/iris_bufmgr.c +++ b/src/gallium/drivers/iris/iris_bufmgr.c @@ -51,6 +51,7 @@ #include <time.h> #include "errno.h" +#include "common/gen_aux_map.h" #include "common/gen_clflush.h" #include "dev/gen_debug.h" #include "common/gen_gem.h" @@ -146,6 +147,8 @@ struct iris_bufmgr { bool has_llc:1; bool bo_reuse:1; + + struct gen_aux_map_context *aux_map_ctx; }; static int bo_set_tiling_internal(struct iris_bo *bo, uint32_t tiling_mode, @@ -1193,6 +1196,12 @@ iris_bo_wait(struct iris_bo *bo, int64_t timeout_ns) void iris_bufmgr_destroy(struct iris_bufmgr *bufmgr) { + /* Free aux-map buffers */ + gen_aux_map_finish(bufmgr->aux_map_ctx); + + /* bufmgr will no longer try to free VMA entries in the aux-map */ + bufmgr->aux_map_ctx = NULL; + mtx_destroy(&bufmgr->lock); /* Free any cached buffer objects we were going to reuse */ @@ -1560,6 +1569,38 @@ iris_gtt_size(int fd) return 0; } +static struct gen_buffer * +gen_aux_map_buffer_alloc(void *driver_ctx, uint32_t size) +{ + struct gen_buffer *buf = malloc(sizeof(struct gen_buffer)); + if (!buf) + return NULL; + + struct iris_bufmgr *bufmgr = (struct iris_bufmgr *)driver_ctx; + + struct iris_bo *bo = + iris_bo_alloc_tiled(bufmgr, "aux-map", size, 64 * 1024, + IRIS_MEMZONE_OTHER, I915_TILING_NONE, 0, 0); + + buf->driver_bo = bo; + buf->gpu = bo->gtt_offset; + buf->gpu_end = buf->gpu + bo->size; + buf->map = iris_bo_map(NULL, bo, MAP_WRITE | MAP_RAW); + return buf; +} + +static void +gen_aux_map_buffer_free(void *driver_ctx, struct gen_buffer *buffer) +{ + iris_bo_unreference((struct iris_bo*)buffer->driver_bo); + free(buffer); +} + +static struct gen_mapped_pinned_buffer_alloc aux_map_allocator = { + .alloc = gen_aux_map_buffer_alloc, + .free = gen_aux_map_buffer_free, +}; + /** * Initializes the GEM buffer manager, which uses the kernel to allocate, map, * and manage map buffer objections. @@ -1627,5 +1668,17 @@ iris_bufmgr_init(struct gen_device_info *devinfo, int fd, bool bo_reuse) bufmgr->handle_table = _mesa_hash_table_create(NULL, key_hash_uint, key_uint_equal); + if (devinfo->gen >= 12) { + bufmgr->aux_map_ctx = gen_aux_map_init(bufmgr, &aux_map_allocator, + devinfo); + assert(bufmgr->aux_map_ctx); + } + return bufmgr; } + +void* +iris_bufmgr_get_aux_map_context(struct iris_bufmgr *bufmgr) +{ + return bufmgr->aux_map_ctx; +} |