[PATCH 4/4] drm/i915/active: Simplify llist search-and-delete
Janusz Krzysztofik
janusz.krzysztofik at linux.intel.com
Fri Feb 17 23:14:52 UTC 2023
While searching for a node to be deleted inside ____active_del_barrier(),
we now rebuild barrier_tasks llist content in reverse order.
Theoretically neutral, it was observed like providing an undocumented
workaround for unexpected loops of llist nodes appearing now and again due
to races, silently breaking those list node loops, then protecting
llist_for_each_safe() from spinning indefinitely.
Having all races hopefully fixed, make that function behavior more
predictable, more easy to follow -- switch to an alternative, equally
simple but less invasive algorithm that only updates a link between list
nodes that precede and follow the deleted node.
Fixes: d8af05ff38ae ("drm/i915: Allow sharing the idle-barrier from other kernel requests")
Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik at linux.intel.com>
Cc: stable at vger.kernel.org # v5.4
---
drivers/gpu/drm/i915/i915_active.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_active.c b/drivers/gpu/drm/i915/i915_active.c
index 8eb10af7928f4..10f52eb4a4592 100644
--- a/drivers/gpu/drm/i915/i915_active.c
+++ b/drivers/gpu/drm/i915/i915_active.c
@@ -391,13 +391,14 @@ static bool ____active_del_barrier(struct i915_active *ref,
llist_for_each_safe(pos, next, llist_del_all(&engine->barrier_tasks)) {
if (node == barrier_from_ll(pos)) {
node = NULL;
+ if (tail)
+ tail->next = next;
continue;
}
- pos->next = head;
- head = pos;
- if (!tail)
- tail = pos;
+ if (!head)
+ head = pos;
+ tail = pos;
}
if (head)
llist_add_batch(head, tail, &engine->barrier_tasks);
--
2.25.1
More information about the Intel-gfx-trybot
mailing list