From: oscar.mateo@intel.com
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 5/8] drm/i915: Extract ringbuffer destroy & generalize alloc to take a ringbuf
Date: Thu, 26 Jun 2014 14:24:16 +0100 [thread overview]
Message-ID: <1403789059-5692-6-git-send-email-oscar.mateo@intel.com> (raw)
In-Reply-To: <1403789059-5692-1-git-send-email-oscar.mateo@intel.com>
From: Oscar Mateo <oscar.mateo@intel.com>
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.
Signed-off-by: Oscar Mateo <oscar.mateo@intel.com>
---
drivers/gpu/drm/i915/intel_ringbuffer.c | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index 2faef26..ffdb366 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -1380,15 +1380,25 @@ static int init_phys_status_page(struct intel_engine_cs *ring)
return 0;
}
-static int allocate_ring_buffer(struct intel_engine_cs *ring)
+static void intel_destroy_ringbuffer_obj(struct intel_ringbuffer *ringbuf)
+{
+ if (!ringbuf->obj)
+ return;
+
+ iounmap(ringbuf->virtual_start);
+ i915_gem_object_ggtt_unpin(ringbuf->obj);
+ drm_gem_object_unreference(&ringbuf->obj->base);
+ ringbuf->obj = NULL;
+}
+
+static int intel_alloc_ringbuffer_obj(struct drm_device *dev,
+ struct intel_ringbuffer *ringbuf)
{
- struct drm_device *dev = ring->dev;
struct drm_i915_private *dev_priv = to_i915(dev);
- struct intel_ringbuffer *ringbuf = ring->buffer;
struct drm_i915_gem_object *obj;
int ret;
- if (intel_ring_initialized(ring))
+ if (ringbuf->obj)
return 0;
obj = NULL;
@@ -1460,7 +1470,7 @@ static int intel_init_ring_buffer(struct drm_device *dev,
goto error;
}
- ret = allocate_ring_buffer(ring);
+ ret = intel_alloc_ringbuffer_obj(dev, ringbuf);
if (ret) {
DRM_ERROR("Failed to allocate ringbuffer %s: %d\n", ring->name, ret);
goto error;
@@ -1501,11 +1511,7 @@ void intel_cleanup_ring_buffer(struct intel_engine_cs *ring)
intel_stop_ring_buffer(ring);
WARN_ON(!IS_GEN2(ring->dev) && (I915_READ_MODE(ring) & MODE_IDLE) == 0);
- iounmap(ringbuf->virtual_start);
-
- i915_gem_object_ggtt_unpin(ringbuf->obj);
- drm_gem_object_unreference(&ringbuf->obj->base);
- ringbuf->obj = NULL;
+ intel_destroy_ringbuffer_obj(ringbuf);
ring->preallocated_lazy_request = NULL;
ring->outstanding_lazy_seqno = 0;
--
1.9.0
next prev parent reply other threads:[~2014-06-26 13:29 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-26 13:24 [PATCH 0/8] Execlists prep-work (II) oscar.mateo
2014-06-26 13:24 ` [PATCH 1/8] drm/i915: Extract context backing object allocation oscar.mateo
2014-06-30 20:46 ` Jesse Barnes
2014-06-26 13:24 ` [PATCH 2/8] drm/i915: Rename ctx->obj to ctx->rcs_state oscar.mateo
2014-06-30 20:49 ` Jesse Barnes
2014-07-03 9:46 ` Chris Wilson
2014-07-03 12:08 ` Mateo Lozano, Oscar
2014-07-03 12:28 ` Chris Wilson
2014-07-03 14:06 ` Mateo Lozano, Oscar
2014-06-26 13:24 ` [PATCH 3/8] drm/i915: Rename ctx->is_initialized to ctx->rcs_is_initialized oscar.mateo
2014-06-30 20:50 ` Jesse Barnes
2014-07-03 9:49 ` Chris Wilson
2014-07-03 12:09 ` Mateo Lozano, Oscar
2014-06-26 13:24 ` [PATCH 4/8] drm/i915: Rename ctx->id to ctx->handle oscar.mateo
2014-06-30 20:53 ` Jesse Barnes
2014-07-01 15:46 ` Mateo Lozano, Oscar
2014-07-01 16:07 ` Jesse Barnes
2014-07-03 9:30 ` Chris Wilson
2014-07-03 9:52 ` Chris Wilson
2014-07-03 12:01 ` Mateo Lozano, Oscar
2014-07-07 15:48 ` Daniel Vetter
2014-06-26 13:24 ` oscar.mateo [this message]
2014-06-30 20:57 ` [PATCH 5/8] drm/i915: Extract ringbuffer destroy & generalize alloc to take a ringbuf Jesse Barnes
2014-06-26 13:24 ` [PATCH 6/8] drm/i915: Generalize ring_space " oscar.mateo
2014-06-30 20:58 ` Jesse Barnes
2014-06-26 13:24 ` [PATCH 7/8] drm/i915: Generalize intel_ring_get_tail " oscar.mateo
2014-06-30 20:59 ` Jesse Barnes
2014-06-26 13:24 ` [PATCH 8/8] drm/i915: Extract the actual workload submission mechanism from execbuffer oscar.mateo
2014-06-30 21:02 ` Jesse Barnes
2014-07-03 7:32 ` Chris Wilson
2014-07-03 9:07 ` Mateo Lozano, Oscar
2014-07-03 9:28 ` Chris Wilson
-- strict thread matches above, loose matches on Subject: below --
2014-07-03 15:27 [PATCH 1/8] drm/i915: Extract context backing object allocation oscar.mateo
2014-07-03 15:28 ` [PATCH 5/8] drm/i915: Extract ringbuffer destroy & generalize alloc to take a ringbuf oscar.mateo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1403789059-5692-6-git-send-email-oscar.mateo@intel.com \
--to=oscar.mateo@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox