Module: Mesa Branch: main Commit: b5bcb658b4dcac0a08031b30a66c6780ea66c6ff URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b5bcb658b4dcac0a08031b30a66c6780ea66c6ff
Author: Kenneth Graunke <kenn...@whitecape.org> Date: Thu Sep 28 01:22:21 2023 -0700 iris: Ensure virtual addresses are aligned to 2MB for 2MB+ blocks When allocating 2MB chunks of memory, the kernel can use 64K pages if both the virtual and physical addresses are aligned to 2MB. While we can't control the physical allocation, we can ensure the virtual address we use with softpin meets the requirements. Reviewed-by: José Roberto de Souza <jose.so...@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25447> --- src/gallium/drivers/iris/iris_bufmgr.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gallium/drivers/iris/iris_bufmgr.c b/src/gallium/drivers/iris/iris_bufmgr.c index cee92c883fa..8c8698f979a 100644 --- a/src/gallium/drivers/iris/iris_bufmgr.c +++ b/src/gallium/drivers/iris/iris_bufmgr.c @@ -371,10 +371,18 @@ vma_alloc(struct iris_bufmgr *bufmgr, { simple_mtx_assert_locked(&bufmgr->lock); + const unsigned _2mb = 2 * 1024 * 1024; + /* Force minimum alignment based on device requirements */ assert((alignment & (alignment - 1)) == 0); alignment = MAX2(alignment, bufmgr->devinfo.mem_alignment); + /* If the allocation is a multiple of 2MB, ensure the virtual address is + * aligned to 2MB, so that it's possible for the kernel to use 64K pages. + */ + if (size % _2mb == 0) + alignment = MAX2(alignment, _2mb); + if (memzone == IRIS_MEMZONE_BORDER_COLOR_POOL) return IRIS_BORDER_COLOR_POOL_ADDRESS;