Skip to contentSkip to conversation

drm/vblank: drop use of DRM_WAIT_ON()

PATCH Superseded Sam Ravnborg 3 participants 6 messages Jul 18, 2019 – Jul 19, 2019

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/vblank: drop use of DRM_WAIT_ON()

From e6f70cb90e0c3c90d45017a8257353652b7e0dcc Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <[email protected]>
Date: Thu, 30 May 2019 09:38:47 +0200
Subject: [PATCH] drm/vblank: drop use of DRM_WAIT_ON()

DRM_WAIT_ON() is from the deprecated drm_os_linux header and the modern replacement is the wait_event_*.

The return values differ, so a conversion is needed to keep the original interface towards userspace. Introduced a switch/case to make code obvious and to allow different debug prints depending on the result.

Cc Maarten Lankhorst <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>

---

To verify if it works with the fix.
(Added wat variable to handle the situation where we never wait)

Sam

 drivers/gpu/drm/drm_vblank.c | 32 ++++++++++++++++++++++----------
 1 file changed, 22 insertions(+), 10 deletions(-)
drivers/gpu/drm/drm_vblank.c +22 -10
index 603ab105125d..4e83f1dfd446 100644
@@ -31,7 +31,6 @@
 #include <drm/drm_drv.h>
 #include <drm/drm_framebuffer.h>
 #include <drm/drm_print.h>
-#include <drm/drm_os_linux.h>
 #include <drm/drm_vblank.h>
 
 #include "drm_internal.h"
