<html>
    <head>
      <base href="https://bugs.freedesktop.org/">
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [HSW]drv_selftest/mock_requests - ida_remove called for id=1 which is not allocated."
   href="https://bugs.freedesktop.org/show_bug.cgi?id=101627#c1">Comment # 1</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [HSW]drv_selftest/mock_requests - ida_remove called for id=1 which is not allocated."
   href="https://bugs.freedesktop.org/show_bug.cgi?id=101627">bug 101627</a>
              from <span class="vcard"><a class="email" href="mailto:chris@chris-wilson.co.uk" title="Chris Wilson <chris@chris-wilson.co.uk>"> <span class="fn">Chris Wilson</span></a>
</span></b>
        <pre>The usual case for this was the worker running after i915_gem_context_fini().
The requirement there was that flush_workqueue() was run before
i915_gem_context_fini().

i.e. we do

static void mock_device_release(struct drm_device *dev)
{
        struct drm_i915_private *i915 = to_i915(dev);
        struct intel_engine_cs *engine;
        enum intel_engine_id id;

        mutex_lock(&i915->drm.struct_mutex);
        mock_device_flush(i915);
        i915_gem_contexts_lost(i915);
        mutex_unlock(&i915->drm.struct_mutex);

        cancel_delayed_work_sync(&i915->gt.retire_work);
        cancel_delayed_work_sync(&i915->gt.idle_work);
        flush_workqueue(i915->wq);

        mutex_lock(&i915->drm.struct_mutex);
        for_each_engine(engine, i915, id)
                mock_engine_free(engine);
        i915_gem_contexts_fini(i915);
        mutex_unlock(&i915->drm.struct_mutex);

...

(I'm assuming that the llist is correct and we can't free the same context
twice, kasan?)

Above though we have an issue in that we need to use drain_workqueue() instead.
Otherwise, I can't see where we might have more requests to retire. Probably
deserves a few bug ons to assert that all requests are retired and we are now
idle, ala i915_gem_suspend(). Hmm, probably better to rework it to use
i915_gem_suspend as well.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
          <li>You are the QA Contact for the bug.</li>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>