From 31f248b382500440379234bfe398ea07f72cb534 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Wed, 4 Jun 2025 03:38:12 -0400 Subject: [PATCH] nvk: Set memory windows in engine init There's no reason to re-set them on every queue state dirty. They're fixed from the dawn of time. Reviewed-by: Mel Henning Part-of: --- src/nouveau/vulkan/nvk_cmd_dispatch.c | 26 +++++++++++++++ src/nouveau/vulkan/nvk_cmd_draw.c | 12 +++++++ src/nouveau/vulkan/nvk_queue.c | 47 --------------------------- 3 files changed, 38 insertions(+), 47 deletions(-) diff --git a/src/nouveau/vulkan/nvk_cmd_dispatch.c b/src/nouveau/vulkan/nvk_cmd_dispatch.c index 015cf1aeaa2..d8423b848b7 100644 --- a/src/nouveau/vulkan/nvk_cmd_dispatch.c +++ b/src/nouveau/vulkan/nvk_cmd_dispatch.c @@ -49,6 +49,32 @@ nvk_push_dispatch_state_init(struct nvk_queue *queue, struct nv_push *p) P_NVA0C0_SET_PROGRAM_REGION_B(p, shader_base_addr); } + if (pdev->info.cls_compute >= VOLTA_COMPUTE_A) { + /* From nvc0_screen.c: + * + * "Reduce likelihood of collision with real buffers by placing the + * hole at the top of the 4G area. This will have to be dealt with + * for real eventually by blocking off that area from the VM." + * + * Really?!? TODO: Fix this for realz. + */ + uint64_t temp = 0xfeULL << 24; + P_MTHD(p, NVC3C0, SET_SHADER_SHARED_MEMORY_WINDOW_A); + P_NVC3C0_SET_SHADER_SHARED_MEMORY_WINDOW_A(p, temp >> 32); + P_NVC3C0_SET_SHADER_SHARED_MEMORY_WINDOW_B(p, temp & 0xffffffff); + + temp = 0xffULL << 24; + P_MTHD(p, NVC3C0, SET_SHADER_LOCAL_MEMORY_WINDOW_A); + P_NVC3C0_SET_SHADER_LOCAL_MEMORY_WINDOW_A(p, temp >> 32); + P_NVC3C0_SET_SHADER_LOCAL_MEMORY_WINDOW_B(p, temp & 0xffffffff); + } else { + P_MTHD(p, NVA0C0, SET_SHADER_LOCAL_MEMORY_WINDOW); + P_NVA0C0_SET_SHADER_LOCAL_MEMORY_WINDOW(p, 0xff << 24); + + P_MTHD(p, NVA0C0, SET_SHADER_SHARED_MEMORY_WINDOW); + P_NVA0C0_SET_SHADER_SHARED_MEMORY_WINDOW(p, 0xfe << 24); + } + return VK_SUCCESS; } diff --git a/src/nouveau/vulkan/nvk_cmd_draw.c b/src/nouveau/vulkan/nvk_cmd_draw.c index 7a8cc6cf56e..b2f021f0170 100644 --- a/src/nouveau/vulkan/nvk_cmd_draw.c +++ b/src/nouveau/vulkan/nvk_cmd_draw.c @@ -519,6 +519,18 @@ nvk_push_draw_state_init(struct nvk_queue *queue, struct nv_push *p) P_NV9097_SET_PROGRAM_REGION_B(p, shader_base_addr); } + /* From nvc0_screen.c: + * + * "Reduce likelihood of collision with real buffers by placing the + * hole at the top of the 4G area. This will have to be dealt with + * for real eventually by blocking off that area from the VM." + * + * Really?!? TODO: Fix this for realz. Annoyingly, we only have a + * 32-bit pointer for this in 3D rather than a full 48 like we have for + * compute. + */ + P_IMMD(p, NV9097, SET_SHADER_LOCAL_MEMORY_WINDOW, 0xff << 24); + for (uint32_t group = 0; group < 5; group++) { for (uint32_t slot = 0; slot < 16; slot++) { P_IMMD(p, NV9097, BIND_GROUP_CONSTANT_BUFFER(group), { diff --git a/src/nouveau/vulkan/nvk_queue.c b/src/nouveau/vulkan/nvk_queue.c index 7aa29346c03..912e9d7d833 100644 --- a/src/nouveau/vulkan/nvk_queue.c +++ b/src/nouveau/vulkan/nvk_queue.c @@ -164,53 +164,6 @@ nvk_queue_state_update(struct nvk_queue *queue, } } - /* We set memory windows unconditionally. Otherwise, the memory window - * might be in a random place and cause us to fault off into nowhere. - */ - if (queue->engines & NVKMD_ENGINE_COMPUTE) { - if (pdev->info.cls_compute >= VOLTA_COMPUTE_A) { - uint64_t temp = 0xfeULL << 24; - P_MTHD(p, NVC3C0, SET_SHADER_SHARED_MEMORY_WINDOW_A); - P_NVC3C0_SET_SHADER_SHARED_MEMORY_WINDOW_A(p, temp >> 32); - P_NVC3C0_SET_SHADER_SHARED_MEMORY_WINDOW_B(p, temp & 0xffffffff); - - temp = 0xffULL << 24; - P_MTHD(p, NVC3C0, SET_SHADER_LOCAL_MEMORY_WINDOW_A); - P_NVC3C0_SET_SHADER_LOCAL_MEMORY_WINDOW_A(p, temp >> 32); - P_NVC3C0_SET_SHADER_LOCAL_MEMORY_WINDOW_B(p, temp & 0xffffffff); - } else { - P_MTHD(p, NVA0C0, SET_SHADER_LOCAL_MEMORY_WINDOW); - P_NVA0C0_SET_SHADER_LOCAL_MEMORY_WINDOW(p, 0xff << 24); - - P_MTHD(p, NVA0C0, SET_SHADER_SHARED_MEMORY_WINDOW); - P_NVA0C0_SET_SHADER_SHARED_MEMORY_WINDOW(p, 0xfe << 24); - } - - /* From nvc0_screen.c: - * - * "Reduce likelihood of collision with real buffers by placing the - * hole at the top of the 4G area. This will have to be dealt with - * for real eventually by blocking off that area from the VM." - * - * Really?!? TODO: Fix this for realz. Annoyingly, we only have a - * 32-bit pointer for this in 3D rather than a full 48 like we have for - * compute. - */ - P_IMMD(p, NV9097, SET_SHADER_LOCAL_MEMORY_WINDOW, 0xff << 24); - } - - /* From nvc0_screen.c: - * - * "Reduce likelihood of collision with real buffers by placing the - * hole at the top of the 4G area. This will have to be dealt with - * for real eventually by blocking off that area from the VM." - * - * Really?!? TODO: Fix this for realz. Annoyingly, we only have a - * 32-bit pointer for this in 3D rather than a full 48 like we have for - * compute. - */ - P_IMMD(p, NV9097, SET_SHADER_LOCAL_MEMORY_WINDOW, 0xff << 24); - return nvk_queue_push(queue, p); }