Mesa (master): iris: Use thread safe slab allocators in transfer_map handling
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Mar 4 22:48:15 UTC 2021
Module: Mesa
Branch: master
Commit: c133d0930fdaa85c7c5dfd70402892eb3d3ee0c3
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c133d0930fdaa85c7c5dfd70402892eb3d3ee0c3
Author: Kenneth Graunke <kenneth at whitecape.org>
Date: Wed Feb 10 15:09:11 2021 -0800
iris: Use thread safe slab allocators in transfer_map handling
pipe->transfer_map can be called from u_threaded_context's thread
rather than the driver thread. We need to use two different slab
allocators, one for each thread. transfer_unmap, on the other hand,
is only ever called from the driver thread.
Reviewed-by: Zoltán Böszörményi <zboszor at gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8964>
---
src/gallium/drivers/iris/iris_context.c | 2 ++
src/gallium/drivers/iris/iris_context.h | 3 +++
src/gallium/drivers/iris/iris_resource.c | 12 +++++++++++-
3 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/src/gallium/drivers/iris/iris_context.c b/src/gallium/drivers/iris/iris_context.c
index d61745d2a9e..4a03cf83508 100644
--- a/src/gallium/drivers/iris/iris_context.c
+++ b/src/gallium/drivers/iris/iris_context.c
@@ -252,6 +252,7 @@ iris_destroy_context(struct pipe_context *ctx)
iris_destroy_binder(&ice->state.binder);
slab_destroy_child(&ice->transfer_pool);
+ slab_destroy_child(&ice->transfer_pool_unsync);
ralloc_free(ice);
}
@@ -328,6 +329,7 @@ iris_create_context(struct pipe_screen *pscreen, void *priv, unsigned flags)
iris_init_binder(ice);
slab_create_child(&ice->transfer_pool, &screen->transfer_pool);
+ slab_create_child(&ice->transfer_pool_unsync, &screen->transfer_pool);
ice->state.surface_uploader =
u_upload_create(ctx, 16384, PIPE_BIND_CUSTOM, PIPE_USAGE_IMMUTABLE,
diff --git a/src/gallium/drivers/iris/iris_context.h b/src/gallium/drivers/iris/iris_context.h
index 477975ecb77..824339bd338 100644
--- a/src/gallium/drivers/iris/iris_context.h
+++ b/src/gallium/drivers/iris/iris_context.h
@@ -576,6 +576,9 @@ struct iris_context {
/** Slab allocator for iris_transfer_map objects. */
struct slab_child_pool transfer_pool;
+ /** Slab allocator for threaded_context's iris_transfer_map objects */
+ struct slab_child_pool transfer_pool_unsync;
+
struct blorp_context blorp;
struct iris_batch batches[IRIS_BATCH_COUNT];
diff --git a/src/gallium/drivers/iris/iris_resource.c b/src/gallium/drivers/iris/iris_resource.c
index 4df30600d9c..4a0ec7748d7 100644
--- a/src/gallium/drivers/iris/iris_resource.c
+++ b/src/gallium/drivers/iris/iris_resource.c
@@ -1865,7 +1865,12 @@ iris_transfer_map(struct pipe_context *ctx,
(usage & PIPE_MAP_DIRECTLY))
return NULL;
- struct iris_transfer *map = slab_alloc(&ice->transfer_pool);
+ struct iris_transfer *map;
+
+ if (usage & TC_TRANSFER_MAP_THREADED_UNSYNC)
+ map = slab_alloc(&ice->transfer_pool_unsync);
+ else
+ map = slab_alloc(&ice->transfer_pool);
if (!map)
return NULL;
@@ -2020,6 +2025,11 @@ iris_transfer_unmap(struct pipe_context *ctx, struct pipe_transfer *xfer)
map->unmap(map);
pipe_resource_reference(&xfer->resource, NULL);
+
+ /* transfer_unmap is always called from the driver thread, so we have to
+ * use transfer_pool, not transfer_pool_unsync. Freeing an object into a
+ * different pool is allowed, however.
+ */
slab_free(&ice->transfer_pool, map);
}
More information about the mesa-commit
mailing list