From 11da35d86d3642b512f8b2c974e22291828d13b1 Mon Sep 17 00:00:00 2001 From: Alexander Monakov Date: Fri, 11 Jun 2021 23:56:17 +0300 Subject: [PATCH] freedreno/drm-shim: keep GEM buffers page-aligned Trying to run turnip under drm-shim reveals that pretended device offsets are not sufficiently aligned, failing this assert in tu_pipeline.c: /* emit program binary & private memory layout * binary_iova should be aligned to 1 instrlen unit (128 bytes) */ assert((binary_iova & 0x7f) == 0); Round up BO size to 4096 in msm_ioctl_gem_new to avoid this (the kernel aligns to page size). Signed-off-by: Alexander Monakov Part-of: --- src/freedreno/drm-shim/freedreno_noop.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/freedreno/drm-shim/freedreno_noop.c b/src/freedreno/drm-shim/freedreno_noop.c index 4476bebcaa9..86e85f1cfda 100644 --- a/src/freedreno/drm-shim/freedreno_noop.c +++ b/src/freedreno/drm-shim/freedreno_noop.c @@ -28,6 +28,8 @@ #include "drm-uapi/msm_drm.h" #include +#include "util/u_math.h" + bool drm_shim_driver_prefers_first_render_node = true; struct msm_bo { @@ -69,13 +71,14 @@ msm_ioctl_gem_new(int fd, unsigned long request, void *arg) struct shim_fd *shim_fd = drm_shim_fd_lookup(fd); struct drm_msm_gem_new *create = arg; struct msm_bo *bo = calloc(1, sizeof(*bo)); + size_t size = ALIGN(create->size, 4096); - drm_shim_bo_init(&bo->base, create->size); + drm_shim_bo_init(&bo->base, size); - assert(UINT_MAX - msm.next_offset > create->size); + assert(UINT_MAX - msm.next_offset > size); bo->offset = msm.next_offset; - msm.next_offset += create->size; + msm.next_offset += size; create->handle = drm_shim_bo_get_handle(shim_fd, &bo->base);