]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
drm/i915/gem: Flush contexts on driver release
authorJanusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
Fri, 16 Sep 2022 09:24:02 +0000 (11:24 +0200)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Tue, 20 Sep 2022 14:19:01 +0000 (10:19 -0400)
Due to i915_perf assuming that it can use the i915_gem_context reference
to protect its i915->gem.contexts.list iteration, we need to defer removal
of the context from the list until last reference to the context is put.
However, there is a risk of triggering kernel warning on contexts list not
empty at driver release time if we deleagate that task to a worker for
i915_gem_context_release_work(), unless that work is flushed first.
Unfortunately, it is not flushed on driver release.  Fix it.

Instead of additionally calling flush_workqueue(), either directly or via
a new dedicated wrapper around it, replace last call to
i915_gem_drain_freed_objects() with existing i915_gem_drain_workqueue()
that performs both tasks.

Fixes: 75eefd82581f ("drm/i915: Release i915_gem_context from a worker")
Suggested-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>
Cc: stable@kernel.org # v5.16+
Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220916092403.201355-2-janusz.krzysztofik@linux.intel.com
(cherry picked from commit 1cec34442408a77ba5396b19725fed2c398005c3)
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
drivers/gpu/drm/i915/i915_gem.c

index 702e5b89be2266c09a9be9fbf708463de30e027b..b605d0ceaefad31b19b7dfbecc272b882652802f 100644 (file)
@@ -1191,7 +1191,8 @@ void i915_gem_driver_release(struct drm_i915_private *dev_priv)
 
        intel_uc_cleanup_firmwares(&to_gt(dev_priv)->uc);
 
-       i915_gem_drain_freed_objects(dev_priv);
+       /* Flush any outstanding work, including i915_gem_context.release_work. */
+       i915_gem_drain_workqueue(dev_priv);
 
        drm_WARN_ON(&dev_priv->drm, !list_empty(&dev_priv->gem.contexts.list));
 }