@@ -1576,7 +1575,7 @@ int drm_wait_vblank_ioctl(struct drm_device *dev, void *data,
 	struct drm_crtc *crtc;
 	struct drm_vblank_crtc *vblank;
 	union drm_wait_vblank *vblwait = data;
-	int ret;
+	int ret, wait;
 	u64 req_seq, seq;
 	unsigned int pipe_index;
 	unsigned int flags, pipe, high_pipe;
@@ -1669,22 +1668,35 @@ int drm_wait_vblank_ioctl(struct drm_device *dev, void *data,
 		return drm_queue_vblank_event(dev, pipe, req_seq, vblwait, file_priv);
 	}
 
+	wait = 1;
 	if (req_seq != seq) {
 		DRM_DEBUG("waiting on vblank count %llu, crtc %u\n",
 			  req_seq, pipe);
-		DRM_WAIT_ON(ret, vblank->queue, 3 * HZ,
-			    vblank_passed(drm_vblank_count(dev, pipe),
-					  req_seq) ||
-			    !READ_ONCE(vblank->enabled));
+		wait = wait_event_interruptible_timeout(vblank->queue,
+			vblank_passed(drm_vblank_count(dev, pipe), req_seq) ||
+				      !READ_ONCE(vblank->enabled),
+			msecs_to_jiffies(3000));
 	}
 
-	if (ret != -EINTR) {
+	switch (wait) {
+	case 0:
+		/* timeout */
+		ret = -EBUSY;
 		drm_wait_vblank_reply(dev, pipe, &vblwait->reply);
-
-		DRM_DEBUG("crtc %d returning %u to client\n",
+		DRM_DEBUG("timeout waiting for vblank. crtc %d returning %u to client\n",
 			  pipe, vblwait->reply.sequence);
-	} else {
+		break;
+	case -ERESTARTSYS:
+		/* interrupted by signal */
+		ret = -EINTR;
 		DRM_DEBUG("crtc %d vblank wait interrupted by signal\n", pipe);
+		break;
+	default:
+		ret = 0;
+		drm_wait_vblank_reply(dev, pipe, &vblwait->reply);
+		DRM_DEBUG("crtc %d returning %u to client\n",
+			  pipe, vblwait->reply.sequence);
+		break;
 	}
 
 done:
Signature · 6 lines
2.20.1

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

✗ Fi.CI.CHECKPATCH: warning for series starting with [1/1] drm/vblank: drop use of DRM_WAIT_ON()

== Series Details ==

== Series Details ==

Series: series starting with [1/1] drm/vblank: drop use of DRM_WAIT_ON()
URL : https://patchwork.freedesktop.org/series/63913/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
d52a61072bb5 drm/vblank: drop use of DRM_WAIT_ON()
-:55: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis
#55: FILE: drivers/gpu/drm/drm_vblank.c:1676:
+		wait = wait_event_interruptible_timeout(vblank->queue,
+			vblank_passed(drm_vblank_count(dev, pipe), req_seq) ||

total: 0 errors, 0 warnings, 1 checks, 58 lines checked

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

#2 lore raw

✓ Fi.CI.BAT: success for series starting with [1/1] drm/vblank: drop use of DRM_WAIT_ON()

In reply to Sam Ravnborg
== Series Details ==

== Series Details ==

Series: series starting with [1/1] drm/vblank: drop use of DRM_WAIT_ON()
URL : https://patchwork.freedesktop.org/series/63913/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_6507 -> Patchwork_13694
====================================================

Summary
-------

**SUCCESS**

No regressions found.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13694/

Known issues
------------

Here are the changes found in Patchwork_13694 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@gem_exec_suspend@basic-s3:
- fi-blb-e6850: [PASS][1] -> [INCOMPLETE][2] ([fdo#107718])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6507/fi-blb-e6850/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13694/fi-blb-e6850/igt@[email protected]

* igt@prime_vgem@basic-fence-flip:
- fi-ilk-650: [PASS][3] -> [DMESG-WARN][4] ([fdo#106387])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6507/fi-ilk-650/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13694/fi-ilk-650/igt@[email protected]

#### Possible fixes ####

* igt@i915_pm_rpm@module-reload:
- fi-icl-dsi: [INCOMPLETE][5] ([fdo#107713] / [fdo#108840]) -> [PASS][6]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6507/fi-icl-dsi/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13694/fi-icl-dsi/igt@[email protected]

* igt@kms_chamelium@dp-edid-read:
- fi-kbl-7500u: [WARN][7] ([fdo#109483]) -> [PASS][8]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6507/fi-kbl-7500u/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13694/fi-kbl-7500u/igt@[email protected]

* igt@kms_chamelium@hdmi-hpd-fast:
- fi-kbl-7500u: [FAIL][9] ([fdo#109485]) -> [PASS][10]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6507/fi-kbl-7500u/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13694/fi-kbl-7500u/igt@[email protected]

* igt@kms_frontbuffer_tracking@basic:
- {fi-icl-u4}: [FAIL][11] ([fdo#103167]) -> [PASS][12]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6507/fi-icl-u4/igt@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13694/fi-icl-u4/igt@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#106387]: https://bugs.freedesktop.org/show_bug.cgi?id=106387
[fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
[fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718
[fdo#108840]: https://bugs.freedesktop.org/show_bug.cgi?id=108840
[fdo#109483]: https://bugs.freedesktop.org/show_bug.cgi?id=109483
[fdo#109485]: https://bugs.freedesktop.org/show_bug.cgi?id=109485

Participating hosts (53 -> 47)
------------------------------

Additional (1): fi-bsw-n3050
Missing (7): fi-kbl-soraka fi-ilk-m540 fi-byt-squawks fi-bsw-cyan fi-icl-y fi-byt-clapper fi-bdw-samus

Build changes
-------------

* Linux: CI_DRM_6507 -> Patchwork_13694

CI_DRM_6507: a607eef7a42e6788090f1ff4de30ed821ad87ad9 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5102: 6038ace76016d8892f4d13aef5301f71ca1a6e2d @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_13694: d52a61072bb50e83ea8d1e82dffe1b55ff8f7a70 @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

d52a61072bb5 drm/vblank: drop use of DRM_WAIT_ON()

== Logs ==

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

#3 lore raw

✓ Fi.CI.IGT: success for series starting with [1/1] drm/vblank: drop use of DRM_WAIT_ON()

In reply to Sam Ravnborg
== Series Details ==

== Series Details ==

Series: series starting with [1/1] drm/vblank: drop use of DRM_WAIT_ON()
URL : https://patchwork.freedesktop.org/series/63913/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_6507_full -> Patchwork_13694_full
====================================================

Summary
-------

**SUCCESS**

No regressions found.

Known issues
------------

Here are the changes found in Patchwork_13694_full that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@i915_selftest@live_hangcheck:
- shard-iclb: [PASS][1] -> [INCOMPLETE][2] ([fdo#107713] / [fdo#108569])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6507/shard-iclb5/igt@i915_selftest@live_hangcheck.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13694/shard-iclb6/igt@i915_selftest@live_hangcheck.html

* igt@kms_fbcon_fbt@fbc-suspend:
- shard-skl: [PASS][3] -> [FAIL][4] ([fdo#103833])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6507/shard-skl8/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13694/shard-skl9/igt@[email protected]

* igt@kms_frontbuffer_tracking@fbc-1p-offscren-pri-shrfb-draw-pwrite:
- shard-iclb: [PASS][5] -> [FAIL][6] ([fdo#103167]) +6 similar issues
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6507/shard-iclb2/igt@kms_frontbuffer_tracking@fbc-1p-offscren-pri-shrfb-draw-pwrite.html
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13694/shard-iclb5/igt@kms_frontbuffer_tracking@fbc-1p-offscren-pri-shrfb-draw-pwrite.html

* igt@kms_frontbuffer_tracking@fbc-1p-primscrn-pri-shrfb-draw-blt:
- shard-skl: [PASS][7] -> [FAIL][8] ([fdo#108040])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6507/shard-skl8/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13694/shard-skl9/igt@[email protected]

* igt@kms_frontbuffer_tracking@fbc-suspend:
- shard-kbl: [PASS][9] -> [DMESG-WARN][10] ([fdo#108566]) +1 similar issue
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6507/shard-kbl7/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13694/shard-kbl6/igt@[email protected]

* igt@kms_frontbuffer_tracking@psr-1p-primscrn-pri-shrfb-draw-blt:
- shard-skl: [PASS][11] -> [FAIL][12] ([fdo#103167]) +2 similar issues
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6507/shard-skl8/igt@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13694/shard-skl9/igt@[email protected]

* igt@kms_plane@plane-panning-bottom-right-suspend-pipe-b-planes:
- shard-apl: [PASS][13] -> [DMESG-WARN][14] ([fdo#108566]) +1 similar issue
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6507/shard-apl4/igt@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13694/shard-apl6/igt@[email protected]

* igt@kms_plane_alpha_blend@pipe-a-coverage-7efc:
- shard-skl: [PASS][15] -> [FAIL][16] ([fdo#108145])
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6507/shard-skl8/igt@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13694/shard-skl9/igt@[email protected]

* igt@kms_plane_lowres@pipe-a-tiling-y:
- shard-iclb: [PASS][17] -> [FAIL][18] ([fdo#103166])
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6507/shard-iclb6/igt@[email protected]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13694/shard-iclb8/igt@[email protected]

* igt@kms_psr2_su@frontbuffer:
- shard-iclb: [PASS][19] -> [SKIP][20] ([fdo#109642] / [fdo#111068])
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6507/shard-iclb2/igt@[email protected]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13694/shard-iclb4/igt@[email protected]

* igt@kms_psr@psr2_primary_page_flip:
- shard-iclb: [PASS][21] -> [SKIP][22] ([fdo#109441])
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6507/shard-iclb2/igt@kms_psr@psr2_primary_page_flip.html
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13694/shard-iclb5/igt@kms_psr@psr2_primary_page_flip.html

* igt@kms_setmode@basic:
- shard-kbl: [PASS][23] -> [FAIL][24] ([fdo#99912])
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6507/shard-kbl3/igt@[email protected]
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13694/shard-kbl3/igt@[email protected]

* igt@perf@oa-exponents:
- shard-glk: [PASS][25] -> [FAIL][26] ([fdo#105483])
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6507/shard-glk7/igt@[email protected]
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13694/shard-glk4/igt@[email protected]

#### Possible fixes ####

* igt@i915_pm_rps@waitboost:
- shard-skl: [FAIL][27] ([fdo#102250]) -> [PASS][28]
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6507/shard-skl9/igt@[email protected]
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13694/shard-skl5/igt@[email protected]

* igt@i915_suspend@fence-restore-tiled2untiled:
- shard-apl: [DMESG-WARN][29] ([fdo#108566]) -> [PASS][30] +2 similar issues
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6507/shard-apl4/igt@[email protected]
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13694/shard-apl6/igt@[email protected]

* igt@kms_flip@flip-vs-expired-vblank:
- shard-skl: [FAIL][31] ([fdo#105363]) -> [PASS][32] +1 similar issue
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6507/shard-skl3/igt@[email protected]
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13694/shard-skl6/igt@[email protected]

* igt@kms_flip@flip-vs-suspend-interruptible:
- shard-hsw: [INCOMPLETE][33] ([fdo#103540]) -> [PASS][34]
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6507/shard-hsw8/igt@[email protected]
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13694/shard-hsw4/igt@[email protected]

* igt@kms_frontbuffer_tracking@fbc-1p-offscren-pri-indfb-draw-render:
- shard-iclb: [FAIL][35] ([fdo#103167]) -> [PASS][36] +5 similar issues
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6507/shard-iclb8/igt@kms_frontbuffer_tracking@fbc-1p-offscren-pri-indfb-draw-render.html
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13694/shard-iclb7/igt@kms_frontbuffer_tracking@fbc-1p-offscren-pri-indfb-draw-render.html

* igt@kms_plane_alpha_blend@pipe-c-constant-alpha-min:
- shard-skl: [FAIL][37] ([fdo#108145]) -> [PASS][38]
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6507/shard-skl7/igt@[email protected]
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13694/shard-skl8/igt@[email protected]

* igt@kms_plane_alpha_blend@pipe-c-coverage-7efc:
- shard-skl: [FAIL][39] ([fdo#108145] / [fdo#110403]) -> [PASS][40]
[39]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6507/shard-skl1/igt@[email protected]
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13694/shard-skl8/igt@[email protected]

* igt@kms_psr@psr2_sprite_plane_move:
- shard-iclb: [SKIP][41] ([fdo#109441]) -> [PASS][42] +1 similar issue
[41]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6507/shard-iclb3/igt@kms_psr@psr2_sprite_plane_move.html
[42]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13694/shard-iclb2/igt@kms_psr@psr2_sprite_plane_move.html

* igt@perf@blocking:
- shard-skl: [FAIL][43] ([fdo#110728]) -> [PASS][44] +1 similar issue
[43]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6507/shard-skl9/igt@[email protected]
[44]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13694/shard-skl2/igt@[email protected]

#### Warnings ####

* igt@i915_pm_rpm@modeset-lpsp-stress:
- shard-apl: [SKIP][45] ([fdo#109271]) -> [INCOMPLETE][46] ([fdo#103927])
[45]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6507/shard-apl6/igt@[email protected]
[46]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13694/shard-apl7/igt@[email protected]

[fdo#102250]: https://bugs.freedesktop.org/show_bug.cgi?id=102250
[fdo#103166]: https://bugs.freedesktop.org/show_bug.cgi?id=103166
[fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#103540]: https://bugs.freedesktop.org/show_bug.cgi?id=103540
[fdo#103833]: https://bugs.freedesktop.org/show_bug.cgi?id=103833
[fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
[fdo#105363]: https://bugs.freedesktop.org/show_bug.cgi?id=105363
[fdo#105483]: https://bugs.freedesktop.org/show_bug.cgi?id=105483
[fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
[fdo#108040]: https://bugs.freedesktop.org/show_bug.cgi?id=108040
[fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
[fdo#108566]: https://bugs.freedesktop.org/show_bug.cgi?id=108566
[fdo#108569]: https://bugs.freedesktop.org/show_bug.cgi?id=108569
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109441]: https://bugs.freedesktop.org/show_bug.cgi?id=109441
[fdo#109642]: https://bugs.freedesktop.org/show_bug.cgi?id=109642
[fdo#110403]: https://bugs.freedesktop.org/show_bug.cgi?id=110403
[fdo#110728]: https://bugs.freedesktop.org/show_bug.cgi?id=110728
[fdo#111068]: https://bugs.freedesktop.org/show_bug.cgi?id=111068
[fdo#99912]: https://bugs.freedesktop.org/show_bug.cgi?id=99912

Participating hosts (10 -> 10)
------------------------------

No changes in participating hosts

Build changes
-------------

* Linux: CI_DRM_6507 -> Patchwork_13694

CI_DRM_6507: a607eef7a42e6788090f1ff4de30ed821ad87ad9 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5102: 6038ace76016d8892f4d13aef5301f71ca1a6e2d @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_13694: d52a61072bb50e83ea8d1e82dffe1b55ff8f7a70 @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

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

#4 lore raw
In reply to Sam Ravnborg
Quoted 8 lines · Sam Ravnborg

From e6f70cb90e0c3c90d45017a8257353652b7e0dcc Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <[email protected]>
Date: Thu, 30 May 2019 09:38:47 +0200
Subject: [PATCH] drm/vblank: drop use of DRM_WAIT_ON()

DRM_WAIT_ON() is from the deprecated drm_os_linux header and the modern replacement is the wait_event_*.

Quoted 7 lines

The return values differ, so a conversion is needed to keep the original interface towards userspace. Introduced a switch/case to make code obvious and to allow different debug prints depending on the result.

A bit bold to keep the r-b for this substantial bugfix to the patch.

Also not per-patch changelog here. Plus doesn't seem to be on dri-devel somehow.

Quoted 36 lines
Cc Maarten Lankhorst <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>

---

To verify if it works with the fix.
(Added wat variable to handle the situation where we never wait)

Sam

 drivers/gpu/drm/drm_vblank.c | 32 ++++++++++++++++++++++----------
 1 file changed, 22 insertions(+), 10 deletions(-)
drivers/gpu/drm/drm_vblank.c +1 -2
index 603ab105125d..4e83f1dfd446 100644
@@ -31,7 +31,6 @@
 #include <drm/drm_drv.h>
 #include <drm/drm_framebuffer.h>
 #include <drm/drm_print.h>
-#include <drm/drm_os_linux.h>
 #include <drm/drm_vblank.h>
 
 #include "drm_internal.h"
@@ -1576,7 +1575,7 @@ int drm_wait_vblank_ioctl(struct drm_device *dev, void *data,
 	struct drm_crtc *crtc;
 	struct drm_vblank_crtc *vblank;
 	union drm_wait_vblank *vblwait = data;
-	int ret;
+	int ret, wait;
 	u64 req_seq, seq;
 	unsigned int pipe_index;
 	unsigned int flags, pipe, high_pipe;

drivers/gpu/drm/drm_vblank.c int drm_wait_vblank_ioctl(struct drm_device *dev, void *data, · line 1671

Quoted 4 lines
drivers/gpu/drm/drm_vblank.c +1 -0
@@ -1669,22 +1668,35 @@ int drm_wait_vblank_ioctl(struct drm_device *dev, void *data,
 		return drm_queue_vblank_event(dev, pipe, req_seq, vblwait, file_priv);
 	}
 
+	wait = 1;

Instead of this hack I think better to remap the ret value in the if condition. This here is really hard to read.
-Daniel

Quoted 46 lines
drivers/gpu/drm/drm_vblank.c +20 -8
 	if (req_seq != seq) {
 		DRM_DEBUG("waiting on vblank count %llu, crtc %u\n",
 			  req_seq, pipe);
-		DRM_WAIT_ON(ret, vblank->queue, 3 * HZ,
-			    vblank_passed(drm_vblank_count(dev, pipe),
-					  req_seq) ||
-			    !READ_ONCE(vblank->enabled));
+		wait = wait_event_interruptible_timeout(vblank->queue,
+			vblank_passed(drm_vblank_count(dev, pipe), req_seq) ||
+				      !READ_ONCE(vblank->enabled),
+			msecs_to_jiffies(3000));
 	}
 
-	if (ret != -EINTR) {
+	switch (wait) {
+	case 0:
+		/* timeout */
+		ret = -EBUSY;
 		drm_wait_vblank_reply(dev, pipe, &vblwait->reply);
-
-		DRM_DEBUG("crtc %d returning %u to client\n",
+		DRM_DEBUG("timeout waiting for vblank. crtc %d returning %u to client\n",
 			  pipe, vblwait->reply.sequence);
-	} else {
+		break;
+	case -ERESTARTSYS:
+		/* interrupted by signal */
+		ret = -EINTR;
 		DRM_DEBUG("crtc %d vblank wait interrupted by signal\n", pipe);
+		break;
+	default:
+		ret = 0;
+		drm_wait_vblank_reply(dev, pipe, &vblwait->reply);
+		DRM_DEBUG("crtc %d returning %u to client\n",
+			  pipe, vblwait->reply.sequence);
+		break;
 	}
 
 done:
Signature · 6 lines
2.20.1

_______________________________________________
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
#5 lore raw

Hi Daniel.

Quoted 14 lines · Daniel Vetter
Quoted 13 lines · Sam Ravnborg

From e6f70cb90e0c3c90d45017a8257353652b7e0dcc Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <[email protected]>
Date: Thu, 30 May 2019 09:38:47 +0200
Subject: [PATCH] drm/vblank: drop use of DRM_WAIT_ON()

DRM_WAIT_ON() is from the deprecated drm_os_linux header and the modern replacement is the wait_event_*.

The return values differ, so a conversion is needed to keep the original interface towards userspace. Introduced a switch/case to make code obvious and to allow different debug prints depending on the result.

Quoted 7 lines
Quoted 2 lines

A bit bold to keep the r-b for this substantial bugfix to the patch.

Also not per-patch changelog here. Plus doesn't seem to be on dri-devel somehow.

It was a quick hack that I just throw after IGT for testing and did not really consider that there are subscribers on the mailing list too. Should have dealt with this like any public patch.

The patch in question handle the situation where req_seq equals seq. This was not correct before.

I looked at the IGT test results while they were running and concluded that the run was bad - was suprised to see it passed this morning.

Anyway, as pointed out on irc and in your other mail, there is a significant difference in polling or just waiting with some explicit wakeups.

So in v3 I have just opencoded DRM_WAIT_ON() - but I will post this only after I have done some more local testing.
Hopefully tonight if the weather is not too good.

If, on the other hand, you think I should try to move forward with wait_event_* then I will address your feedback below. It needs to be simpler and more clear what is going on.

Sam

Quoted 84 lines
Quoted 37 lines
Cc Maarten Lankhorst <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>

---

To verify if it works with the fix.
(Added wat variable to handle the situation where we never wait)

Sam

 drivers/gpu/drm/drm_vblank.c | 32 ++++++++++++++++++++++----------
 1 file changed, 22 insertions(+), 10 deletions(-)
drivers/gpu/drm/drm_vblank.c +1 -2
index 603ab105125d..4e83f1dfd446 100644
@@ -31,7 +31,6 @@
 #include <drm/drm_drv.h>
 #include <drm/drm_framebuffer.h>
 #include <drm/drm_print.h>
-#include <drm/drm_os_linux.h>
 #include <drm/drm_vblank.h>
 
 #include "drm_internal.h"
@@ -1576,7 +1575,7 @@ int drm_wait_vblank_ioctl(struct drm_device *dev, void *data,
 	struct drm_crtc *crtc;
 	struct drm_vblank_crtc *vblank;
 	union drm_wait_vblank *vblwait = data;
-	int ret;
+	int ret, wait;
 	u64 req_seq, seq;
 	unsigned int pipe_index;
 	unsigned int flags, pipe, high_pipe;

drivers/gpu/drm/drm_vblank.c int drm_wait_vblank_ioctl(struct drm_device *dev, void *data, · line 1671

Quoted 4 lines
drivers/gpu/drm/drm_vblank.c +1 -0
@@ -1669,22 +1668,35 @@ int drm_wait_vblank_ioctl(struct drm_device *dev, void *data,
 		return drm_queue_vblank_event(dev, pipe, req_seq, vblwait, file_priv);
 	}
 
+	wait = 1;

Instead of this hack I think better to remap the ret value in the if condition. This here is really hard to read.
-Daniel

Quoted 38 lines
drivers/gpu/drm/drm_vblank.c +20 -8
 	if (req_seq != seq) {
 		DRM_DEBUG("waiting on vblank count %llu, crtc %u\n",
 			  req_seq, pipe);
-		DRM_WAIT_ON(ret, vblank->queue, 3 * HZ,
-			    vblank_passed(drm_vblank_count(dev, pipe),
-					  req_seq) ||
-			    !READ_ONCE(vblank->enabled));
+		wait = wait_event_interruptible_timeout(vblank->queue,
+			vblank_passed(drm_vblank_count(dev, pipe), req_seq) ||
+				      !READ_ONCE(vblank->enabled),
+			msecs_to_jiffies(3000));
 	}
 
-	if (ret != -EINTR) {
+	switch (wait) {
+	case 0:
+		/* timeout */
+		ret = -EBUSY;
 		drm_wait_vblank_reply(dev, pipe, &vblwait->reply);
-
-		DRM_DEBUG("crtc %d returning %u to client\n",
+		DRM_DEBUG("timeout waiting for vblank. crtc %d returning %u to client\n",
 			  pipe, vblwait->reply.sequence);
-	} else {
+		break;
+	case -ERESTARTSYS:
+		/* interrupted by signal */
+		ret = -EINTR;
 		DRM_DEBUG("crtc %d vblank wait interrupted by signal\n", pipe);
+		break;
+	default:
+		ret = 0;
+		drm_wait_vblank_reply(dev, pipe, &vblwait->reply);
+		DRM_DEBUG("crtc %d returning %u to client\n",
+			  pipe, vblwait->reply.sequence);
+		break;
 	}
 
Quoted 13 lines
Quoted 8 lines
drivers/gpu/drm/drm_vblank.c +0 -0
 done:
Signature · 6 lines
2.20.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 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