summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/intel_lrc.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2016-04-28 10:56:48 +0200
committerChris Wilson <chris@chris-wilson.co.uk>2016-04-28 13:17:32 +0200
commitbfa0120073de10717c02ea42cb0f3d8ada35c43f (patch)
tree9bb6ca14829034c366edf78ac238a058ed884460 /drivers/gpu/drm/i915/intel_lrc.c
parentdrm/i915: Remove the identical implementations of request space reservation (diff)
downloadlinux-bfa0120073de10717c02ea42cb0f3d8ada35c43f.tar.xz
linux-bfa0120073de10717c02ea42cb0f3d8ada35c43f.zip
drm/i915: Manually unwind after a failed request allocation
In the next patches, we want to move the work out of freeing the request and into its retirement (so that we can free the request without requiring the struct_mutex). This means that we cannot rely on unreferencing the request to completely teardown the request any more and so we need to manually unwind the failed allocation. In doing so, we reorder the allocation in order to make the unwind simple (and ensure that we don't try to unwind a partial request that may have modified global state) and so we end up pushing the initial preallocation down into the engine request initialisation functions where we have the requisite control over the state of the request. Moving the initial preallocation into the engine is less than ideal: it moves logic to handle a specific problem with request handling out of the common code. On the other hand, it does allow those backends significantly more flexibility in performing its allocations. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com> Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/1461833819-3991-14-git-send-email-chris@chris-wilson.co.uk
Diffstat (limited to 'drivers/gpu/drm/i915/intel_lrc.c')
-rw-r--r--drivers/gpu/drm/i915/intel_lrc.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index c60f4fe36537..413985832351 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -698,7 +698,7 @@ static int execlists_move_to_gpu(struct drm_i915_gem_request *req,
int intel_logical_ring_alloc_request_extras(struct drm_i915_gem_request *request)
{
- int ret = 0;
+ int ret;
request->ringbuf = request->ctx->engine[request->engine->id].ringbuf;
@@ -715,9 +715,21 @@ int intel_logical_ring_alloc_request_extras(struct drm_i915_gem_request *request
return ret;
}
- if (request->ctx != request->i915->kernel_context)
+ if (request->ctx != request->i915->kernel_context) {
ret = intel_lr_context_pin(request->ctx, request->engine);
+ if (ret)
+ return ret;
+ }
+ ret = intel_ring_begin(request, 0);
+ if (ret)
+ goto err_unpin;
+
+ return 0;
+
+err_unpin:
+ if (request->ctx != request->i915->kernel_context)
+ intel_lr_context_unpin(request->ctx, request->engine);
return ret;
}