summaryrefslogtreecommitdiff
path: root/linux-core
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2008-05-01 11:39:06 -0700
committerEric Anholt <eric@anholt.net>2008-05-01 11:39:20 -0700
commit2140e102f942edf7982cee2a3f00caf234551687 (patch)
tree8e100f76d07666d0d957859779a3c54308fd0895 /linux-core
parent1a8406795052e3ec49e400465f3211d04fd9dd86 (diff)
checkpoint: rename to GEM and a few more i915 bits.
Diffstat (limited to 'linux-core')
-rw-r--r--linux-core/Makefile.kernel4
-rw-r--r--linux-core/drmP.h45
-rw-r--r--linux-core/drm_drv.c10
-rw-r--r--linux-core/drm_fops.c8
-rw-r--r--linux-core/drm_gem.c (renamed from linux-core/drm_mm.c)110
-rw-r--r--linux-core/i915_drv.c2
-rw-r--r--linux-core/i915_gem.c140
7 files changed, 244 insertions, 75 deletions
diff --git a/linux-core/Makefile.kernel b/linux-core/Makefile.kernel
index 97d53622..82132ff4 100644
--- a/linux-core/Makefile.kernel
+++ b/linux-core/Makefile.kernel
@@ -14,13 +14,13 @@ drm-objs := drm_auth.o drm_bufs.o drm_context.o drm_dma.o drm_drawable.o \
drm_memory_debug.o ati_pcigart.o drm_sman.o \
drm_hashtab.o drm_memrange.o drm_object.o drm_compat.o \
drm_fence.o drm_ttm.o drm_bo.o drm_bo_move.o drm_bo_lock.o \
- drm_regman.o drm_mm.o
+ drm_regman.o drm_gem.o
tdfx-objs := tdfx_drv.o
r128-objs := r128_drv.o r128_cce.o r128_state.o r128_irq.o
mga-objs := mga_drv.o mga_dma.o mga_state.o mga_warp.o mga_irq.o
i810-objs := i810_drv.o i810_dma.o
i915-objs := i915_drv.o i915_dma.o i915_irq.o i915_mem.o i915_fence.o \
- i915_buffer.o i915_compat.o i915_execbuf.o i915_mm.o
+ i915_buffer.o i915_compat.o i915_execbuf.o i915_gem.o
nouveau-objs := nouveau_drv.o nouveau_state.o nouveau_fifo.o nouveau_mem.o \
nouveau_object.o nouveau_irq.o nouveau_notifier.o nouveau_swmthd.o \
nouveau_sgdma.o nouveau_dma.o nouveau_bo.o nouveau_fence.o \
diff --git a/linux-core/drmP.h b/linux-core/drmP.h
index 113cbecb..c582b80b 100644
--- a/linux-core/drmP.h
+++ b/linux-core/drmP.h
@@ -107,7 +107,7 @@ struct drm_file;
#define DRIVER_IRQ_SHARED 0x80
#define DRIVER_DMA_QUEUE 0x100
#define DRIVER_FB_DMA 0x200
-#define DRIVER_MM 0x400
+#define DRIVER_GEM 0x400
/*@}*/
@@ -613,7 +613,7 @@ struct drm_ati_pcigart_info {
* This structure defines the drm_mm memory object, which will be used by the
* DRM for its buffer objects.
*/
-struct drm_mm_object {
+struct drm_gem_object {
/** File representing the shmem storage */
struct file *filp;
@@ -627,6 +627,8 @@ struct drm_mm_object {
/** Reference count of this object, protected by object_lock */
int refcount;
+
+ void *driver_private;
};
#include "drm_objects.h"
@@ -730,6 +732,17 @@ struct drm_driver {
void (*set_version) (struct drm_device *dev,
struct drm_set_version *sv);
+ /**
+ * Driver-specific constructor for drm_gem_objects, to set up
+ * obj->driver_private.
+ *
+ * Returns 0 on success.
+ */
+ int (*gem_init_object) (struct drm_device *dev,
+ struct drm_gem_object *obj);
+ void (*gem_free_object) (struct drm_device *dev,
+ struct drm_gem_object *obj);
+
struct drm_fence_driver *fence_driver;
struct drm_bo_driver *bo_driver;
@@ -1289,20 +1302,22 @@ static inline struct drm_memrange *drm_get_mm(struct drm_memrange_node *block)
}
/* Memory manager (drm_mm.c) */
-void drm_mm_object_reference(struct drm_mm_object *obj);
-void drm_mm_object_unreference(struct drm_mm_object *obj);
-int drm_mm_alloc_ioctl(struct drm_device *dev, void *data,
- struct drm_file *file_priv);
-int drm_mm_unreference_ioctl(struct drm_device *dev, void *data,
- struct drm_file *file_priv);
-int drm_mm_pread_ioctl(struct drm_device *dev, void *data,
- struct drm_file *file_priv);
-int drm_mm_pwrite_ioctl(struct drm_device *dev, void *data,
+void drm_gem_object_reference(struct drm_device *dev,
+ struct drm_gem_object *obj);
+void drm_gem_object_unreference(struct drm_device *dev,
+ struct drm_gem_object *obj);
+int drm_gem_alloc_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
-int drm_mm_mmap_ioctl(struct drm_device *dev, void *data,
- struct drm_file *file_priv);
-void drm_mm_open(struct drm_file *file_private);
-void drm_mm_release(struct drm_file *file_private);
+int drm_gem_unreference_ioctl(struct drm_device *dev, void *data,
+ struct drm_file *file_priv);
+int drm_gem_pread_ioctl(struct drm_device *dev, void *data,
+ struct drm_file *file_priv);
+int drm_gem_pwrite_ioctl(struct drm_device *dev, void *data,
+ struct drm_file *file_priv);
+int drm_gem_mmap_ioctl(struct drm_device *dev, void *data,
+ struct drm_file *file_priv);
+void drm_gem_open(struct drm_device *dev, struct drm_file *file_private);
+void drm_gem_release(struct drm_device *dev, struct drm_file *file_private);
extern void drm_core_ioremap(struct drm_map *map, struct drm_device *dev);
extern void drm_core_ioremapfree(struct drm_map *map, struct drm_device *dev);
diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c
index 2847f51b..11fedad6 100644
--- a/linux-core/drm_drv.c
+++ b/linux-core/drm_drv.c
@@ -151,11 +151,11 @@ static struct drm_ioctl_desc drm_ioctls[] = {
DRM_IOCTL_DEF(DRM_IOCTL_MM_INFO, drm_mm_info_ioctl, 0),
- DRM_IOCTL_DEF(DRM_IOCTL_MM_ALLOC, drm_mm_alloc_ioctl, 0),
- DRM_IOCTL_DEF(DRM_IOCTL_MM_UNREFERENCE, drm_mm_unreference_ioctl, 0),
- DRM_IOCTL_DEF(DRM_IOCTL_MM_PREAD, drm_mm_pread_ioctl, 0),
- DRM_IOCTL_DEF(DRM_IOCTL_MM_PWRITE, drm_mm_pwrite_ioctl, 0),
- DRM_IOCTL_DEF(DRM_IOCTL_MM_MMAP, drm_mm_mmap_ioctl, 0),
+ DRM_IOCTL_DEF(DRM_IOCTL_GEM_ALLOC, drm_gem_alloc_ioctl, 0),
+ DRM_IOCTL_DEF(DRM_IOCTL_GEM_UNREFERENCE, drm_gem_unreference_ioctl, 0),
+ DRM_IOCTL_DEF(DRM_IOCTL_GEM_PREAD, drm_gem_pread_ioctl, 0),
+ DRM_IOCTL_DEF(DRM_IOCTL_GEM_PWRITE, drm_gem_pwrite_ioctl, 0),
+ DRM_IOCTL_DEF(DRM_IOCTL_GEM_MMAP, drm_gem_mmap_ioctl, 0),
};
#define DRM_CORE_IOCTL_COUNT ARRAY_SIZE( drm_ioctls )
diff --git a/linux-core/drm_fops.c b/linux-core/drm_fops.c
index 2213230c..c42bfaab 100644
--- a/linux-core/drm_fops.c
+++ b/linux-core/drm_fops.c
@@ -274,8 +274,8 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
goto out_free;
}
- if (dev->driver->driver_features & DRIVER_MM)
- drm_mm_open(priv);
+ if (dev->driver->driver_features & DRIVER_GEM)
+ drm_gem_open(dev, priv);
if (dev->driver->open) {
ret = dev->driver->open(dev, priv);
@@ -450,8 +450,8 @@ int drm_release(struct inode *inode, struct file *filp)
dev->driver->reclaim_buffers(dev, file_priv);
}
- if (dev->driver->driver_features & DRIVER_MM)
- drm_mm_release(file_priv);
+ if (dev->driver->driver_features & DRIVER_GEM)
+ drm_gem_release(dev, file_priv);
drm_fasync(-1, filp, 0);
diff --git a/linux-core/drm_mm.c b/linux-core/drm_gem.c
index 7e9fe39c..bd51362e 100644
--- a/linux-core/drm_mm.c
+++ b/linux-core/drm_gem.c
@@ -36,7 +36,7 @@
#include <linux/pagemap.h>
#include "drmP.h"
-/** @file drm_mm.c
+/** @file drm_gem.c
*
* This file provides some of the base ioctls and library routines for
* the graphics memory manager implemented by each device driver.
@@ -64,10 +64,10 @@
* up at a later data, and as our interface with shmfs for memory allocation.
*/
-static struct drm_mm_object *
-drm_mm_object_alloc(size_t size)
+static struct drm_gem_object *
+drm_gem_object_alloc(struct drm_device *dev, size_t size)
{
- struct drm_mm_object *obj;
+ struct drm_gem_object *obj;
BUG_ON((size & (PAGE_SIZE - 1)) != 0);
@@ -81,6 +81,12 @@ drm_mm_object_alloc(size_t size)
obj->refcount = 1;
+ if (dev->driver->gem_init_object != NULL &&
+ dev->driver->gem_init_object(dev, obj) != 0) {
+ fput(obj->filp);
+ kfree(obj);
+ return NULL;
+ }
return obj;
}
@@ -88,9 +94,10 @@ drm_mm_object_alloc(size_t size)
* Removes the mapping from handle to filp for this object.
*/
static int
-drm_mm_handle_delete(struct drm_file *filp, int handle)
+drm_gem_handle_delete(struct drm_device *dev, struct drm_file *filp,
+ int handle)
{
- struct drm_mm_object *obj;
+ struct drm_gem_object *obj;
/* This is gross. The idr system doesn't let us try a delete and
* return an error code. It just spews if you fail at deleting.
@@ -112,7 +119,7 @@ drm_mm_handle_delete(struct drm_file *filp, int handle)
/* Release reference and decrement refcount. */
idr_remove(&filp->object_idr, handle);
- drm_mm_object_unreference(obj);
+ drm_gem_object_unreference(dev, obj);
spin_unlock(&filp->table_lock);
@@ -120,10 +127,11 @@ drm_mm_handle_delete(struct drm_file *filp, int handle)
}
/** Returns a reference to the object named by the handle. */
-static struct drm_mm_object *
-drm_mm_object_lookup(struct drm_file *filp, int handle)
+static struct drm_gem_object *
+drm_gem_object_lookup(struct drm_device *dev, struct drm_file *filp,
+ int handle)
{
- struct drm_mm_object *obj;
+ struct drm_gem_object *obj;
spin_lock(&filp->table_lock);
@@ -134,7 +142,7 @@ drm_mm_object_lookup(struct drm_file *filp, int handle)
return NULL;
}
- drm_mm_object_reference(obj);
+ drm_gem_object_reference(dev, obj);
spin_unlock(&filp->table_lock);
@@ -146,18 +154,18 @@ drm_mm_object_lookup(struct drm_file *filp, int handle)
* Allocates a new mm object and returns a handle to it.
*/
int
-drm_mm_alloc_ioctl(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
+drm_gem_alloc_ioctl(struct drm_device *dev, void *data,
+ struct drm_file *file_priv)
{
- struct drm_mm_alloc_args *args = data;
- struct drm_mm_object *obj;
+ struct drm_gem_alloc_args *args = data;
+ struct drm_gem_object *obj;
int handle, ret;
/* Round requested size up to page size */
args->size = (args->size + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);
/* Allocate the new object */
- obj = drm_mm_object_alloc(args->size);
+ obj = drm_gem_object_alloc(dev, args->size);
if (obj == NULL)
return -ENOMEM;
@@ -178,7 +186,7 @@ drm_mm_alloc_ioctl(struct drm_device *dev, void *data,
} while (ret == -EAGAIN);
if (ret != 0) {
- drm_mm_object_unreference(obj);
+ drm_gem_object_unreference(dev, obj);
return -EFAULT;
}
@@ -191,13 +199,13 @@ drm_mm_alloc_ioctl(struct drm_device *dev, void *data,
* Releases the handle to an mm object.
*/
int
-drm_mm_unreference_ioctl(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
+drm_gem_unreference_ioctl(struct drm_device *dev, void *data,
+ struct drm_file *file_priv)
{
- struct drm_mm_unreference_args *args = data;
+ struct drm_gem_unreference_args *args = data;
int ret;
- ret = drm_mm_handle_delete(file_priv, args->handle);
+ ret = drm_gem_handle_delete(dev, file_priv, args->handle);
return ret;
}
@@ -208,15 +216,15 @@ drm_mm_unreference_ioctl(struct drm_device *dev, void *data,
* On error, the contents of *data are undefined.
*/
int
-drm_mm_pread_ioctl(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
+drm_gem_pread_ioctl(struct drm_device *dev, void *data,
+ struct drm_file *file_priv)
{
- struct drm_mm_pread_args *args = data;
- struct drm_mm_object *obj;
+ struct drm_gem_pread_args *args = data;
+ struct drm_gem_object *obj;
ssize_t read;
loff_t offset;
- obj = drm_mm_object_lookup(file_priv, args->handle);
+ obj = drm_gem_object_lookup(dev, file_priv, args->handle);
if (obj == NULL)
return -EINVAL;
@@ -225,14 +233,14 @@ drm_mm_pread_ioctl(struct drm_device *dev, void *data,
read = obj->filp->f_op->read(obj->filp, (char __user *)args->data,
args->size, &offset);
if (read != args->size) {
- drm_mm_object_unreference(obj);
+ drm_gem_object_unreference(dev, obj);
if (read < 0)
return read;
else
return -EINVAL;
}
- drm_mm_object_unreference(obj);
+ drm_gem_object_unreference(dev, obj);
return 0;
}
@@ -245,14 +253,14 @@ drm_mm_pread_ioctl(struct drm_device *dev, void *data,
* imply a ref on the object itself.
*/
int
-drm_mm_mmap_ioctl(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
+drm_gem_mmap_ioctl(struct drm_device *dev, void *data,
+ struct drm_file *file_priv)
{
- struct drm_mm_mmap_args *args = data;
- struct drm_mm_object *obj;
+ struct drm_gem_mmap_args *args = data;
+ struct drm_gem_object *obj;
loff_t offset;
- obj = drm_mm_object_lookup(file_priv, args->handle);
+ obj = drm_gem_object_lookup(dev, file_priv, args->handle);
if (obj == NULL)
return -EINVAL;
@@ -264,7 +272,7 @@ drm_mm_mmap_ioctl(struct drm_device *dev, void *data,
args->offset);
up_write(&current->mm->mmap_sem);
- drm_mm_object_unreference(obj);
+ drm_gem_object_unreference(dev, obj);
return 0;
}
@@ -275,15 +283,15 @@ drm_mm_mmap_ioctl(struct drm_device *dev, void *data,
* On error, the contents of the buffer that were to be modified are undefined.
*/
int
-drm_mm_pwrite_ioctl(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
+drm_gem_pwrite_ioctl(struct drm_device *dev, void *data,
+ struct drm_file *file_priv)
{
- struct drm_mm_pwrite_args *args = data;
- struct drm_mm_object *obj;
+ struct drm_gem_pwrite_args *args = data;
+ struct drm_gem_object *obj;
ssize_t written;
loff_t offset;
- obj = drm_mm_object_lookup(file_priv, args->handle);
+ obj = drm_gem_object_lookup(dev, file_priv, args->handle);
if (obj == NULL)
return -EINVAL;
@@ -292,14 +300,14 @@ drm_mm_pwrite_ioctl(struct drm_device *dev, void *data,
written = obj->filp->f_op->write(obj->filp, (char __user *)args->data,
args->size, &offset);
if (written != args->size) {
- drm_mm_object_unreference(obj);
+ drm_gem_object_unreference(dev, obj);
if (written < 0)
return written;
else
return -EINVAL;
}
- drm_mm_object_unreference(obj);
+ drm_gem_object_unreference(dev, obj);
return 0;
}
@@ -309,18 +317,19 @@ drm_mm_pwrite_ioctl(struct drm_device *dev, void *data,
* of mm objects.
*/
void
-drm_mm_open(struct drm_file *file_private)
+drm_gem_open(struct drm_device *dev, struct drm_file *file_private)
{
idr_init(&file_private->object_idr);
}
/** Called at device close to release the file's references on objects. */
static int
-drm_mm_object_release(int id, void *ptr, void *data)
+drm_gem_object_release(int id, void *ptr, void *data)
{
- struct drm_mm_object *obj = ptr;
+ struct drm_device *dev = data;
+ struct drm_gem_object *obj = ptr;
- drm_mm_object_unreference(obj);
+ drm_gem_object_unreference(dev, obj);
return 0;
}
@@ -331,15 +340,15 @@ drm_mm_object_release(int id, void *ptr, void *data)
* Releases any remaining references on objects by this filp.
*/
void
-drm_mm_release(struct drm_file *file_private)
+drm_gem_release(struct drm_device *dev, struct drm_file *file_private)
{
- idr_for_each(&file_private->object_idr, &drm_mm_object_release, NULL);
+ idr_for_each(&file_private->object_idr, &drm_gem_object_release, dev);
idr_destroy(&file_private->object_idr);
}
void
-drm_mm_object_reference(struct drm_mm_object *obj)
+drm_gem_object_reference(struct drm_device *dev, struct drm_gem_object *obj)
{
spin_lock(&obj->lock);
obj->refcount++;
@@ -347,12 +356,15 @@ drm_mm_object_reference(struct drm_mm_object *obj)
}
void
-drm_mm_object_unreference(struct drm_mm_object *obj)
+drm_gem_object_unreference(struct drm_device *dev, struct drm_gem_object *obj)
{
spin_lock(&obj->lock);
obj->refcount--;
spin_unlock(&obj->lock);
if (obj->refcount == 0) {
+ if (dev->driver->gem_free_object != NULL)
+ dev->driver->gem_free_object(dev, obj);
+
fput(obj->filp);
kfree(obj);
}
diff --git a/linux-core/i915_drv.c b/linux-core/i915_drv.c
index 5a6f0adc..c77c329f 100644
--- a/linux-core/i915_drv.c
+++ b/linux-core/i915_drv.c
@@ -586,6 +586,8 @@ static struct drm_driver driver = {
.get_map_ofs = drm_core_get_map_ofs,
.get_reg_ofs = drm_core_get_reg_ofs,
.ioctls = i915_ioctls,
+ .gem_init_object = i915_gem_init_object,
+ .gem_free_object = i915_gem_free_object,
.fops = {
.owner = THIS_MODULE,
.open = drm_open,
diff --git a/linux-core/i915_gem.c b/linux-core/i915_gem.c
new file mode 100644
index 00000000..0685a1b9
--- /dev/null
+++ b/linux-core/i915_gem.c
@@ -0,0 +1,140 @@
+/*
+ * Copyright © 2008 Intel Corporation
+ *
+ * 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, sublicense,
+ * 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 NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS 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:
+ * Eric Anholt <eric@anholt.net>
+ *
+ */
+
+#include "drmP.h"
+#include "drm.h"
+#include "i915_drm.h"
+#include "i915_drv.h"
+
+int
+i915_gem_init_ioctl(struct drm_device *dev, void *data,
+ struct drm_file *file_priv)
+{
+ drm_i915_private_t *dev_priv = dev->dev_private;
+ struct drm_i915_gem_init *args = data;
+
+ if (args->gtt_start >= args->gtt_end ||
+ (args->gtt_start & (PAGE_SIZE - 1)) != 0 ||
+ (args->gtt_end & (PAGE_SIZE - 1)) != 0)
+ return -EINVAL;
+
+ drm_memrange_init(&dev_priv->mm.gtt_space, args->gtt_start,
+ args->gtt_end);
+
+ return 0;
+}
+
+static void
+i915_gem_evict_object(struct drm_device *dev, struct drm_gem_object *obj)
+{
+
+}
+
+static int
+evict_callback(struct drm_memrange_node *node, void *data)
+{
+ struct drm_device *dev = data;
+ struct drm_gem_object *obj = node->private;
+ struct drm_i915_gem_object *obj_priv = obj->driver_private;
+
+ if (obj_priv->pin_count == 0)
+ i915_gem_evict_object(dev, obj);
+
+ return 0;
+}
+
+int
+i915_gem_execbuffer(struct drm_device *dev, void *data,
+ struct drm_file *file_priv)
+{
+ drm_i915_private_t *dev_priv = dev->dev_private;
+ struct drm_i915_gem_execbuffer *args = data;
+ struct drm_i915_gem_validate_entry *validate_list;
+ int ret, i;
+ RING_LOCALS;
+
+ LOCK_TEST_WITH_RETURN(dev, file_priv);
+
+ /* Big hammer: flush and idle the hardware so we can map things in/out.
+ */
+ BEGIN_LP_RING(2);
+ OUT_RING(CMD_MI_FLUSH | MI_READ_FLUSH | MI_EXE_FLUSH);
+ OUT_RING(0); /* noop */
+ ADVANCE_LP_RING();
+ ret = i915_quiescent(dev);
+ if (ret != 0)
+ return ret;
+
+ /* Evict everything so we have space for sure. */
+ drm_memrange_for_each(&dev_priv->mm.gtt_space, evict_callback);
+
+ /* Copy in the validate list from userland */
+ validate_list = drm_calloc(sizeof(*validate_list), args->buffer_count,
+ DRM_MEM_DRIVER);
+ ret = copy_from_user(validate_list,
+ (struct drm_i915_relocation_entry __user*)
+ args->buffers,
+ sizeof(*validate_list) * args->buffer_count);
+ if (ret != 0) {
+ drm_free(validate_list,
+ sizeof(*validate_list) * args->buffer_count,
+ DRM_MEM_DRIVER);
+ return ret;
+ }
+
+ /* Perform the relocations */
+ for (i = 0; i < args->buffer_count; i++) {
+ intel_gem_reloc_and_validate_buffer(dev, &validate_list[i]);
+ }
+
+ /* Exec the batchbuffer */
+
+
+ drm_free(validate_list, sizeof(*validate_list) * args->buffer_count,
+ DRM_MEM_DRIVER);
+
+ return 0;
+}
+
+int i915_gem_init_object(struct drm_device *dev, struct drm_gem_object *obj)
+{
+ struct drm_i915_gem_object *obj_priv;
+
+ obj_priv = drm_calloc(1, sizeof(*obj_priv), DRM_MEM_DRIVER);
+ if (obj_priv == NULL)
+ return -ENOMEM;
+
+ obj->driver_private = obj_priv;
+
+ return 0;
+}
+
+void i915_gem_free_object(struct drm_device *dev, struct drm_gem_object *obj)
+{
+ drm_free(obj->driver_private, 1, DRM_MEM_DRIVER);
+}
+