Mesa (master): iris/bufmgr: Initialize aux map context for gen12
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Oct 28 07:46:34 UTC 2019
Module: Mesa
Branch: master
Commit: f118ca20758c85da1aaf1792e61aadb298b32a47
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f118ca20758c85da1aaf1792e61aadb298b32a47
Author: Jordan Justen <jordan.l.justen at intel.com>
Date: Fri Apr 27 16:35:28 2018 -0700
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 <jordan.l.justen at intel.com>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
---
src/gallium/drivers/iris/iris_bufmgr.c | 53 ++++++++++++++++++++++++++++++++++
src/gallium/drivers/iris/iris_bufmgr.h | 9 ++++++
2 files changed, 62 insertions(+)
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;
+}
diff --git a/src/gallium/drivers/iris/iris_bufmgr.h b/src/gallium/drivers/iris/iris_bufmgr.h
index d5ae9b42ab1..c23cd403023 100644
--- a/src/gallium/drivers/iris/iris_bufmgr.h
+++ b/src/gallium/drivers/iris/iris_bufmgr.h
@@ -33,6 +33,7 @@
#include "util/list.h"
#include "pipe/p_defines.h"
+struct iris_batch;
struct gen_device_info;
struct pipe_debug_callback;
@@ -113,6 +114,11 @@ struct iris_bo {
uint64_t gtt_offset;
/**
+ * If non-zero, then this bo has an aux-map translation to this address.
+ */
+ uint64_t aux_map_address;
+
+ /**
* The validation list index for this buffer, or -1 when not in a batch.
* Note that a single buffer may be in multiple batches (contexts), and
* this is a global field, which refers to the last batch using the BO.
@@ -328,6 +334,9 @@ struct iris_bufmgr *iris_bufmgr_init(struct gen_device_info *devinfo, int fd,
struct iris_bo *iris_bo_gem_create_from_name(struct iris_bufmgr *bufmgr,
const char *name,
unsigned handle);
+
+void* iris_bufmgr_get_aux_map_context(struct iris_bufmgr *bufmgr);
+
int iris_bo_wait(struct iris_bo *bo, int64_t timeout_ns);
uint32_t iris_create_hw_context(struct iris_bufmgr *bufmgr);
More information about the mesa-commit
mailing list