aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorBen Widawsky <ben@bwidawsk.net>2012-04-26 19:02:58 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2012-05-03 05:18:20 -0400
commitb2da9fe5d5994a104bbae154590070d698279919 (patch)
tree06ebd3a0f0c0be5ba35265922ca4b67b7488dbf0 /drivers/gpu
parent507432986c15f18c5102b18027e4716fc9e9009e (diff)
drm/i915: remove do_retire from i915_wait_request
This originates from a hack by me to quickly fix a bug in an earlier patch where we needed control over whether or not waiting on a seqno actually did any retire list processing. Since the two operations aren't clearly related, we should pull the parameter out of the wait function, and make the caller responsible for retiring if the action is desired. The only function call site which did not get an explicit retire_request call (on purpose) is i915_gem_inactive_shrink(). That code was already calling retire_request a second time. v2: don't modify any behavior excepit i915_gem_inactive_shrink(Daniel) Signed-off-by: Ben Widawsky <ben@bwidawsk.net> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c3
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h5
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c33
-rw-r--r--drivers/gpu/drm/i915/i915_gem_evict.c15
-rw-r--r--drivers/gpu/drm/i915/i915_gem_execbuffer.c3
-rw-r--r--drivers/gpu/drm/i915/i915_gem_gtt.c2
-rw-r--r--drivers/gpu/drm/i915/intel_overlay.c8
-rw-r--r--drivers/gpu/drm/i915/intel_ringbuffer.c4
8 files changed, 37 insertions, 36 deletions
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 7a55abbddc99..17081dad3faa 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -2009,9 +2009,10 @@ int i915_driver_unload(struct drm_device *dev)
2009 unregister_shrinker(&dev_priv->mm.inactive_shrinker); 2009 unregister_shrinker(&dev_priv->mm.inactive_shrinker);
2010 2010
2011 mutex_lock(&dev->struct_mutex); 2011 mutex_lock(&dev->struct_mutex);
2012 ret = i915_gpu_idle(dev, true); 2012 ret = i915_gpu_idle(dev);
2013 if (ret) 2013 if (ret)
2014 DRM_ERROR("failed to idle hardware: %d\n", ret); 2014 DRM_ERROR("failed to idle hardware: %d\n", ret);
2015 i915_gem_retire_requests(dev);
2015 mutex_unlock(&dev->struct_mutex); 2016 mutex_unlock(&dev->struct_mutex);
2016 2017
2017 /* Cancel the retire work handler, which should be idle now. */ 2018 /* Cancel the retire work handler, which should be idle now. */
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 0095c8d12569..2113a1ab9625 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1297,14 +1297,13 @@ int __must_check i915_gem_init_hw(struct drm_device *dev);
1297void i915_gem_init_swizzling(struct drm_device *dev); 1297void i915_gem_init_swizzling(struct drm_device *dev);
1298void i915_gem_init_ppgtt(struct drm_device *dev); 1298void i915_gem_init_ppgtt(struct drm_device *dev);
1299void i915_gem_cleanup_ringbuffer(struct drm_device *dev); 1299void i915_gem_cleanup_ringbuffer(struct drm_device *dev);
1300int __must_check i915_gpu_idle(struct drm_device *dev, bool do_retire); 1300int __must_check i915_gpu_idle(struct drm_device *dev);
1301int __must_check i915_gem_idle(struct drm_device *dev); 1301int __must_check i915_gem_idle(struct drm_device *dev);
1302int __must_check i915_add_request(struct intel_ring_buffer *ring, 1302int __must_check i915_add_request(struct intel_ring_buffer *ring,
1303 struct drm_file *file, 1303 struct drm_file *file,
1304 struct drm_i915_gem_request *request); 1304 struct drm_i915_gem_request *request);
1305int __must_check i915_wait_request(struct intel_ring_buffer *ring, 1305int __must_check i915_wait_request(struct intel_ring_buffer *ring,
1306 uint32_t seqno, 1306 uint32_t seqno);
1307 bool do_retire);
1308int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf); 1307int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
1309int __must_check 1308int __must_check
1310i915_gem_object_set_to_gtt_domain(struct drm_i915_gem_object *obj, 1309i915_gem_object_set_to_gtt_domain(struct drm_i915_gem_object *obj,
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index b46a3fd17746..e378204970fd 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1825,8 +1825,7 @@ i915_gem_retire_work_handler(struct work_struct *work)
1825 */ 1825 */
1826int 1826int
1827i915_wait_request(struct intel_ring_buffer *ring, 1827i915_wait_request(struct intel_ring_buffer *ring,
1828 uint32_t seqno, 1828 uint32_t seqno)
1829 bool do_retire)
1830{ 1829{
1831 drm_i915_private_t *dev_priv = ring->dev->dev_private; 1830 drm_i915_private_t *dev_priv = ring->dev->dev_private;
1832 u32 ier; 1831 u32 ier;
@@ -1902,14 +1901,6 @@ i915_wait_request(struct intel_ring_buffer *ring,
1902 if (atomic_read(&dev_priv->mm.wedged)) 1901 if (atomic_read(&dev_priv->mm.wedged))
1903 ret = -EAGAIN; 1902 ret = -EAGAIN;
1904 1903
1905 /* Directly dispatch request retiring. While we have the work queue
1906 * to handle this, the waiter on a request often wants an associated
1907 * buffer to have made it to the inactive list, and we would need
1908 * a separate wait queue to handle that.
1909 */
1910 if (ret == 0 && do_retire)
1911 i915_gem_retire_requests_ring(ring);
1912
1913 return ret; 1904 return ret;
1914} 1905}
1915 1906
@@ -1931,10 +1922,10 @@ i915_gem_object_wait_rendering(struct drm_i915_gem_object *obj)
1931 * it. 1922 * it.
1932 */ 1923 */
1933 if (obj->active) { 1924 if (obj->active) {
1934 ret = i915_wait_request(obj->ring, obj->last_rendering_seqno, 1925 ret = i915_wait_request(obj->ring, obj->last_rendering_seqno);
1935 true);
1936 if (ret) 1926 if (ret)
1937 return ret; 1927 return ret;
1928 i915_gem_retire_requests_ring(obj->ring);
1938 } 1929 }
1939 1930
1940 return 0; 1931 return 0;
@@ -2117,7 +2108,7 @@ i915_gem_flush_ring(struct intel_ring_buffer *ring,
2117 return 0; 2108 return 0;
2118} 2109}
2119 2110
2120static int i915_ring_idle(struct intel_ring_buffer *ring, bool do_retire) 2111static int i915_ring_idle(struct intel_ring_buffer *ring)
2121{ 2112{
2122 int ret; 2113 int ret;
2123 2114
@@ -2131,18 +2122,17 @@ static int i915_ring_idle(struct intel_ring_buffer *ring, bool do_retire)
2131 return ret; 2122 return ret;
2132 } 2123 }
2133 2124
2134 return i915_wait_request(ring, i915_gem_next_request_seqno(ring), 2125 return i915_wait_request(ring, i915_gem_next_request_seqno(ring));
2135 do_retire);
2136} 2126}
2137 2127
2138int i915_gpu_idle(struct drm_device *dev, bool do_retire) 2128int i915_gpu_idle(struct drm_device *dev)
2139{ 2129{
2140 drm_i915_private_t *dev_priv = dev->dev_private; 2130 drm_i915_private_t *dev_priv = dev->dev_private;
2141 int ret, i; 2131 int ret, i;
2142 2132
2143 /* Flush everything onto the inactive list. */ 2133 /* Flush everything onto the inactive list. */
2144 for (i = 0; i < I915_NUM_RINGS; i++) { 2134 for (i = 0; i < I915_NUM_RINGS; i++) {
2145 ret = i915_ring_idle(&dev_priv->ring[i], do_retire); 2135 ret = i915_ring_idle(&dev_priv->ring[i]);
2146 if (ret) 2136 if (ret)
2147 return ret; 2137 return ret;
2148 } 2138 }
@@ -2331,9 +2321,7 @@ i915_gem_object_flush_fence(struct drm_i915_gem_object *obj)
2331 } 2321 }
2332 2322
2333 if (obj->last_fenced_seqno) { 2323 if (obj->last_fenced_seqno) {
2334 ret = i915_wait_request(obj->ring, 2324 ret = i915_wait_request(obj->ring, obj->last_fenced_seqno);
2335 obj->last_fenced_seqno,
2336 false);
2337 if (ret) 2325 if (ret)
2338 return ret; 2326 return ret;
2339 2327
@@ -3394,11 +3382,12 @@ i915_gem_idle(struct drm_device *dev)
3394 return 0; 3382 return 0;
3395 } 3383 }
3396 3384
3397 ret = i915_gpu_idle(dev, true); 3385 ret = i915_gpu_idle(dev);
3398 if (ret) { 3386 if (ret) {
3399 mutex_unlock(&dev->struct_mutex); 3387 mutex_unlock(&dev->struct_mutex);
3400 return ret; 3388 return ret;
3401 } 3389 }
3390 i915_gem_retire_requests(dev);
3402 3391
3403 /* Under UMS, be paranoid and evict. */ 3392 /* Under UMS, be paranoid and evict. */
3404 if (!drm_core_check_feature(dev, DRIVER_MODESET)) 3393 if (!drm_core_check_feature(dev, DRIVER_MODESET))
@@ -4025,7 +4014,7 @@ rescan:
4025 * This has a dramatic impact to reduce the number of 4014 * This has a dramatic impact to reduce the number of
4026 * OOM-killer events whilst running the GPU aggressively. 4015 * OOM-killer events whilst running the GPU aggressively.
4027 */ 4016 */
4028 if (i915_gpu_idle(dev, true) == 0) 4017 if (i915_gpu_idle(dev) == 0)
4029 goto rescan; 4018 goto rescan;
4030 } 4019 }
4031 mutex_unlock(&dev->struct_mutex); 4020 mutex_unlock(&dev->struct_mutex);
diff --git a/drivers/gpu/drm/i915/i915_gem_evict.c b/drivers/gpu/drm/i915/i915_gem_evict.c
index 91ebb94d7c8b..3bcf0451d07c 100644
--- a/drivers/gpu/drm/i915/i915_gem_evict.c
+++ b/drivers/gpu/drm/i915/i915_gem_evict.c
@@ -168,7 +168,7 @@ i915_gem_evict_everything(struct drm_device *dev, bool purgeable_only)
168 drm_i915_private_t *dev_priv = dev->dev_private; 168 drm_i915_private_t *dev_priv = dev->dev_private;
169 struct drm_i915_gem_object *obj, *next; 169 struct drm_i915_gem_object *obj, *next;
170 bool lists_empty; 170 bool lists_empty;
171 int ret; 171 int ret,i;
172 172
173 lists_empty = (list_empty(&dev_priv->mm.inactive_list) && 173 lists_empty = (list_empty(&dev_priv->mm.inactive_list) &&
174 list_empty(&dev_priv->mm.flushing_list) && 174 list_empty(&dev_priv->mm.flushing_list) &&
@@ -178,11 +178,20 @@ i915_gem_evict_everything(struct drm_device *dev, bool purgeable_only)
178 178
179 trace_i915_gem_evict_everything(dev, purgeable_only); 179 trace_i915_gem_evict_everything(dev, purgeable_only);
180 180
181 /* Flush everything (on to the inactive lists) and evict */ 181 ret = i915_gpu_idle(dev);
182 ret = i915_gpu_idle(dev, true);
183 if (ret) 182 if (ret)
184 return ret; 183 return ret;
185 184
185 /* The gpu_idle will flush everything in the write domain to the
186 * active list. Then we must move everything off the active list
187 * with retire requests.
188 */
189 for (i = 0; i < I915_NUM_RINGS; i++)
190 if (WARN_ON(!list_empty(&dev_priv->ring[i].gpu_write_list)))
191 return -EBUSY;
192
193 i915_gem_retire_requests(dev);
194
186 BUG_ON(!list_empty(&dev_priv->mm.flushing_list)); 195 BUG_ON(!list_empty(&dev_priv->mm.flushing_list));
187 196
188 /* Having flushed everything, unbind() should never raise an error */ 197 /* Having flushed everything, unbind() should never raise an error */
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index 68ec0130a626..cbba0aa6104b 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -1220,9 +1220,10 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
1220 * so every billion or so execbuffers, we need to stall 1220 * so every billion or so execbuffers, we need to stall
1221 * the GPU in order to reset the counters. 1221 * the GPU in order to reset the counters.
1222 */ 1222 */
1223 ret = i915_gpu_idle(dev, true); 1223 ret = i915_gpu_idle(dev);
1224 if (ret) 1224 if (ret)
1225 goto err; 1225 goto err;
1226 i915_gem_retire_requests(dev);
1226 1227
1227 BUG_ON(ring->sync_seqno[i]); 1228 BUG_ON(ring->sync_seqno[i]);
1228 } 1229 }
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 25c8bf9d1d4e..29d573c27b35 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -317,7 +317,7 @@ static bool do_idling(struct drm_i915_private *dev_priv)
317 317
318 if (unlikely(dev_priv->mm.gtt->do_idle_maps)) { 318 if (unlikely(dev_priv->mm.gtt->do_idle_maps)) {
319 dev_priv->mm.interruptible = false; 319 dev_priv->mm.interruptible = false;
320 if (i915_gpu_idle(dev_priv->dev, false)) { 320 if (i915_gpu_idle(dev_priv->dev)) {
321 DRM_ERROR("Couldn't idle GPU\n"); 321 DRM_ERROR("Couldn't idle GPU\n");
322 /* Wait a bit, in hopes it avoids the hang */ 322 /* Wait a bit, in hopes it avoids the hang */
323 udelay(10); 323 udelay(10);
diff --git a/drivers/gpu/drm/i915/intel_overlay.c b/drivers/gpu/drm/i915/intel_overlay.c
index a0b5053c5a32..e06e46a30757 100644
--- a/drivers/gpu/drm/i915/intel_overlay.c
+++ b/drivers/gpu/drm/i915/intel_overlay.c
@@ -225,10 +225,10 @@ static int intel_overlay_do_wait_request(struct intel_overlay *overlay,
225 } 225 }
226 overlay->last_flip_req = request->seqno; 226 overlay->last_flip_req = request->seqno;
227 overlay->flip_tail = tail; 227 overlay->flip_tail = tail;
228 ret = i915_wait_request(LP_RING(dev_priv), overlay->last_flip_req, 228 ret = i915_wait_request(LP_RING(dev_priv), overlay->last_flip_req);
229 true);
230 if (ret) 229 if (ret)
231 return ret; 230 return ret;
231 i915_gem_retire_requests(dev);
232 232
233 overlay->last_flip_req = 0; 233 overlay->last_flip_req = 0;
234 return 0; 234 return 0;
@@ -447,10 +447,10 @@ static int intel_overlay_recover_from_interrupt(struct intel_overlay *overlay)
447 if (overlay->last_flip_req == 0) 447 if (overlay->last_flip_req == 0)
448 return 0; 448 return 0;
449 449
450 ret = i915_wait_request(LP_RING(dev_priv), overlay->last_flip_req, 450 ret = i915_wait_request(LP_RING(dev_priv), overlay->last_flip_req);
451 true);
452 if (ret) 451 if (ret)
453 return ret; 452 return ret;
453 i915_gem_retire_requests(dev);
454 454
455 if (overlay->flip_tail) 455 if (overlay->flip_tail)
456 overlay->flip_tail(overlay); 456 overlay->flip_tail(overlay);
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index 427b7c55ffe0..a7d97d17b285 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -1088,9 +1088,11 @@ static int intel_ring_wait_seqno(struct intel_ring_buffer *ring, u32 seqno)
1088 was_interruptible = dev_priv->mm.interruptible; 1088 was_interruptible = dev_priv->mm.interruptible;
1089 dev_priv->mm.interruptible = false; 1089 dev_priv->mm.interruptible = false;
1090 1090
1091 ret = i915_wait_request(ring, seqno, true); 1091 ret = i915_wait_request(ring, seqno);
1092 1092
1093 dev_priv->mm.interruptible = was_interruptible; 1093 dev_priv->mm.interruptible = was_interruptible;
1094 if (!ret)
1095 i915_gem_retire_requests_ring(ring);
1094 1096
1095 return ret; 1097 return ret;
1096} 1098}