[Intel-gfx] [PATCH v4 15/25] drm/i915: Preallocate enough space for the average request
Chris Wilson
chris at chris-wilson.co.uk
Tue Apr 26 06:54:22 UTC 2016
Rather than being interrupted when we run out of space halfway through
the request, and having to restart from the beginning (and returning to
userspace), flush a little more free space when we prepare the request.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
drivers/gpu/drm/i915/intel_lrc.c | 6 +++++-
drivers/gpu/drm/i915/intel_ringbuffer.c | 7 ++++++-
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 1ecdebb88c1a..d2c41b85fad0 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -702,7 +702,11 @@ int intel_logical_ring_alloc_request_extras(struct drm_i915_gem_request *request
request->ringbuf = request->ctx->engine[request->engine->id].ringbuf;
- ret = intel_ring_begin(request, 0);
+ /* Flush enough space to reduce the likelihood of waiting after
+ * we start building the request - in which case we will just
+ * have to repeat work.
+ */
+ ret = intel_ring_begin(request, MIN_SPACE_FOR_ADD_REQUEST);
if (ret)
return ret;
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index 68da54680efd..511a49fd9f02 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -2333,7 +2333,12 @@ int intel_engine_idle(struct intel_engine_cs *engine)
int intel_ring_alloc_request_extras(struct drm_i915_gem_request *request)
{
request->ringbuf = request->engine->buffer;
- return intel_ring_begin(request, 0);
+
+ /* Flush enough space to reduce the likelihood of waiting after
+ * we start building the request - in which case we will just
+ * have to repeat work.
+ */
+ return intel_ring_begin(request, MIN_SPACE_FOR_ADD_REQUEST);
}
static int wait_for_space(struct drm_i915_gem_request *req, int bytes)
--
2.8.1
More information about the Intel-gfx
mailing list