On Wed, Jan 13, 2016 at 04:19:45PM +0000, Nick Hoath wrote:
> +     if (ctx->engine[ring->id].dirty) {
> +             struct drm_i915_gem_request *req = NULL;
> +
> +             /**
> +              * If there is already a request pending on
> +              * this ring, wait for that to complete,
> +              * otherwise create a switch to idle request
> +              */
> +             if (list_empty(&ring->request_list)) {
> +                     int ret;
> +
> +                     ret = i915_gem_request_alloc(
> +                                     ring,
> +                                     ring->default_context,
> +                                     &req);
> +                     if (!ret)
> +                             i915_add_request(req);
> +                     else
> +                             DRM_DEBUG("Failed to ensure context saved");
> +             } else {
> +                     req = list_first_entry(
> +                                     &ring->request_list,
> +                                     typeof(*req), list);
> +             }
> +             if (req) {
> +                     ret = i915_wait_request(req);
> +                     if (ret != 0) {
> +                             /**
> +                              * If we get here, there's probably been a ring
> +                              * reset, so we just clean up the dirty flag.&
> +                              * pin count.
> +                              */
> +                             ctx->engine[ring->id].dirty = false;
> +                             __intel_lr_context_unpin(
> +                                     ring,
> +                                     ctx);
> +                     }
> +             }

If you were to take a lr_context_pin on the last_context, and only
release that pin when you change to a new context, you do not need to
introduce a blocking context-close, nor do you need to introduce the
usage of default_context.

(lr_context_pin should take a reference on the ctx to prevent early
freeeing ofc).

The code at that point starts to look v.v.similar to legacy, right down
to the need to use a GPU reset during shutdown to prevent writing back
the context image. (Which you still currently need to get rid of the
default context now.)
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to