[Mesa-dev] [PATCH] svga: remove open-coded vmw_ioctl_surface_req()

Emil Velikov emil.l.velikov at gmail.com
Mon Jun 3 17:32:25 UTC 2019


From: Emil Velikov <emil.velikov at collabora.com>

Cc: Brian Paul <brianp at vmware.com>
Cc: Jose Fonseca <jfonseca at vmware.com>
Cc: Roland Scheidegger <sroland at vmware.com>
Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
 src/gallium/winsys/svga/drm/vmw_screen_dri.c | 29 ++++----------------
 1 file changed, 6 insertions(+), 23 deletions(-)

diff --git a/src/gallium/winsys/svga/drm/vmw_screen_dri.c b/src/gallium/winsys/svga/drm/vmw_screen_dri.c
index a85ee18e45b..264c61a5f69 100644
--- a/src/gallium/winsys/svga/drm/vmw_screen_dri.c
+++ b/src/gallium/winsys/svga/drm/vmw_screen_dri.c
@@ -221,7 +221,7 @@ vmw_drm_surface_from_handle(struct svga_winsys_screen *sws,
     union drm_vmw_surface_reference_arg arg;
     struct drm_vmw_surface_arg *req = &arg.req;
     struct drm_vmw_surface_create_req *rep = &arg.rep;
-    uint32_t handle = 0;
+    boolean needs_unref = FALSE;
     struct drm_vmw_size size;
     SVGA3dSize base_size;
     int ret;
@@ -233,28 +233,11 @@ vmw_drm_surface_from_handle(struct svga_winsys_screen *sws,
        return NULL;
     }
 
-    switch (whandle->type) {
-    case WINSYS_HANDLE_TYPE_SHARED:
-    case WINSYS_HANDLE_TYPE_KMS:
-       handle = whandle->handle;
-       break;
-    case WINSYS_HANDLE_TYPE_FD:
-       ret = drmPrimeFDToHandle(vws->ioctl.drm_fd, whandle->handle,
-                                &handle);
-       if (ret) {
-	  vmw_error("Failed to get handle from prime fd %d.\n",
-		    (int) whandle->handle);
-	  return NULL;
-       }
-       break;
-    default:
-       vmw_error("Attempt to import unsupported handle type %d.\n",
-                 whandle->type);
-       return NULL;
-    }
-
     memset(&arg, 0, sizeof(arg));
-    req->sid = handle;
+    ret = vmw_ioctl_surface_req(vws, whandle, req, &needs_unref);
+    if (ret)
+        return NULL;
+
     rep->size_addr = (unsigned long)&size;
 
     ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_REF_SURFACE,
@@ -263,7 +246,7 @@ vmw_drm_surface_from_handle(struct svga_winsys_screen *sws,
     /*
      * Need to close the handle we got from prime.
      */
-    if (whandle->type == WINSYS_HANDLE_TYPE_FD)
+    if (needs_unref)
        vmw_ioctl_surface_destroy(vws, handle);
 
     if (ret) {
-- 
2.21.0



More information about the mesa-dev mailing list