From: Dave Gordon <david.s.gordon@intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH v5 02/11] drm/i915: consolidate LRC mode HWSP setup & teardown
Date: Fri, 5 Feb 2016 18:33:39 +0000 [thread overview]
Message-ID: <1454697228-33164-3-git-send-email-david.s.gordon@intel.com> (raw)
In-Reply-To: <1454697228-33164-1-git-send-email-david.s.gordon@intel.com>
In legacy ringbuffer mode, the HWSP is a separate GEM object with its
own pinning and reference counts. In LRC mode, however, it's not;
instead its part of the default context object. The LRC-mode setup &
teardown code therefore needs to handle this specially; the presence
of the two bugs fixed in this patchset suggests that this code is not
well-understood or maintained at present.
So, this patch:
moves the (newly-fixed!) LRC-mode HWSP teardown code to its own
(trivial) function lrc_teardown_hardware_status_page(), and
changes the call signature of lrc_setup_hardware_status_page()
to match
so that all knowledge of this special arrangement is local to these
two functions.
v3: Rebased
Signed-off-by: Dave Gordon <david.s.gordon@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
---
drivers/gpu/drm/i915/intel_lrc.c | 41 +++++++++++++++++++++++-----------------
1 file changed, 24 insertions(+), 17 deletions(-)
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index c551c97..148d291 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -227,9 +227,8 @@ enum {
static int intel_lr_context_pin(struct intel_context *ctx,
struct intel_engine_cs *engine);
-static void lrc_setup_hardware_status_page(struct intel_engine_cs *ring,
- struct drm_i915_gem_object *default_ctx_obj);
-
+static void lrc_setup_hardware_status_page(struct intel_engine_cs *ring);
+static void lrc_teardown_hardware_status_page(struct intel_engine_cs *ring);
/**
* intel_sanitize_enable_execlists() - sanitize i915.enable_execlists
@@ -1555,8 +1554,7 @@ static int gen8_init_common_ring(struct intel_engine_cs *ring)
struct drm_i915_private *dev_priv = dev->dev_private;
u8 next_context_status_buffer_hw;
- lrc_setup_hardware_status_page(ring,
- dev_priv->kernel_context->engine[ring->id].state);
+ lrc_setup_hardware_status_page(ring);
I915_WRITE_IMR(ring, ~(ring->irq_enable_mask | ring->irq_keep_mask));
I915_WRITE(RING_HWSTAM(ring->mmio_base), 0xffffffff);
@@ -2011,10 +2009,7 @@ void intel_logical_ring_cleanup(struct intel_engine_cs *ring)
i915_cmd_parser_fini_ring(ring);
i915_gem_batch_pool_fini(&ring->batch_pool);
- if (ring->status_page.obj) {
- kunmap(kmap_to_page(ring->status_page.page_addr));
- ring->status_page.obj = NULL;
- }
+ lrc_teardown_hardware_status_page(ring);
ring->disable_lite_restore_wa = false;
ring->ctx_desc_template = 0;
@@ -2506,24 +2501,36 @@ uint32_t intel_lr_context_size(struct intel_engine_cs *ring)
return ret;
}
-static void lrc_setup_hardware_status_page(struct intel_engine_cs *ring,
- struct drm_i915_gem_object *default_ctx_obj)
+static void lrc_setup_hardware_status_page(struct intel_engine_cs *ring)
{
- struct drm_i915_private *dev_priv = ring->dev->dev_private;
+ struct drm_i915_private *dev_priv = to_i915(ring->dev);
+ struct intel_context *dctx = dev_priv->kernel_context;
+ struct drm_i915_gem_object *dctx_obj = dctx->engine[ring->id].state;
+ u64 dctx_addr = i915_gem_obj_ggtt_offset(dctx_obj);
struct page *page;
- /* The HWSP is part of the default context object in LRC mode. */
- ring->status_page.gfx_addr = i915_gem_obj_ggtt_offset(default_ctx_obj)
- + LRC_PPHWSP_PN * PAGE_SIZE;
- page = i915_gem_object_get_page(default_ctx_obj, LRC_PPHWSP_PN);
+ /*
+ * The HWSP is part of the default context object in LRC mode.
+ * Note that it doesn't contribute to the refcount!
+ */
+ page = i915_gem_object_get_page(dctx_obj, LRC_PPHWSP_PN);
ring->status_page.page_addr = kmap(page);
- ring->status_page.obj = default_ctx_obj;
+ ring->status_page.gfx_addr = dctx_addr + LRC_PPHWSP_PN * PAGE_SIZE;
+ ring->status_page.obj = dctx_obj;
I915_WRITE(RING_HWS_PGA(ring->mmio_base),
(u32)ring->status_page.gfx_addr);
POSTING_READ(RING_HWS_PGA(ring->mmio_base));
}
+static void lrc_teardown_hardware_status_page(struct intel_engine_cs *ring)
+{
+ if (ring->status_page.obj) {
+ kunmap(kmap_to_page(ring->status_page.page_addr));
+ ring->status_page.obj = NULL;
+ }
+}
+
/**
* intel_lr_context_deferred_alloc() - create the LRC specific bits of a context
* @ctx: LR context to create.
--
1.9.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2016-02-05 18:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-05 18:33 [PATCH v5 00/11] A collection of cleanups, revisited Dave Gordon
2016-02-05 18:33 ` [PATCH v5 01/11] drm/i915: unmap the correct page in intel_logical_ring_cleanup() Dave Gordon
2016-02-05 18:33 ` Dave Gordon [this message]
2016-02-05 18:33 ` [PATCH v5 03/11] drm/i915: remove useless copypasted code Dave Gordon
2016-02-05 18:33 ` [PATCH v5 04/11] drm/i915: tidy up initialisation failure paths (GEM) Dave Gordon
2016-02-05 18:33 ` [PATCH v5 05/11] drm/i915: tidy initialisation failure paths (legacy, part 1) Dave Gordon
2016-02-05 18:33 ` [PATCH v5 06/11] drm/i915: tidy initialisation failure paths (legacy, part 2) Dave Gordon
2016-02-05 18:33 ` [PATCH v5 07/11] drm/i915: tidy initialisation failure paths (legacy, part 3) Dave Gordon
2016-02-05 18:33 ` [PATCH v5 08/11] drm/i915: two small moves towards more consistency Dave Gordon
2016-02-05 18:33 ` [PATCH v5 09/11] drm/i915: tear down hardware status page mappings earlier Dave Gordon
2016-02-05 18:33 ` [PATCH v5 10/11] drm/i915: interchange context/engine cleanup order Dave Gordon
2016-02-05 18:33 ` [PATCH v5 11/11] drm/i915: make LRC status page teardown code a bit more robust Dave Gordon
2016-02-08 12:58 ` ✓ Fi.CI.BAT: success for A collection of cleanups, revisited Patchwork
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=1454697228-33164-3-git-send-email-david.s.gordon@intel.com \
--to=david.s.gordon@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;
as well as URLs for NNTP newsgroup(s).