From 6cd58de4eb79dcced41ca77faae1449368f9ac5e Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Tue, 7 May 2024 10:50:46 -0500 Subject: [PATCH] nouveau/winsys: Make BO_LOCAL and BO_GART separate flags It's sometimes useful to specify both to allow migration. Reviewed-by: Dave Airlie Part-of: --- src/nouveau/vulkan/nvk_device_memory.c | 2 +- src/nouveau/winsys/nouveau_bo.c | 15 +++++++++++---- src/nouveau/winsys/nouveau_bo.h | 8 ++++---- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/nouveau/vulkan/nvk_device_memory.c b/src/nouveau/vulkan/nvk_device_memory.c index 0791b7eb0f0..4dfb868129d 100644 --- a/src/nouveau/vulkan/nvk_device_memory.c +++ b/src/nouveau/vulkan/nvk_device_memory.c @@ -127,7 +127,7 @@ nvk_AllocateMemory(VkDevice device, nvk_memory_type_flags(type, handle_types); uint32_t alignment = (1ULL << 12); - if (!(flags & NOUVEAU_WS_BO_GART)) + if (flags & NOUVEAU_WS_BO_LOCAL) alignment = (1ULL << 16); const uint64_t aligned_size = diff --git a/src/nouveau/winsys/nouveau_bo.c b/src/nouveau/winsys/nouveau_bo.c index 71fd46a1538..97604cf21a6 100644 --- a/src/nouveau/winsys/nouveau_bo.c +++ b/src/nouveau/winsys/nouveau_bo.c @@ -189,6 +189,15 @@ nouveau_ws_bo_new_locked(struct nouveau_ws_device *dev, req.info.domain = 0; + /* It needs to live somewhere */ + assert((flags & NOUVEAU_WS_BO_LOCAL) || (flags & NOUVEAU_WS_BO_GART)); + + if (flags & NOUVEAU_WS_BO_LOCAL) + req.info.domain |= dev->local_mem_domain; + + if (flags & NOUVEAU_WS_BO_GART) + req.info.domain |= NOUVEAU_GEM_DOMAIN_GART; + /* TODO: * * VRAM maps on Kepler appear to be broken and we don't really know why. @@ -196,12 +205,8 @@ nouveau_ws_bo_new_locked(struct nouveau_ws_device *dev, * should but they don't today. Force everything that may be mapped to * use GART for now. */ - if (flags & NOUVEAU_WS_BO_GART) - req.info.domain |= NOUVEAU_GEM_DOMAIN_GART; else if (dev->info.chipset < 0x110 && (flags & NOUVEAU_WS_BO_MAP)) req.info.domain |= NOUVEAU_GEM_DOMAIN_GART; - else - req.info.domain |= dev->local_mem_domain; if (flags & NOUVEAU_WS_BO_MAP) req.info.domain |= NOUVEAU_GEM_DOMAIN_MAPPABLE; @@ -289,6 +294,8 @@ nouveau_ws_bo_from_dma_buf_locked(struct nouveau_ws_device *dev, int fd) goto fail_fd_to_handle; enum nouveau_ws_bo_flags flags = 0; + if (info.domain & dev->local_mem_domain) + flags |= NOUVEAU_WS_BO_LOCAL; if (info.domain & NOUVEAU_GEM_DOMAIN_GART) flags |= NOUVEAU_WS_BO_GART; if (info.map_handle) diff --git a/src/nouveau/winsys/nouveau_bo.h b/src/nouveau/winsys/nouveau_bo.h index 27a2c5ebf57..ad3faec9c2e 100644 --- a/src/nouveau/winsys/nouveau_bo.h +++ b/src/nouveau/winsys/nouveau_bo.h @@ -20,10 +20,10 @@ extern "C" { enum nouveau_ws_bo_flags { /* vram or gart depending on GPU */ - NOUVEAU_WS_BO_LOCAL = 0 << 0, - NOUVEAU_WS_BO_GART = 1 << 0, - NOUVEAU_WS_BO_MAP = 1 << 1, - NOUVEAU_WS_BO_NO_SHARE = 1 << 2, + NOUVEAU_WS_BO_LOCAL = 1 << 0, + NOUVEAU_WS_BO_GART = 1 << 1, + NOUVEAU_WS_BO_MAP = 1 << 2, + NOUVEAU_WS_BO_NO_SHARE = 1 << 3, }; enum nouveau_ws_bo_map_flags {