Skip to contentSkip to conversation

drm/atomic: Make drm_atomic_legacy_backoff reset crtc->acquire_ctx

PATCH In review Maarten Lankhorst 3 participants 3 messages Jun 23, 2016 – Jun 24, 2016

Subsystems (2)
lore
Share & tools
lore

Maarten Lankhorst

author maintainer
#0 lore raw

PATCH 1/1 drm/atomic: Make drm_atomic_legacy_backoff reset crtc->acquire_ctx

Atomic updates may acquire more state than initially locked through drm_modeset_lock_crtc, running with heavy stress can cause a WARN_ON(crtc->acquire_ctx) in drm_modeset_lock_crtc:

[  601.491296] ------------[ cut here ]------------
[  601.491366] WARNING: CPU: 0 PID: 2411 at
drivers/gpu/drm/drm_modeset_lock.c:191 drm_modeset_lock_crtc+0xeb/0xf0 [drm]
[  601.491369] Modules linked in: drm i915 drm_kms_helper
[  601.491414] CPU: 0 PID: 2411 Comm: kms_cursor_lega Tainted: G     U 4.7.0-rc4-patser+ #4798
[  601.491417] Hardware name: Intel Corporation Skylake Client
[  601.491420]  0000000000000000 ffff88044d153c98 ffffffff812ead28 0000000000000000
[  601.491425]  0000000000000000 ffff88044d153cd8 ffffffff810868e6 000000bf58058030
[  601.491431]  ffff880088b415e8 ffff880458058030 ffff88008a271548 ffff88008a271568
[  601.491436] Call Trace:
[  601.491443]  [<ffffffff812ead28>] dump_stack+0x4d/0x65
[  601.491447]  [<ffffffff810868e6>] __warn+0xc6/0xe0
[  601.491452]  [<ffffffff81086968>] warn_slowpath_null+0x18/0x20
[  601.491472]  [<ffffffffc00d4ffb>] drm_modeset_lock_crtc+0xeb/0xf0 [drm]
[  601.491491]  [<ffffffffc00c5526>] drm_mode_cursor_common+0x66/0x180 [drm]
[  601.491509]  [<ffffffffc00c91cc>] drm_mode_cursor_ioctl+0x3c/0x40 [drm]
[  601.491524]  [<ffffffffc00bc94d>] drm_ioctl+0x14d/0x530 [drm]
[  601.491540]  [<ffffffffc00c9190>] ? drm_mode_setcrtc+0x520/0x520 [drm]
[  601.491545]  [<ffffffff81176aeb>] ? handle_mm_fault+0x106b/0x1430
[  601.491550]  [<ffffffff81108441>] ? stop_one_cpu+0x61/0x70
[  601.491556]  [<ffffffff811bb71d>] do_vfs_ioctl+0x8d/0x570
[  601.491560]  [<ffffffff81290d7e>] ? security_file_ioctl+0x3e/0x60
[  601.491565]  [<ffffffff811bbc74>] SyS_ioctl+0x74/0x80
[  601.491571]  [<ffffffff810e321c>] ? posix_get_monotonic_raw+0xc/0x10
[  601.491576]  [<ffffffff8175b11b>] entry_SYSCALL_64_fastpath+0x13/0x8f
[  601.491581] ---[ end trace 56f3d3d85f000d00 ]---

For good measure, test mode_config.acquire_ctx too, although this should never happen.

Testcase: kms_cursor_legacy

---
 drivers/gpu/drm/drm_atomic.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_atomic.c +26 -1
index d99ab2f6663f..3cee084e9d28 100644
@@ -1299,14 +1299,39 @@ EXPORT_SYMBOL(drm_atomic_add_affected_planes);
  */
 void drm_atomic_legacy_backoff(struct drm_atomic_state *state)
 {
+	struct drm_device *dev = state->dev;
+	unsigned crtc_mask = 0;
+	struct drm_crtc *crtc;
 	int ret;
+	bool global = false;
+
+	drm_for_each_crtc(crtc, dev) {
+		if (crtc->acquire_ctx != state->acquire_ctx)
+			continue;
+
+		crtc_mask |= drm_crtc_mask(crtc);
+		crtc->acquire_ctx = NULL;
+	}
+
+	if (WARN_ON(dev->mode_config.acquire_ctx == state->acquire_ctx)) {
+		global = true;
+
+		dev->mode_config.acquire_ctx = NULL;
+	}
 
 retry:
 	drm_modeset_backoff(state->acquire_ctx);
 
-	ret = drm_modeset_lock_all_ctx(state->dev, state->acquire_ctx);
+	ret = drm_modeset_lock_all_ctx(dev, state->acquire_ctx);
 	if (ret)
 		goto retry;
+
+	drm_for_each_crtc(crtc, dev)
+		if (drm_crtc_mask(crtc) & crtc_mask)
+			crtc->acquire_ctx = state->acquire_ctx;
+
+	if (global)
+		dev->mode_config.acquire_ctx = state->acquire_ctx;
 }
 EXPORT_SYMBOL(drm_atomic_legacy_backoff);
 
Signature · 6 lines
2.5.5

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

Atomic updates may acquire more state than initially locked through drm_modeset_lock_crtc, running with heavy stress can cause a WARN_ON(crtc->acquire_ctx) in drm_modeset_lock_crtc:

[  601.491296] ------------[ cut here ]------------
[  601.491366] WARNING: CPU: 0 PID: 2411 at
drivers/gpu/drm/drm_modeset_lock.c:191 drm_modeset_lock_crtc+0xeb/0xf0 [drm]
[  601.491369] Modules linked in: drm i915 drm_kms_helper
[  601.491414] CPU: 0 PID: 2411 Comm: kms_cursor_lega Tainted: G     U 4.7.0-rc4-patser+ #4798
[  601.491417] Hardware name: Intel Corporation Skylake Client
[  601.491420]  0000000000000000 ffff88044d153c98 ffffffff812ead28 0000000000000000
[  601.491425]  0000000000000000 ffff88044d153cd8 ffffffff810868e6 000000bf58058030
[  601.491431]  ffff880088b415e8 ffff880458058030 ffff88008a271548 ffff88008a271568
[  601.491436] Call Trace:
[  601.491443]  [<ffffffff812ead28>] dump_stack+0x4d/0x65
[  601.491447]  [<ffffffff810868e6>] __warn+0xc6/0xe0
[  601.491452]  [<ffffffff81086968>] warn_slowpath_null+0x18/0x20
[  601.491472]  [<ffffffffc00d4ffb>] drm_modeset_lock_crtc+0xeb/0xf0 [drm]
[  601.491491]  [<ffffffffc00c5526>] drm_mode_cursor_common+0x66/0x180 [drm]
[  601.491509]  [<ffffffffc00c91cc>] drm_mode_cursor_ioctl+0x3c/0x40 [drm]
[  601.491524]  [<ffffffffc00bc94d>] drm_ioctl+0x14d/0x530 [drm]
[  601.491540]  [<ffffffffc00c9190>] ? drm_mode_setcrtc+0x520/0x520 [drm]
[  601.491545]  [<ffffffff81176aeb>] ? handle_mm_fault+0x106b/0x1430
[  601.491550]  [<ffffffff81108441>] ? stop_one_cpu+0x61/0x70
[  601.491556]  [<ffffffff811bb71d>] do_vfs_ioctl+0x8d/0x570
[  601.491560]  [<ffffffff81290d7e>] ? security_file_ioctl+0x3e/0x60
[  601.491565]  [<ffffffff811bbc74>] SyS_ioctl+0x74/0x80
[  601.491571]  [<ffffffff810e321c>] ? posix_get_monotonic_raw+0xc/0x10
[  601.491576]  [<ffffffff8175b11b>] entry_SYSCALL_64_fastpath+0x13/0x8f
[  601.491581] ---[ end trace 56f3d3d85f000d00 ]---
Quoted 5 lines

For good measure, test mode_config.acquire_ctx too, although this should never happen.

Testcase: kms_cursor_legacy

It's kinda a bug in the skl wm code which unecessarily looks at other plane state.

Given that this is fairly hard to hit, but will blow in really strange ways in practice I think also justified for backporting.

Dave, can you pls pick up for -fixes directly?

Thanks, Daniel

Quoted 56 lines
---
 drivers/gpu/drm/drm_atomic.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_atomic.c +26 -1
index d99ab2f6663f..3cee084e9d28 100644
@@ -1299,14 +1299,39 @@ EXPORT_SYMBOL(drm_atomic_add_affected_planes);
  */
 void drm_atomic_legacy_backoff(struct drm_atomic_state *state)
 {
+	struct drm_device *dev = state->dev;
+	unsigned crtc_mask = 0;
+	struct drm_crtc *crtc;
 	int ret;
+	bool global = false;
+
+	drm_for_each_crtc(crtc, dev) {
+		if (crtc->acquire_ctx != state->acquire_ctx)
+			continue;
+
+		crtc_mask |= drm_crtc_mask(crtc);
+		crtc->acquire_ctx = NULL;
+	}
+
+	if (WARN_ON(dev->mode_config.acquire_ctx == state->acquire_ctx)) {
+		global = true;
+
+		dev->mode_config.acquire_ctx = NULL;
+	}
 
 retry:
 	drm_modeset_backoff(state->acquire_ctx);
 
-	ret = drm_modeset_lock_all_ctx(state->dev, state->acquire_ctx);
+	ret = drm_modeset_lock_all_ctx(dev, state->acquire_ctx);
 	if (ret)
 		goto retry;
+
+	drm_for_each_crtc(crtc, dev)
+		if (drm_crtc_mask(crtc) & crtc_mask)
+			crtc->acquire_ctx = state->acquire_ctx;
+
+	if (global)
+		dev->mode_config.acquire_ctx = state->acquire_ctx;
 }
 EXPORT_SYMBOL(drm_atomic_legacy_backoff);
 
Signature · 6 lines
2.5.5

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

✗ Ro.CI.BAT: failure for drm/atomic: Make drm_atomic_legacy_backoff reset crtc->acquire_ctx

In reply to Maarten Lankhorst
== Series Details ==

== Series Details ==

Series: drm/atomic: Make drm_atomic_legacy_backoff reset crtc->acquire_ctx
URL : https://patchwork.freedesktop.org/series/9077/
State : failure

== Summary ==

Series 9077v1 drm/atomic: Make drm_atomic_legacy_backoff reset crtc->acquire_ctx
http://patchwork.freedesktop.org/api/1.0/series/9077/revisions/1/mbox

Test vgem_basic:

        Subgroup create:
                skip       -> PASS       (ro-ilk1-i5-650)
                skip       -> PASS       (ro-hsw-i3-4010u)
                skip       -> PASS       (ro-bdw-i7-5600u)
                skip       -> PASS       (ro-bdw-i5-5250u)
                skip       -> PASS       (ro-hsw-i7-4770r)
                skip       -> PASS       (ro-ivb-i7-3770)
                skip       -> PASS       (ro-ivb2-i7-3770)
                skip       -> PASS       (ro-byt-n2820)
                skip       -> PASS       (ro-skl3-i5-6260u)
        Subgroup debugfs:
                skip       -> PASS       (ro-ilk1-i5-650)
                skip       -> PASS       (ro-hsw-i3-4010u)
                skip       -> PASS       (ro-bdw-i7-5600u)
                skip       -> PASS       (ro-bdw-i5-5250u)
                skip       -> PASS       (ro-hsw-i7-4770r)
                skip       -> PASS       (ro-ivb-i7-3770)
                skip       -> PASS       (ro-ivb2-i7-3770)
                skip       -> PASS       (ro-byt-n2820)
                skip       -> PASS       (ro-skl3-i5-6260u)
        Subgroup mmap:
                skip       -> DMESG-FAIL (ro-ilk1-i5-650)
                skip       -> DMESG-FAIL (ro-hsw-i3-4010u)
                skip       -> DMESG-FAIL (ro-bdw-i7-5600u)
                skip       -> DMESG-FAIL (ro-bdw-i5-5250u)
                skip       -> DMESG-FAIL (ro-hsw-i7-4770r)
                skip       -> DMESG-FAIL (ro-ivb-i7-3770)
                skip       -> DMESG-FAIL (ro-ivb2-i7-3770)
                skip       -> DMESG-FAIL (ro-byt-n2820)
                skip       -> DMESG-FAIL (ro-skl3-i5-6260u)
        Subgroup sysfs:
                skip       -> PASS       (ro-ilk1-i5-650)
                skip       -> PASS       (ro-hsw-i3-4010u)
                skip       -> PASS       (ro-bdw-i7-5600u)
                skip       -> PASS       (ro-bdw-i5-5250u)
                skip       -> PASS       (ro-hsw-i7-4770r)
                skip       -> PASS       (ro-ivb-i7-3770)
                skip       -> PASS       (ro-ivb2-i7-3770)
                skip       -> PASS       (ro-byt-n2820)
                skip       -> PASS       (ro-skl3-i5-6260u)
Test vgem_reload_basic:
                skip       -> PASS       (ro-ilk1-i5-650)
                skip       -> PASS       (ro-hsw-i3-4010u)
                skip       -> PASS       (ro-bdw-i7-5600u)
                skip       -> PASS       (ro-bdw-i5-5250u)
                skip       -> PASS       (ro-hsw-i7-4770r)
                skip       -> PASS       (ro-ivb-i7-3770)
                skip       -> PASS       (ro-ivb2-i7-3770)
                skip       -> PASS       (ro-byt-n2820)
                skip       -> PASS       (ro-skl3-i5-6260u)
fi-hsw-i7-4770k  total:227  pass:194  dwarn:0   dfail:0   fail:1   skip:32 
fi-kbl-qkkr      total:227  pass:161  dwarn:29  dfail:0   fail:0   skip:37 
fi-skl-i5-6260u  total:227  pass:202  dwarn:0   dfail:0   fail:1   skip:24 
fi-skl-i7-6700k  total:227  pass:188  dwarn:0   dfail:0   fail:1   skip:38 
fi-snb-i7-2600   total:227  pass:174  dwarn:0   dfail:0   fail:1   skip:52 
ro-bdw-i5-5250u  total:227  pass:201  dwarn:2   dfail:1   fail:1   skip:22 
ro-bdw-i7-5600u  total:227  pass:189  dwarn:0   dfail:1   fail:0   skip:37 
ro-byt-n2820     total:227  pass:177  dwarn:0   dfail:1   fail:4   skip:45 
ro-hsw-i3-4010u  total:227  pass:194  dwarn:0   dfail:1   fail:1   skip:31 
ro-hsw-i7-4770r  total:227  pass:194  dwarn:0   dfail:1   fail:1   skip:31 
ro-ilk1-i5-650   total:222  pass:154  dwarn:0   dfail:1   fail:2   skip:65 
ro-ivb-i7-3770   total:227  pass:185  dwarn:0   dfail:1   fail:1   skip:40 
ro-ivb2-i7-3770  total:227  pass:189  dwarn:0   dfail:1   fail:1   skip:36 
ro-skl3-i5-6260u total:227  pass:205  dwarn:1   dfail:1   fail:1   skip:19 

ro-bdw-i7-5557U failed to connect after reboot
ro-bsw-n3050 failed to connect after reboot

Results at /archive/results/CI_IGT_test/RO_Patchwork_1285/

8e5ac92 drm-intel-nightly: 2016y-06m-22d-18h-10m-30s UTC integration manifest f7de488 drm/atomic: Make drm_atomic_legacy_backoff reset crtc->acquire_ctx

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