Mesa (main): llvmpipe: page-align memory allocations

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Nov 17 14:57:42 UTC 2021


Module: Mesa
Branch: main
Commit: 58a0d8d0ded2f41afd9ff8d0f19f93341687442f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=58a0d8d0ded2f41afd9ff8d0f19f93341687442f

Author: Omar Akkila <omar.akkila at collabora.com>
Date:   Fri Nov 12 12:51:26 2021 -0500

llvmpipe: page-align memory allocations

Allows memory allocated by llvmpipe_allocate_memory_fd to be
mappable to guests in virtualized environments like KVM which
requires page-aligned memory.

llvmpipe_allocate_memory is updated similarly for consistency.

Signed-off-by: Omar Akkila <omar.akkila at collabora.com>
Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13793>

---

 src/gallium/drivers/llvmpipe/lp_texture.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c
index 5bfc8dbc973..09907722729 100644
--- a/src/gallium/drivers/llvmpipe/lp_texture.c
+++ b/src/gallium/drivers/llvmpipe/lp_texture.c
@@ -950,7 +950,10 @@ llvmpipe_memory_barrier(struct pipe_context *pipe,
 
 static struct pipe_memory_allocation *llvmpipe_allocate_memory(struct pipe_screen *screen, uint64_t size)
 {
-   return os_malloc_aligned(size, 256);
+   uint64_t alignment;
+   if (!os_get_page_size(&alignment))
+      alignment = 256;
+   return os_malloc_aligned(size, alignment);
 }
 
 static void llvmpipe_free_memory(struct pipe_screen *screen,
@@ -965,7 +968,10 @@ static const char *driver_id = "llvmpipe" MESA_GIT_SHA1;
 
 static struct pipe_memory_allocation *llvmpipe_allocate_memory_fd(struct pipe_screen *screen, uint64_t size, int *fd)
 {
-   return os_malloc_aligned_fd(size, 256, fd, "llvmpipe memory fd", driver_id);
+   uint64_t alignment;
+   if (!os_get_page_size(&alignment))
+      alignment = 256;
+   return os_malloc_aligned_fd(size, alignment, fd, "llvmpipe memory fd", driver_id);
 }
 
 static bool llvmpipe_import_memory_fd(struct pipe_screen *screen, int fd, struct pipe_memory_allocation **ptr, uint64_t *size)



More information about the mesa-commit mailing list