From c133d0930fdaa85c7c5dfd70402892eb3d3ee0c3 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 10 Feb 2021 15:09:11 -0800 Subject: [PATCH] iris: Use thread safe slab allocators in transfer_map handling MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Ian Romanick Part-of: --- 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 d61745d..4a03cf8 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 477975e..824339b 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 4df3060..4a0ec77 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); } -- 2.7.4