Skip to contentSkip to conversation

drm/i915: Fix waiting for engines to idle

PATCH In review Tvrtko Ursulin 6 participants 17 messages May 23, 2017 – May 24, 2017

Subsystems (2)
lore
Share & tools
lore

Tvrtko Ursulin

author maintainer
#0 lore raw

PATCH 1/1 drm/i915: Fix waiting for engines to idle

From: Tvrtko Ursulin <[email protected]>

Waiting for engines needs to happen even in the non-debug builds so it is incorrect to wrap it in a GEM_WARN_ON.

Call it unconditionally and add GEM_WARN so that the debug warning can still be emitted when things go bad.

Fixes 25112b64b3d2 ("drm/i915: Wait for all engines to be idle as part of i915_gem_wait_for_idle()")
Cc Chris Wilson <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Jani Nikula <[email protected]>
Cc Nick Desaulniers <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem.c | 3 ++-
 drivers/gpu/drm/i915/i915_gem.h | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem.c +2 -1
index a637cc05cc4a..ecaa21f106c8 100644
@@ -3332,7 +3332,8 @@ static int wait_for_engines(struct drm_i915_private *i915)
 	enum intel_engine_id id;
 
 	for_each_engine(engine, i915, id) {
-		if (GEM_WARN_ON(wait_for_engine(engine, 50))) {
+		if (wait_for_engine(engine, 50)) {
+			GEM_WARN(1, "%s wait for idle timeout", engine->name);
 			i915_gem_set_wedged(i915);
 			return -EIO;
 		}
drivers/gpu/drm/i915/i915_gem.h +2 -0
index ee54597465b6..cefc6cf96a60 100644
@@ -30,6 +30,7 @@
 #ifdef CONFIG_DRM_I915_DEBUG_GEM
 #define GEM_BUG_ON(expr) BUG_ON(expr)
 #define GEM_WARN_ON(expr) WARN_ON(expr)
+#define GEM_WARN(condition, format, ...) WARN(condition, format, __VA_ARGS__)
 
 #define GEM_DEBUG_DECL(var) var
 #define GEM_DEBUG_EXEC(expr) expr
@@ -38,6 +39,7 @@
 #else
 #define GEM_BUG_ON(expr) BUILD_BUG_ON_INVALID(expr)
 #define GEM_WARN_ON(expr) (BUILD_BUG_ON_INVALID(expr), 0)
+#define GEM_WARN(condition, format, ...) BUILD_BUG_ON_INVALID(condition)
 
 #define GEM_DEBUG_DECL(var)
 #define GEM_DEBUG_EXEC(expr) do { } while (0)
Signature · 6 lines
2.9.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 1/1
#1 lore raw
Quoted 27 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

Waiting for engines needs to happen even in the non-debug builds so it is incorrect to wrap it in a GEM_WARN_ON.

Call it unconditionally and add GEM_WARN so that the debug warning can still be emitted when things go bad.

Fixes 25112b64b3d2 ("drm/i915: Wait for all engines to be idle as part of i915_gem_wait_for_idle()")
Cc Chris Wilson <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Jani Nikula <[email protected]>
Cc Nick Desaulniers <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem.c | 3 ++-
 drivers/gpu/drm/i915/i915_gem.h | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem.c +0 -0
index a637cc05cc4a..ecaa21f106c8 100644

drivers/gpu/drm/i915/i915_gem.c static int wait_for_engines(struct drm_i915_private *i915) · line 3336

Quoted 6 lines
drivers/gpu/drm/i915/i915_gem.c +2 -1
@@ -3332,7 +3332,8 @@ static int wait_for_engines(struct drm_i915_private *i915)
 	enum intel_engine_id id;
 
 	for_each_engine(engine, i915, id) {
-		if (GEM_WARN_ON(wait_for_engine(engine, 50))) {
+		if (wait_for_engine(engine, 50)) {
+			GEM_WARN(1, "%s wait for idle timeout", engine->name);

Nice touching adding the engine->name

Quoted 16 lines
drivers/gpu/drm/i915/i915_gem.c +0 -0
 			i915_gem_set_wedged(i915);
 			return -EIO;
 		}
drivers/gpu/drm/i915/i915_gem.h +1 -0
index ee54597465b6..cefc6cf96a60 100644
@@ -30,6 +30,7 @@
 #ifdef CONFIG_DRM_I915_DEBUG_GEM
 #define GEM_BUG_ON(expr) BUG_ON(expr)
 #define GEM_WARN_ON(expr) WARN_ON(expr)
+#define GEM_WARN(condition, format, ...) WARN(condition, format, __VA_ARGS__)
 
 #define GEM_DEBUG_DECL(var) var
 #define GEM_DEBUG_EXEC(expr) expr

drivers/gpu/drm/i915/i915_gem.h line 42

Quoted 4 lines
drivers/gpu/drm/i915/i915_gem.h +1 -0
@@ -38,6 +39,7 @@
 #else
 #define GEM_BUG_ON(expr) BUILD_BUG_ON_INVALID(expr)
 #define GEM_WARN_ON(expr) (BUILD_BUG_ON_INVALID(expr), 0)
+#define GEM_WARN(condition, format, ...) BUILD_BUG_ON_INVALID(condition)

WARNs can be used as part of an if(), so perhaps

#define GEM_WARN(condition, format, ...) (BUILD_BUG_ON_INVALID(condition), 0) #define GEM_WARN_ON(expr) GEM_WARN((expr), 0)

?
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#9 lore raw

✓ Fi.CI.BAT: success for drm/i915: Fix waiting for engines to idle

In reply to Tvrtko Ursulin
== Series Details ==

== Series Details ==

Series: drm/i915: Fix waiting for engines to idle
URL : https://patchwork.freedesktop.org/series/24821/
State : success

== Summary ==

Series 24821v1 drm/i915: Fix waiting for engines to idle
https://patchwork.freedesktop.org/api/1.0/series/24821/revisions/1/mbox/

Test kms_cursor_legacy:

        Subgroup basic-busy-flip-before-cursor-legacy:
                pass       -> FAIL       (fi-snb-2600) fdo#100215

fdo#100215 https://bugs.freedesktop.org/show_bug.cgi?id=100215

fi-bdw-5557u     total:278  pass:267  dwarn:0   dfail:0   fail:0   skip:11  time:451s
fi-bdw-gvtdvm    total:278  pass:256  dwarn:8   dfail:0   fail:0   skip:14  time:433s
fi-bsw-n3050     total:278  pass:242  dwarn:0   dfail:0   fail:0   skip:36  time:586s
fi-bxt-j4205     total:278  pass:259  dwarn:0   dfail:0   fail:0   skip:19  time:512s
fi-byt-j1900     total:278  pass:254  dwarn:0   dfail:0   fail:0   skip:24  time:491s
fi-byt-n2820     total:278  pass:250  dwarn:0   dfail:0   fail:0   skip:28  time:495s
fi-hsw-4770      total:278  pass:262  dwarn:0   dfail:0   fail:0   skip:16  time:413s
fi-hsw-4770r     total:278  pass:262  dwarn:0   dfail:0   fail:0   skip:16  time:413s
fi-ilk-650       total:278  pass:228  dwarn:0   dfail:0   fail:0   skip:50  time:419s
fi-ivb-3520m     total:278  pass:260  dwarn:0   dfail:0   fail:0   skip:18  time:491s
fi-ivb-3770      total:278  pass:260  dwarn:0   dfail:0   fail:0   skip:18  time:472s
fi-kbl-7500u     total:278  pass:255  dwarn:5   dfail:0   fail:0   skip:18  time:468s
fi-kbl-7560u     total:278  pass:263  dwarn:5   dfail:0   fail:0   skip:10  time:564s
fi-skl-6260u     total:278  pass:268  dwarn:0   dfail:0   fail:0   skip:10  time:460s
fi-skl-6700hq    total:278  pass:260  dwarn:1   dfail:0   fail:0   skip:17  time:576s
fi-skl-6700k     total:278  pass:256  dwarn:4   dfail:0   fail:0   skip:18  time:468s
fi-skl-6770hq    total:278  pass:268  dwarn:0   dfail:0   fail:0   skip:10  time:508s
fi-skl-gvtdvm    total:278  pass:265  dwarn:0   dfail:0   fail:0   skip:13  time:439s
fi-snb-2520m     total:278  pass:250  dwarn:0   dfail:0   fail:0   skip:28  time:530s
fi-snb-2600      total:278  pass:248  dwarn:0   dfail:0   fail:1   skip:29  time:415s

f0db4d0afaead343e29f6c4609d4b912ad3304c1 drm-tip: 2017y-05m-23d-07h-43m-17s UTC integration manifest f7002d6 drm/i915: Fix waiting for engines to idle

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_4782/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#10 lore raw
In reply to Tvrtko Ursulin
Quoted 10 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

Waiting for engines needs to happen even in the non-debug builds so it is incorrect to wrap it in a GEM_WARN_ON.

Call it unconditionally and add GEM_WARN so that the debug warning can still be emitted when things go bad.

Fixes 25112b64b3d2 ("drm/i915: Wait for all engines to be idle as part of i915_gem_wait_for_idle()")

I would also say

Fixes 7a453fb82f86 ("drm/i915: Remove redudant wait for each engine to idle from seqno wrap")

as that's the patch that assumes wait_for_idle included the wait on engines.
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw
In reply to Chris Wilson
Quoted 61 lines · Chris Wilson
Quoted 27 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

Waiting for engines needs to happen even in the non-debug builds so it is incorrect to wrap it in a GEM_WARN_ON.

Call it unconditionally and add GEM_WARN so that the debug warning can still be emitted when things go bad.

Fixes 25112b64b3d2 ("drm/i915: Wait for all engines to be idle as part of i915_gem_wait_for_idle()")
Cc Chris Wilson <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Jani Nikula <[email protected]>
Cc Nick Desaulniers <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem.c | 3 ++-
 drivers/gpu/drm/i915/i915_gem.h | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem.c +0 -0
index a637cc05cc4a..ecaa21f106c8 100644

drivers/gpu/drm/i915/i915_gem.c static int wait_for_engines(struct drm_i915_private *i915) · line 3336

Quoted 6 lines
drivers/gpu/drm/i915/i915_gem.c +2 -1
@@ -3332,7 +3332,8 @@ static int wait_for_engines(struct drm_i915_private *i915)
 	enum intel_engine_id id;
 
 	for_each_engine(engine, i915, id) {
-		if (GEM_WARN_ON(wait_for_engine(engine, 50))) {
+		if (wait_for_engine(engine, 50)) {
+			GEM_WARN(1, "%s wait for idle timeout", engine->name);

Nice touching adding the engine->name

Quoted 16 lines
drivers/gpu/drm/i915/i915_gem.c +0 -0
 			i915_gem_set_wedged(i915);
 			return -EIO;
 		}
drivers/gpu/drm/i915/i915_gem.h +1 -0
index ee54597465b6..cefc6cf96a60 100644
@@ -30,6 +30,7 @@
 #ifdef CONFIG_DRM_I915_DEBUG_GEM
 #define GEM_BUG_ON(expr) BUG_ON(expr)
 #define GEM_WARN_ON(expr) WARN_ON(expr)
+#define GEM_WARN(condition, format, ...) WARN(condition, format, __VA_ARGS__)
 
 #define GEM_DEBUG_DECL(var) var
 #define GEM_DEBUG_EXEC(expr) expr

drivers/gpu/drm/i915/i915_gem.h line 42

Quoted 4 lines
drivers/gpu/drm/i915/i915_gem.h +1 -0
@@ -38,6 +39,7 @@
 #else
 #define GEM_BUG_ON(expr) BUILD_BUG_ON_INVALID(expr)
 #define GEM_WARN_ON(expr) (BUILD_BUG_ON_INVALID(expr), 0)
+#define GEM_WARN(condition, format, ...) BUILD_BUG_ON_INVALID(condition)

WARNs can be used as part of an if(), so perhaps

Quoted 2 lines

#define GEM_WARN(condition, format, ...) (BUILD_BUG_ON_INVALID(condition), 0) #define GEM_WARN_ON(expr) GEM_WARN((expr), 0)

Doesn't work for statements. :( I don't know, more compiler trickery needed...

Regards,

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

#3 lore raw
Quoted 63 lines · Tvrtko Ursulin
Quoted 61 lines · Chris Wilson
Quoted 27 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

Waiting for engines needs to happen even in the non-debug builds so it is incorrect to wrap it in a GEM_WARN_ON.

Call it unconditionally and add GEM_WARN so that the debug warning can still be emitted when things go bad.

Fixes 25112b64b3d2 ("drm/i915: Wait for all engines to be idle as part of i915_gem_wait_for_idle()")
Cc Chris Wilson <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Jani Nikula <[email protected]>
Cc Nick Desaulniers <[email protected]>

---
drivers/gpu/drm/i915/i915_gem.c | 3 ++-
drivers/gpu/drm/i915/i915_gem.h | 2 ++

2 files changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem.c +0 -0
index a637cc05cc4a..ecaa21f106c8 100644

drivers/gpu/drm/i915/i915_gem.c static int wait_for_engines(struct drm_i915_private *i915) · line 3336

Quoted 6 lines
drivers/gpu/drm/i915/i915_gem.c +2 -1
@@ -3332,7 +3332,8 @@ static int wait_for_engines(struct drm_i915_private *i915)
 	enum intel_engine_id id;
 
 	for_each_engine(engine, i915, id) {
-		if (GEM_WARN_ON(wait_for_engine(engine, 50))) {
+		if (wait_for_engine(engine, 50)) {
+			GEM_WARN(1, "%s wait for idle timeout", engine->name);

Nice touching adding the engine->name

Quoted 16 lines
drivers/gpu/drm/i915/i915_gem.c +0 -0
 			i915_gem_set_wedged(i915);
 			return -EIO;
 		}
drivers/gpu/drm/i915/i915_gem.h +1 -0
index ee54597465b6..cefc6cf96a60 100644
@@ -30,6 +30,7 @@
 #ifdef CONFIG_DRM_I915_DEBUG_GEM
 #define GEM_BUG_ON(expr) BUG_ON(expr)
 #define GEM_WARN_ON(expr) WARN_ON(expr)
+#define GEM_WARN(condition, format, ...) WARN(condition, format, __VA_ARGS__)
 
 #define GEM_DEBUG_DECL(var) var
 #define GEM_DEBUG_EXEC(expr) expr

drivers/gpu/drm/i915/i915_gem.h line 42

Quoted 4 lines
drivers/gpu/drm/i915/i915_gem.h +1 -0
@@ -38,6 +39,7 @@
 #else
 #define GEM_BUG_ON(expr) BUILD_BUG_ON_INVALID(expr)
 #define GEM_WARN_ON(expr) (BUILD_BUG_ON_INVALID(expr), 0)
+#define GEM_WARN(condition, format, ...) BUILD_BUG_ON_INVALID(condition)

WARNs can be used as part of an if(), so perhaps

Quoted 5 lines
Quoted 2 lines

#define GEM_WARN(condition, format, ...) (BUILD_BUG_ON_INVALID(condition), 0) #define GEM_WARN_ON(expr) GEM_WARN((expr), 0)

Doesn't work for statements. :( I don't know, more compiler trickery needed...

Unless it turns out to be easy, go with simple and we can play later when needed.
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
maintainer
#4 lore raw
In reply to Chris Wilson
Quoted 61 lines · Chris Wilson
Quoted 27 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

Waiting for engines needs to happen even in the non-debug builds so it is incorrect to wrap it in a GEM_WARN_ON.

Call it unconditionally and add GEM_WARN so that the debug warning can still be emitted when things go bad.

Fixes 25112b64b3d2 ("drm/i915: Wait for all engines to be idle as part of i915_gem_wait_for_idle()")
Cc Chris Wilson <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Jani Nikula <[email protected]>
Cc Nick Desaulniers <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem.c | 3 ++-
 drivers/gpu/drm/i915/i915_gem.h | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem.c +0 -0
index a637cc05cc4a..ecaa21f106c8 100644

drivers/gpu/drm/i915/i915_gem.c static int wait_for_engines(struct drm_i915_private *i915) · line 3336

Quoted 6 lines
drivers/gpu/drm/i915/i915_gem.c +2 -1
@@ -3332,7 +3332,8 @@ static int wait_for_engines(struct drm_i915_private *i915)
 	enum intel_engine_id id;
 
 	for_each_engine(engine, i915, id) {
-		if (GEM_WARN_ON(wait_for_engine(engine, 50))) {
+		if (wait_for_engine(engine, 50)) {
+			GEM_WARN(1, "%s wait for idle timeout", engine->name);

Nice touching adding the engine->name

Quoted 16 lines
drivers/gpu/drm/i915/i915_gem.c +0 -0
 			i915_gem_set_wedged(i915);
 			return -EIO;
 		}
drivers/gpu/drm/i915/i915_gem.h +1 -0
index ee54597465b6..cefc6cf96a60 100644
@@ -30,6 +30,7 @@
 #ifdef CONFIG_DRM_I915_DEBUG_GEM
 #define GEM_BUG_ON(expr) BUG_ON(expr)
 #define GEM_WARN_ON(expr) WARN_ON(expr)
+#define GEM_WARN(condition, format, ...) WARN(condition, format, __VA_ARGS__)
 
 #define GEM_DEBUG_DECL(var) var
 #define GEM_DEBUG_EXEC(expr) expr

drivers/gpu/drm/i915/i915_gem.h line 42

Quoted 4 lines
drivers/gpu/drm/i915/i915_gem.h +1 -0
@@ -38,6 +39,7 @@
 #else
 #define GEM_BUG_ON(expr) BUILD_BUG_ON_INVALID(expr)
 #define GEM_WARN_ON(expr) (BUILD_BUG_ON_INVALID(expr), 0)
+#define GEM_WARN(condition, format, ...) BUILD_BUG_ON_INVALID(condition)

WARNs can be used as part of an if(), so perhaps

Quoted 2 lines

#define GEM_WARN(condition, format, ...) (BUILD_BUG_ON_INVALID(condition), 0) #define GEM_WARN_ON(expr) GEM_WARN((expr), 0)

Sorry, I just can't resist the "told you so" here.

If you come up with a local pattern that's deceptively similar to a widely used one, with the crucial difference that you can't use anything with required side effects in it, you'll screw it up eventually.

if (GEM_WARN_ON(wait_for_engine(engine, 50))) looks completely natural and "obviously correct" in code, but is dead wrong. This won't be the last time.

BR,
Jani.

Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw
Quoted 67 lines · Jani Nikula
Quoted 61 lines · Chris Wilson
Quoted 27 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

Waiting for engines needs to happen even in the non-debug builds so it is incorrect to wrap it in a GEM_WARN_ON.

Call it unconditionally and add GEM_WARN so that the debug warning can still be emitted when things go bad.

Fixes 25112b64b3d2 ("drm/i915: Wait for all engines to be idle as part of i915_gem_wait_for_idle()")
Cc Chris Wilson <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Jani Nikula <[email protected]>
Cc Nick Desaulniers <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem.c | 3 ++-
 drivers/gpu/drm/i915/i915_gem.h | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem.c +0 -0
index a637cc05cc4a..ecaa21f106c8 100644

drivers/gpu/drm/i915/i915_gem.c static int wait_for_engines(struct drm_i915_private *i915) · line 3336

Quoted 6 lines
drivers/gpu/drm/i915/i915_gem.c +2 -1
@@ -3332,7 +3332,8 @@ static int wait_for_engines(struct drm_i915_private *i915)
 	enum intel_engine_id id;
 
 	for_each_engine(engine, i915, id) {
-		if (GEM_WARN_ON(wait_for_engine(engine, 50))) {
+		if (wait_for_engine(engine, 50)) {
+			GEM_WARN(1, "%s wait for idle timeout", engine->name);

Nice touching adding the engine->name

Quoted 16 lines
drivers/gpu/drm/i915/i915_gem.c +0 -0
 			i915_gem_set_wedged(i915);
 			return -EIO;
 		}
drivers/gpu/drm/i915/i915_gem.h +1 -0
index ee54597465b6..cefc6cf96a60 100644
@@ -30,6 +30,7 @@
 #ifdef CONFIG_DRM_I915_DEBUG_GEM
 #define GEM_BUG_ON(expr) BUG_ON(expr)
 #define GEM_WARN_ON(expr) WARN_ON(expr)
+#define GEM_WARN(condition, format, ...) WARN(condition, format, __VA_ARGS__)
 
 #define GEM_DEBUG_DECL(var) var
 #define GEM_DEBUG_EXEC(expr) expr

drivers/gpu/drm/i915/i915_gem.h line 42

Quoted 4 lines
drivers/gpu/drm/i915/i915_gem.h +1 -0
@@ -38,6 +39,7 @@
 #else
 #define GEM_BUG_ON(expr) BUILD_BUG_ON_INVALID(expr)
 #define GEM_WARN_ON(expr) (BUILD_BUG_ON_INVALID(expr), 0)
+#define GEM_WARN(condition, format, ...) BUILD_BUG_ON_INVALID(condition)

WARNs can be used as part of an if(), so perhaps

Quoted 2 lines

#define GEM_WARN(condition, format, ...) (BUILD_BUG_ON_INVALID(condition), 0) #define GEM_WARN_ON(expr) GEM_WARN((expr), 0)

Sorry, I just can't resist the "told you so" here.

Quoted 7 lines

If you come up with a local pattern that's deceptively similar to a widely used one, with the crucial difference that you can't use anything with required side effects in it, you'll screw it up eventually.

if (GEM_WARN_ON(wait_for_engine(engine, 50))) looks completely natural and "obviously correct" in code, but is dead wrong. This won't be the last time.

I would also prefer to make it consistent.

There are two other users of GEM_WARN_ON in i915_vma_bind to consider what to do with, but anyway it would be a much better solution.

Regards,

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

#11 lore raw
In reply to Chris Wilson
Quoted 9 lines · Chris Wilson
Quoted 8 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

Waiting for engines needs to happen even in the non-debug builds so it is incorrect to wrap it in a GEM_WARN_ON.

Call it unconditionally and add GEM_WARN so that the debug warning can still be emitted when things go bad.

Quoted 7 lines
Quoted 2 lines
Fixes 25112b64b3d2 ("drm/i915: Wait for all engines to be idle as part of i915_gem_wait_for_idle()")

I would also say

Fixes 7a453fb82f86 ("drm/i915: Remove redudant wait for each engine to idle from seqno wrap")

as that's the patch that assumes wait_for_idle included the wait on engines.

Hmm, actually that was only to prevent a DEBUG_GEM failure so not a relevant citation for fixes?
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#12 lore raw
Quoted 13 lines · Chris Wilson
Quoted 12 lines · Chris Wilson
Quoted 10 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

Waiting for engines needs to happen even in the non-debug builds so it is incorrect to wrap it in a GEM_WARN_ON.

Call it unconditionally and add GEM_WARN so that the debug warning can still be emitted when things go bad.

Fixes 25112b64b3d2 ("drm/i915: Wait for all engines to be idle as part of i915_gem_wait_for_idle()")
Quoted 7 lines
Quoted 4 lines

I would also say

Fixes 7a453fb82f86 ("drm/i915: Remove redudant wait for each engine to idle from seqno wrap")

as that's the patch that assumes wait_for_idle included the wait on engines.

Hmm, actually that was only to prevent a DEBUG_GEM failure so not a relevant citation for fixes?

And actually, this if for debug only code so the Fixes 25112b64b3d2 is wrong as well as we as introducing a change in behaviour (making the debug only code run all the time) with no urgent need for backporting. -Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#13 lore raw
Quoted 19 lines · Chris Wilson
Quoted 18 lines · Chris Wilson
Quoted 16 lines · Chris Wilson
Quoted 10 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

Waiting for engines needs to happen even in the non-debug builds so it is incorrect to wrap it in a GEM_WARN_ON.

Call it unconditionally and add GEM_WARN so that the debug warning can still be emitted when things go bad.

Fixes 25112b64b3d2 ("drm/i915: Wait for all engines to be idle as part of i915_gem_wait_for_idle()")

I would also say

Fixes 7a453fb82f86 ("drm/i915: Remove redudant wait for each engine to idle from seqno wrap")

as that's the patch that assumes wait_for_idle included the wait on engines.

Quoted 6 lines
Quoted 2 lines

Hmm, actually that was only to prevent a DEBUG_GEM failure so not a relevant citation for fixes?

And actually, this if for debug only code so the Fixes 25112b64b3d2 is wrong as well as we as introducing a change in behaviour (making the debug only code run all the time) with no urgent need for backporting.

Which part is for debug code only? Without it i915_gem_wait_for_idle is left with no checking for irq idleness, but it only seqno based. If that is what you say is debug only I think we need to mark it better in the code.

Regards,

Tvrtko

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

#14 lore raw
Quoted 24 lines · Tvrtko Ursulin
Quoted 22 lines · Chris Wilson
Quoted 20 lines · Chris Wilson
Quoted 9 lines · Chris Wilson
Quoted 8 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

Waiting for engines needs to happen even in the non-debug builds so it is incorrect to wrap it in a GEM_WARN_ON.

Call it unconditionally and add GEM_WARN so that the debug warning can still be emitted when things go bad.

Quoted 7 lines
Quoted 2 lines
Fixes 25112b64b3d2 ("drm/i915: Wait for all engines to be idle as part of i915_gem_wait_for_idle()")

I would also say

Fixes 7a453fb82f86 ("drm/i915: Remove redudant wait for each engine to idle from seqno wrap")

as that's the patch that assumes wait_for_idle included the wait on engines.

Hmm, actually that was only to prevent a DEBUG_GEM failure so not a relevant citation for fixes?

Quoted 8 lines
Quoted 3 lines

And actually, this if for debug only code so the Fixes 25112b64b3d2 is wrong as well as we as introducing a change in behaviour (making the debug only code run all the time) with no urgent need for backporting.

Which part is for debug code only? Without it i915_gem_wait_for_idle is left with no checking for irq idleness, but it only seqno based. If that is what you say is debug only I think we need to mark it better in the code.

The code for waiting on engines was added purely to solve an issue created by GEM_BUG_ONs presuming a strict order between context-switch, retirement and seqno update on wrap. It is not observable, i.e. has no effect, outside of DRM_I915_DEBUG_GEM. This patch is introducing an observable effect for production systems by declaring the machine wedged, which is far more severe than the normal course of events to first try a reset. I'm suggesting that we should be in no hurry to call set-wedged here without first allowing it to percolate through linux-next. -Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#15 lore raw
Quoted 34 lines · Chris Wilson
Quoted 24 lines · Tvrtko Ursulin
Quoted 22 lines · Chris Wilson
Quoted 20 lines · Chris Wilson
Quoted 9 lines · Chris Wilson
Quoted 8 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

Waiting for engines needs to happen even in the non-debug builds so it is incorrect to wrap it in a GEM_WARN_ON.

Call it unconditionally and add GEM_WARN so that the debug warning can still be emitted when things go bad.

Quoted 7 lines
Quoted 2 lines
Fixes 25112b64b3d2 ("drm/i915: Wait for all engines to be idle as part of i915_gem_wait_for_idle()")

I would also say

Fixes 7a453fb82f86 ("drm/i915: Remove redudant wait for each engine to idle from seqno wrap")

as that's the patch that assumes wait_for_idle included the wait on engines.

Hmm, actually that was only to prevent a DEBUG_GEM failure so not a relevant citation for fixes?

Quoted 8 lines
Quoted 3 lines

And actually, this if for debug only code so the Fixes 25112b64b3d2 is wrong as well as we as introducing a change in behaviour (making the debug only code run all the time) with no urgent need for backporting.

Which part is for debug code only? Without it i915_gem_wait_for_idle is left with no checking for irq idleness, but it only seqno based. If that is what you say is debug only I think we need to mark it better in the code.

Quoted 8 lines

The code for waiting on engines was added purely to solve an issue created by GEM_BUG_ONs presuming a strict order between context-switch, retirement and seqno update on wrap. It is not observable, i.e. has no effect, outside of DRM_I915_DEBUG_GEM. This patch is introducing an observable effect for production systems by declaring the machine wedged, which is far more severe than the normal course of events to first try a reset. I'm suggesting that we should be in no hurry to call set-wedged here without first allowing it to percolate through linux-next.

But that means broken GEM_WARN_ON semantics were actually correct in this case, even if non-obviously so. Which is why I said which should mark it better in the code. And by that I mean the call site of wait_engines in i915_gem_wait_for_idle should be #ifdef GEM_DEBUG (I can't suggest GEM_WARN_ON!).

Regards,

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

maintainer
#6 lore raw
In reply to Tvrtko Ursulin
Quoted 72 lines · Tvrtko Ursulin
Quoted 71 lines · Jani Nikula
Quoted 61 lines · Chris Wilson
Quoted 27 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

Waiting for engines needs to happen even in the non-debug builds so it is incorrect to wrap it in a GEM_WARN_ON.

Call it unconditionally and add GEM_WARN so that the debug warning can still be emitted when things go bad.

Fixes 25112b64b3d2 ("drm/i915: Wait for all engines to be idle as part of i915_gem_wait_for_idle()")
Cc Chris Wilson <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Jani Nikula <[email protected]>
Cc Nick Desaulniers <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem.c | 3 ++-
 drivers/gpu/drm/i915/i915_gem.h | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem.c +0 -0
index a637cc05cc4a..ecaa21f106c8 100644

drivers/gpu/drm/i915/i915_gem.c static int wait_for_engines(struct drm_i915_private *i915) · line 3336

Quoted 6 lines
drivers/gpu/drm/i915/i915_gem.c +2 -1
@@ -3332,7 +3332,8 @@ static int wait_for_engines(struct drm_i915_private *i915)
 	enum intel_engine_id id;
 
 	for_each_engine(engine, i915, id) {
-		if (GEM_WARN_ON(wait_for_engine(engine, 50))) {
+		if (wait_for_engine(engine, 50)) {
+			GEM_WARN(1, "%s wait for idle timeout", engine->name);

Nice touching adding the engine->name

Quoted 16 lines
drivers/gpu/drm/i915/i915_gem.c +0 -0
 			i915_gem_set_wedged(i915);
 			return -EIO;
 		}
drivers/gpu/drm/i915/i915_gem.h +1 -0
index ee54597465b6..cefc6cf96a60 100644
@@ -30,6 +30,7 @@
 #ifdef CONFIG_DRM_I915_DEBUG_GEM
 #define GEM_BUG_ON(expr) BUG_ON(expr)
 #define GEM_WARN_ON(expr) WARN_ON(expr)
+#define GEM_WARN(condition, format, ...) WARN(condition, format, __VA_ARGS__)
 
 #define GEM_DEBUG_DECL(var) var
 #define GEM_DEBUG_EXEC(expr) expr

drivers/gpu/drm/i915/i915_gem.h line 42

Quoted 4 lines
drivers/gpu/drm/i915/i915_gem.h +1 -0
@@ -38,6 +39,7 @@
 #else
 #define GEM_BUG_ON(expr) BUILD_BUG_ON_INVALID(expr)
 #define GEM_WARN_ON(expr) (BUILD_BUG_ON_INVALID(expr), 0)
+#define GEM_WARN(condition, format, ...) BUILD_BUG_ON_INVALID(condition)

WARNs can be used as part of an if(), so perhaps

Quoted 2 lines

#define GEM_WARN(condition, format, ...) (BUILD_BUG_ON_INVALID(condition), 0) #define GEM_WARN_ON(expr) GEM_WARN((expr), 0)

Sorry, I just can't resist the "told you so" here.

If you come up with a local pattern that's deceptively similar to a widely used one, with the crucial difference that you can't use anything with required side effects in it, you'll screw it up eventually.

Quoted 8 lines
Quoted 3 lines

if (GEM_WARN_ON(wait_for_engine(engine, 50))) looks completely natural and "obviously correct" in code, but is dead wrong. This won't be the last time.

I would also prefer to make it consistent.

There are two other users of GEM_WARN_ON in i915_vma_bind to consider what to do with, but anyway it would be a much better solution.

My suggestion is to make GEM_WARN_ON and friends that are conditional to CONFIG_DRM_I915_DEBUG_GEM unusable as expressions. Make them fail to build within if (...) for both CONFIG_DRM_I915_DEBUG_GEM=y and =n. Then if you need that kind of construct, handle it with something like:

	if (IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM) && condition) {
		GEM_WARN(...);
		...
	}

maybe wrapping that IS_ENABLED bit in a more manageable macro.

BR,
Jani.

Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#7 lore raw
In reply to Jani Nikula
Quoted 87 lines · Jani Nikula
Quoted 72 lines · Tvrtko Ursulin
Quoted 71 lines · Jani Nikula
Quoted 61 lines · Chris Wilson
Quoted 27 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

Waiting for engines needs to happen even in the non-debug builds so it is incorrect to wrap it in a GEM_WARN_ON.

Call it unconditionally and add GEM_WARN so that the debug warning can still be emitted when things go bad.

Fixes 25112b64b3d2 ("drm/i915: Wait for all engines to be idle as part of i915_gem_wait_for_idle()")
Cc Chris Wilson <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Jani Nikula <[email protected]>
Cc Nick Desaulniers <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem.c | 3 ++-
 drivers/gpu/drm/i915/i915_gem.h | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem.c +0 -0
index a637cc05cc4a..ecaa21f106c8 100644

drivers/gpu/drm/i915/i915_gem.c static int wait_for_engines(struct drm_i915_private *i915) · line 3336

Quoted 6 lines
drivers/gpu/drm/i915/i915_gem.c +2 -1
@@ -3332,7 +3332,8 @@ static int wait_for_engines(struct drm_i915_private *i915)
 	enum intel_engine_id id;
 
 	for_each_engine(engine, i915, id) {
-		if (GEM_WARN_ON(wait_for_engine(engine, 50))) {
+		if (wait_for_engine(engine, 50)) {
+			GEM_WARN(1, "%s wait for idle timeout", engine->name);

Nice touching adding the engine->name

Quoted 16 lines
drivers/gpu/drm/i915/i915_gem.c +0 -0
 			i915_gem_set_wedged(i915);
 			return -EIO;
 		}
drivers/gpu/drm/i915/i915_gem.h +1 -0
index ee54597465b6..cefc6cf96a60 100644
@@ -30,6 +30,7 @@
 #ifdef CONFIG_DRM_I915_DEBUG_GEM
 #define GEM_BUG_ON(expr) BUG_ON(expr)
 #define GEM_WARN_ON(expr) WARN_ON(expr)
+#define GEM_WARN(condition, format, ...) WARN(condition, format, __VA_ARGS__)
 
 #define GEM_DEBUG_DECL(var) var
 #define GEM_DEBUG_EXEC(expr) expr

drivers/gpu/drm/i915/i915_gem.h line 42

Quoted 4 lines
drivers/gpu/drm/i915/i915_gem.h +1 -0
@@ -38,6 +39,7 @@
 #else
 #define GEM_BUG_ON(expr) BUILD_BUG_ON_INVALID(expr)
 #define GEM_WARN_ON(expr) (BUILD_BUG_ON_INVALID(expr), 0)
+#define GEM_WARN(condition, format, ...) BUILD_BUG_ON_INVALID(condition)

WARNs can be used as part of an if(), so perhaps

Quoted 2 lines

#define GEM_WARN(condition, format, ...) (BUILD_BUG_ON_INVALID(condition), 0) #define GEM_WARN_ON(expr) GEM_WARN((expr), 0)

Sorry, I just can't resist the "told you so" here.

If you come up with a local pattern that's deceptively similar to a widely used one, with the crucial difference that you can't use anything with required side effects in it, you'll screw it up eventually.

Quoted 8 lines
Quoted 3 lines

if (GEM_WARN_ON(wait_for_engine(engine, 50))) looks completely natural and "obviously correct" in code, but is dead wrong. This won't be the last time.

I would also prefer to make it consistent.

There are two other users of GEM_WARN_ON in i915_vma_bind to consider what to do with, but anyway it would be a much better solution.

My suggestion is to make GEM_WARN_ON and friends that are conditional to CONFIG_DRM_I915_DEBUG_GEM unusable as expressions. Make them fail to build within if (...) for both CONFIG_DRM_I915_DEBUG_GEM=y and =n. Then if you need that kind of construct, handle it with something like:

Quoted 6 lines
	if (IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM) && condition) {
		GEM_WARN(...);
		...
	}

maybe wrapping that IS_ENABLED bit in a more manageable macro.

Why not simply make it work like a normal WARN_ON? Eg:

#ifdef ...DEBUG_GEM
#define GEM_WARN_ON(expr) WARN_ON(expr)
#else
#define GEM_WARN_ON(expr) (expr)
#endif

Regards,

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

maintainer
#8 lore raw
Quoted 95 lines · Tvrtko Ursulin
Quoted 87 lines · Jani Nikula
Quoted 72 lines · Tvrtko Ursulin
Quoted 71 lines · Jani Nikula
Quoted 61 lines · Chris Wilson
Quoted 27 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

Waiting for engines needs to happen even in the non-debug builds so it is incorrect to wrap it in a GEM_WARN_ON.

Call it unconditionally and add GEM_WARN so that the debug warning can still be emitted when things go bad.

Fixes 25112b64b3d2 ("drm/i915: Wait for all engines to be idle as part of i915_gem_wait_for_idle()")
Cc Chris Wilson <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Jani Nikula <[email protected]>
Cc Nick Desaulniers <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem.c | 3 ++-
 drivers/gpu/drm/i915/i915_gem.h | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem.c +0 -0
index a637cc05cc4a..ecaa21f106c8 100644

drivers/gpu/drm/i915/i915_gem.c static int wait_for_engines(struct drm_i915_private *i915) · line 3336

Quoted 6 lines
drivers/gpu/drm/i915/i915_gem.c +2 -1
@@ -3332,7 +3332,8 @@ static int wait_for_engines(struct drm_i915_private *i915)
 	enum intel_engine_id id;
 
 	for_each_engine(engine, i915, id) {
-		if (GEM_WARN_ON(wait_for_engine(engine, 50))) {
+		if (wait_for_engine(engine, 50)) {
+			GEM_WARN(1, "%s wait for idle timeout", engine->name);

Nice touching adding the engine->name

Quoted 16 lines
drivers/gpu/drm/i915/i915_gem.c +0 -0
 			i915_gem_set_wedged(i915);
 			return -EIO;
 		}
drivers/gpu/drm/i915/i915_gem.h +1 -0
index ee54597465b6..cefc6cf96a60 100644
@@ -30,6 +30,7 @@
 #ifdef CONFIG_DRM_I915_DEBUG_GEM
 #define GEM_BUG_ON(expr) BUG_ON(expr)
 #define GEM_WARN_ON(expr) WARN_ON(expr)
+#define GEM_WARN(condition, format, ...) WARN(condition, format, __VA_ARGS__)
 
 #define GEM_DEBUG_DECL(var) var
 #define GEM_DEBUG_EXEC(expr) expr

drivers/gpu/drm/i915/i915_gem.h line 42

Quoted 4 lines
drivers/gpu/drm/i915/i915_gem.h +1 -0
@@ -38,6 +39,7 @@
 #else
 #define GEM_BUG_ON(expr) BUILD_BUG_ON_INVALID(expr)
 #define GEM_WARN_ON(expr) (BUILD_BUG_ON_INVALID(expr), 0)
+#define GEM_WARN(condition, format, ...) BUILD_BUG_ON_INVALID(condition)

WARNs can be used as part of an if(), so perhaps

Quoted 2 lines

#define GEM_WARN(condition, format, ...) (BUILD_BUG_ON_INVALID(condition), 0) #define GEM_WARN_ON(expr) GEM_WARN((expr), 0)

Sorry, I just can't resist the "told you so" here.

If you come up with a local pattern that's deceptively similar to a widely used one, with the crucial difference that you can't use anything with required side effects in it, you'll screw it up eventually.

Quoted 8 lines
Quoted 3 lines

if (GEM_WARN_ON(wait_for_engine(engine, 50))) looks completely natural and "obviously correct" in code, but is dead wrong. This won't be the last time.

I would also prefer to make it consistent.

There are two other users of GEM_WARN_ON in i915_vma_bind to consider what to do with, but anyway it would be a much better solution.

My suggestion is to make GEM_WARN_ON and friends that are conditional to CONFIG_DRM_I915_DEBUG_GEM unusable as expressions. Make them fail to build within if (...) for both CONFIG_DRM_I915_DEBUG_GEM=y and =n. Then if you need that kind of construct, handle it with something like:

Quoted 6 lines
	if (IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM) && condition) {
		GEM_WARN(...);
		...
	}

maybe wrapping that IS_ENABLED bit in a more manageable macro.

Quoted 7 lines

Why not simply make it work like a normal WARN_ON? Eg:

#ifdef ...DEBUG_GEM
#define GEM_WARN_ON(expr) WARN_ON(expr)
#else
#define GEM_WARN_ON(expr) (expr)
#endif

I thought Chris explicitly wanted it to be lighter and leave expr out completely on non-debug builds.

BR,
Jani.

Quoted 4 lines

Regards,

Tvrtko

Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx