Mesa (main): freedreno/drm-shim: keep GEM buffers page-aligned

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jun 14 17:48:41 UTC 2021


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

Author: Alexander Monakov <amonakov at ispras.ru>
Date:   Fri Jun 11 23:56:17 2021 +0300

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 <amonakov at ispras.ru>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11331>

---

 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 <sys/ioctl.h>
 
+#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);
 



More information about the mesa-commit mailing list