aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2010-09-26 06:03:27 -0400
committerChris Wilson <chris@chris-wilson.co.uk>2010-09-26 06:03:27 -0400
commit1c25595f8d31392b8c36b54c624d01591dbfb87b (patch)
tree961ce6bb76bdc7aa7b245bb77fa054df6ee9b463 /drivers
parent447da18742b170b8e09ac71edf63c5798d2dbb0b (diff)
drm/i915: Convert the file mutex into a spinlock
Daniel Vetter pointed out that in this case is would be clearer and cleaner to use a spinlock instead of a mutex to protect the per-file request list manipulation. Make it so. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c2
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h2
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c28
3 files changed, 17 insertions, 15 deletions
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index ba050ed8df51..b752c31fbcff 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -2173,8 +2173,8 @@ int i915_driver_open(struct drm_device *dev, struct drm_file *file)
2173 2173
2174 file->driver_priv = file_priv; 2174 file->driver_priv = file_priv;
2175 2175
2176 spin_lock_init(&file_priv->mm.lock);
2176 INIT_LIST_HEAD(&file_priv->mm.request_list); 2177 INIT_LIST_HEAD(&file_priv->mm.request_list);
2177 mutex_init(&file_priv->mutex);
2178 2178
2179 return 0; 2179 return 0;
2180} 2180}
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index f2ff258cdfd5..710d59ea479c 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -851,8 +851,8 @@ struct drm_i915_gem_request {
851}; 851};
852 852
853struct drm_i915_file_private { 853struct drm_i915_file_private {
854 struct mutex mutex;
855 struct { 854 struct {
855 struct spinlock lock;
856 struct list_head request_list; 856 struct list_head request_list;
857 } mm; 857 } mm;
858}; 858};
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index ac5bff85a4c7..78282edc02ca 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1694,11 +1694,11 @@ i915_add_request(struct drm_device *dev,
1694 list_add_tail(&request->list, &ring->request_list); 1694 list_add_tail(&request->list, &ring->request_list);
1695 1695
1696 if (file_priv) { 1696 if (file_priv) {
1697 mutex_lock(&file_priv->mutex); 1697 spin_lock(&file_priv->mm.lock);
1698 request->file_priv = file_priv; 1698 request->file_priv = file_priv;
1699 list_add_tail(&request->client_list, 1699 list_add_tail(&request->client_list,
1700 &file_priv->mm.request_list); 1700 &file_priv->mm.request_list);
1701 mutex_unlock(&file_priv->mutex); 1701 spin_unlock(&file_priv->mm.lock);
1702 } 1702 }
1703 1703
1704 if (!dev_priv->mm.suspended) { 1704 if (!dev_priv->mm.suspended) {
@@ -1733,11 +1733,15 @@ i915_retire_commands(struct drm_device *dev, struct intel_ring_buffer *ring)
1733static inline void 1733static inline void
1734i915_gem_request_remove_from_client(struct drm_i915_gem_request *request) 1734i915_gem_request_remove_from_client(struct drm_i915_gem_request *request)
1735{ 1735{
1736 if (request->file_priv) { 1736 struct drm_i915_file_private *file_priv = request->file_priv;
1737 mutex_lock(&request->file_priv->mutex); 1737
1738 list_del(&request->client_list); 1738 if (!file_priv)
1739 mutex_unlock(&request->file_priv->mutex); 1739 return;
1740 } 1740
1741 spin_lock(&file_priv->mm.lock);
1742 list_del(&request->client_list);
1743 request->file_priv = NULL;
1744 spin_unlock(&file_priv->mm.lock);
1741} 1745}
1742 1746
1743static void i915_gem_reset_ring_lists(struct drm_i915_private *dev_priv, 1747static void i915_gem_reset_ring_lists(struct drm_i915_private *dev_priv,
@@ -3464,7 +3468,7 @@ i915_gem_ring_throttle(struct drm_device *dev, struct drm_file *file)
3464 u32 seqno = 0; 3468 u32 seqno = 0;
3465 int ret; 3469 int ret;
3466 3470
3467 mutex_lock(&file_priv->mutex); 3471 spin_lock(&file_priv->mm.lock);
3468 list_for_each_entry(request, &file_priv->mm.request_list, client_list) { 3472 list_for_each_entry(request, &file_priv->mm.request_list, client_list) {
3469 if (time_after_eq(request->emitted_jiffies, recent_enough)) 3473 if (time_after_eq(request->emitted_jiffies, recent_enough))
3470 break; 3474 break;
@@ -3472,7 +3476,7 @@ i915_gem_ring_throttle(struct drm_device *dev, struct drm_file *file)
3472 ring = request->ring; 3476 ring = request->ring;
3473 seqno = request->seqno; 3477 seqno = request->seqno;
3474 } 3478 }
3475 mutex_unlock(&file_priv->mutex); 3479 spin_unlock(&file_priv->mm.lock);
3476 3480
3477 if (seqno == 0) 3481 if (seqno == 0)
3478 return 0; 3482 return 0;
@@ -4974,8 +4978,7 @@ void i915_gem_release(struct drm_device *dev, struct drm_file *file)
4974 * later retire_requests won't dereference our soon-to-be-gone 4978 * later retire_requests won't dereference our soon-to-be-gone
4975 * file_priv. 4979 * file_priv.
4976 */ 4980 */
4977 mutex_lock(&dev->struct_mutex); 4981 spin_lock(&file_priv->mm.lock);
4978 mutex_lock(&file_priv->mutex);
4979 while (!list_empty(&file_priv->mm.request_list)) { 4982 while (!list_empty(&file_priv->mm.request_list)) {
4980 struct drm_i915_gem_request *request; 4983 struct drm_i915_gem_request *request;
4981 4984
@@ -4985,8 +4988,7 @@ void i915_gem_release(struct drm_device *dev, struct drm_file *file)
4985 list_del(&request->client_list); 4988 list_del(&request->client_list);
4986 request->file_priv = NULL; 4989 request->file_priv = NULL;
4987 } 4990 }
4988 mutex_unlock(&file_priv->mutex); 4991 spin_unlock(&file_priv->mm.lock);
4989 mutex_unlock(&dev->struct_mutex);
4990} 4992}
4991 4993
4992static int 4994static int