From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 10/11] drm/i915: Mark the context and address space as closed
Date: Thu, 17 Dec 2015 14:15:52 +0000 [thread overview]
Message-ID: <5672C398.7050509@linux.intel.com> (raw)
In-Reply-To: <1450093012-14955-10-git-send-email-chris@chris-wilson.co.uk>
On 14/12/15 11:36, Chris Wilson wrote:
> When the user closes the context mark it and the dependent address space
> as closed. As we use an asynchronous destruct method, this has two purposes.
> First it allows us to flag the closed context and detect internal errors if
> we to create any new objects for it (as it is removed from the user's
> namespace, these should be internal bugs only). And secondly, it allows
> us to immediately reap stale vma.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
> drivers/gpu/drm/i915/i915_drv.h | 4 ++++
> drivers/gpu/drm/i915/i915_gem.c | 15 ++++++++-----
> drivers/gpu/drm/i915/i915_gem_context.c | 39 +++++++++++++++++++++++++++++----
> drivers/gpu/drm/i915/i915_gem_gtt.c | 11 +++++++---
> drivers/gpu/drm/i915/i915_gem_gtt.h | 9 ++++++++
> drivers/gpu/drm/i915/i915_gem_stolen.c | 2 +-
> 6 files changed, 66 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 696469a06715..66ecd6b3df95 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -892,6 +892,8 @@ struct intel_context {
> } engine[I915_NUM_RINGS];
>
> struct list_head link;
> +
> + bool closed:1;
> };
>
> enum fb_op_origin {
> @@ -2720,6 +2722,8 @@ int __must_check i915_vma_unbind(struct i915_vma *vma);
> * _guarantee_ VMA in question is _not in use_ anywhere.
> */
> int __must_check __i915_vma_unbind_no_wait(struct i915_vma *vma);
> +void i915_vma_close(struct i915_vma *vma);
> +
> int i915_gem_object_put_pages(struct drm_i915_gem_object *obj);
> void i915_gem_release_all_mmaps(struct drm_i915_private *dev_priv);
> void i915_gem_release_mmap(struct drm_i915_gem_object *obj);
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 7c13c27a6470..08ea0b7eda8b 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -2367,12 +2367,13 @@ i915_gem_object_flush_active(struct drm_i915_gem_object *obj)
> return 0;
> }
>
> -static void i915_vma_close(struct i915_vma *vma)
> +void i915_vma_close(struct i915_vma *vma)
> {
> RQ_BUG_ON(vma->closed);
> vma->closed = true;
>
> list_del_init(&vma->obj_link);
> + list_del_init(&vma->vm_link);
> if (!vma->active)
> WARN_ON(i915_vma_unbind(vma));
> }
> @@ -2620,12 +2621,13 @@ static int __i915_vma_unbind(struct i915_vma *vma, bool wait)
> return ret;
> }
>
> - trace_i915_vma_unbind(vma);
> -
> - vma->vm->unbind_vma(vma);
> + if (likely(!vma->vm->closed)) {
> + trace_i915_vma_unbind(vma);
> + vma->vm->unbind_vma(vma);
> + }
> vma->bound = 0;
>
> - list_del_init(&vma->vm_link);
> + list_move_tail(&vma->vm_link, &vma->vm->unbound_list);
> if (vma->is_ggtt) {
> if (vma->ggtt_view.type == I915_GGTT_VIEW_NORMAL) {
> obj->map_and_fenceable = false;
> @@ -2882,7 +2884,7 @@ search_free:
> goto err_remove_node;
>
> list_move_tail(&obj->global_list, &dev_priv->mm.bound_list);
> - list_add_tail(&vma->vm_link, &vm->inactive_list);
> + list_move_tail(&vma->vm_link, &vm->inactive_list);
>
> return vma;
>
> @@ -3890,6 +3892,7 @@ void i915_gem_vma_destroy(struct i915_vma *vma)
> if (!list_empty(&vma->exec_list))
> return;
>
> + list_del(&vma->vm_link);
> if (!vma->is_ggtt)
> i915_ppgtt_put(i915_vm_to_ppgtt(vma->vm));
>
> diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
> index c4a8a64cd1b2..9669547c7c2d 100644
> --- a/drivers/gpu/drm/i915/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/i915_gem_context.c
> @@ -153,6 +153,7 @@ void i915_gem_context_free(struct kref *ctx_ref)
> struct intel_context *ctx = container_of(ctx_ref, typeof(*ctx), ref);
>
> trace_i915_context_free(ctx);
> + RQ_BUG_ON(!ctx->closed);
>
> if (i915.enable_execlists)
> intel_lr_context_free(ctx);
> @@ -209,6 +210,36 @@ i915_gem_alloc_context_obj(struct drm_device *dev, size_t size)
> return obj;
> }
>
> +static void i915_ppgtt_close(struct i915_address_space *vm)
> +{
> + struct list_head *phases[] = {
> + &vm->active_list,
> + &vm->inactive_list,
> + &vm->unbound_list,
> + NULL,
> + }, **phase;
> +
> + RQ_BUG_ON(vm->is_ggtt);
> + RQ_BUG_ON(vm->closed);
> + vm->closed = true;
> +
> + for (phase = phases; *phase; phase++) {
> + struct i915_vma *vma, *vn;
> +
> + list_for_each_entry_safe(vma, vn, *phase, vm_link)
> + i915_vma_close(vma);
> + }
> +}
Hm so VMAs get unlinked from everywhere, but then on retire goes back to
inactive. Is it not a bit weird?
Why it is needed to unlink VMAs from everywhere when marking them as closed?
And actually on retire objects are ahead of VMAs in the req->active_list
so the last object unreference happens before the last vma is retired,
which is even weirder.
Am I missing something?
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2015-12-17 14:16 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-14 11:36 [PATCH 01/11] drm/i915: Introduce drm_i915_gem_request_node for request tracking Chris Wilson
2015-12-14 11:36 ` [PATCH 02/11] drm/i915: Refactor activity tracking for requests Chris Wilson
2015-12-16 17:16 ` Tvrtko Ursulin
2015-12-16 17:31 ` Chris Wilson
2015-12-14 11:36 ` [PATCH 03/11] drm/i915: Rename vma->*_list to *_link for consistency Chris Wilson
2015-12-17 11:14 ` Tvrtko Ursulin
2015-12-17 11:24 ` Chris Wilson
2015-12-17 11:45 ` Chris Wilson
2015-12-14 11:36 ` [PATCH 04/11] drm/i915: Amalgamate GGTT/ppGTT vma debug list walkers Chris Wilson
2015-12-17 11:21 ` Tvrtko Ursulin
2015-12-14 11:36 ` [PATCH 05/11] drm/i915: Reduce the pointer dance of i915_is_ggtt() Chris Wilson
2015-12-17 11:31 ` Tvrtko Ursulin
2015-12-14 11:36 ` [PATCH 06/11] drm/i915: Store owning file on the i915_address_space Chris Wilson
2015-12-17 11:52 ` Tvrtko Ursulin
2015-12-17 13:25 ` Chris Wilson
2015-12-14 11:36 ` [PATCH 07/11] drm/i915: i915_vma_move_to_active prep patch Chris Wilson
2015-12-17 12:04 ` Tvrtko Ursulin
2015-12-14 11:36 ` [PATCH 08/11] drm/i915: Track active vma requests Chris Wilson
2015-12-17 12:26 ` Tvrtko Ursulin
2015-12-14 11:36 ` [PATCH 09/11] drm/i915: Release vma when the handle is closed Chris Wilson
2015-12-17 13:46 ` Tvrtko Ursulin
2015-12-17 14:11 ` Chris Wilson
2015-12-17 14:21 ` Chris Wilson
2015-12-17 14:32 ` Tvrtko Ursulin
2015-12-14 11:36 ` [PATCH 10/11] drm/i915: Mark the context and address space as closed Chris Wilson
2015-12-17 12:37 ` Tvrtko Ursulin
2015-12-17 12:39 ` Tvrtko Ursulin
2015-12-17 12:48 ` Chris Wilson
2015-12-17 13:26 ` Tvrtko Ursulin
2015-12-17 14:15 ` Tvrtko Ursulin [this message]
2015-12-17 14:26 ` Chris Wilson
2015-12-17 14:35 ` Tvrtko Ursulin
2015-12-14 11:36 ` [PATCH 11/11] Revert "drm/i915: Clean up associated VMAs on context destruction" Chris Wilson
2015-12-14 15:58 ` [PATCH 01/11] drm/i915: Introduce drm_i915_gem_request_node for request tracking Tvrtko Ursulin
2015-12-14 16:11 ` Chris Wilson
2015-12-15 10:51 ` [PATCH v2] drm/i915: Introduce drm_i915_gem_request_active " Chris Wilson
2015-12-17 14:48 ` ✗ failure: UK.CI.checkpatch.pl 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=5672C398.7050509@linux.intel.com \
--to=tvrtko.ursulin@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox