Make flink save the kernel-assigned name and return it instead of creating another...
authorKeith Packard <keithp@keithp.com>
Thu, 7 Aug 2008 22:26:30 +0000 (15:26 -0700)
committerKeith Packard <keithp@keithp.com>
Thu, 7 Aug 2008 22:26:30 +0000 (15:26 -0700)
libdrm/intel/intel_bufmgr_gem.c

index 22f8695..f573222 100644 (file)
@@ -103,6 +103,11 @@ struct _dri_bo_gem {
     const char *name;
 
     /**
+     * Kenel-assigned global name for this object
+     */
+    unsigned int global_name;
+    
+    /**
      * Index of the buffer within the validation list while preparing a
      * batchbuffer execution.
      */
@@ -833,13 +838,16 @@ dri_gem_flink(dri_bo *bo, uint32_t *name)
     struct drm_gem_flink flink;
     int ret;
 
-    flink.handle = bo_gem->gem_handle;
-
-    ret = ioctl(bufmgr_gem->fd, DRM_IOCTL_GEM_FLINK, &flink);
-    if (ret != 0)
-       return -errno;
-
-    *name = flink.name;
+    if (!bo_gem->global_name) {
+       flink.handle = bo_gem->gem_handle;
+    
+       ret = ioctl(bufmgr_gem->fd, DRM_IOCTL_GEM_FLINK, &flink);
+       if (ret != 0)
+           return -errno;
+       bo_gem->gem_handle = flink.name;
+    }
+    
+    *name = bo_gem->gem_handle;
     return 0;
 }