svn commit: r261662 - stable/9/sys/dev/drm2

Jean-Sebastien Pedron dumbbell at FreeBSD.org
Sun Feb 9 15:48:50 UTC 2014


Author: dumbbell
Date: Sun Feb  9 15:48:49 2014
New Revision: 261662
URL: http://svnweb.freebsd.org/changeset/base/261662

Log:
  MFC r254836, r254837:
  
  drm: Support gem_open_object() and gem_close_object() callbacks
  
  ... in struct drm_driver_info.

Modified:
  stable/9/sys/dev/drm2/drmP.h
  stable/9/sys/dev/drm2/drm_gem.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/drm2/drmP.h
==============================================================================
--- stable/9/sys/dev/drm2/drmP.h	Sun Feb  9 15:34:38 2014	(r261661)
+++ stable/9/sys/dev/drm2/drmP.h	Sun Feb  9 15:48:49 2014	(r261662)
@@ -736,6 +736,8 @@ struct drm_driver_info {
 
 	int	(*gem_init_object)(struct drm_gem_object *obj);
 	void	(*gem_free_object)(struct drm_gem_object *obj);
+	int	(*gem_open_object)(struct drm_gem_object *, struct drm_file *);
+	void	(*gem_close_object)(struct drm_gem_object *, struct drm_file *);
 
 	struct cdev_pager_ops *gem_pager_ops;
 

Modified: stable/9/sys/dev/drm2/drm_gem.c
==============================================================================
--- stable/9/sys/dev/drm2/drm_gem.c	Sun Feb  9 15:34:38 2014	(r261661)
+++ stable/9/sys/dev/drm2/drm_gem.c	Sun Feb  9 15:48:49 2014	(r261662)
@@ -242,24 +242,40 @@ int
 drm_gem_handle_create(struct drm_file *file_priv, struct drm_gem_object *obj,
     uint32_t *handle)
 {
-	int error;
+	struct drm_device *dev = obj->dev;
+	int ret;
 
-	error = drm_gem_name_create(&file_priv->object_names, obj, handle);
-	if (error != 0)
-		return (error);
+	ret = drm_gem_name_create(&file_priv->object_names, obj, handle);
+	if (ret != 0)
+		return (ret);
 	drm_gem_object_handle_reference(obj);
+
+	if (dev->driver->gem_open_object) {
+		ret = dev->driver->gem_open_object(obj, file_priv);
+		if (ret) {
+			drm_gem_handle_delete(file_priv, *handle);
+			return ret;
+		}
+	}
+
 	return (0);
 }
 
 int
 drm_gem_handle_delete(struct drm_file *file_priv, uint32_t handle)
 {
+	struct drm_device *dev;
 	struct drm_gem_object *obj;
 
 	obj = drm_gem_names_remove(&file_priv->object_names, handle);
 	if (obj == NULL)
 		return (EINVAL);
+
+	dev = obj->dev;
+	if (dev->driver->gem_close_object)
+		dev->driver->gem_close_object(obj, file_priv);
 	drm_gem_object_handle_unreference_unlocked(obj);
+
 	return (0);
 }
 
@@ -312,9 +328,17 @@ drm_gem_open(struct drm_device *dev, str
 static int
 drm_gem_object_release_handle(uint32_t name, void *ptr, void *arg)
 {
+	struct drm_file *file_priv;
 	struct drm_gem_object *obj;
+	struct drm_device *dev;
 
+	file_priv = arg;
 	obj = ptr;
+	dev = obj->dev;
+
+	if (dev->driver->gem_close_object)
+		dev->driver->gem_close_object(obj, file_priv);
+
 	drm_gem_object_handle_unreference(obj);
 	return (0);
 }
@@ -324,7 +348,7 @@ drm_gem_release(struct drm_device *dev, 
 {
 
 	drm_gem_names_foreach(&file_priv->object_names,
-	    drm_gem_object_release_handle, NULL);
+	    drm_gem_object_release_handle, file_priv);
 	drm_gem_names_fini(&file_priv->object_names);
 }
 


More information about the svn-src-stable-9 mailing list