diff options
author | Oscar Mateo <oscar.mateo@intel.com> | 2014-07-03 11:28:02 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2014-07-08 06:30:53 -0400 |
commit | 2919d2913c515fcfef6d50a46aae31128d454ce9 (patch) | |
tree | 1d23c9c1db1022d4a7566a2acf54e7fe0a63dee0 /drivers/gpu | |
parent | 31b7a88d354e5d7f7d2e68818e4bd8f115ab1ba6 (diff) |
drm/i915: Extract ringbuffer destroy & generalize alloc to take a ringbuf
More prep work: with Execlists, we are going to start creating a lot
of extra ringbuffers soon, so these functions are handy.
No functional changes.
v2: rename allocate/destroy_ring_buffer to alloc/destroy_ringbuffer_obj
because the name is more meaningful and to mirror a similar function in
the context world: i915_gem_alloc_context_obj(). Change suggested by Brad
Volkin.
Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Oscar Mateo <oscar.mateo@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/i915/intel_ringbuffer.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c index e18ed05dc0d5..40b17f246a69 100644 --- a/drivers/gpu/drm/i915/intel_ringbuffer.c +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c | |||
@@ -1482,15 +1482,25 @@ static int init_phys_status_page(struct intel_engine_cs *ring) | |||
1482 | return 0; | 1482 | return 0; |
1483 | } | 1483 | } |
1484 | 1484 | ||
1485 | static int allocate_ring_buffer(struct intel_engine_cs *ring) | 1485 | static void intel_destroy_ringbuffer_obj(struct intel_ringbuffer *ringbuf) |
1486 | { | ||
1487 | if (!ringbuf->obj) | ||
1488 | return; | ||
1489 | |||
1490 | iounmap(ringbuf->virtual_start); | ||
1491 | i915_gem_object_ggtt_unpin(ringbuf->obj); | ||
1492 | drm_gem_object_unreference(&ringbuf->obj->base); | ||
1493 | ringbuf->obj = NULL; | ||
1494 | } | ||
1495 | |||
1496 | static int intel_alloc_ringbuffer_obj(struct drm_device *dev, | ||
1497 | struct intel_ringbuffer *ringbuf) | ||
1486 | { | 1498 | { |
1487 | struct drm_device *dev = ring->dev; | ||
1488 | struct drm_i915_private *dev_priv = to_i915(dev); | 1499 | struct drm_i915_private *dev_priv = to_i915(dev); |
1489 | struct intel_ringbuffer *ringbuf = ring->buffer; | ||
1490 | struct drm_i915_gem_object *obj; | 1500 | struct drm_i915_gem_object *obj; |
1491 | int ret; | 1501 | int ret; |
1492 | 1502 | ||
1493 | if (intel_ring_initialized(ring)) | 1503 | if (ringbuf->obj) |
1494 | return 0; | 1504 | return 0; |
1495 | 1505 | ||
1496 | obj = NULL; | 1506 | obj = NULL; |
@@ -1562,7 +1572,7 @@ static int intel_init_ring_buffer(struct drm_device *dev, | |||
1562 | goto error; | 1572 | goto error; |
1563 | } | 1573 | } |
1564 | 1574 | ||
1565 | ret = allocate_ring_buffer(ring); | 1575 | ret = intel_alloc_ringbuffer_obj(dev, ringbuf); |
1566 | if (ret) { | 1576 | if (ret) { |
1567 | DRM_ERROR("Failed to allocate ringbuffer %s: %d\n", ring->name, ret); | 1577 | DRM_ERROR("Failed to allocate ringbuffer %s: %d\n", ring->name, ret); |
1568 | goto error; | 1578 | goto error; |
@@ -1603,11 +1613,7 @@ void intel_cleanup_ring_buffer(struct intel_engine_cs *ring) | |||
1603 | intel_stop_ring_buffer(ring); | 1613 | intel_stop_ring_buffer(ring); |
1604 | WARN_ON(!IS_GEN2(ring->dev) && (I915_READ_MODE(ring) & MODE_IDLE) == 0); | 1614 | WARN_ON(!IS_GEN2(ring->dev) && (I915_READ_MODE(ring) & MODE_IDLE) == 0); |
1605 | 1615 | ||
1606 | iounmap(ringbuf->virtual_start); | 1616 | intel_destroy_ringbuffer_obj(ringbuf); |
1607 | |||
1608 | i915_gem_object_ggtt_unpin(ringbuf->obj); | ||
1609 | drm_gem_object_unreference(&ringbuf->obj->base); | ||
1610 | ringbuf->obj = NULL; | ||
1611 | ring->preallocated_lazy_request = NULL; | 1617 | ring->preallocated_lazy_request = NULL; |
1612 | ring->outstanding_lazy_seqno = 0; | 1618 | ring->outstanding_lazy_seqno = 0; |
1613 | 1619 | ||