aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/intel_ringbuffer.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2013-09-04 05:45:52 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2013-09-05 06:03:53 -0400
commit3c0e234c847318304c12f9e7fffac7e1cf3db3ff (patch)
tree11f5b83d1a88a9aa1683a28356ac617845862999 /drivers/gpu/drm/i915/intel_ringbuffer.c
parent1823521d2b2fa614e7ad95fdc8a0f59e571f37ce (diff)
drm/i915; Preallocate the lazy request
It is possible for us to be forced to perform an allocation for the lazy request whilst running the shrinker. This allocation may fail, leaving us unable to reclaim any memory leading to premature OOM. A neat solution to the problem is to preallocate the request at the same time as acquiring the seqno for the ring transaction. This means that we can report ENOMEM prior to touching the rings. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Mika Kuoppala <mika.kuoppala@intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/i915/intel_ringbuffer.c')
-rw-r--r--drivers/gpu/drm/i915/intel_ringbuffer.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index a83ff1863a5e..284afaf5d6ff 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -1498,6 +1498,16 @@ intel_ring_alloc_seqno(struct intel_ring_buffer *ring)
1498 if (ring->outstanding_lazy_seqno) 1498 if (ring->outstanding_lazy_seqno)
1499 return 0; 1499 return 0;
1500 1500
1501 if (ring->preallocated_lazy_request == NULL) {
1502 struct drm_i915_gem_request *request;
1503
1504 request = kmalloc(sizeof(*request), GFP_KERNEL);
1505 if (request == NULL)
1506 return -ENOMEM;
1507
1508 ring->preallocated_lazy_request = request;
1509 }
1510
1501 return i915_gem_get_seqno(ring->dev, &ring->outstanding_lazy_seqno); 1511 return i915_gem_get_seqno(ring->dev, &ring->outstanding_lazy_seqno);
1502} 1512}
1503 1513