*
* 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);
+ int (*gem_init_object) (struct drm_gem_object *obj);
+ void (*gem_free_object) (struct drm_gem_object *obj);
struct drm_fence_driver *fence_driver;
struct drm_bo_driver *bo_driver;
return block->mm;
}
+void
+drm_gem_object_free (struct kref *kref);
+
/* Graphics Execution Manager library functions (drm_gem.c) */
-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);
+static inline void drm_gem_object_reference(struct drm_gem_object *obj)
+{
+ kref_get(&obj->refcount);
+}
+
+static inline void drm_gem_object_unreference(struct drm_gem_object *obj)
+{
+ if (obj == NULL)
+ return;
+
+ kref_put (&obj->refcount, drm_gem_object_free);
+}
+
struct drm_gem_object *
drm_gem_object_lookup(struct drm_device *dev, struct drm_file *filp,
int handle);
obj->size = size;
if (dev->driver->gem_init_object != NULL &&
- dev->driver->gem_init_object(dev, obj) != 0) {
+ dev->driver->gem_init_object(obj) != 0) {
fput(obj->filp);
kfree(obj);
return NULL;
/* Release reference and decrement refcount. */
idr_remove(&filp->object_idr, handle);
- drm_gem_object_unreference(dev, obj);
+ drm_gem_object_unreference(obj);
spin_unlock(&filp->table_lock);
return NULL;
}
- drm_gem_object_reference(dev, obj);
+ drm_gem_object_reference(obj);
spin_unlock(&filp->table_lock);
} while (ret == -EAGAIN);
if (ret != 0) {
- drm_gem_object_unreference(dev, obj);
+ drm_gem_object_unreference(obj);
return -EFAULT;
}
read = obj->filp->f_op->read(obj->filp, (char __user *)(uintptr_t)args->data_ptr,
args->size, &offset);
if (read != args->size) {
- drm_gem_object_unreference(dev, obj);
+ drm_gem_object_unreference(obj);
if (read < 0)
return read;
else
return -EINVAL;
}
- drm_gem_object_unreference(dev, obj);
+ drm_gem_object_unreference(obj);
return 0;
}
args->offset);
up_write(¤t->mm->mmap_sem);
- drm_gem_object_unreference(dev, obj);
+ drm_gem_object_unreference(obj);
return 0;
}
offset = args->offset;
- written = obj->filp->f_op->write(obj->filp, (char __user *)args->data_ptr,
+ written = obj->filp->f_op->write(obj->filp, (char __user *)(uintptr_t) args->data_ptr,
args->size, &offset);
if (written != args->size) {
- drm_gem_object_unreference(dev, obj);
+ drm_gem_object_unreference(obj);
if (written < 0)
return written;
else
return -EINVAL;
}
- drm_gem_object_unreference(dev, obj);
+ drm_gem_object_unreference(obj);
return 0;
}
static int
drm_gem_object_release(int id, void *ptr, void *data)
{
- struct drm_device *dev = data;
struct drm_gem_object *obj = ptr;
- drm_gem_object_unreference(dev, obj);
+ drm_gem_object_unreference(obj);
return 0;
}
void
drm_gem_release(struct drm_device *dev, struct drm_file *file_private)
{
- idr_for_each(&file_private->object_idr, &drm_gem_object_release, dev);
+ idr_for_each(&file_private->object_idr, &drm_gem_object_release, NULL);
idr_destroy(&file_private->object_idr);
}
void
-drm_gem_object_reference(struct drm_device *dev, struct drm_gem_object *obj)
-{
- kref_get(&obj->refcount);
-}
-EXPORT_SYMBOL(drm_gem_object_reference);
-
-static void
drm_gem_object_free (struct kref *kref)
{
struct drm_gem_object *obj = (struct drm_gem_object *) kref;
struct drm_device *dev = obj->dev;
if (dev->driver->gem_free_object != NULL)
- dev->driver->gem_free_object(dev, obj);
+ dev->driver->gem_free_object(obj);
fput(obj->filp);
kfree(obj);
}
-
-void
-drm_gem_object_unreference(struct drm_device *dev, struct drm_gem_object *obj)
-{
- if (obj == NULL)
- return;
-
- kref_put (&obj->refcount, drm_gem_object_free);
-}
-EXPORT_SYMBOL(drm_gem_object_unreference);
+EXPORT_SYMBOL(drm_gem_object_free);
}
static void
-i915_gem_object_free_page_list(struct drm_device *dev,
- struct drm_gem_object *obj)
+i915_gem_object_free_page_list(struct drm_gem_object *obj)
{
struct drm_i915_gem_object *obj_priv = obj->driver_private;
int page_count = obj->size / PAGE_SIZE;
* Unbinds an object from the GTT aperture.
*/
static void
-i915_gem_object_unbind(struct drm_device *dev, struct drm_gem_object *obj)
+i915_gem_object_unbind(struct drm_gem_object *obj)
{
struct drm_i915_gem_object *obj_priv = obj->driver_private;
drm_free_agp(obj_priv->agp_mem, obj->size / PAGE_SIZE);
}
- i915_gem_object_free_page_list(dev, obj);
+ i915_gem_object_free_page_list(obj);
drm_memrange_put_block(obj_priv->gtt_space);
obj_priv->gtt_space = NULL;
* Finds free space in the GTT aperture and binds the object there.
*/
static int
-i915_gem_object_bind_to_gtt(struct drm_device *dev, struct drm_gem_object *obj, unsigned alignment)
+i915_gem_object_bind_to_gtt(struct drm_gem_object *obj, unsigned alignment)
{
+ struct drm_device *dev = obj->dev;
drm_i915_private_t *dev_priv = dev->dev_private;
struct drm_i915_gem_object *obj_priv = obj->driver_private;
struct drm_memrange_node *free_space;
find_or_create_page(obj->filp->f_mapping, i, GFP_HIGHUSER);
if (obj_priv->page_list[i] == NULL) {
- i915_gem_object_free_page_list(dev, obj);
+ i915_gem_object_free_page_list(obj);
drm_memrange_put_block(obj_priv->gtt_space);
obj_priv->gtt_space = NULL;
return -ENOMEM;
page_count,
obj_priv->gtt_offset);
if (obj_priv->agp_mem == NULL) {
- i915_gem_object_free_page_list(dev, obj);
+ i915_gem_object_free_page_list(obj);
drm_memrange_put_block(obj_priv->gtt_space);
obj_priv->gtt_space = NULL;
return -ENOMEM;
}
static int
-i915_gem_reloc_and_validate_object(struct drm_device *dev,
+i915_gem_reloc_and_validate_object(struct drm_gem_object *obj,
struct drm_file *file_priv,
- struct drm_i915_gem_validate_entry *entry,
- struct drm_gem_object *obj)
+ struct drm_i915_gem_validate_entry *entry)
{
+ struct drm_device *dev = obj->dev;
struct drm_i915_gem_relocation_entry reloc;
struct drm_i915_gem_relocation_entry __user *relocs;
struct drm_i915_gem_object *obj_priv = obj->driver_private;
/* Choose the GTT offset for our buffer and put it there. */
if (obj_priv->gtt_space == NULL) {
- i915_gem_object_bind_to_gtt(dev, obj, (unsigned) entry->alignment);
+ i915_gem_object_bind_to_gtt(obj, (unsigned) entry->alignment);
if (obj_priv->gtt_space == NULL)
return -ENOMEM;
}
if (ret != 0)
return ret;
- target_obj = drm_gem_object_lookup(dev, file_priv,
+ target_obj = drm_gem_object_lookup(obj->dev, file_priv,
reloc.target_handle);
if (target_obj == NULL)
return -EINVAL;
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_object_unbind(dev, obj);
+ i915_gem_object_unbind(obj);
return 0;
}
return ret;
/* Evict everything so we have space for sure. */
- drm_memrange_for_each(&dev_priv->mm.gtt_space, evict_callback, dev);
+ drm_memrange_for_each(&dev_priv->mm.gtt_space, evict_callback, NULL);
return 0;
}
goto err;
}
- i915_gem_reloc_and_validate_object(dev, file_priv,
- &validate_list[i],
- object_list[i]);
+ i915_gem_reloc_and_validate_object(object_list[i], file_priv,
+ &validate_list[i]);
}
/* Exec the batchbuffer */
err:
if (object_list != NULL) {
for (i = 0; i < args->buffer_count; i++)
- drm_gem_object_unreference(dev, object_list[i]);
+ drm_gem_object_unreference(object_list[i]);
}
drm_free(object_list, sizeof(*object_list) * args->buffer_count,
DRM_MEM_DRIVER);
return -EINVAL;
}
- ret = i915_gem_object_bind_to_gtt(dev, obj, (unsigned) args->alignment);
+ ret = i915_gem_object_bind_to_gtt(obj, (unsigned) args->alignment);
if (ret != 0) {
DRM_ERROR("Failure to bind in i915_gem_pin_ioctl(): %d\n",
ret);
return 0;
}
-int i915_gem_init_object(struct drm_device *dev, struct drm_gem_object *obj)
+int i915_gem_init_object(struct drm_gem_object *obj)
{
struct drm_i915_gem_object *obj_priv;
return 0;
}
-void i915_gem_free_object(struct drm_device *dev, struct drm_gem_object *obj)
+void i915_gem_free_object(struct drm_gem_object *obj)
{
- i915_gem_object_unbind(dev, obj);
+ i915_gem_object_unbind(obj);
drm_free(obj->driver_private, 1, DRM_MEM_DRIVER);
}