Module: Mesa
Branch: master
Commit: 82cdb801fda294465aadcdd5dde426a1fa02ffd2
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=82cdb801fda294465aadcdd5dde426a1fa02ffd2

Author: Eric Anholt <e...@anholt.net>
Date:   Thu Apr 12 13:47:52 2018 -0700

broadcom/vc5: Add sim support for the GET_BO_OFFSET ioctl.

Otherwise we'd crash immediately upon importing a BO through EGL
interfaces.

---

 src/gallium/drivers/vc5/vc5_bufmgr.c    | 13 +++++++------
 src/gallium/drivers/vc5/vc5_simulator.c | 14 ++++++++++++++
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/vc5/vc5_bufmgr.c 
b/src/gallium/drivers/vc5/vc5_bufmgr.c
index 7a9c04a268..1b91fbbdae 100644
--- a/src/gallium/drivers/vc5/vc5_bufmgr.c
+++ b/src/gallium/drivers/vc5/vc5_bufmgr.c
@@ -348,6 +348,12 @@ vc5_bo_open_handle(struct vc5_screen *screen,
         bo->name = "winsys";
         bo->private = false;
 
+#ifdef USE_VC5_SIMULATOR
+        vc5_simulator_open_from_handle(screen->fd, winsys_stride,
+                                       bo->handle, bo->size);
+        bo->map = malloc(bo->size);
+#endif
+
         struct drm_vc5_get_bo_offset get = {
                 .handle = handle,
         };
@@ -355,17 +361,12 @@ vc5_bo_open_handle(struct vc5_screen *screen,
         if (ret) {
                 fprintf(stderr, "Failed to get BO offset: %s\n",
                         strerror(errno));
+                free(bo->map);
                 free(bo);
                 return NULL;
         }
         bo->offset = get.offset;
 
-#ifdef USE_VC5_SIMULATOR
-        vc5_simulator_open_from_handle(screen->fd, winsys_stride,
-                                       bo->handle, bo->size);
-        bo->map = malloc(bo->size);
-#endif
-
         util_hash_table_set(screen->bo_handles, (void *)(uintptr_t)handle, bo);
 
 done:
diff --git a/src/gallium/drivers/vc5/vc5_simulator.c 
b/src/gallium/drivers/vc5/vc5_simulator.c
index d677293f3e..ee4ffb28c0 100644
--- a/src/gallium/drivers/vc5/vc5_simulator.c
+++ b/src/gallium/drivers/vc5/vc5_simulator.c
@@ -511,6 +511,18 @@ vc5_simulator_mmap_bo_ioctl(int fd, struct drm_vc5_mmap_bo 
*args)
 }
 
 static int
+vc5_simulator_get_bo_offset_ioctl(int fd, struct drm_vc5_get_bo_offset *args)
+{
+        struct vc5_simulator_file *file = vc5_get_simulator_file_for_fd(fd);
+        struct vc5_simulator_bo *sim_bo = vc5_get_simulator_bo(file,
+                                                               args->handle);
+
+        args->offset = sim_bo->block->ofs;
+
+        return 0;
+}
+
+static int
 vc5_simulator_gem_close_ioctl(int fd, struct drm_gem_close *args)
 {
         /* Free the simulator's internal tracking. */
@@ -541,6 +553,8 @@ vc5_simulator_ioctl(int fd, unsigned long request, void 
*args)
                 return vc5_simulator_create_bo_ioctl(fd, args);
         case DRM_IOCTL_VC5_MMAP_BO:
                 return vc5_simulator_mmap_bo_ioctl(fd, args);
+        case DRM_IOCTL_VC5_GET_BO_OFFSET:
+                return vc5_simulator_get_bo_offset_ioctl(fd, args);
 
         case DRM_IOCTL_VC5_WAIT_BO:
                 /* We do all of the vc5 rendering synchronously, so we just

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to