From 91859a9a54647ac3fc38ef74ac73417f762c65ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Roberto=20de=20Souza?= Date: Thu, 20 Apr 2023 11:52:20 -0700 Subject: [PATCH] iris: Allow shared scanout buffer to be placed in smem as well MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit i915 and Xe kmd allows scanout to display of prime buffers placed in smem. Allowing shared and scanout bos to be placed in smem and lmem allows the dma buf to work in some cases that only lmem is not enough. Fixes: c10ff1970461 ("iris: Place scanout buffers only into lmem for discrete GPUs") Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/8867 Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/8766 Signed-off-by: José Roberto de Souza Reviewed-by: Tapani Pälli Tested-by: Tapani Pälli Part-of: (cherry picked from commit ec6d520eb996156da69e0a9a5cf9867b00d29320) --- .pick_status.json | 2 +- src/gallium/drivers/iris/iris_bufmgr.c | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 46799dfc386..c2b478db878 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -337,7 +337,7 @@ "description": "iris: Allow shared scanout buffer to be placed in smem as well", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "c10ff1970461f59a1a0861ba79c3ea24ed4904aa" }, diff --git a/src/gallium/drivers/iris/iris_bufmgr.c b/src/gallium/drivers/iris/iris_bufmgr.c index 6227bad583e..f844055c813 100644 --- a/src/gallium/drivers/iris/iris_bufmgr.c +++ b/src/gallium/drivers/iris/iris_bufmgr.c @@ -776,11 +776,13 @@ fail: static enum iris_heap flags_to_heap(struct iris_bufmgr *bufmgr, unsigned flags) { - if (bufmgr->vram.size > 0 && - !(flags & BO_ALLOC_SMEM) && - !(flags & BO_ALLOC_COHERENT)) { - return flags & BO_ALLOC_LMEM ? IRIS_HEAP_DEVICE_LOCAL : - IRIS_HEAP_DEVICE_LOCAL_PREFERRED; + if (bufmgr->vram.size > 0) { + if ((flags & BO_ALLOC_SMEM) || (flags & BO_ALLOC_COHERENT)) + return IRIS_HEAP_SYSTEM_MEMORY; + if ((flags & BO_ALLOC_LMEM) || + ((flags & BO_ALLOC_SCANOUT) && !(flags & BO_ALLOC_SHARED))) + return IRIS_HEAP_DEVICE_LOCAL; + return IRIS_HEAP_DEVICE_LOCAL_PREFERRED; } else { assert(!(flags & BO_ALLOC_LMEM)); return IRIS_HEAP_SYSTEM_MEMORY; @@ -1016,8 +1018,7 @@ alloc_fresh_bo(struct iris_bufmgr *bufmgr, uint64_t bo_size, unsigned flags) case IRIS_HEAP_DEVICE_LOCAL_PREFERRED: /* For vram allocations, still use system memory as a fallback. */ regions[num_regions++] = bufmgr->vram.region; - if (!(flags & BO_ALLOC_SCANOUT)) - regions[num_regions++] = bufmgr->sys.region; + regions[num_regions++] = bufmgr->sys.region; break; case IRIS_HEAP_DEVICE_LOCAL: regions[num_regions++] = bufmgr->vram.region;