From: Mika Kuoppala <mika.kuoppala@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Subject: Re: [Intel-gfx] [PATCH] drm/i915: Discard a misplaced GGTT vma
Date: Fri, 29 May 2020 17:24:17 +0300 [thread overview]
Message-ID: <87y2pastta.fsf@gaia.fi.intel.com> (raw)
In-Reply-To: <20200529130019.17977-1-chris@chris-wilson.co.uk>
Chris Wilson <chris@chris-wilson.co.uk> writes:
> Across the many users of the GGTT vma (internal objects, mmapings,
> display etc), we may end up with conflicting requirements for the
> placement. Currently, we try to resolve the conflict by unbinding the
> vma and rebinding it to match the new constraints; over time we will end
> up with a GGTT that matches the most strict constraints over all
> concurrent users. However, this causes a problem if the vma is currently
> in use as we must wait until it is idle before moving it. But there is
> no restriction on the number of views we may (apart from the limited
we may...have/impose?
-Mika
> size of the GGTT itself), and so if the active vma does not meet our
> requirements, try and build a new one!
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
> drivers/gpu/drm/i915/i915_gem.c | 44 +++++++++++++++++++++++++++++++++
> 1 file changed, 44 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 0cbcb9f54e7d..29a4594ddef2 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -933,6 +933,44 @@ void i915_gem_runtime_suspend(struct drm_i915_private *i915)
> }
> }
>
> +static bool
> +discard_ggtt_vma(struct i915_vma *vma, const struct i915_ggtt_view *view)
> +{
> + const struct i915_ggtt_view discard = {
> + .type = I915_GGTT_VIEW_PARTIAL,
> + };
> + struct drm_i915_gem_object *obj = vma->obj;
> +
> + spin_lock(&obj->vma.lock);
> + if (i915_vma_compare(vma, vma->vm, &discard)) {
> + struct rb_node *rb, **p;
> +
> + rb_erase(&vma->obj_node, &obj->vma.tree);
> + vma->ggtt_view = discard;
> +
> + rb = NULL;
> + p = &obj->vma.tree.rb_node;
> + while (*p) {
> + struct i915_vma *pos;
> + long cmp;
> +
> + rb = *p;
> + pos = rb_entry(rb, struct i915_vma, obj_node);
> +
> + cmp = i915_vma_compare(pos, vma->vm, &discard);
> + if (cmp < 0)
> + p = &rb->rb_right;
> + else
> + p = &rb->rb_left;
> + }
> + rb_link_node(&vma->obj_node, rb, p);
> + rb_insert_color(&vma->obj_node, &obj->vma.tree);
> + }
> + spin_unlock(&obj->vma.lock);
> +
> + return i915_vma_compare(vma, vma->vm, view);
> +}
> +
> struct i915_vma *
> i915_gem_object_ggtt_pin(struct drm_i915_gem_object *obj,
> const struct i915_ggtt_view *view,
> @@ -979,6 +1017,7 @@ i915_gem_object_ggtt_pin(struct drm_i915_gem_object *obj,
> return ERR_PTR(-ENOSPC);
> }
>
> +new_vma:
> vma = i915_vma_instance(obj, &ggtt->vm, view);
> if (IS_ERR(vma))
> return vma;
> @@ -993,6 +1032,11 @@ i915_gem_object_ggtt_pin(struct drm_i915_gem_object *obj,
> return ERR_PTR(-ENOSPC);
> }
>
> + if (i915_vma_is_pinned(vma) || i915_vma_is_active(vma)) {
> + if (discard_ggtt_vma(vma, view))
> + goto new_vma;
> + }
> +
> ret = i915_vma_unbind(vma);
> if (ret)
> return ERR_PTR(ret);
> --
> 2.20.1
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2020-05-29 14:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-29 13:00 [Intel-gfx] [PATCH] drm/i915: Discard a misplaced GGTT vma Chris Wilson
2020-05-29 14:11 ` [Intel-gfx] ✓ Fi.CI.BAT: success for " Patchwork
2020-05-29 14:24 ` Mika Kuoppala [this message]
2020-05-29 14:37 ` [Intel-gfx] [PATCH] " Chris Wilson
2020-05-29 16:11 ` [Intel-gfx] ✓ Fi.CI.IGT: success for " 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=87y2pastta.fsf@gaia.fi.intel.com \
--to=mika.kuoppala@linux.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.