summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/i915_gem_request.c
diff options
context:
space:
mode:
authorChris Wilson2016-07-20 10:21:09 +0200
committerChris Wilson2016-07-20 10:29:53 +0200
commit9b5f4e5ed6fd58390ecad3772b80936357f1aba6 (patch)
tree696a3be9872caa8e2b7366390a202ff733f3f01c /drivers/gpu/drm/i915/i915_gem_request.c
parentdrm/i915: Move GEM request routines to i915_gem_request.c (diff)
downloadkernel-qcow2-linux-9b5f4e5ed6fd58390ecad3772b80936357f1aba6.tar.gz
kernel-qcow2-linux-9b5f4e5ed6fd58390ecad3772b80936357f1aba6.tar.xz
kernel-qcow2-linux-9b5f4e5ed6fd58390ecad3772b80936357f1aba6.zip
drm/i915: Retire oldest completed request before allocating next
In order to keep the memory allocated for requests reasonably tight, try to reuse the oldest request (so long as it is completed and has no external references) for the next allocation. v2: Throw in a comment to hopefully make sure no one mistakes the optimistic retirement of the oldest request for simply stealing it. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Mika Kuoppala <mika.kuoppala@intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/1469002875-2335-2-git-send-email-chris@chris-wilson.co.uk
Diffstat (limited to 'drivers/gpu/drm/i915/i915_gem_request.c')
-rw-r--r--drivers/gpu/drm/i915/i915_gem_request.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem_request.c b/drivers/gpu/drm/i915/i915_gem_request.c
index 9e9aa6b725f7..5cbb11ece60a 100644
--- a/drivers/gpu/drm/i915/i915_gem_request.c
+++ b/drivers/gpu/drm/i915/i915_gem_request.c
@@ -226,6 +226,14 @@ __i915_gem_request_alloc(struct intel_engine_cs *engine,
if (ret)
return ret;
+ /* Move the oldest request to the slab-cache (if not in use!) */
+ if (!list_empty(&engine->request_list)) {
+ req = list_first_entry(&engine->request_list,
+ typeof(*req), list);
+ if (i915_gem_request_completed(req))
+ i915_gem_request_retire(req);
+ }
+
req = kmem_cache_zalloc(dev_priv->requests, GFP_KERNEL);
if (!req)
return -ENOMEM;