public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Ben Widawsky <ben@bwidawsk.net>
To: Chris Wilson <chris@chris-wilson.co.uk>,
	Ben Widawsky <benjamin.widawsky@intel.com>,
	intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 4/6] drm/i915: Add bind/unbind object functions to VM
Date: Mon, 16 Sep 2013 22:44:29 -0700	[thread overview]
Message-ID: <20130917054428.GA2585@bwidawsk.net> (raw)
In-Reply-To: <20130916221302.GA24051@nuc-i3427.alporthouse.com>

On Mon, Sep 16, 2013 at 11:13:02PM +0100, Chris Wilson wrote:
> On Mon, Sep 16, 2013 at 11:23:43AM -0700, Ben Widawsky wrote:
> > On Mon, Sep 16, 2013 at 10:25:28AM +0100, Chris Wilson wrote:
> > > On Sat, Sep 14, 2013 at 03:03:17PM -0700, Ben Widawsky wrote:
> > > > +static void gen6_ggtt_bind_vma(struct i915_vma *vma,
> > > > +			       enum i915_cache_level cache_level,
> > > > +			       u32 flags)
> > > > +{
> > > > +	struct drm_device *dev = vma->vm->dev;
> > > > +	struct drm_i915_private *dev_priv = dev->dev_private;
> > > > +	struct drm_i915_gem_object *obj = vma->obj;
> > > > +	const unsigned long entry = vma->node.start >> PAGE_SHIFT;
> > > > +
> > > > +	/* If there is an aliasing PPGTT, and the user didn't explicitly ask for
> > > > +	 * the global, just use aliasing */
> > > > +	if (!dev_priv->mm.aliasing_ppgtt || flags & GLOBAL_BIND) {
> > > > +		/* If the object is unbound, or we're change the cache bits */
> > > > +		if (!obj->has_global_gtt_mapping ||
> > > > +		    (cache_level != obj->cache_level)) {
> > > > +			gen6_ggtt_insert_entries(vma->vm, obj->pages, entry,
> > > > +						 cache_level);
> > > > +			obj->has_global_gtt_mapping = 1;
> > > > +		}
> > > > +	}
> > > > +
> > > > +	/* If put the mapping in the aliasing PPGTT as well as Global if we have
> > > > +	 * aliasing, but the user requested global. */
> > > 
> > > Why? As a proponent of full-ppgtt I thought you would be envisoning a
> > > future where the aliasing_ppgtt was used far less (i.e. never), and the
> > > ggtt would only continue to be used for the truly global entries such as
> > > scanouts, contexts, pdes, execlists etc.
> > > 
> > 
> > Firstly, I've still yet to expose the grand plan at this point in the
> > series, so I am not really certain if you're just complaining for the
> > fun of it, or what. I'd like to make everything functionally the same,
> > just with VMA support.
> 
> I'm complaining because the comment is awful: telling me what the code
> is doing but not why. It doesn't seem obvious that if the user
> explicitly wanted a global mapping and that the object is not already in
> aliasing ppgtt that it is likely to be used in the aliasing ppgtt in the
> near future.
> 
> > Secondly, I was under the impression that for Sandybridge we had to have
> > all global mappings in the aliasing to support PIPE_CONTROL, or some
> > command like that. It's a bit mixed up in my head atm, and I'm too lazy
> > to look at the exact reason.
> 
> It does, but if we never enable full-ppgtt for SNB we don't have to
> worry about full-ppgtt being unusable for OpenGL (at least not without a
> 1:1 ppgtt to global mapping of all oq objects).
> -Chris
> 
> -- 
> Chris Wilson, Intel Open Source Technology Centre

I'm sorry. After reading my comments again, you're absolutely right.

How's this?

diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 2a71a29..fcf36ae 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -658,10 +658,17 @@ static void gen6_ggtt_bind_vma(struct i915_vma *vma,
        struct drm_i915_gem_object *obj = vma->obj;
        const unsigned long entry = vma->node.start >> PAGE_SHIFT;
 
-       /* If there is an aliasing PPGTT, and the user didn't explicitly ask for
-        * the global, just use aliasing */
+       /* If there is no aliasing PPGTT, or the caller needs a global mapping,
+        * or we have a global mapping already but the cacheability flags have
+        * changed, set the global PTES.
+        *
+        * If there is an aliasing PPGTT it is anecdotally faster, so use that
+        * instead if none of the above hold true.
+        *
+        * NB: A global mapping should only be needed for special regions like
+        * "gtt mappable", SNB errata, or if specified via special execbuf flags
+        */
        if (!dev_priv->mm.aliasing_ppgtt || flags & GLOBAL_BIND) {
-               /* If the object is unbound, or we're change the cache bits */
                if (!obj->has_global_gtt_mapping ||
                    (cache_level != obj->cache_level)) {
                        gen6_ggtt_insert_entries(vma->vm, obj->pages, entry,
@@ -670,8 +677,6 @@ static void gen6_ggtt_bind_vma(struct i915_vma *vma,
                }
        }
 
-       /* If put the mapping in the aliasing PPGTT as well as Global if we have
-        * aliasing, but the user requested global. */
        if (dev_priv->mm.aliasing_ppgtt &&
            (!obj->has_aliasing_ppgtt_mapping ||
             (cache_level != obj->cache_level))) {


-- 
Ben Widawsky, Intel Open Source Technology Center

  reply	other threads:[~2013-09-17  5:44 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-14 22:03 [PATCH 1/6] drm/i915: trace vm eviction instead of everything Ben Widawsky
2013-09-14 22:03 ` [PATCH 2/6] drm/i915: Provide a cheap ggtt vma lookup Ben Widawsky
2013-09-14 22:03 ` [PATCH 3/6] drm/i915: Convert active API to VMA Ben Widawsky
2013-09-14 22:03 ` [PATCH 4/6] drm/i915: Add bind/unbind object functions to VM Ben Widawsky
2013-09-16  9:25   ` Chris Wilson
2013-09-16 18:23     ` Ben Widawsky
2013-09-16 22:05       ` Daniel Vetter
2013-09-16 22:18         ` Chris Wilson
2013-09-16 22:20           ` Daniel Vetter
2013-09-16 22:13       ` Chris Wilson
2013-09-17  5:44         ` Ben Widawsky [this message]
2013-09-17  7:49           ` Chris Wilson
2013-09-17 17:00             ` [PATCH 4/6] [v5] " Ben Widawsky
2013-09-14 22:03 ` [PATCH 5/6] drm/i915: Use the new vm [un]bind functions Ben Widawsky
2013-09-16  7:37   ` Chris Wilson
2013-09-16 18:31     ` Ben Widawsky
2013-09-17 17:01     ` [PATCH 5/6] [v3] " Ben Widawsky
2013-09-17 20:55       ` Chris Wilson
2013-09-17 23:14         ` Ben Widawsky
2013-09-17 23:33           ` Chris Wilson
2013-09-17 23:48             ` Ben Widawsky
2013-09-17 23:57               ` Chris Wilson
2013-09-18  0:02                 ` Ben Widawsky
2013-09-18  8:30                   ` Chris Wilson
2013-09-18 14:47                     ` Ben Widawsky
2013-09-18 14:53                       ` Chris Wilson
2013-09-18 15:48                         ` Ben Widawsky
2013-09-18 15:59                           ` Chris Wilson
2013-09-18 16:11                             ` Ben Widawsky
2013-09-18 16:15                               ` Chris Wilson
2013-09-18 16:20                                 ` Daniel Vetter
2013-09-18 16:37                                   ` Ben Widawsky
2013-09-19  0:12                                 ` [PATCH] [v4] " Ben Widawsky
2013-09-19  9:13                                   ` Chris Wilson
2013-09-19 14:15                                     ` [PATCH] [v5] " Ben Widawsky
2013-09-19 14:26                                       ` Chris Wilson
2013-09-19 14:41                                         ` [PATCH] [v6] " Ben Widawsky
2013-09-19 14:45                                           ` [PATCH] [v7] " Ben Widawsky
2013-09-20  4:06                                             ` [PATCH] " Ben Widawsky
2013-09-20 10:43                                               ` Chris Wilson
2013-09-20 13:24                                                 ` Daniel Vetter
2013-09-20 13:26                                                   ` Daniel Vetter
2013-09-20 13:29                                                   ` Chris Wilson
2013-09-20 20:44                                                 ` Ben Widawsky
2013-09-20 20:55                                                   ` Chris Wilson
2013-09-20 21:08                                                     ` Ben Widawsky
2013-09-20 21:22                                                     ` Daniel Vetter
2013-09-22 18:46                                                 ` [PATCH] [v9] " Ben Widawsky
2013-09-23  8:39                                                   ` Chris Wilson
2013-09-23 22:00                                                     ` Ben Widawsky
2013-09-23 22:10                                                       ` Chris Wilson
2013-09-19 14:47                                           ` [PATCH] [v6] " Chris Wilson
2013-09-19 17:41                                             ` Ben Widawsky
2013-09-19 18:36                                               ` Daniel Vetter
2013-09-14 22:03 ` [PATCH 6/6] drm/i915: eliminate vm->insert_entries() Ben Widawsky
  -- strict thread matches above, loose matches on Subject: below --
2013-09-24 16:57 [PATCH 1/6] drm/i915: trace vm eviction instead of everything Ben Widawsky
2013-09-24 16:57 ` [PATCH 4/6] drm/i915: Add bind/unbind object functions to VM Ben Widawsky

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=20130917054428.GA2585@bwidawsk.net \
    --to=ben@bwidawsk.net \
    --cc=benjamin.widawsky@intel.com \
    --cc=chris@chris-wilson.co.uk \
    --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