From 188cddfb3897da004b98d0136790df5c10ac8353 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Thu, 22 Jul 2021 15:29:16 -0500 Subject: [PATCH] iris: Add a new IRIS_MMAP_NONE map type This indicates that the buffer can never be mapped. We use this primarily for imported BOs. Reviewed-by: Kenneth Graunke Part-of: --- src/gallium/drivers/iris/iris_bufmgr.c | 9 +++++++-- src/gallium/drivers/iris/iris_bufmgr.h | 1 + src/gallium/drivers/iris/iris_resource.c | 5 +++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/iris/iris_bufmgr.c b/src/gallium/drivers/iris/iris_bufmgr.c index 7dfb2cc8df3..8d1ee2a3d76 100644 --- a/src/gallium/drivers/iris/iris_bufmgr.c +++ b/src/gallium/drivers/iris/iris_bufmgr.c @@ -801,7 +801,7 @@ iris_bo_gem_create_from_name(struct iris_bufmgr *bufmgr, bo->global_name = handle; bo->reusable = false; bo->imported = true; - bo->mmap_mode = IRIS_MMAP_WC; + bo->mmap_mode = IRIS_MMAP_NONE; bo->kflags = EXEC_OBJECT_SUPPORTS_48B_ADDRESS | EXEC_OBJECT_PINNED; bo->address = vma_alloc(bufmgr, IRIS_MEMZONE_OTHER, bo->size, 1); @@ -1051,6 +1051,7 @@ iris_bo_gem_mmap_offset(struct pipe_debug_callback *dbg, struct iris_bo *bo) [IRIS_MMAP_WC] = I915_MMAP_OFFSET_WC, [IRIS_MMAP_WB] = I915_MMAP_OFFSET_WB, }; + assert(bo->mmap_mode != IRIS_MMAP_NONE); assert(bo->mmap_mode < ARRAY_SIZE(mmap_offset_for_mode)); mmap_arg.flags = mmap_offset_for_mode[bo->mmap_mode]; @@ -1080,6 +1081,10 @@ iris_bo_map(struct pipe_debug_callback *dbg, { struct iris_bufmgr *bufmgr = bo->bufmgr; + assert(bo->mmap_mode != IRIS_MMAP_NONE); + if (bo->mmap_mode == IRIS_MMAP_NONE) + return NULL; + if (!bo->map) { DBG("iris_bo_map: %d (%s)\n", bo->gem_handle, bo->name); void *map = bufmgr->has_mmap_offset ? iris_bo_gem_mmap_offset(dbg, bo) @@ -1306,7 +1311,7 @@ iris_bo_import_dmabuf(struct iris_bufmgr *bufmgr, int prime_fd) bo->name = "prime"; bo->reusable = false; bo->imported = true; - bo->mmap_mode = IRIS_MMAP_WC; + bo->mmap_mode = IRIS_MMAP_NONE; bo->kflags = EXEC_OBJECT_SUPPORTS_48B_ADDRESS | EXEC_OBJECT_PINNED; /* From the Bspec, Memory Compression - Gfx12: diff --git a/src/gallium/drivers/iris/iris_bufmgr.h b/src/gallium/drivers/iris/iris_bufmgr.h index 57046d2df34..1f43456bae4 100644 --- a/src/gallium/drivers/iris/iris_bufmgr.h +++ b/src/gallium/drivers/iris/iris_bufmgr.h @@ -123,6 +123,7 @@ iris_domain_is_read_only(enum iris_domain access) } enum iris_mmap_mode { + IRIS_MMAP_NONE, /**< Cannot be mapped */ IRIS_MMAP_UC, /**< Fully uncached memory map */ IRIS_MMAP_WC, /**< Write-combining map with no caching of reads */ IRIS_MMAP_WB, /**< Write-back mapping with CPU caches enabled */ diff --git a/src/gallium/drivers/iris/iris_resource.c b/src/gallium/drivers/iris/iris_resource.c index cc32a64559c..b6cd0bcc03f 100644 --- a/src/gallium/drivers/iris/iris_resource.c +++ b/src/gallium/drivers/iris/iris_resource.c @@ -2087,7 +2087,7 @@ iris_transfer_map(struct pipe_context *ctx, if (usage & PIPE_MAP_WRITE) util_range_add(&res->base.b, &res->valid_buffer_range, box->x, box->x + box->width); - if (!res->bo->imported) { + if (res->bo->mmap_mode != IRIS_MMAP_NONE) { /* GPU copies are not useful for buffer reads. Instead of stalling to * read from the original buffer, we'd simply copy it to a temporary... * then stall (a bit longer) to read from that buffer. @@ -2257,7 +2257,8 @@ iris_texture_subdata(struct pipe_context *ctx, */ if (surf->tiling == ISL_TILING_LINEAR || isl_aux_usage_has_compression(res->aux.usage) || - resource_is_busy(ice, res)) { + resource_is_busy(ice, res) || + res->bo->mmap_mode == IRIS_MMAP_NONE) { return u_default_texture_subdata(ctx, resource, level, usage, box, data, stride, layer_stride); }