• Matthew Auld's avatar
    drm/i915: move the pre_pin earlier · 10ceccb8
    Matthew Auld authored
    In intel_context_do_pin_ww, when calling into the pre_pin hook(which is
    passed the ww context) it could in theory return -EDEADLK(which is very
    likely with debug kernels), once we start adding more ww locking in there,
    like in the next patch. If so then we need to be mindful of having to
    restart the do_pin at this point.
    
    If this is the kernel_context, or some other early in-kernel context
    where we have yet to setup the default_state, then we always inhibit the
    context restore, and instead rely on the delayed active_release to set
    the CONTEXT_VALID_BIT for us(if we even care), which should indicate
    that we have context switched away, and that our newly saved context
    state should now be valid. However, since we currently grab the active
    reference before the potential ww dance, we can end up setting the
    CONTEXT_VALID_BIT much too early, if we need to backoff, and then upon
    re-trying the do_pin, we could potentially cause the hardware to
    incorrectly load some garbage context state when later context switching
    to that context, but at the very least this will trigger the
    GEM_BUG_ON() in __engine_unpark. For now let's just move any ww dance
    stuff prior to arming the active reference.
    
    For normal user contexts this shouldn't be a concern, since we should
    already have the default_state ready when initialising the lrc state,
    and so there should be no concern with active_release somehow
    prematurely setting the CONTEXT_VALID_BIT.
    
    v2(Thomas):
      - Also re-order the onion unwind
    Signed-off-by: default avatarMatthew Auld <matthew.auld@intel.com>
    Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
    Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
    Reviewed-by: default avatarThomas Hellström <thomas.hellstrom@linux.intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211117142024.1043017-1-matthew.auld@intel.com
    10ceccb8
intel_context.c 13.1 KB