From owner-svn-src-head@FreeBSD.ORG Sun Aug 25 09:58:32 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 83647F3A; Sun, 25 Aug 2013 09:58:32 +0000 (UTC) (envelope-from dumbbell@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 5729624A5; Sun, 25 Aug 2013 09:58:32 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r7P9wWAg087373; Sun, 25 Aug 2013 09:58:32 GMT (envelope-from dumbbell@svn.freebsd.org) Received: (from dumbbell@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r7P9wVcr087371; Sun, 25 Aug 2013 09:58:31 GMT (envelope-from dumbbell@svn.freebsd.org) Message-Id: <201308250958.r7P9wVcr087371@svn.freebsd.org> From: Jean-Sebastien Pedron Date: Sun, 25 Aug 2013 09:58:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r254836 - head/sys/dev/drm2 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Aug 2013 09:58:32 -0000 Author: dumbbell Date: Sun Aug 25 09:58:31 2013 New Revision: 254836 URL: http://svnweb.freebsd.org/changeset/base/254836 Log: drm: Support gem_open_object() and gem_close_object() callbacks ... in struct drm_driver_info. Modified: head/sys/dev/drm2/drmP.h head/sys/dev/drm2/drm_gem.c Modified: head/sys/dev/drm2/drmP.h ============================================================================== --- head/sys/dev/drm2/drmP.h Sun Aug 25 09:53:00 2013 (r254835) +++ head/sys/dev/drm2/drmP.h Sun Aug 25 09:58:31 2013 (r254836) @@ -737,6 +737,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: head/sys/dev/drm2/drm_gem.c ============================================================================== --- head/sys/dev/drm2/drm_gem.c Sun Aug 25 09:53:00 2013 (r254835) +++ head/sys/dev/drm2/drm_gem.c Sun Aug 25 09:58:31 2013 (r254836) @@ -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); }