Skip to contentSkip to conversation

drm/i915: Filter wake_flags passed to default_wake_function

Intel-gfx Chris Wilson 3 participants 3 messages Jul 28, 2020 – Aug 3, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

The flags passed to the wait_entry.func are passed onwards to try_to_wake_up(), which has a very particular interpretation for its wake_flags. In particular, beyond the published WF_SYNC, it has a few internal flags as well. Since we passed the fence->error down the chain via the flags argument, these ended up in the default_wake_function confusing the kernel/sched.

Fixes ef4688497512 ("drm/i915: Propagate fence errors")
Cc Matthew Auld <[email protected]>
Cc <[email protected]> # v5.4+
---
 drivers/gpu/drm/i915/i915_sw_fence.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_sw_fence.c +7 -3
index 295b9829e2da..4cd2038cbe35 100644
@@ -164,9 +164,13 @@ static void __i915_sw_fence_wake_up_all(struct i915_sw_fence *fence,
 
 		do {
 			list_for_each_entry_safe(pos, next, &x->head, entry) {
-				pos->func(pos,
-					  TASK_NORMAL, fence->error,
-					  &extra);
+				int wake_flags;
+
+				wake_flags = fence->error;
+				if (pos->func == autoremove_wake_function)
+					wake_flags = 0;
+
+				pos->func(pos, TASK_NORMAL, wake_flags, &extra);
 			}
 
 			if (list_empty(&extra))
Signature · 6 lines
2.20.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

[Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915: Filter wake_flags passed to default_wake_function (rev2)

== Series Details ==

== Series Details ==

Series: drm/i915: Filter wake_flags passed to default_wake_function (rev2)
URL : https://patchwork.freedesktop.org/series/79824/
State : failure

== Summary ==

Applying: drm/i915: Filter wake_flags passed to default_wake_function Using index info to reconstruct a base tree...
M drivers/gpu/drm/i915/i915_sw_fence.c
Falling back to patching base and 3-way merge...
No changes -- Patch already applied.

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

maintainer
#2 lore raw
In reply to Chris Wilson
Quoted 29 lines · Chris Wilson

The flags passed to the wait_entry.func are passed onwards to try_to_wake_up(), which has a very particular interpretation for its wake_flags. In particular, beyond the published WF_SYNC, it has a few internal flags as well. Since we passed the fence->error down the chain via the flags argument, these ended up in the default_wake_function confusing the kernel/sched.

Fixes ef4688497512 ("drm/i915: Propagate fence errors")
Cc Matthew Auld <[email protected]>
Cc <[email protected]> # v5.4+
---
 drivers/gpu/drm/i915/i915_sw_fence.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_sw_fence.c +0 -3
index 295b9829e2da..4cd2038cbe35 100644
@@ -164,9 +164,13 @@ static void __i915_sw_fence_wake_up_all(struct i915_sw_fence *fence,
 
                do {
                        list_for_each_entry_safe(pos, next, &x->head, entry) {
-                               pos->func(pos,
-                                         TASK_NORMAL, fence->error,
-                                         &extra);

drivers/gpu/drm/i915/i915_sw_fence.c static void __i915_sw_fence_wake_up_all(struct i915_sw_fence *fence, · line 176

Quoted 10 lines
drivers/gpu/drm/i915/i915_sw_fence.c +7 -0
+                               int wake_flags;
+
+                               wake_flags = fence->error;
+                               if (pos->func == autoremove_wake_function)
+                                       wake_flags = 0;
+
+                               pos->func(pos, TASK_NORMAL, wake_flags, &extra);
                        }
 
                        if (list_empty(&extra))

This seems to be heading for my tree at the moment, there is only one place in the kernel where someone compares pos->func with autoremove_wake_function, and it's in this file.

This seems horribly brittle, can we at least make this better in -next even if we have to have this fix in fixes?

I also have to question the whole raison d'etre for i915_sw_fence, it's initial commit says it was meant to be a core kernel struct, but I haven't seen any effort on behalf of i915 team to make that happen, I expect when that is attempted the whole thing will get shredded for layering violations like the above.

Dave.
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx