drm: move ttm global code to core drm
authorDave Airlie <airlied@redhat.com>
Tue, 9 Mar 2010 00:56:52 +0000 (10:56 +1000)
committerDave Airlie <airlied@redhat.com>
Tue, 3 Aug 2010 23:46:06 +0000 (09:46 +1000)
I wrote this for the prime sharing work, but I also noticed other external
non-upstream drivers from a large company carrying a similiar patch, so I
may as well ship it in master.

Signed-off-by: Dave Airlie <airlied@redhat.com>
18 files changed:
drivers/gpu/drm/Makefile
drivers/gpu/drm/drm_drv.c
drivers/gpu/drm/drm_global.c [new file with mode: 0644]
drivers/gpu/drm/nouveau/nouveau_drv.h
drivers/gpu/drm/nouveau/nouveau_ttm.c
drivers/gpu/drm/radeon/radeon.h
drivers/gpu/drm/radeon/radeon_ttm.c
drivers/gpu/drm/ttm/Makefile
drivers/gpu/drm/ttm/ttm_bo.c
drivers/gpu/drm/ttm/ttm_global.c [deleted file]
drivers/gpu/drm/ttm/ttm_module.c
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c
include/drm/drm.h
include/drm/drmP.h
include/drm/drm_global.h [new file with mode: 0644]
include/drm/ttm/ttm_bo_driver.h
include/drm/ttm/ttm_module.h

index df8f923228656c095f7c57d770aa8b0e7af2abc0..f3a23a329f4e29e7817755bf7f9f367cbdd74d0a 100644 (file)
@@ -12,7 +12,7 @@ drm-y       :=        drm_auth.o drm_buffer.o drm_bufs.o drm_cache.o \
                drm_platform.o drm_sysfs.o drm_hashtab.o drm_sman.o drm_mm.o \
                drm_crtc.o drm_modes.o drm_edid.o \
                drm_info.o drm_debugfs.o drm_encoder_slave.o \
-               drm_trace_points.o
+               drm_trace_points.o drm_global.o
 
 drm-$(CONFIG_COMPAT) += drm_ioc32.o
 
index b5a51686f492edce08e59bc0bb9fb391a5faae34..d5b349d279f5ce04a2adaaeafe71e8b4ceb7468b 100644 (file)
@@ -288,6 +288,7 @@ static int __init drm_core_init(void)
 {
        int ret = -ENOMEM;
 
+       drm_global_init();
        idr_init(&drm_minors_idr);
 
        if (register_chrdev(DRM_MAJOR, "drm", &drm_stub_fops))
diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
new file mode 100644 (file)
index 0000000..c87dc96
--- /dev/null
@@ -0,0 +1,112 @@
+/**************************************************************************
+ *
+ * Copyright 2008-2009 VMware, Inc., Palo Alto, CA., USA
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+/*
+ * Authors: Thomas Hellstrom <thellstrom-at-vmware-dot-com>
+ */
+
+#include <linux/mutex.h>
+#include <linux/slab.h>
+#include <linux/module.h>
+#include "drm_global.h"
+
+struct drm_global_item {
+       struct mutex mutex;
+       void *object;
+       int refcount;
+};
+
+static struct drm_global_item glob[DRM_GLOBAL_NUM];
+
+void drm_global_init(void)
+{
+       int i;
+
+       for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
+               struct drm_global_item *item = &glob[i];
+               mutex_init(&item->mutex);
+               item->object = NULL;
+               item->refcount = 0;
+       }
+}
+
+void drm_global_release(void)
+{
+       int i;
+       for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
+               struct drm_global_item *item = &glob[i];
+               BUG_ON(item->object != NULL);
+               BUG_ON(item->refcount != 0);
+       }
+}
+
+int drm_global_item_ref(struct drm_global_reference *ref)
+{
+       int ret;
+       struct drm_global_item *item = &glob[ref->global_type];
+       void *object;
+
+       mutex_lock(&item->mutex);
+       if (item->refcount == 0) {
+               item->object = kzalloc(ref->size, GFP_KERNEL);
+               if (unlikely(item->object == NULL)) {
+                       ret = -ENOMEM;
+                       goto out_err;
+               }
+
+               ref->object = item->object;
+               ret = ref->init(ref);
+               if (unlikely(ret != 0))
+                       goto out_err;
+
+       }
+       ++item->refcount;
+       ref->object = item->object;
+       object = item->object;
+       mutex_unlock(&item->mutex);
+       return 0;
+out_err:
+       mutex_unlock(&item->mutex);
+       item->object = NULL;
+       return ret;
+}
+EXPORT_SYMBOL(drm_global_item_ref);
+
+void drm_global_item_unref(struct drm_global_reference *ref)
+{
+       struct drm_global_item *item = &glob[ref->global_type];
+
+       mutex_lock(&item->mutex);
+       BUG_ON(item->refcount == 0);
+       BUG_ON(ref->object != item->object);
+       if (--item->refcount == 0) {
+               ref->release(ref);
+               item->object = NULL;
+       }
+       mutex_unlock(&item->mutex);
+}
+EXPORT_SYMBOL(drm_global_item_unref);
+
index d0a35d9ba522004d419dba43858593e3ff4e3f0e..e15db15dca77507ec13614ecc2cac5d2ec147bd4 100644 (file)
@@ -533,7 +533,7 @@ struct drm_nouveau_private {
        struct list_head vbl_waiting;
 
        struct {
-               struct ttm_global_reference mem_global_ref;
+               struct drm_global_reference mem_global_ref;
                struct ttm_bo_global_ref bo_global_ref;
                struct ttm_bo_device bdev;
                spinlock_t bo_list_lock;
index c385d50f041b0f6ecf6e08cb6c58effba677c942..bd35f930568c922b9b275aa3de418c502e543e7f 100644 (file)
@@ -42,13 +42,13 @@ nouveau_ttm_mmap(struct file *filp, struct vm_area_struct *vma)
 }
 
 static int
-nouveau_ttm_mem_global_init(struct ttm_global_reference *ref)
+nouveau_ttm_mem_global_init(struct drm_global_reference *ref)
 {
        return ttm_mem_global_init(ref->object);
 }
 
 static void
-nouveau_ttm_mem_global_release(struct ttm_global_reference *ref)
+nouveau_ttm_mem_global_release(struct drm_global_reference *ref)
 {
        ttm_mem_global_release(ref->object);
 }
@@ -56,16 +56,16 @@ nouveau_ttm_mem_global_release(struct ttm_global_reference *ref)
 int
 nouveau_ttm_global_init(struct drm_nouveau_private *dev_priv)
 {
-       struct ttm_global_reference *global_ref;
+       struct drm_global_reference *global_ref;
        int ret;
 
        global_ref = &dev_priv->ttm.mem_global_ref;
-       global_ref->global_type = TTM_GLOBAL_TTM_MEM;
+       global_ref->global_type = DRM_GLOBAL_TTM_MEM;
        global_ref->size = sizeof(struct ttm_mem_global);
        global_ref->init = &nouveau_ttm_mem_global_init;
        global_ref->release = &nouveau_ttm_mem_global_release;
 
-       ret = ttm_global_item_ref(global_ref);
+       ret = drm_global_item_ref(global_ref);
        if (unlikely(ret != 0)) {
                DRM_ERROR("Failed setting up TTM memory accounting\n");
                dev_priv->ttm.mem_global_ref.release = NULL;
@@ -74,15 +74,15 @@ nouveau_ttm_global_init(struct drm_nouveau_private *dev_priv)
 
        dev_priv->ttm.bo_global_ref.mem_glob = global_ref->object;
        global_ref = &dev_priv->ttm.bo_global_ref.ref;
-       global_ref->global_type = TTM_GLOBAL_TTM_BO;
+       global_ref->global_type = DRM_GLOBAL_TTM_BO;
        global_ref->size = sizeof(struct ttm_bo_global);
        global_ref->init = &ttm_bo_global_init;
        global_ref->release = &ttm_bo_global_release;
 
-       ret = ttm_global_item_ref(global_ref);
+       ret = drm_global_item_ref(global_ref);
        if (unlikely(ret != 0)) {
                DRM_ERROR("Failed setting up TTM BO subsystem\n");
-               ttm_global_item_unref(&dev_priv->ttm.mem_global_ref);
+               drm_global_item_unref(&dev_priv->ttm.mem_global_ref);
                dev_priv->ttm.mem_global_ref.release = NULL;
                return ret;
        }
@@ -96,8 +96,8 @@ nouveau_ttm_global_release(struct drm_nouveau_private *dev_priv)
        if (dev_priv->ttm.mem_global_ref.release == NULL)
                return;
 
-       ttm_global_item_unref(&dev_priv->ttm.bo_global_ref.ref);
-       ttm_global_item_unref(&dev_priv->ttm.mem_global_ref);
+       drm_global_item_unref(&dev_priv->ttm.bo_global_ref.ref);
+       drm_global_item_unref(&dev_priv->ttm.mem_global_ref);
        dev_priv->ttm.mem_global_ref.release = NULL;
 }
 
index 368fecf0c2b7a7d1f824a42e50f5188d34917294..3cd1c470b7770639c44151d6c9d627da435db07e 100644 (file)
@@ -235,7 +235,7 @@ struct radeon_surface_reg {
  */
 struct radeon_mman {
        struct ttm_bo_global_ref        bo_global_ref;
-       struct ttm_global_reference     mem_global_ref;
+       struct drm_global_reference     mem_global_ref;
        struct ttm_bo_device            bdev;
        bool                            mem_global_referenced;
        bool                            initialized;
index e9918d88f5b049675cfebe754d15ef83338bb91d..84c53e41a88fd783d6f7ba32c9155109eb3c95be 100644 (file)
@@ -59,28 +59,28 @@ static struct radeon_device *radeon_get_rdev(struct ttm_bo_device *bdev)
 /*
  * Global memory.
  */
-static int radeon_ttm_mem_global_init(struct ttm_global_reference *ref)
+static int radeon_ttm_mem_global_init(struct drm_global_reference *ref)
 {
        return ttm_mem_global_init(ref->object);
 }
 
-static void radeon_ttm_mem_global_release(struct ttm_global_reference *ref)
+static void radeon_ttm_mem_global_release(struct drm_global_reference *ref)
 {
        ttm_mem_global_release(ref->object);
 }
 
 static int radeon_ttm_global_init(struct radeon_device *rdev)
 {
-       struct ttm_global_reference *global_ref;
+       struct drm_global_reference *global_ref;
        int r;
 
        rdev->mman.mem_global_referenced = false;
        global_ref = &rdev->mman.mem_global_ref;
-       global_ref->global_type = TTM_GLOBAL_TTM_MEM;
+       global_ref->global_type = DRM_GLOBAL_TTM_MEM;
        global_ref->size = sizeof(struct ttm_mem_global);
        global_ref->init = &radeon_ttm_mem_global_init;
        global_ref->release = &radeon_ttm_mem_global_release;
-       r = ttm_global_item_ref(global_ref);
+       r = drm_global_item_ref(global_ref);
        if (r != 0) {
                DRM_ERROR("Failed setting up TTM memory accounting "
                          "subsystem.\n");
@@ -90,14 +90,14 @@ static int radeon_ttm_global_init(struct radeon_device *rdev)
        rdev->mman.bo_global_ref.mem_glob =
                rdev->mman.mem_global_ref.object;
        global_ref = &rdev->mman.bo_global_ref.ref;
-       global_ref->global_type = TTM_GLOBAL_TTM_BO;
+       global_ref->global_type = DRM_GLOBAL_TTM_BO;
        global_ref->size = sizeof(struct ttm_bo_global);
        global_ref->init = &ttm_bo_global_init;
        global_ref->release = &ttm_bo_global_release;
-       r = ttm_global_item_ref(global_ref);
+       r = drm_global_item_ref(global_ref);
        if (r != 0) {
                DRM_ERROR("Failed setting up TTM BO subsystem.\n");
-               ttm_global_item_unref(&rdev->mman.mem_global_ref);
+               drm_global_item_unref(&rdev->mman.mem_global_ref);
                return r;
        }
 
@@ -108,8 +108,8 @@ static int radeon_ttm_global_init(struct radeon_device *rdev)
 static void radeon_ttm_global_fini(struct radeon_device *rdev)
 {
        if (rdev->mman.mem_global_referenced) {
-               ttm_global_item_unref(&rdev->mman.bo_global_ref.ref);
-               ttm_global_item_unref(&rdev->mman.mem_global_ref);
+               drm_global_item_unref(&rdev->mman.bo_global_ref.ref);
+               drm_global_item_unref(&rdev->mman.mem_global_ref);
                rdev->mman.mem_global_referenced = false;
        }
 }
index 4256e200647614b339f5d3110ff54732b29fa809..b256d4adfafe76710cf1dd6e3b03371e03f7fd46 100644 (file)
@@ -3,7 +3,7 @@
 
 ccflags-y := -Iinclude/drm
 ttm-y := ttm_agp_backend.o ttm_memory.o ttm_tt.o ttm_bo.o \
-       ttm_bo_util.o ttm_bo_vm.o ttm_module.o ttm_global.o \
+       ttm_bo_util.o ttm_bo_vm.o ttm_module.o \
        ttm_object.o ttm_lock.o ttm_execbuf_util.o ttm_page_alloc.o
 
 obj-$(CONFIG_DRM_TTM) += ttm.o
index 9763288c6b2d300f355f2bba367a405a7bd859f1..cb4cf7ef4d1eee9bc726c4d4ee34f8962526b316 100644 (file)
@@ -1395,7 +1395,7 @@ static void ttm_bo_global_kobj_release(struct kobject *kobj)
        kfree(glob);
 }
 
-void ttm_bo_global_release(struct ttm_global_reference *ref)
+void ttm_bo_global_release(struct drm_global_reference *ref)
 {
        struct ttm_bo_global *glob = ref->object;
 
@@ -1404,7 +1404,7 @@ void ttm_bo_global_release(struct ttm_global_reference *ref)
 }
 EXPORT_SYMBOL(ttm_bo_global_release);
 
-int ttm_bo_global_init(struct ttm_global_reference *ref)
+int ttm_bo_global_init(struct drm_global_reference *ref)
 {
        struct ttm_bo_global_ref *bo_ref =
                container_of(ref, struct ttm_bo_global_ref, ref);
diff --git a/drivers/gpu/drm/ttm/ttm_global.c b/drivers/gpu/drm/ttm/ttm_global.c
deleted file mode 100644 (file)
index b170071..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2008-2009 VMware, Inc., Palo Alto, CA., USA
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-/*
- * Authors: Thomas Hellstrom <thellstrom-at-vmware-dot-com>
- */
-
-#include "ttm/ttm_module.h"
-#include <linux/mutex.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-
-struct ttm_global_item {
-       struct mutex mutex;
-       void *object;
-       int refcount;
-};
-
-static struct ttm_global_item glob[TTM_GLOBAL_NUM];
-
-void ttm_global_init(void)
-{
-       int i;
-
-       for (i = 0; i < TTM_GLOBAL_NUM; ++i) {
-               struct ttm_global_item *item = &glob[i];
-               mutex_init(&item->mutex);
-               item->object = NULL;
-               item->refcount = 0;
-       }
-}
-
-void ttm_global_release(void)
-{
-       int i;
-       for (i = 0; i < TTM_GLOBAL_NUM; ++i) {
-               struct ttm_global_item *item = &glob[i];
-               BUG_ON(item->object != NULL);
-               BUG_ON(item->refcount != 0);
-       }
-}
-
-int ttm_global_item_ref(struct ttm_global_reference *ref)
-{
-       int ret;
-       struct ttm_global_item *item = &glob[ref->global_type];
-       void *object;
-
-       mutex_lock(&item->mutex);
-       if (item->refcount == 0) {
-               item->object = kzalloc(ref->size, GFP_KERNEL);
-               if (unlikely(item->object == NULL)) {
-                       ret = -ENOMEM;
-                       goto out_err;
-               }
-
-               ref->object = item->object;
-               ret = ref->init(ref);
-               if (unlikely(ret != 0))
-                       goto out_err;
-
-       }
-       ++item->refcount;
-       ref->object = item->object;
-       object = item->object;
-       mutex_unlock(&item->mutex);
-       return 0;
-out_err:
-       mutex_unlock(&item->mutex);
-       item->object = NULL;
-       return ret;
-}
-EXPORT_SYMBOL(ttm_global_item_ref);
-
-void ttm_global_item_unref(struct ttm_global_reference *ref)
-{
-       struct ttm_global_item *item = &glob[ref->global_type];
-
-       mutex_lock(&item->mutex);
-       BUG_ON(item->refcount == 0);
-       BUG_ON(ref->object != item->object);
-       if (--item->refcount == 0) {
-               ref->release(ref);
-               item->object = NULL;
-       }
-       mutex_unlock(&item->mutex);
-}
-EXPORT_SYMBOL(ttm_global_item_unref);
-
index 9a6edbfeaa9e49c7369623dbb542eb61204fe904..902d7cf9fb4eb5a59cc4bdb13518449344208a22 100644 (file)
@@ -70,8 +70,6 @@ static int __init ttm_init(void)
        if (unlikely(ret != 0))
                return ret;
 
-       ttm_global_init();
-
        atomic_set(&device_released, 0);
        ret = drm_class_device_register(&ttm_drm_class_device);
        if (unlikely(ret != 0))
@@ -81,7 +79,6 @@ static int __init ttm_init(void)
 out_no_dev_reg:
        atomic_set(&device_released, 1);
        wake_up_all(&exit_q);
-       ttm_global_release();
        return ret;
 }
 
@@ -95,7 +92,6 @@ static void __exit ttm_exit(void)
         */
 
        wait_event(exit_q, atomic_read(&device_released) == 1);
-       ttm_global_release();
 }
 
 module_init(ttm_init);
index eaad520953393f5f5da3601627e0ec141c4c4a1f..429f917b60bf4b30ecdfd0946f9f1f0978bd5c58 100644 (file)
@@ -164,7 +164,7 @@ struct vmw_vga_topology_state {
 struct vmw_private {
        struct ttm_bo_device bdev;
        struct ttm_bo_global_ref bo_global_ref;
-       struct ttm_global_reference mem_global_ref;
+       struct drm_global_reference mem_global_ref;
 
        struct vmw_fifo_state fifo;
 
index e3df4adfb4d8ce4b89a0902bb6c24d9db2bc45a3..83123287c60c2d3f245fa3ab0a9696db2f694ede 100644 (file)
@@ -44,29 +44,29 @@ int vmw_mmap(struct file *filp, struct vm_area_struct *vma)
        return ttm_bo_mmap(filp, vma, &dev_priv->bdev);
 }
 
-static int vmw_ttm_mem_global_init(struct ttm_global_reference *ref)
+static int vmw_ttm_mem_global_init(struct drm_global_reference *ref)
 {
        DRM_INFO("global init.\n");
        return ttm_mem_global_init(ref->object);
 }
 
-static void vmw_ttm_mem_global_release(struct ttm_global_reference *ref)
+static void vmw_ttm_mem_global_release(struct drm_global_reference *ref)
 {
        ttm_mem_global_release(ref->object);
 }
 
 int vmw_ttm_global_init(struct vmw_private *dev_priv)
 {
-       struct ttm_global_reference *global_ref;
+       struct drm_global_reference *global_ref;
        int ret;
 
        global_ref = &dev_priv->mem_global_ref;
-       global_ref->global_type = TTM_GLOBAL_TTM_MEM;
+       global_ref->global_type = DRM_GLOBAL_TTM_MEM;
        global_ref->size = sizeof(struct ttm_mem_global);
        global_ref->init = &vmw_ttm_mem_global_init;
        global_ref->release = &vmw_ttm_mem_global_release;
 
-       ret = ttm_global_item_ref(global_ref);
+       ret = drm_global_item_ref(global_ref);
        if (unlikely(ret != 0)) {
                DRM_ERROR("Failed setting up TTM memory accounting.\n");
                return ret;
@@ -75,11 +75,11 @@ int vmw_ttm_global_init(struct vmw_private *dev_priv)
        dev_priv->bo_global_ref.mem_glob =
                dev_priv->mem_global_ref.object;
        global_ref = &dev_priv->bo_global_ref.ref;
-       global_ref->global_type = TTM_GLOBAL_TTM_BO;
+       global_ref->global_type = DRM_GLOBAL_TTM_BO;
        global_ref->size = sizeof(struct ttm_bo_global);
        global_ref->init = &ttm_bo_global_init;
        global_ref->release = &ttm_bo_global_release;
-               ret = ttm_global_item_ref(global_ref);
+       ret = drm_global_item_ref(global_ref);
 
        if (unlikely(ret != 0)) {
                DRM_ERROR("Failed setting up TTM buffer objects.\n");
@@ -88,12 +88,12 @@ int vmw_ttm_global_init(struct vmw_private *dev_priv)
 
        return 0;
 out_no_bo:
-       ttm_global_item_unref(&dev_priv->mem_global_ref);
+       drm_global_item_unref(&dev_priv->mem_global_ref);
        return ret;
 }
 
 void vmw_ttm_global_release(struct vmw_private *dev_priv)
 {
-       ttm_global_item_unref(&dev_priv->bo_global_ref.ref);
-       ttm_global_item_unref(&dev_priv->mem_global_ref);
+       drm_global_item_unref(&dev_priv->bo_global_ref.ref);
+       drm_global_item_unref(&dev_priv->mem_global_ref);
 }
index e3f46e0cb7dc305f8ab0b9ea7af3f96deb3bba0d..e5f70617dec55db8b8671c5d6c4444a23a698837 100644 (file)
@@ -663,6 +663,8 @@ struct drm_gem_open {
 #define DRM_IOCTL_UNLOCK               DRM_IOW( 0x2b, struct drm_lock)
 #define DRM_IOCTL_FINISH               DRM_IOW( 0x2c, struct drm_lock)
 
+#define DRM_IOCTL_GEM_PRIME_OPEN        DRM_IOWR(0x2e, struct drm_gem_open)
+
 #define DRM_IOCTL_AGP_ACQUIRE          DRM_IO(  0x30)
 #define DRM_IOCTL_AGP_RELEASE          DRM_IO(  0x31)
 #define DRM_IOCTL_AGP_ENABLE           DRM_IOW( 0x32, struct drm_agp_mode)
index 04b564bfc4a1f0084a9c6cd60e52af03ba930764..53017ba0ab7b646e8185a83db0dc42f4d76938ec 100644 (file)
@@ -1453,6 +1453,8 @@ void drm_gem_vm_open(struct vm_area_struct *vma);
 void drm_gem_vm_close(struct vm_area_struct *vma);
 int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);
 
+#include "drm_global.h"
+
 static inline void
 drm_gem_object_reference(struct drm_gem_object *obj)
 {
diff --git a/include/drm/drm_global.h b/include/drm/drm_global.h
new file mode 100644 (file)
index 0000000..a06805e
--- /dev/null
@@ -0,0 +1,53 @@
+/**************************************************************************
+ *
+ * Copyright 2008-2009 VMware, Inc., Palo Alto, CA., USA
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+/*
+ * Authors: Thomas Hellstrom <thellstrom-at-vmware-dot-com>
+ */
+
+#ifndef _DRM_GLOBAL_H_
+#define _DRM_GLOBAL_H_
+enum drm_global_types {
+       DRM_GLOBAL_TTM_MEM = 0,
+       DRM_GLOBAL_TTM_BO,
+       DRM_GLOBAL_TTM_OBJECT,
+       DRM_GLOBAL_NUM
+};
+
+struct drm_global_reference {
+       enum drm_global_types global_type;
+       size_t size;
+       void *object;
+       int (*init) (struct drm_global_reference *);
+       void (*release) (struct drm_global_reference *);
+};
+
+extern void drm_global_init(void);
+extern void drm_global_release(void);
+extern int drm_global_item_ref(struct drm_global_reference *ref);
+extern void drm_global_item_unref(struct drm_global_reference *ref);
+
+#endif
index 0ea602da43e7787bced23b98527ba257c695c888..b87504235f183f45c01d527ae585cbbafbd197ab 100644 (file)
@@ -34,6 +34,7 @@
 #include "ttm/ttm_memory.h"
 #include "ttm/ttm_module.h"
 #include "drm_mm.h"
+#include "drm_global.h"
 #include "linux/workqueue.h"
 #include "linux/fs.h"
 #include "linux/spinlock.h"
@@ -362,7 +363,7 @@ struct ttm_bo_driver {
  */
 
 struct ttm_bo_global_ref {
-       struct ttm_global_reference ref;
+       struct drm_global_reference ref;
        struct ttm_mem_global *mem_glob;
 };
 
@@ -687,8 +688,8 @@ extern int ttm_mem_io_reserve(struct ttm_bo_device *bdev,
 extern void ttm_mem_io_free(struct ttm_bo_device *bdev,
                                struct ttm_mem_reg *mem);
 
-extern void ttm_bo_global_release(struct ttm_global_reference *ref);
-extern int ttm_bo_global_init(struct ttm_global_reference *ref);
+extern void ttm_bo_global_release(struct drm_global_reference *ref);
+extern int ttm_bo_global_init(struct drm_global_reference *ref);
 
 extern int ttm_bo_device_release(struct ttm_bo_device *bdev);
 
index cf416aee19affcfaaa519e111e9f6d3b4e1f30d6..45fa318c158525b8ea9b30809ba20e0f99b4071d 100644 (file)
 struct kobject;
 
 #define TTM_PFX "[TTM] "
-
-enum ttm_global_types {
-       TTM_GLOBAL_TTM_MEM = 0,
-       TTM_GLOBAL_TTM_BO,
-       TTM_GLOBAL_TTM_OBJECT,
-       TTM_GLOBAL_NUM
-};
-
-struct ttm_global_reference {
-       enum ttm_global_types global_type;
-       size_t size;
-       void *object;
-       int (*init) (struct ttm_global_reference *);
-       void (*release) (struct ttm_global_reference *);
-};
-
-extern void ttm_global_init(void);
-extern void ttm_global_release(void);
-extern int ttm_global_item_ref(struct ttm_global_reference *ref);
-extern void ttm_global_item_unref(struct ttm_global_reference *ref);
 extern struct kobject *ttm_get_kobj(void);
 
 #endif /* _TTM_MODULE_H_ */