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.souza@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25447>
This commit is contained in:
Kenneth Graunke 2023-09-28 01:22:21 -07:00 committed by Marge Bot
parent 0b6693a3a1
commit b5bcb658b4

View file

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