@@ -764,6 +764,13 @@ static int logical_ring_prepare(struct intel_ringbuffer *ringbuf,
return ret;
}
+ /* Ensure we have a request before touching the ring */
+ if (!ringbuf->ring->outstanding_lazy_request) {
+ ret = i915_gem_request_alloc(ringbuf->ring, ctx);
+ if (ret)
+ return ret;
+ }
+
if (unlikely(fill)) {
uint32_t __iomem *virt = ringbuf->virtual_start + ringbuf->tail;
@@ -812,11 +819,6 @@ static int intel_logical_ring_begin(struct intel_ringbuffer *ringbuf,
if (ret)
return ret;
- /* Preallocate the olr before touching the ring */
- ret = i915_gem_request_alloc(ring, ctx);
- if (ret)
- return ret;
-
ringbuf->space -= num_dwords * sizeof(uint32_t);
return 0;
}
@@ -2195,6 +2195,13 @@ static int __intel_ring_prepare(struct intel_engine_cs *ring,
return ret;
}
+ /* Ensure we have a request before touching the ring */
+ if (!ringbuf->ring->outstanding_lazy_request) {
+ ret = i915_gem_request_alloc(ringbuf->ring, ring->default_context);
+ if (ret)
+ return ret;
+ }
+
if (unlikely(fill)) {
uint32_t __iomem *virt = ringbuf->virtual_start + ringbuf->tail;
@@ -2228,11 +2235,6 @@ int intel_ring_begin(struct intel_engine_cs *ring,
if (ret)
return ret;
- /* Preallocate the olr before touching the ring */
- ret = i915_gem_request_alloc(ring, ring->default_context);
- if (ret)
- return ret;
-
ring->buffer->space -= num_dwords * sizeof(uint32_t);
return 0;
}