drm/i915: Pin the context as we work on it

Since we now allow the intel_context_unpin() to run unserialised, we
risk our operations under the intel_context_lock_pinned() being run as
the context is unpinned (and thus invalidating our state). We can
atomically acquire the pin, testing to see if it is pinned in the
process, thus ensuring that the state remains consistent during the
course of the whole operation.

Fixes: 8413502238 ("drm/i915/gt: Drop mutex serialisation between context pin/unpin")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200109085142.871563-1-chris@chris-wilson.co.uk
This commit is contained in:
Chris Wilson
2020-01-09 08:51:42 +00:00
parent 921f0c47f2
commit feed5c7be2
4 changed files with 22 additions and 20 deletions

View File

@@ -2159,8 +2159,6 @@ static int gen8_modify_context(struct intel_context *ce,
struct i915_request *rq;
int err;
lockdep_assert_held(&ce->pin_mutex);
rq = intel_engine_create_kernel_request(ce->engine);
if (IS_ERR(rq))
return PTR_ERR(rq);
@@ -2203,17 +2201,14 @@ static int gen8_configure_context(struct i915_gem_context *ctx,
if (ce->engine->class != RENDER_CLASS)
continue;
err = intel_context_lock_pinned(ce);
if (err)
break;
/* Otherwise OA settings will be set upon first use */
if (!intel_context_pin_if_active(ce))
continue;
flex->value = intel_sseu_make_rpcs(ctx->i915, &ce->sseu);
err = gen8_modify_context(ce, flex, count);
/* Otherwise OA settings will be set upon first use */
if (intel_context_is_pinned(ce))
err = gen8_modify_context(ce, flex, count);
intel_context_unlock_pinned(ce);
intel_context_unpin(ce);
if (err)
break;
}