summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2007-10-09 21:09:31 -0400
committerDave Airlie <airlied@linux.ie>2007-10-16 22:03:05 +1100
commita69c85fec8ed323bffb1324ea08157b3897e97db (patch)
tree8af6864cc448c13e11ee52a5bda8912bbba54e90
parentdccefba71a65566e7e1628b3be67621866000411 (diff)
Drop destroy ioctls for fences and buffer objects.
We now always create a drm_ref_object for user objects and this is then the only things that holds a reference to the user object. This way unreference on will destroy the user object when the last drm_ref_object goes way.
-rw-r--r--libdrm/xf86drm.c32
-rw-r--r--libdrm/xf86mm.h2
-rw-r--r--linux-core/drmP.h1
-rw-r--r--linux-core/drm_bo.c31
-rw-r--r--linux-core/drm_drv.c2
-rw-r--r--linux-core/drm_fence.c28
-rw-r--r--linux-core/drm_fops.c13
-rw-r--r--linux-core/drm_object.c27
-rw-r--r--linux-core/drm_objects.h12
-rw-r--r--shared-core/drm.h2
10 files changed, 10 insertions, 140 deletions
diff --git a/libdrm/xf86drm.c b/libdrm/xf86drm.c
index c450a985..7666d431 100644
--- a/libdrm/xf86drm.c
+++ b/libdrm/xf86drm.c
@@ -2389,18 +2389,6 @@ int drmFenceBuffers(int fd, unsigned flags, uint32_t fence_class, drmFence *fenc
fence->signaled = 0;
return 0;
}
-
-int drmFenceDestroy(int fd, const drmFence *fence)
-{
- drm_fence_arg_t arg;
-
- memset(&arg, 0, sizeof(arg));
- arg.handle = fence->handle;
-
- if (ioctl(fd, DRM_IOCTL_FENCE_DESTROY, &arg))
- return -errno;
- return 0;
-}
int drmFenceReference(int fd, unsigned handle, drmFence *fence)
{
@@ -2732,26 +2720,6 @@ int drmBOCreate(int fd, unsigned long size,
return 0;
}
-int drmBODestroy(int fd, drmBO *buf)
-{
- struct drm_bo_handle_arg arg;
-
- if (buf->mapVirtual) {
- (void) drmUnmap(buf->mapVirtual, buf->start + buf->size);
- buf->mapVirtual = NULL;
- buf->virtual = NULL;
- }
-
- memset(&arg, 0, sizeof(arg));
- arg.handle = buf->handle;
-
- if (ioctl(fd, DRM_IOCTL_BO_DESTROY, &arg))
- return -errno;
-
- buf->handle = 0;
- return 0;
-}
-
int drmBOReference(int fd, unsigned handle, drmBO *buf)
{
struct drm_bo_reference_info_arg arg;
diff --git a/libdrm/xf86mm.h b/libdrm/xf86mm.h
index 0dac7eff..d99e61e7 100644
--- a/libdrm/xf86mm.h
+++ b/libdrm/xf86mm.h
@@ -150,7 +150,6 @@ typedef struct _drmBOList {
extern int drmFenceCreate(int fd, unsigned flags, int fence_class,
unsigned type, drmFence *fence);
-extern int drmFenceDestroy(int fd, const drmFence *fence);
extern int drmFenceReference(int fd, unsigned handle, drmFence *fence);
extern int drmFenceUnreference(int fd, const drmFence *fence);
extern int drmFenceFlush(int fd, drmFence *fence, unsigned flush_type);
@@ -181,7 +180,6 @@ extern int drmBOCreateList(int numTarget, drmBOList *list);
extern int drmBOCreate(int fd, unsigned long size,
unsigned pageAlignment, void *user_buffer,
uint64_t mask, unsigned hint, drmBO *buf);
-extern int drmBODestroy(int fd, drmBO *buf);
extern int drmBOReference(int fd, unsigned handle, drmBO *buf);
extern int drmBOUnReference(int fd, drmBO *buf);
extern int drmBOMap(int fd, drmBO *buf, unsigned mapFlags, unsigned mapHint,
diff --git a/linux-core/drmP.h b/linux-core/drmP.h
index f8ca3f4b..d0ab2c94 100644
--- a/linux-core/drmP.h
+++ b/linux-core/drmP.h
@@ -428,7 +428,6 @@ struct drm_file {
*/
struct list_head refd_objects;
- struct list_head user_objects;
struct drm_open_hash refd_object_hash[_DRM_NO_REF_TYPES];
struct file *filp;
diff --git a/linux-core/drm_bo.c b/linux-core/drm_bo.c
index e2f460ed..fb360e7f 100644
--- a/linux-core/drm_bo.c
+++ b/linux-core/drm_bo.c
@@ -1674,8 +1674,8 @@ int drm_buffer_object_create(struct drm_device *dev,
}
EXPORT_SYMBOL(drm_buffer_object_create);
-int drm_bo_add_user_object(struct drm_file *file_priv,
- struct drm_buffer_object *bo, int shareable)
+static int drm_bo_add_user_object(struct drm_file *file_priv,
+ struct drm_buffer_object *bo, int shareable)
{
struct drm_device *dev = file_priv->head->dev;
int ret;
@@ -1694,7 +1694,6 @@ int drm_bo_add_user_object(struct drm_file *file_priv,
mutex_unlock(&dev->struct_mutex);
return ret;
}
-EXPORT_SYMBOL(drm_bo_add_user_object);
static int drm_bo_lock_test(struct drm_device * dev, struct drm_file *file_priv)
{
@@ -1816,32 +1815,6 @@ out:
return ret;
}
-
-int drm_bo_destroy_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv)
-{
- struct drm_bo_handle_arg *arg = data;
- struct drm_user_object *uo;
- int ret = 0;
-
- DRM_DEBUG("drm_bo_destroy_ioctl: buffer %d\n", arg->handle);
-
- if (!dev->bm.initialized) {
- DRM_ERROR("Buffer object manager is not initialized.\n");
- return -EINVAL;
- }
-
- mutex_lock(&dev->struct_mutex);
- uo = drm_lookup_user_object(file_priv, arg->handle);
- if (!uo || (uo->type != drm_buffer_type) || uo->owner != file_priv) {
- mutex_unlock(&dev->struct_mutex);
- return -EINVAL;
- }
- ret = drm_remove_user_object(file_priv, uo);
- mutex_unlock(&dev->struct_mutex);
-
- return ret;
-}
-
int drm_bo_map_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
struct drm_bo_map_wait_idle_arg *arg = data;
diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c
index a09fa96e..0fca3a27 100644
--- a/linux-core/drm_drv.c
+++ b/linux-core/drm_drv.c
@@ -129,7 +129,6 @@ static struct drm_ioctl_desc drm_ioctls[] = {
DRM_IOCTL_DEF(DRM_IOCTL_MM_UNLOCK, drm_mm_unlock_ioctl, DRM_AUTH),
DRM_IOCTL_DEF(DRM_IOCTL_FENCE_CREATE, drm_fence_create_ioctl, DRM_AUTH),
- DRM_IOCTL_DEF(DRM_IOCTL_FENCE_DESTROY, drm_fence_destroy_ioctl, DRM_AUTH),
DRM_IOCTL_DEF(DRM_IOCTL_FENCE_REFERENCE, drm_fence_reference_ioctl, DRM_AUTH),
DRM_IOCTL_DEF(DRM_IOCTL_FENCE_UNREFERENCE, drm_fence_unreference_ioctl, DRM_AUTH),
DRM_IOCTL_DEF(DRM_IOCTL_FENCE_SIGNALED, drm_fence_signaled_ioctl, DRM_AUTH),
@@ -139,7 +138,6 @@ static struct drm_ioctl_desc drm_ioctls[] = {
DRM_IOCTL_DEF(DRM_IOCTL_FENCE_BUFFERS, drm_fence_buffers_ioctl, DRM_AUTH),
DRM_IOCTL_DEF(DRM_IOCTL_BO_CREATE, drm_bo_create_ioctl, DRM_AUTH),
- DRM_IOCTL_DEF(DRM_IOCTL_BO_DESTROY, drm_bo_destroy_ioctl, DRM_AUTH),
DRM_IOCTL_DEF(DRM_IOCTL_BO_MAP, drm_bo_map_ioctl, DRM_AUTH),
DRM_IOCTL_DEF(DRM_IOCTL_BO_UNMAP, drm_bo_unmap_ioctl, DRM_AUTH),
DRM_IOCTL_DEF(DRM_IOCTL_BO_REFERENCE, drm_bo_reference_ioctl, DRM_AUTH),
diff --git a/linux-core/drm_fence.c b/linux-core/drm_fence.c
index 9a29356b..d1969f86 100644
--- a/linux-core/drm_fence.c
+++ b/linux-core/drm_fence.c
@@ -517,7 +517,7 @@ static int drm_fence_object_init(struct drm_device * dev, uint32_t fence_class,
return ret;
}
-int drm_fence_add_user_object(struct drm_file * priv, struct drm_fence_object * fence,
+static int drm_fence_add_user_object(struct drm_file * priv, struct drm_fence_object * fence,
int shareable)
{
struct drm_device *dev = priv->head->dev;
@@ -535,7 +535,6 @@ out:
mutex_unlock(&dev->struct_mutex);
return ret;
}
-EXPORT_SYMBOL(drm_fence_add_user_object);
int drm_fence_object_create(struct drm_device * dev, uint32_t fence_class, uint32_t type,
unsigned flags, struct drm_fence_object ** c_fence)
@@ -670,31 +669,6 @@ int drm_fence_create_ioctl(struct drm_device *dev, void *data, struct drm_file *
return ret;
}
-int drm_fence_destroy_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv)
-{
- int ret;
- struct drm_fence_manager *fm = &dev->fm;
- struct drm_fence_arg *arg = data;
- struct drm_user_object *uo;
- ret = 0;
-
- if (!fm->initialized) {
- DRM_ERROR("The DRM driver does not support fencing.\n");
- return -EINVAL;
- }
-
- mutex_lock(&dev->struct_mutex);
- uo = drm_lookup_user_object(file_priv, arg->handle);
- if (!uo || (uo->type != drm_fence_type) || uo->owner != file_priv) {
- mutex_unlock(&dev->struct_mutex);
- return -EINVAL;
- }
- ret = drm_remove_user_object(file_priv, uo);
- mutex_unlock(&dev->struct_mutex);
- return ret;
-}
-
-
int drm_fence_reference_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
int ret;
diff --git a/linux-core/drm_fops.c b/linux-core/drm_fops.c
index ab5f4ca5..0ccaed5b 100644
--- a/linux-core/drm_fops.c
+++ b/linux-core/drm_fops.c
@@ -263,7 +263,6 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
priv->lock_count = 0;
INIT_LIST_HEAD(&priv->lhead);
- INIT_LIST_HEAD(&priv->user_objects);
INIT_LIST_HEAD(&priv->refd_objects);
for (i=0; i<_DRM_NO_REF_TYPES; ++i) {
@@ -338,7 +337,6 @@ static void drm_object_release(struct file *filp) {
struct drm_file *priv = filp->private_data;
struct list_head *head;
- struct drm_user_object *user_object;
struct drm_ref_object *ref_object;
int i;
@@ -357,17 +355,6 @@ static void drm_object_release(struct file *filp) {
head = &priv->refd_objects;
}
- /*
- * Free leftover user objects created by me.
- */
-
- head = &priv->user_objects;
- while (head->next != head) {
- user_object = list_entry(head->next, struct drm_user_object, list);
- drm_remove_user_object(priv, user_object);
- head = &priv->user_objects;
- }
-
for(i=0; i<_DRM_NO_REF_TYPES; ++i) {
drm_ht_remove(&priv->refd_object_hash[i]);
}
diff --git a/linux-core/drm_object.c b/linux-core/drm_object.c
index 6bd89b1d..a6d6c0d7 100644
--- a/linux-core/drm_object.c
+++ b/linux-core/drm_object.c
@@ -38,7 +38,8 @@ int drm_add_user_object(struct drm_file * priv, struct drm_user_object * item,
DRM_ASSERT_LOCKED(&dev->struct_mutex);
- atomic_set(&item->refcount, 1);
+ /* The refcount will be bumped to 1 when we add the ref object below. */
+ atomic_set(&item->refcount, 0);
item->shareable = shareable;
item->owner = priv;
@@ -47,8 +48,11 @@ int drm_add_user_object(struct drm_file * priv, struct drm_user_object * item,
if (ret)
return ret;
- list_add_tail(&item->list, &priv->user_objects);
- return 0;
+ ret = drm_add_ref_object(priv, item, _DRM_REF_USE);
+ if (ret)
+ ret = drm_ht_remove_item(&dev->object_hash, &item->hash);
+
+ return ret;
}
EXPORT_SYMBOL(drm_add_user_object);
@@ -87,27 +91,10 @@ static void drm_deref_user_object(struct drm_file * priv, struct drm_user_object
if (atomic_dec_and_test(&item->refcount)) {
ret = drm_ht_remove_item(&dev->object_hash, &item->hash);
BUG_ON(ret);
- list_del_init(&item->list);
item->remove(priv, item);
}
}
-int drm_remove_user_object(struct drm_file * priv, struct drm_user_object * item)
-{
- DRM_ASSERT_LOCKED(&priv->head->dev->struct_mutex);
-
- if (item->owner != priv) {
- DRM_ERROR("Cannot destroy object not owned by you.\n");
- return -EINVAL;
- }
- item->owner = 0;
- item->shareable = 0;
- list_del_init(&item->list);
- drm_deref_user_object(priv, item);
- return 0;
-}
-EXPORT_SYMBOL(drm_remove_user_object);
-
static int drm_object_ref_action(struct drm_file * priv, struct drm_user_object * ro,
enum drm_ref_type action)
{
diff --git a/linux-core/drm_objects.h b/linux-core/drm_objects.h
index b58db57f..67c33745 100644
--- a/linux-core/drm_objects.h
+++ b/linux-core/drm_objects.h
@@ -103,15 +103,6 @@ extern struct drm_user_object *drm_lookup_user_object(struct drm_file * priv,
uint32_t key);
/*
- * Must be called with the struct_mutex held.
- * If "item" has been obtained by a call to drm_lookup_user_object. You may not
- * release the struct_mutex before calling drm_remove_ref_object.
- * This function may temporarily release the struct_mutex.
- */
-
-extern int drm_remove_user_object(struct drm_file * priv, struct drm_user_object * item);
-
-/*
* Must be called with the struct_mutex held. May temporarily release it.
*/
@@ -222,9 +213,6 @@ extern int drm_fence_object_emit(struct drm_fence_object * fence,
extern void drm_fence_fill_arg(struct drm_fence_object *fence,
struct drm_fence_arg *arg);
-extern int drm_fence_add_user_object(struct drm_file * priv,
- struct drm_fence_object * fence, int shareable);
-
extern int drm_fence_create_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
extern int drm_fence_destroy_ioctl(struct drm_device *dev, void *data,
diff --git a/shared-core/drm.h b/shared-core/drm.h
index 568b1003..30650bd9 100644
--- a/shared-core/drm.h
+++ b/shared-core/drm.h
@@ -962,7 +962,6 @@ struct drm_mm_init_arg {
#define DRM_IOCTL_MM_UNLOCK DRM_IOWR(0xc3, struct drm_mm_type_arg)
#define DRM_IOCTL_FENCE_CREATE DRM_IOWR(0xc4, struct drm_fence_arg)
-#define DRM_IOCTL_FENCE_DESTROY DRM_IOWR(0xc5, struct drm_fence_arg)
#define DRM_IOCTL_FENCE_REFERENCE DRM_IOWR(0xc6, struct drm_fence_arg)
#define DRM_IOCTL_FENCE_UNREFERENCE DRM_IOWR(0xc7, struct drm_fence_arg)
#define DRM_IOCTL_FENCE_SIGNALED DRM_IOWR(0xc8, struct drm_fence_arg)
@@ -972,7 +971,6 @@ struct drm_mm_init_arg {
#define DRM_IOCTL_FENCE_BUFFERS DRM_IOWR(0xcc, struct drm_fence_arg)
#define DRM_IOCTL_BO_CREATE DRM_IOWR(0xcd, struct drm_bo_create_arg)
-#define DRM_IOCTL_BO_DESTROY DRM_IOWR(0xce, struct drm_bo_handle_arg)
#define DRM_IOCTL_BO_MAP DRM_IOWR(0xcf, struct drm_bo_map_wait_idle_arg)
#define DRM_IOCTL_BO_UNMAP DRM_IOWR(0xd0, struct drm_bo_handle_arg)
#define DRM_IOCTL_BO_REFERENCE DRM_IOWR(0xd1, struct drm_bo_reference_info_arg)