diff --git a/src/nouveau/vulkan/nvkmd/nouveau/nvkmd_nouveau.h b/src/nouveau/vulkan/nvkmd/nouveau/nvkmd_nouveau.h index 8191f0e53d4..514afa5bd04 100644 --- a/src/nouveau/vulkan/nvkmd/nouveau/nvkmd_nouveau.h +++ b/src/nouveau/vulkan/nvkmd/nouveau/nvkmd_nouveau.h @@ -59,9 +59,6 @@ VkResult nvkmd_nouveau_create_dev(struct nvkmd_pdev *pdev, struct vk_object_base *log_obj, struct nvkmd_dev **dev_out); -#define NVKMD_NOUVEAU_GART_ALIGN_B (1 << 12) -#define NVKMD_NOUVEAU_VRAM_ALIGN_B (1 << 16) - struct nvkmd_nouveau_mem { struct nvkmd_mem base; diff --git a/src/nouveau/vulkan/nvkmd/nouveau/nvkmd_nouveau_mem.c b/src/nouveau/vulkan/nvkmd/nouveau/nvkmd_nouveau_mem.c index aa5467ceef7..62ace88f250 100644 --- a/src/nouveau/vulkan/nvkmd/nouveau/nvkmd_nouveau_mem.c +++ b/src/nouveau/vulkan/nvkmd/nouveau/nvkmd_nouveau_mem.c @@ -25,7 +25,6 @@ nvkmd_nouveau_alloc_mem(struct nvkmd_dev *dev, static VkResult create_mem_or_close_bo(struct nvkmd_nouveau_dev *dev, struct vk_object_base *log_obj, - uint64_t mem_align_B, enum nvkmd_mem_flags mem_flags, struct nouveau_ws_bo *bo, enum nvkmd_va_flags va_flags, @@ -45,7 +44,7 @@ create_mem_or_close_bo(struct nvkmd_nouveau_dev *dev, mem->base.dev = &dev->base; mem->base.refcnt = 1; mem->base.flags = mem_flags; - mem->base.bind_align_B = mem_align_B; + mem->base.bind_align_B = dev->base.pdev->bind_align_B; mem->base.size_B = size_B; mem->bo = bo; @@ -114,10 +113,7 @@ nvkmd_nouveau_alloc_tiled_mem(struct nvkmd_dev *_dev, domains = NOUVEAU_WS_BO_GART; } - uint32_t mem_align_B = NVKMD_NOUVEAU_GART_ALIGN_B; - if (domains & NOUVEAU_WS_BO_VRAM) - mem_align_B = NVKMD_NOUVEAU_VRAM_ALIGN_B; - + const uint32_t mem_align_B = _dev->pdev->bind_align_B; size_B = align64(size_B, mem_align_B); assert(util_is_power_of_two_or_zero64(align_B)); @@ -140,7 +136,7 @@ nvkmd_nouveau_alloc_tiled_mem(struct nvkmd_dev *_dev, if (domains == NOUVEAU_WS_BO_GART) va_flags |= NVKMD_VA_GART; - return create_mem_or_close_bo(dev, log_obj, mem_align_B, flags, bo, + return create_mem_or_close_bo(dev, log_obj, flags, bo, va_flags, pte_kind, va_align_B, mem_out); } @@ -166,10 +162,7 @@ nvkmd_nouveau_import_dma_buf(struct nvkmd_dev *_dev, if (bo->flags & NOUVEAU_WS_BO_MAP) flags |= NVKMD_MEM_CAN_MAP; - /* We don't know so assume VRAM */ - uint32_t mem_align_B = NVKMD_NOUVEAU_VRAM_ALIGN_B; - - return create_mem_or_close_bo(dev, log_obj, mem_align_B, flags, bo, + return create_mem_or_close_bo(dev, log_obj, flags, bo, 0 /* va_flags */, 0 /* pte_kind */, 0 /* va_align_B */, diff --git a/src/nouveau/vulkan/nvkmd/nouveau/nvkmd_nouveau_pdev.c b/src/nouveau/vulkan/nvkmd/nouveau/nvkmd_nouveau_pdev.c index a13b2ab73e2..0e8c35ff2c6 100644 --- a/src/nouveau/vulkan/nvkmd/nouveau/nvkmd_nouveau_pdev.c +++ b/src/nouveau/vulkan/nvkmd/nouveau/nvkmd_nouveau_pdev.c @@ -6,6 +6,7 @@ #include "nvkmd_nouveau.h" #include "nouveau_device.h" +#include "util/os_misc.h" #include "vk_log.h" #include @@ -106,6 +107,14 @@ nvkmd_nouveau_try_create_pdev(struct _drmDevice *drm_device, .has_overmap = true, }; + /* Nouveau uses the OS page size for all pages, regardless of whether they + * come from VRAM or system RAM. + */ + uint64_t os_page_size; + os_get_page_size(&os_page_size); + assert(os_page_size <= UINT32_MAX); + pdev->base.bind_align_B = os_page_size; + pdev->base.drm.render_dev = render_dev; /* DRM primary is optional */ diff --git a/src/nouveau/vulkan/nvkmd/nouveau/nvkmd_nouveau_va.c b/src/nouveau/vulkan/nvkmd/nouveau/nvkmd_nouveau_va.c index 9dfab6ac640..922215d8889 100644 --- a/src/nouveau/vulkan/nvkmd/nouveau/nvkmd_nouveau_va.c +++ b/src/nouveau/vulkan/nvkmd/nouveau/nvkmd_nouveau_va.c @@ -125,9 +125,7 @@ nvkmd_nouveau_alloc_va(struct nvkmd_dev *_dev, if (va == NULL) return vk_error(log_obj, VK_ERROR_OUT_OF_HOST_MEMORY); - const uint32_t min_align_B = - (flags & NVKMD_VA_GART) ? NVKMD_NOUVEAU_GART_ALIGN_B - : NVKMD_NOUVEAU_VRAM_ALIGN_B; + const uint32_t min_align_B = _dev->pdev->bind_align_B; size_B = align64(size_B, min_align_B); assert(util_is_power_of_two_or_zero64(align_B)); diff --git a/src/nouveau/vulkan/nvkmd/nvkmd.h b/src/nouveau/vulkan/nvkmd/nvkmd.h index ef470807ed4..4bb35fe5ecc 100644 --- a/src/nouveau/vulkan/nvkmd/nvkmd.h +++ b/src/nouveau/vulkan/nvkmd/nvkmd.h @@ -123,6 +123,13 @@ struct nvkmd_pdev { struct nv_device_info dev_info; struct nvkmd_info kmd_info; + /** Device-wide GPU memory bind alignment + * + * Individual BOs may have a smaller alignment if, for instance, we know + * they are pinned to system ram. + */ + uint32_t bind_align_B; + struct { dev_t render_dev; dev_t primary_dev;