From: oscar.mateo@intel.com
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 3/8] drm/i915: Enable the PPGTT in the ring init
Date: Wed, 18 Jun 2014 17:15:37 +0100 [thread overview]
Message-ID: <1403108138-6366-3-git-send-email-oscar.mateo@intel.com> (raw)
In-Reply-To: <1403108138-6366-1-git-send-email-oscar.mateo@intel.com>
From: Oscar Mateo <oscar.mateo@intel.com>
PPGTT enabling is per-ring on GEN7+, so it makes sense that the enable
functions takes a ring argument. GEN6 can live with multiple calls to
the enable function.
And, more importantly, this allows us to enable the PPGTT from the ring
init code (the place where all the initializations should be done).
Signed-off-by: Oscar Mateo <oscar.mateo@intel.com>
---
drivers/gpu/drm/i915/i915_gem_context.c | 7 ---
drivers/gpu/drm/i915/i915_gem_gtt.c | 79 +++++++++++++++------------------
drivers/gpu/drm/i915/i915_gem_gtt.h | 3 +-
drivers/gpu/drm/i915/intel_ringbuffer.c | 6 +++
4 files changed, 43 insertions(+), 52 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index 14cd7fc..bf07d9d 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -471,13 +471,6 @@ int i915_gem_context_enable(struct drm_i915_private *dev_priv)
struct intel_engine_cs *ring;
int ret, i;
- /* This is the only place the aliasing PPGTT gets enabled, which means
- * it has to happen before we bail on reset */
- if (dev_priv->mm.aliasing_ppgtt) {
- struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt;
- ppgtt->enable(ppgtt);
- }
-
/* FIXME: We should make this work, even in reset */
if (i915_reset_in_progress(&dev_priv->gpu_error))
return 0;
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 49f103f..63507eb 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -77,7 +77,8 @@ static void ppgtt_bind_vma(struct i915_vma *vma,
enum i915_cache_level cache_level,
u32 flags);
static void ppgtt_unbind_vma(struct i915_vma *vma);
-static int gen8_ppgtt_enable(struct i915_hw_ppgtt *ppgtt);
+static int gen8_ppgtt_enable(struct i915_hw_ppgtt *ppgtt,
+ struct intel_engine_cs *ring);
static inline gen8_gtt_pte_t gen8_pte_encode(dma_addr_t addr,
enum i915_cache_level level,
@@ -928,43 +929,38 @@ static int gen6_mm_switch(struct i915_hw_ppgtt *ppgtt,
return 0;
}
-static int gen8_ppgtt_enable(struct i915_hw_ppgtt *ppgtt)
+static int gen8_ppgtt_enable(struct i915_hw_ppgtt *ppgtt,
+ struct intel_engine_cs *ring)
{
struct drm_device *dev = ppgtt->base.dev;
struct drm_i915_private *dev_priv = dev->dev_private;
- struct intel_engine_cs *ring;
- int j, ret;
+ int ret;
- for_each_ring(ring, dev_priv, j) {
- I915_WRITE(RING_MODE_GEN7(ring),
- _MASKED_BIT_ENABLE(GFX_PPGTT_ENABLE));
+ I915_WRITE(RING_MODE_GEN7(ring),
+ _MASKED_BIT_ENABLE(GFX_PPGTT_ENABLE));
- /* We promise to do a switch later with FULL PPGTT. If this is
- * aliasing, this is the one and only switch we'll do */
- if (USES_FULL_PPGTT(dev))
- continue;
+ /* We promise to do a switch later with FULL PPGTT. If this is
+ * aliasing, this is the one and only switch we'll do */
+ if (USES_FULL_PPGTT(dev))
+ return 0;
- ret = ppgtt->sync_switch_mm(ppgtt, ring);
- if (ret)
- goto err_out;
+ ret = ppgtt->sync_switch_mm(ppgtt, ring);
+ if (ret) {
+ I915_WRITE(RING_MODE_GEN7(ring),
+ _MASKED_BIT_DISABLE(GFX_PPGTT_ENABLE));
+ return ret;
}
return 0;
-
-err_out:
- for_each_ring(ring, dev_priv, j)
- I915_WRITE(RING_MODE_GEN7(ring),
- _MASKED_BIT_DISABLE(GFX_PPGTT_ENABLE));
- return ret;
}
-static int gen7_ppgtt_enable(struct i915_hw_ppgtt *ppgtt)
+static int gen7_ppgtt_enable(struct i915_hw_ppgtt *ppgtt,
+ struct intel_engine_cs *ring)
{
struct drm_device *dev = ppgtt->base.dev;
struct drm_i915_private *dev_priv = dev->dev_private;
- struct intel_engine_cs *ring;
uint32_t ecochk, ecobits;
- int i;
+ int ret;
ecobits = I915_READ(GAC_ECO_BITS);
I915_WRITE(GAC_ECO_BITS, ecobits | ECOBITS_PPGTT_CACHE64B);
@@ -978,32 +974,29 @@ static int gen7_ppgtt_enable(struct i915_hw_ppgtt *ppgtt)
}
I915_WRITE(GAM_ECOCHK, ecochk);
- for_each_ring(ring, dev_priv, i) {
- int ret;
- /* GFX_MODE is per-ring on gen7+ */
- I915_WRITE(RING_MODE_GEN7(ring),
- _MASKED_BIT_ENABLE(GFX_PPGTT_ENABLE));
+ /* GFX_MODE is per-ring on gen7+ */
+ I915_WRITE(RING_MODE_GEN7(ring),
+ _MASKED_BIT_ENABLE(GFX_PPGTT_ENABLE));
- /* We promise to do a switch later with FULL PPGTT. If this is
- * aliasing, this is the one and only switch we'll do */
- if (USES_FULL_PPGTT(dev))
- continue;
+ /* We promise to do a switch later with FULL PPGTT. If this is
+ * aliasing, this is the one and only switch we'll do */
+ if (USES_FULL_PPGTT(dev))
+ return 0;
- ret = ppgtt->sync_switch_mm(ppgtt, ring);
- if (ret)
- return ret;
- }
+ ret = ppgtt->sync_switch_mm(ppgtt, ring);
+ if (ret)
+ return ret;
return 0;
}
-static int gen6_ppgtt_enable(struct i915_hw_ppgtt *ppgtt)
+static int gen6_ppgtt_enable(struct i915_hw_ppgtt *ppgtt,
+ struct intel_engine_cs *ring)
{
struct drm_device *dev = ppgtt->base.dev;
struct drm_i915_private *dev_priv = dev->dev_private;
- struct intel_engine_cs *ring;
uint32_t ecochk, gab_ctl, ecobits;
- int i;
+ int ret;
ecobits = I915_READ(GAC_ECO_BITS);
I915_WRITE(GAC_ECO_BITS, ecobits | ECOBITS_SNB_BIT |
@@ -1017,11 +1010,9 @@ static int gen6_ppgtt_enable(struct i915_hw_ppgtt *ppgtt)
I915_WRITE(GFX_MODE, _MASKED_BIT_ENABLE(GFX_PPGTT_ENABLE));
- for_each_ring(ring, dev_priv, i) {
- int ret = ppgtt->sync_switch_mm(ppgtt, ring);
- if (ret)
- return ret;
- }
+ ret = ppgtt->sync_switch_mm(ppgtt, ring);
+ if (ret)
+ return ret;
return 0;
}
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.h b/drivers/gpu/drm/i915/i915_gem_gtt.h
index c260ada..15ed42f 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.h
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.h
@@ -261,7 +261,8 @@ struct i915_hw_ppgtt {
dma_addr_t scratch_dma_addr;
struct intel_context *ctx;
- int (*enable)(struct i915_hw_ppgtt *ppgtt);
+ int (*enable)(struct i915_hw_ppgtt *ppgtt,
+ struct intel_engine_cs *ring);
int (*sync_switch_mm)(struct i915_hw_ppgtt *ppgtt,
struct intel_engine_cs *ring);
int (*switch_mm)(struct i915_hw_ppgtt *ppgtt,
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index 0eaaaec..e53e32e 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -1426,6 +1426,7 @@ err_unref:
static int intel_init_ring_buffer(struct drm_device *dev,
struct intel_engine_cs *ring)
{
+ struct drm_i915_private *dev_priv = to_i915(dev);
struct intel_ringbuffer *ringbuf = ring->buffer;
int ret;
@@ -1477,6 +1478,11 @@ static int intel_init_ring_buffer(struct drm_device *dev,
if (ret)
goto error;
+ if (dev_priv->mm.aliasing_ppgtt) {
+ struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt;
+ ppgtt->enable(ppgtt, ring);
+ }
+
return 0;
error:
--
1.9.0
next prev parent reply other threads:[~2014-06-18 16:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-18 16:15 [PATCH 1/8] drm/i915: Get rid of the synchronous flag in switch_mm oscar.mateo
2014-06-18 16:15 ` [PATCH 2/8] drm/i915/bdw: If we are in reset, switch the GEN8 ppgtt synchronously oscar.mateo
2014-06-18 16:15 ` oscar.mateo [this message]
2014-06-18 16:15 ` [PATCH 4/8] drm/i915: Split PPGTT enabling from Aliasing PPGTT switching oscar.mateo
2014-06-18 16:27 ` [PATCH 1/8] drm/i915: Get rid of the synchronous flag in switch_mm Mateo Lozano, Oscar
2014-06-18 19:50 ` Daniel Vetter
2014-06-19 14:00 ` Mateo Lozano, Oscar
2014-06-19 16:03 ` Daniel Vetter
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=1403108138-6366-3-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