Commit dc76e576 authored by Chris Wilson's avatar Chris Wilson

drm/i915: Complete both freed-object passes before draining the workqueue

The workqueue code complains viciously if we try to queue more work onto
the queue while attampting to drain it. As we asynchronously free
objects and defer their enqueuing with RCU, it is quite tricky to
quiesce the system before attempting to drain the workqueue. Yet drain
we must to ensure that the worker is idle before unloading the module.

Give the freed object drain 3 whole passes with multiple rcu_barrier()
to give the defer freeing of several levels each protected by RCU and
needing a grace period before its parent can be freed, ultimately
resulting in a GEM object being freed after another RCU period.

A consequence is that it will make module unload even slower.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110550Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarMatthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190501135753.8711-1-chris@chris-wilson.co.uk
parent 45b9c968
...@@ -2824,15 +2824,15 @@ static inline void i915_gem_drain_workqueue(struct drm_i915_private *i915) ...@@ -2824,15 +2824,15 @@ static inline void i915_gem_drain_workqueue(struct drm_i915_private *i915)
* grace period so that we catch work queued via RCU from the first * grace period so that we catch work queued via RCU from the first
* pass. As neither drain_workqueue() nor flush_workqueue() report * pass. As neither drain_workqueue() nor flush_workqueue() report
* a result, we make an assumption that we only don't require more * a result, we make an assumption that we only don't require more
* than 2 passes to catch all recursive RCU delayed work. * than 3 passes to catch all _recursive_ RCU delayed work.
* *
*/ */
int pass = 2; int pass = 3;
do { do {
rcu_barrier(); rcu_barrier();
i915_gem_drain_freed_objects(i915); i915_gem_drain_freed_objects(i915);
drain_workqueue(i915->wq);
} while (--pass); } while (--pass);
drain_workqueue(i915->wq);
} }
struct i915_vma * __must_check struct i915_vma * __must_check
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment