|
@@ -58,10 +58,21 @@ int __intel_ring_space(int head, int tail, int size)
|
|
|
return space - I915_RING_FREE_SPACE;
|
|
|
}
|
|
|
|
|
|
+void intel_ring_update_space(struct intel_ringbuffer *ringbuf)
|
|
|
+{
|
|
|
+ if (ringbuf->last_retired_head != -1) {
|
|
|
+ ringbuf->head = ringbuf->last_retired_head;
|
|
|
+ ringbuf->last_retired_head = -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ ringbuf->space = __intel_ring_space(ringbuf->head & HEAD_ADDR,
|
|
|
+ ringbuf->tail, ringbuf->size);
|
|
|
+}
|
|
|
+
|
|
|
int intel_ring_space(struct intel_ringbuffer *ringbuf)
|
|
|
{
|
|
|
- return __intel_ring_space(ringbuf->head & HEAD_ADDR,
|
|
|
- ringbuf->tail, ringbuf->size);
|
|
|
+ intel_ring_update_space(ringbuf);
|
|
|
+ return ringbuf->space;
|
|
|
}
|
|
|
|
|
|
bool intel_ring_stopped(struct intel_engine_cs *ring)
|
|
@@ -589,10 +600,10 @@ static int init_ring_common(struct intel_engine_cs *ring)
|
|
|
goto out;
|
|
|
}
|
|
|
|
|
|
+ ringbuf->last_retired_head = -1;
|
|
|
ringbuf->head = I915_READ_HEAD(ring);
|
|
|
ringbuf->tail = I915_READ_TAIL(ring) & TAIL_ADDR;
|
|
|
- ringbuf->space = intel_ring_space(ringbuf);
|
|
|
- ringbuf->last_retired_head = -1;
|
|
|
+ intel_ring_update_space(ringbuf);
|
|
|
|
|
|
memset(&ring->hangcheck, 0, sizeof(ring->hangcheck));
|
|
|
|
|
@@ -1901,14 +1912,8 @@ static int intel_ring_wait_request(struct intel_engine_cs *ring, int n)
|
|
|
struct drm_i915_gem_request *request;
|
|
|
int ret;
|
|
|
|
|
|
- if (ringbuf->last_retired_head != -1) {
|
|
|
- ringbuf->head = ringbuf->last_retired_head;
|
|
|
- ringbuf->last_retired_head = -1;
|
|
|
-
|
|
|
- ringbuf->space = intel_ring_space(ringbuf);
|
|
|
- if (ringbuf->space >= n)
|
|
|
- return 0;
|
|
|
- }
|
|
|
+ if (intel_ring_space(ringbuf) >= n)
|
|
|
+ return 0;
|
|
|
|
|
|
list_for_each_entry(request, &ring->request_list, list) {
|
|
|
if (__intel_ring_space(request->tail, ringbuf->tail,
|
|
@@ -1925,10 +1930,7 @@ static int intel_ring_wait_request(struct intel_engine_cs *ring, int n)
|
|
|
return ret;
|
|
|
|
|
|
i915_gem_retire_requests_ring(ring);
|
|
|
- ringbuf->head = ringbuf->last_retired_head;
|
|
|
- ringbuf->last_retired_head = -1;
|
|
|
|
|
|
- ringbuf->space = intel_ring_space(ringbuf);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -1954,14 +1956,14 @@ static int ring_wait_for_space(struct intel_engine_cs *ring, int n)
|
|
|
* case by choosing an insanely large timeout. */
|
|
|
end = jiffies + 60 * HZ;
|
|
|
|
|
|
+ ret = 0;
|
|
|
trace_i915_ring_wait_begin(ring);
|
|
|
do {
|
|
|
+ if (intel_ring_space(ringbuf) >= n)
|
|
|
+ break;
|
|
|
ringbuf->head = I915_READ_HEAD(ring);
|
|
|
- ringbuf->space = intel_ring_space(ringbuf);
|
|
|
- if (ringbuf->space >= n) {
|
|
|
- ret = 0;
|
|
|
+ if (intel_ring_space(ringbuf) >= n)
|
|
|
break;
|
|
|
- }
|
|
|
|
|
|
msleep(1);
|
|
|
|
|
@@ -2002,7 +2004,7 @@ static int intel_wrap_ring_buffer(struct intel_engine_cs *ring)
|
|
|
iowrite32(MI_NOOP, virt++);
|
|
|
|
|
|
ringbuf->tail = 0;
|
|
|
- ringbuf->space = intel_ring_space(ringbuf);
|
|
|
+ intel_ring_update_space(ringbuf);
|
|
|
|
|
|
return 0;
|
|
|
}
|