summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2013-01-08 11:39:53 -0800
committerEric Anholt <eric@anholt.net>2013-01-08 11:44:46 -0800
commit653b8199f7cc44d5a10757862fd684dad2276361 (patch)
treeb593cb915e28d2ba396828c9cd80efd2396db365
parentc0c36b941b6f0be6ac74f340040cbb29d6a0b06c (diff)
drm: Convert the lock protecting object handles to a mutex.
In execbuf, we want to be able to do many lookups of handles without having to take and drop a lock every time. Convert it to a mutex so that we'll be able to hold the lock across all our lookups. Signed-off-by: Eric Anholt <eric@anholt.net>
-rw-r--r--drivers/gpu/drm/drm_gem.c18
-rw-r--r--include/drm/drmP.h2
2 files changed, 10 insertions, 10 deletions
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 24efae464e2..0746ce07cae 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -232,19 +232,19 @@ drm_gem_handle_delete(struct drm_file *filp, u32 handle)
* we may want to use ida for number allocation and a hash table
* for the pointers, anyway.
*/
- spin_lock(&filp->table_lock);
+ mutex_lock(&filp->table_lock);
/* Check if we currently have a reference on the object */
obj = idr_find(&filp->object_idr, handle);
if (obj == NULL) {
- spin_unlock(&filp->table_lock);
+ mutex_unlock(&filp->table_lock);
return -EINVAL;
}
dev = obj->dev;
/* Release reference and decrement refcount. */
idr_remove(&filp->object_idr, handle);
- spin_unlock(&filp->table_lock);
+ mutex_unlock(&filp->table_lock);
drm_gem_remove_prime_handles(obj, filp);
@@ -278,9 +278,9 @@ again:
return -ENOMEM;
/* do the allocation under our spinlock */
- spin_lock(&file_priv->table_lock);
+ mutex_lock(&file_priv->table_lock);
ret = idr_get_new_above(&file_priv->object_idr, obj, 1, (int *)handlep);
- spin_unlock(&file_priv->table_lock);
+ mutex_unlock(&file_priv->table_lock);
if (ret == -EAGAIN)
goto again;
else if (ret)
@@ -395,18 +395,18 @@ drm_gem_object_lookup(struct drm_device *dev, struct drm_file *filp,
{
struct drm_gem_object *obj;
- spin_lock(&filp->table_lock);
+ mutex_lock(&filp->table_lock);
/* Check if we currently have a reference on the object */
obj = idr_find(&filp->object_idr, handle);
if (obj == NULL) {
- spin_unlock(&filp->table_lock);
+ mutex_unlock(&filp->table_lock);
return NULL;
}
drm_gem_object_reference(obj);
- spin_unlock(&filp->table_lock);
+ mutex_unlock(&filp->table_lock);
return obj;
}
@@ -527,7 +527,7 @@ void
drm_gem_open(struct drm_device *dev, struct drm_file *file_private)
{
idr_init(&file_private->object_idr);
- spin_lock_init(&file_private->table_lock);
+ mutex_init(&file_private->table_lock);
}
/**
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index fad21c927a3..fec34eab617 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -438,7 +438,7 @@ struct drm_file {
/** Mapping of mm object handles to object pointers. */
struct idr object_idr;
/** Lock for synchronization of access to object_idr. */
- spinlock_t table_lock;
+ struct mutex table_lock;
struct file *filp;
void *driver_priv;