nvk/nvkmd: nouveau uses the OS page size

It's the same, regardless of whether the memory comes from VRAM or
system RAM.

Fixes: 7f45d20d2b ("nvk/nvkmd: Be more specific about memory alignments")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30138>
This commit is contained in:
Faith Ekstrand 2024-07-11 15:40:01 -05:00 committed by Marge Bot
parent 78c00fbc2c
commit bccb9fe091
5 changed files with 21 additions and 17 deletions

View File

@ -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;

View File

@ -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 */,

View File

@ -6,6 +6,7 @@
#include "nvkmd_nouveau.h"
#include "nouveau_device.h"
#include "util/os_misc.h"
#include "vk_log.h"
#include <fcntl.h>
@ -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 */

View File

@ -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));

View File

@ -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;