Skip to contentSkip to conversation

tests/kms_flip: Skip VBlank tests in modules without VBlank

PATCH In review Rodrigo Siqueira 3 participants 6 messages Jun 5, 2019 – Jun 7, 2019 Library code

lore
Share & tools
lore
#0 lore raw

PATCH v8 1/1 tests/kms_flip: Skip VBlank tests in modules without VBlank

The kms_flip test relies on VBlank support, and this situation may exclude some virtual drivers to take advantage of this set of tests. This commit adds a mechanism that checks if a module has VBlank. If the target module has VBlank support, kms_flip will run all the VBlank tests; otherwise, the VBlank tests will be skipped. Additionally, this commit improves the test coverage by checks if the function drmWaitVBlank() returns EOPNOTSUPP (i.e., no VBlank support).

V7: Changes since V6
- Skip TEST_DPMS with TEST_MODESET and TEST_EBUSY if the device does not support vblank

V6: Set errno to zero before call drmWaitVBlank() (Chris Wilson)

V5: Drop the DRM_VBLANK_NEXTONMISS (Chris Wilson)

V4: Replace DRM_VBLANK_ABSOLUTE by DRM_VBLANK_RELATIVE and DRM_VBLANK_NEXTONMISS

V3: Add documentation (Daniel Vetter)

V2: Add new branch coverage to check if VBlank is enabled or not and update commit message

V1: Chris Wilson
- Change function name from igt_there_is_vblank to kms_has_vblank
- Move vblank function check from igt_aux to igt_kms
- Utilizes memset in dummy_vbl variable
- Directly return the result of drmWaitVBlank()

---
 lib/igt_kms.c    | 21 +++++++++++++++++++++
 lib/igt_kms.h    |  2 ++
 tests/kms_flip.c | 24 +++++++++++++++++++++++-
 3 files changed, 46 insertions(+), 1 deletion(-)
lib/igt_kms.c +21 -0
index d7d711a7..8a465f67 100644
@@ -1673,6 +1673,27 @@ void igt_assert_plane_visible(int fd, enum pipe pipe, int plane_index, bool visi
 	igt_assert_eq(visible, visibility);
 }
 
+/**
+ * kms_has_vblank:
+ * @fd: DRM fd
+ *
+ * Get the VBlank errno after an attempt to call drmWaitVBlank(). This
+ * function is useful for checking if a driver has support or not for VBlank.
+ *
+ * Returns: true if target driver has VBlank support, otherwise return false.
+ */
+bool kms_has_vblank(int fd)
+{
+	drmVBlank dummy_vbl;
+
+	memset(&dummy_vbl, 0, sizeof(drmVBlank));
+	dummy_vbl.request.type = DRM_VBLANK_RELATIVE;
+
+	errno = 0;
+	drmWaitVBlank(fd, &dummy_vbl);
+	return (errno != EOPNOTSUPP);
+}
+
 /*
  * A small modeset API
  */
lib/igt_kms.h +2 -0
index 4ac28131..5b5cf274 100644
@@ -229,6 +229,8 @@ void kmstest_wait_for_pageflip(int fd);
 unsigned int kmstest_get_vblank(int fd, int pipe, unsigned int flags);
 void igt_assert_plane_visible(int fd, enum pipe pipe, int plane_index, bool visibility);
 
+bool kms_has_vblank(int fd);
+
 /*
  * A small modeset API
  */
tests/kms_flip.c +23 -1
index d7c1f9cf..2a158d97 100755
@@ -71,6 +71,7 @@
 #define TEST_SUSPEND		(1 << 26)
 #define TEST_BO_TOOBIG		(1 << 28)
 
+#define TEST_NO_VBLANK		(1 << 29)
 #define TEST_BASIC		(1 << 30)
 
 #define EVENT_FLIP		(1 << 0)
@@ -126,6 +127,18 @@ struct event_state {
 	int seq_step;
 };
 
+static bool vblank_dependence(int flags)
+{
+	int vblank_flags = TEST_VBLANK | TEST_VBLANK_BLOCK |
+			   TEST_VBLANK_ABSOLUTE | TEST_VBLANK_EXPIRED_SEQ |
+			   TEST_CHECK_TS | TEST_VBLANK_RACE | TEST_EBUSY;
+
+	if (flags & vblank_flags)
+		return true;
+
+	return false;
+}
+
 static float timeval_float(const struct timeval *tv)
 {
 	return tv->tv_sec + tv->tv_usec / 1000000.0f;
@@ -494,7 +507,7 @@ static void check_state(const struct test_output *o, const struct event_state *e
 	/* check only valid if no modeset happens in between, that increments by
 	 * (1 << 23) on each step. This bounding matches the one in
 	 * DRM_IOCTL_WAIT_VBLANK. */
-	if (!(o->flags & (TEST_DPMS | TEST_MODESET)))
+	if (!(o->flags & (TEST_DPMS | TEST_MODESET | TEST_NO_VBLANK)))
 		igt_assert_f(es->current_seq - (es->last_seq + o->seq_step) <= 1UL << 23,
 			     "unexpected %s seq %u, should be >= %u\n",
 			     es->name, es->current_seq, es->last_seq + o->seq_step);
@@ -1176,6 +1189,7 @@ static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs,
 	unsigned bo_size = 0;
 	uint64_t tiling;
 	int i;
+	bool vblank = true;
 
 	switch (crtc_count) {
 	case RUN_TEST:
@@ -1259,6 +1273,14 @@ static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs,
 	}
 	igt_assert(fb_is_bound(o, o->fb_ids[0]));
 
+	vblank = kms_has_vblank(drm_fd);
+	if (!vblank) {
+		if (vblank_dependence(o->flags))
+			igt_require_f(vblank, "There is no VBlank\n");
+		else
+			o->flags |= TEST_NO_VBLANK;
+	}
+
 	/* quiescent the hw a bit so ensure we don't miss a single frame */
 	if (o->flags & TEST_CHECK_TS)
 		calibrate_ts(o, crtc_idxs[0]);
Signature · 1 line
2.21.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#1 lore raw

[igt-dev] ✓ Fi.CI.BAT: success for tests/kms_flip: Skip VBlank tests in modules without VBlank (rev7)

== Series Details ==

== Series Details ==

Series: tests/kms_flip: Skip VBlank tests in modules without VBlank (rev7)
URL : https://patchwork.freedesktop.org/series/58091/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_6189 -> IGTPW_3109
====================================================

Summary
-------

**SUCCESS**

No regressions found.

External URL: https://patchwork.freedesktop.org/api/1.0/series/58091/revisions/7/mbox/

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

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

### IGT changes ###

#### Possible fixes ####

* igt@i915_module_load@reload:
- fi-blb-e6850: [INCOMPLETE][1] ([fdo#107718]) -> [PASS][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6189/fi-blb-e6850/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3109/fi-blb-e6850/igt@[email protected]

* igt@i915_pm_rpm@module-reload:
- fi-skl-6770hq: [FAIL][3] ([fdo#108511]) -> [PASS][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6189/fi-skl-6770hq/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3109/fi-skl-6770hq/igt@[email protected]

[fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718
[fdo#108511]: https://bugs.freedesktop.org/show_bug.cgi?id=108511

Participating hosts (50 -> 45)
------------------------------

Additional (2): fi-byt-j1900 fi-icl-u2
Missing (7): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-kbl-7560u fi-byt-clapper fi-bdw-samus

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

* IGT: IGT_5037 -> IGTPW_3109

CI_DRM_6189: 66841d188556097ec9c386a17d96eb4661c5a843 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_3109: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3109/
IGT_5037: a98c9cd50aa48933217ca41055279ccb1680d25b @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

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

#2 lore raw

[igt-dev] ✓ Fi.CI.IGT: success for tests/kms_flip: Skip VBlank tests in modules without VBlank (rev7)

In reply to Rodrigo Siqueira
== Series Details ==

== Series Details ==

Series: tests/kms_flip: Skip VBlank tests in modules without VBlank (rev7)
URL : https://patchwork.freedesktop.org/series/58091/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_6189_full -> IGTPW_3109_full
====================================================

Summary
-------

**SUCCESS**

No regressions found.

External URL: https://patchwork.freedesktop.org/api/1.0/series/58091/revisions/7/mbox/

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

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

### IGT changes ###

#### Issues hit ####

* igt@gem_fence_thrash@bo-copy:
- shard-glk: [PASS][1] -> [INCOMPLETE][2] ([fdo#103359] / [k.org#198133])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6189/shard-glk9/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3109/shard-glk9/igt@[email protected]

* igt@i915_suspend@forcewake:
- shard-apl: [PASS][3] -> [DMESG-WARN][4] ([fdo#108566]) +1 similar issue
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6189/shard-apl4/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3109/shard-apl4/igt@[email protected]

* igt@kms_cursor_crc@pipe-a-cursor-128x128-onscreen:
- shard-kbl: [PASS][5] -> [FAIL][6] ([fdo#103232]) +1 similar issue
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6189/shard-kbl4/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3109/shard-kbl2/igt@[email protected]

* igt@kms_cursor_crc@pipe-a-cursor-64x64-random:
- shard-apl: [PASS][7] -> [FAIL][8] ([fdo#103232])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6189/shard-apl2/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3109/shard-apl3/igt@[email protected]

* igt@kms_flip@2x-flip-vs-modeset-interruptible:
- shard-hsw: [PASS][9] -> [SKIP][10] ([fdo#109271]) +6 similar issues
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6189/shard-hsw6/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3109/shard-hsw1/igt@[email protected]

* igt@kms_frontbuffer_tracking@fbc-suspend:
- shard-kbl: [PASS][11] -> [INCOMPLETE][12] ([fdo#103665]) +1 similar issue
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6189/shard-kbl6/igt@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3109/shard-kbl4/igt@[email protected]

* igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-shrfb-plflip-blt:
- shard-iclb: [PASS][13] -> [FAIL][14] ([fdo#103167]) +6 similar issues
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6189/shard-iclb4/igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-shrfb-plflip-blt.html
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3109/shard-iclb4/igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-shrfb-plflip-blt.html

#### Possible fixes ####

* {igt@gem_ctx_param@vm}:
- shard-hsw: [DMESG-WARN][15] ([fdo#110836]) -> [PASS][16]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6189/shard-hsw8/igt@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3109/shard-hsw2/igt@[email protected]

* igt@gem_exec_schedule@in-order-vebox:
- shard-apl: [INCOMPLETE][17] ([fdo#103927]) -> [PASS][18]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6189/shard-apl3/igt@[email protected]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3109/shard-apl4/igt@[email protected]

* igt@gem_tiled_swapping@non-threaded:
- shard-iclb: [FAIL][19] ([fdo#108686]) -> [PASS][20]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6189/shard-iclb7/igt@[email protected]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3109/shard-iclb5/igt@[email protected]

* igt@i915_suspend@fence-restore-tiled2untiled:
- shard-apl: [DMESG-WARN][21] ([fdo#108566]) -> [PASS][22] +1 similar issue
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6189/shard-apl5/igt@[email protected]
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3109/shard-apl6/igt@[email protected]

* igt@kms_fbcon_fbt@psr-suspend:
- shard-iclb: [FAIL][23] ([fdo#103833]) -> [PASS][24]
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6189/shard-iclb2/igt@[email protected]
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3109/shard-iclb6/igt@[email protected]

* igt@kms_frontbuffer_tracking@fbc-2p-primscrn-cur-indfb-draw-pwrite:
- shard-hsw: [SKIP][25] ([fdo#109271]) -> [PASS][26] +36 similar issues
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6189/shard-hsw1/igt@kms_frontbuffer_tracking@fbc-2p-primscrn-cur-indfb-draw-pwrite.html
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3109/shard-hsw2/igt@kms_frontbuffer_tracking@fbc-2p-primscrn-cur-indfb-draw-pwrite.html

* igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-spr-indfb-draw-pwrite:
- shard-iclb: [FAIL][27] ([fdo#103167]) -> [PASS][28] +4 similar issues
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6189/shard-iclb5/igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-spr-indfb-draw-pwrite.html
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3109/shard-iclb2/igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-spr-indfb-draw-pwrite.html

* igt@kms_frontbuffer_tracking@fbcpsr-rgb101010-draw-mmap-wc:
- shard-iclb: [INCOMPLETE][29] ([fdo#106978] / [fdo#107713]) -> [PASS][30]
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6189/shard-iclb1/igt@[email protected]
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3109/shard-iclb2/igt@[email protected]

* igt@kms_frontbuffer_tracking@psr-rgb101010-draw-render:
- shard-iclb: [FAIL][31] ([fdo#109247]) -> [PASS][32]
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6189/shard-iclb2/igt@[email protected]
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3109/shard-iclb1/igt@[email protected]

* igt@kms_psr@psr2_cursor_render:
- shard-iclb: [SKIP][33] ([fdo#109441]) -> [PASS][34]
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6189/shard-iclb5/igt@kms_psr@psr2_cursor_render.html
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3109/shard-iclb2/igt@kms_psr@psr2_cursor_render.html

* igt@kms_sysfs_edid_timing:
- shard-hsw: [FAIL][35] ([fdo#100047]) -> [PASS][36]
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6189/shard-hsw1/igt@kms_sysfs_edid_timing.html
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3109/shard-hsw8/igt@kms_sysfs_edid_timing.html

* igt@perf@blocking:
- shard-iclb: [FAIL][37] ([fdo#110728]) -> [PASS][38]
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6189/shard-iclb8/igt@[email protected]
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3109/shard-iclb8/igt@[email protected]

#### Warnings ####

* igt@gem_mmap_gtt@forked-big-copy:
- shard-iclb: [INCOMPLETE][39] ([fdo#107713] / [fdo#109100]) -> [TIMEOUT][40] ([fdo#109673])
[39]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6189/shard-iclb3/igt@[email protected]
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3109/shard-iclb5/igt@[email protected]

* igt@kms_cursor_legacy@2x-long-cursor-vs-flip-atomic:
- shard-hsw: [SKIP][41] ([fdo#109271]) -> [FAIL][42] ([fdo#105767])
[41]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6189/shard-hsw1/igt@[email protected]
[42]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3109/shard-hsw8/igt@[email protected]

* igt@kms_psr@psr2_primary_mmap_cpu:
- shard-iclb: [FAIL][43] ([fdo#107383] / [fdo#110215]) -> [SKIP][44] ([fdo#109441])
[43]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6189/shard-iclb2/igt@kms_psr@psr2_primary_mmap_cpu.html
[44]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3109/shard-iclb3/igt@kms_psr@psr2_primary_mmap_cpu.html

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

[fdo#100047]: https://bugs.freedesktop.org/show_bug.cgi?id=100047
[fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#103232]: https://bugs.freedesktop.org/show_bug.cgi?id=103232
[fdo#103359]: https://bugs.freedesktop.org/show_bug.cgi?id=103359
[fdo#103665]: https://bugs.freedesktop.org/show_bug.cgi?id=103665
[fdo#103833]: https://bugs.freedesktop.org/show_bug.cgi?id=103833
[fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
[fdo#105767]: https://bugs.freedesktop.org/show_bug.cgi?id=105767
[fdo#106978]: https://bugs.freedesktop.org/show_bug.cgi?id=106978
[fdo#107383]: https://bugs.freedesktop.org/show_bug.cgi?id=107383
[fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
[fdo#108566]: https://bugs.freedesktop.org/show_bug.cgi?id=108566
[fdo#108686]: https://bugs.freedesktop.org/show_bug.cgi?id=108686
[fdo#109100]: https://bugs.freedesktop.org/show_bug.cgi?id=109100
[fdo#109247]: https://bugs.freedesktop.org/show_bug.cgi?id=109247
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109441]: https://bugs.freedesktop.org/show_bug.cgi?id=109441
[fdo#109673]: https://bugs.freedesktop.org/show_bug.cgi?id=109673
[fdo#110215]: https://bugs.freedesktop.org/show_bug.cgi?id=110215
[fdo#110728]: https://bugs.freedesktop.org/show_bug.cgi?id=110728
[fdo#110836]: https://bugs.freedesktop.org/show_bug.cgi?id=110836
[k.org#198133]: https://bugzilla.kernel.org/show_bug.cgi?id=198133

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

Missing (4): pig-skl-6260u shard-skl pig-hsw-4770r pig-glk-j5005

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

* IGT: IGT_5037 -> IGTPW_3109
* Piglit: piglit_4509 -> None

CI_DRM_6189: 66841d188556097ec9c386a17d96eb4661c5a843 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_3109: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3109/
IGT_5037: a98c9cd50aa48933217ca41055279ccb1680d25b @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

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

#3 lore raw
In reply to Rodrigo Siqueira
Quoted 11 lines · Rodrigo Siqueira

The kms_flip test relies on VBlank support, and this situation may exclude some virtual drivers to take advantage of this set of tests. This commit adds a mechanism that checks if a module has VBlank. If the target module has VBlank support, kms_flip will run all the VBlank tests; otherwise, the VBlank tests will be skipped. Additionally, this commit improves the test coverage by checks if the function drmWaitVBlank() returns EOPNOTSUPP (i.e., no VBlank support).

V7: Changes since V6
- Skip TEST_DPMS with TEST_MODESET and TEST_EBUSY if the device does not support vblank

Hmm, I'm not sure I understand this line. If I'm reading this correctly it refers to this line:

    if (!(o->flags & (TEST_DPMS | TEST_MODESET | TEST_NO_VBLANK)))

So the check was previously skipped on TEST_DPMS and TEST_MODESET. It's now skipped on TEST_NO_VBLANK too. So I'm a little confused with the changelog line: should it say "skip seq number checking it the device doesn't support vblank"?

Am I missing something?

Apart from this, the patch itself looks good to me.

Quoted 123 lines

V6: Set errno to zero before call drmWaitVBlank() (Chris Wilson)

V5: Drop the DRM_VBLANK_NEXTONMISS (Chris Wilson)

V4: Replace DRM_VBLANK_ABSOLUTE by DRM_VBLANK_RELATIVE and DRM_VBLANK_NEXTONMISS

V3: Add documentation (Daniel Vetter)

V2: Add new branch coverage to check if VBlank is enabled or not and update commit message

V1: Chris Wilson
- Change function name from igt_there_is_vblank to kms_has_vblank
- Move vblank function check from igt_aux to igt_kms
- Utilizes memset in dummy_vbl variable
- Directly return the result of drmWaitVBlank()

---
 lib/igt_kms.c    | 21 +++++++++++++++++++++
 lib/igt_kms.h    |  2 ++
 tests/kms_flip.c | 24 +++++++++++++++++++++++-
 3 files changed, 46 insertions(+), 1 deletion(-)
lib/igt_kms.c +21 -0
index d7d711a7..8a465f67 100644
@@ -1673,6 +1673,27 @@ void igt_assert_plane_visible(int fd, enum pipe pipe, int plane_index, bool visi
 	igt_assert_eq(visible, visibility);
 }
 
+/**
+ * kms_has_vblank:
+ * @fd: DRM fd
+ *
+ * Get the VBlank errno after an attempt to call drmWaitVBlank(). This
+ * function is useful for checking if a driver has support or not for VBlank.
+ *
+ * Returns: true if target driver has VBlank support, otherwise return false.
+ */
+bool kms_has_vblank(int fd)
+{
+	drmVBlank dummy_vbl;
+
+	memset(&dummy_vbl, 0, sizeof(drmVBlank));
+	dummy_vbl.request.type = DRM_VBLANK_RELATIVE;
+
+	errno = 0;
+	drmWaitVBlank(fd, &dummy_vbl);
+	return (errno != EOPNOTSUPP);
+}
+
 /*
  * A small modeset API
  */
lib/igt_kms.h +2 -0
index 4ac28131..5b5cf274 100644
@@ -229,6 +229,8 @@ void kmstest_wait_for_pageflip(int fd);
 unsigned int kmstest_get_vblank(int fd, int pipe, unsigned int flags);
 void igt_assert_plane_visible(int fd, enum pipe pipe, int plane_index, bool visibility);
 
+bool kms_has_vblank(int fd);
+
 /*
  * A small modeset API
  */
tests/kms_flip.c +16 -1
index d7c1f9cf..2a158d97 100755
@@ -71,6 +71,7 @@
 #define TEST_SUSPEND		(1 << 26)
 #define TEST_BO_TOOBIG		(1 << 28)
 
+#define TEST_NO_VBLANK		(1 << 29)
 #define TEST_BASIC		(1 << 30)
 
 #define EVENT_FLIP		(1 << 0)
@@ -126,6 +127,18 @@ struct event_state {
 	int seq_step;
 };
 
+static bool vblank_dependence(int flags)
+{
+	int vblank_flags = TEST_VBLANK | TEST_VBLANK_BLOCK |
+			   TEST_VBLANK_ABSOLUTE | TEST_VBLANK_EXPIRED_SEQ |
+			   TEST_CHECK_TS | TEST_VBLANK_RACE | TEST_EBUSY;
+
+	if (flags & vblank_flags)
+		return true;
+
+	return false;
+}
+
 static float timeval_float(const struct timeval *tv)
 {
 	return tv->tv_sec + tv->tv_usec / 1000000.0f;
@@ -494,7 +507,7 @@ static void check_state(const struct test_output *o, const struct event_state *e
 	/* check only valid if no modeset happens in between, that increments by
 	 * (1 << 23) on each step. This bounding matches the one in
 	 * DRM_IOCTL_WAIT_VBLANK. */
-	if (!(o->flags & (TEST_DPMS | TEST_MODESET)))
+	if (!(o->flags & (TEST_DPMS | TEST_MODESET | TEST_NO_VBLANK)))
 		igt_assert_f(es->current_seq - (es->last_seq + o->seq_step) <= 1UL << 23,
 			     "unexpected %s seq %u, should be >= %u\n",
 			     es->name, es->current_seq, es->last_seq + o->seq_step);
@@ -1176,6 +1189,7 @@ static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs,
 	unsigned bo_size = 0;
 	uint64_t tiling;
 	int i;
+	bool vblank = true;
 
 	switch (crtc_count) {
 	case RUN_TEST:
@@ -1259,6 +1273,14 @@ static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs,
 	}
 	igt_assert(fb_is_bound(o, o->fb_ids[0]));
 
+	vblank = kms_has_vblank(drm_fd);

tests/kms_flip.c static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs, · line 1286

Quoted 10 lines
tests/kms_flip.c +7 -0
+	if (!vblank) {
+		if (vblank_dependence(o->flags))
+			igt_require_f(vblank, "There is no VBlank\n");
+		else
+			o->flags |= TEST_NO_VBLANK;
+	}
+
 	/* quiescent the hw a bit so ensure we don't miss a single frame */
 	if (o->flags & TEST_CHECK_TS)
 		calibrate_ts(o, crtc_idxs[0]);

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#4 lore raw
Quoted 18 lines · Simon
Quoted 11 lines · Rodrigo Siqueira

The kms_flip test relies on VBlank support, and this situation may exclude some virtual drivers to take advantage of this set of tests. This commit adds a mechanism that checks if a module has VBlank. If the target module has VBlank support, kms_flip will run all the VBlank tests; otherwise, the VBlank tests will be skipped. Additionally, this commit improves the test coverage by checks if the function drmWaitVBlank() returns EOPNOTSUPP (i.e., no VBlank support).

V7: Changes since V6
- Skip TEST_DPMS with TEST_MODESET and TEST_EBUSY if the device does not support vblank

Hmm, I'm not sure I understand this line. If I'm reading this correctly it refers to this line:

    if (!(o->flags & (TEST_DPMS | TEST_MODESET | TEST_NO_VBLANK)))
Quoted 8 lines

So the check was previously skipped on TEST_DPMS and TEST_MODESET. It's now skipped on TEST_NO_VBLANK too. So I'm a little confused with the changelog line: should it say "skip seq number checking it the device doesn't support vblank"?

Am I missing something?

Apart from this, the patch itself looks good to me.

Hi Simon,

Thank you for your review.

About the changelog message, I'll update it to:

Skip seq number checking and busy flip if the device doesn't support vblank

Can I add your Reviewed-by before applying this patch?

Quoted 133 lines
Quoted 133 lines

V6: Set errno to zero before call drmWaitVBlank() (Chris Wilson)

V5: Drop the DRM_VBLANK_NEXTONMISS (Chris Wilson)

V4: Replace DRM_VBLANK_ABSOLUTE by DRM_VBLANK_RELATIVE and DRM_VBLANK_NEXTONMISS

V3: Add documentation (Daniel Vetter)

V2: Add new branch coverage to check if VBlank is enabled or not and update commit message

V1: Chris Wilson
- Change function name from igt_there_is_vblank to kms_has_vblank
- Move vblank function check from igt_aux to igt_kms
- Utilizes memset in dummy_vbl variable
- Directly return the result of drmWaitVBlank()

---
 lib/igt_kms.c    | 21 +++++++++++++++++++++
 lib/igt_kms.h    |  2 ++
 tests/kms_flip.c | 24 +++++++++++++++++++++++-
 3 files changed, 46 insertions(+), 1 deletion(-)
lib/igt_kms.c +21 -0
index d7d711a7..8a465f67 100644
@@ -1673,6 +1673,27 @@ void igt_assert_plane_visible(int fd, enum pipe pipe, int plane_index, bool visi
 	igt_assert_eq(visible, visibility);
 }
 
+/**
+ * kms_has_vblank:
+ * @fd: DRM fd
+ *
+ * Get the VBlank errno after an attempt to call drmWaitVBlank(). This
+ * function is useful for checking if a driver has support or not for VBlank.
+ *
+ * Returns: true if target driver has VBlank support, otherwise return false.
+ */
+bool kms_has_vblank(int fd)
+{
+	drmVBlank dummy_vbl;
+
+	memset(&dummy_vbl, 0, sizeof(drmVBlank));
+	dummy_vbl.request.type = DRM_VBLANK_RELATIVE;
+
+	errno = 0;
+	drmWaitVBlank(fd, &dummy_vbl);
+	return (errno != EOPNOTSUPP);
+}
+
 /*
  * A small modeset API
  */
lib/igt_kms.h +2 -0
index 4ac28131..5b5cf274 100644
@@ -229,6 +229,8 @@ void kmstest_wait_for_pageflip(int fd);
 unsigned int kmstest_get_vblank(int fd, int pipe, unsigned int flags);
 void igt_assert_plane_visible(int fd, enum pipe pipe, int plane_index, bool visibility);
 
+bool kms_has_vblank(int fd);
+
 /*
  * A small modeset API
  */
tests/kms_flip.c +23 -1
index d7c1f9cf..2a158d97 100755
@@ -71,6 +71,7 @@
 #define TEST_SUSPEND		(1 << 26)
 #define TEST_BO_TOOBIG		(1 << 28)
 
+#define TEST_NO_VBLANK		(1 << 29)
 #define TEST_BASIC		(1 << 30)
 
 #define EVENT_FLIP		(1 << 0)
@@ -126,6 +127,18 @@ struct event_state {
 	int seq_step;
 };
 
+static bool vblank_dependence(int flags)
+{
+	int vblank_flags = TEST_VBLANK | TEST_VBLANK_BLOCK |
+			   TEST_VBLANK_ABSOLUTE | TEST_VBLANK_EXPIRED_SEQ |
+			   TEST_CHECK_TS | TEST_VBLANK_RACE | TEST_EBUSY;
+
+	if (flags & vblank_flags)
+		return true;
+
+	return false;
+}
+
 static float timeval_float(const struct timeval *tv)
 {
 	return tv->tv_sec + tv->tv_usec / 1000000.0f;
@@ -494,7 +507,7 @@ static void check_state(const struct test_output *o, const struct event_state *e
 	/* check only valid if no modeset happens in between, that increments by
 	 * (1 << 23) on each step. This bounding matches the one in
 	 * DRM_IOCTL_WAIT_VBLANK. */
-	if (!(o->flags & (TEST_DPMS | TEST_MODESET)))
+	if (!(o->flags & (TEST_DPMS | TEST_MODESET | TEST_NO_VBLANK)))
 		igt_assert_f(es->current_seq - (es->last_seq + o->seq_step) <= 1UL << 23,
 			     "unexpected %s seq %u, should be >= %u\n",
 			     es->name, es->current_seq, es->last_seq + o->seq_step);
@@ -1176,6 +1189,7 @@ static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs,
 	unsigned bo_size = 0;
 	uint64_t tiling;
 	int i;
+	bool vblank = true;
 
 	switch (crtc_count) {
 	case RUN_TEST:
@@ -1259,6 +1273,14 @@ static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs,
 	}
 	igt_assert(fb_is_bound(o, o->fb_ids[0]));
 
+	vblank = kms_has_vblank(drm_fd);
+	if (!vblank) {
+		if (vblank_dependence(o->flags))
+			igt_require_f(vblank, "There is no VBlank\n");
+		else
+			o->flags |= TEST_NO_VBLANK;
+	}
+
 	/* quiescent the hw a bit so ensure we don't miss a single frame */
 	if (o->flags & TEST_CHECK_TS)
 		calibrate_ts(o, crtc_idxs[0]);
Signature · 2 lines
Rodrigo Siqueira
https://siqueira.tech

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

Reviewed-by
#5 lore raw
Quoted 30 lines · Rodrigo Siqueira
Quoted 18 lines · Simon
Quoted 11 lines · Rodrigo Siqueira

The kms_flip test relies on VBlank support, and this situation may exclude some virtual drivers to take advantage of this set of tests. This commit adds a mechanism that checks if a module has VBlank. If the target module has VBlank support, kms_flip will run all the VBlank tests; otherwise, the VBlank tests will be skipped. Additionally, this commit improves the test coverage by checks if the function drmWaitVBlank() returns EOPNOTSUPP (i.e., no VBlank support).

V7: Changes since V6
- Skip TEST_DPMS with TEST_MODESET and TEST_EBUSY if the device does not support vblank

Hmm, I'm not sure I understand this line. If I'm reading this correctly it refers to this line:

    if (!(o->flags & (TEST_DPMS | TEST_MODESET | TEST_NO_VBLANK)))
Quoted 8 lines

So the check was previously skipped on TEST_DPMS and TEST_MODESET. It's now skipped on TEST_NO_VBLANK too. So I'm a little confused with the changelog line: should it say "skip seq number checking it the device doesn't support vblank"?

Am I missing something?

Apart from this, the patch itself looks good to me.

Hi Simon,

Quoted 7 lines

Thank you for your review.

About the changelog message, I'll update it to:

Skip seq number checking and busy flip if the device doesn't support vblank

Can I add your Reviewed-by before applying this patch?

Yes!

Quoted 122 lines
Quoted 122 lines
Quoted 122 lines

V6: Set errno to zero before call drmWaitVBlank() (Chris Wilson)

V5: Drop the DRM_VBLANK_NEXTONMISS (Chris Wilson)

V4: Replace DRM_VBLANK_ABSOLUTE by DRM_VBLANK_RELATIVE and DRM_VBLANK_NEXTONMISS

V3: Add documentation (Daniel Vetter)

V2: Add new branch coverage to check if VBlank is enabled or not and update commit message

V1: Chris Wilson
- Change function name from igt_there_is_vblank to kms_has_vblank
- Move vblank function check from igt_aux to igt_kms
- Utilizes memset in dummy_vbl variable
- Directly return the result of drmWaitVBlank()

---
 lib/igt_kms.c    | 21 +++++++++++++++++++++
 lib/igt_kms.h    |  2 ++
 tests/kms_flip.c | 24 +++++++++++++++++++++++-
 3 files changed, 46 insertions(+), 1 deletion(-)
lib/igt_kms.c +21 -0
index d7d711a7..8a465f67 100644
@@ -1673,6 +1673,27 @@ void igt_assert_plane_visible(int fd, enum pipe pipe, int plane_index, bool visi
 	igt_assert_eq(visible, visibility);
 }
 
+/**
+ * kms_has_vblank:
+ * @fd: DRM fd
+ *
+ * Get the VBlank errno after an attempt to call drmWaitVBlank(). This
+ * function is useful for checking if a driver has support or not for VBlank.
+ *
+ * Returns: true if target driver has VBlank support, otherwise return false.
+ */
+bool kms_has_vblank(int fd)
+{
+	drmVBlank dummy_vbl;
+
+	memset(&dummy_vbl, 0, sizeof(drmVBlank));
+	dummy_vbl.request.type = DRM_VBLANK_RELATIVE;
+
+	errno = 0;
+	drmWaitVBlank(fd, &dummy_vbl);
+	return (errno != EOPNOTSUPP);
+}
+
 /*
  * A small modeset API
  */
lib/igt_kms.h +2 -0
index 4ac28131..5b5cf274 100644
@@ -229,6 +229,8 @@ void kmstest_wait_for_pageflip(int fd);
 unsigned int kmstest_get_vblank(int fd, int pipe, unsigned int flags);
 void igt_assert_plane_visible(int fd, enum pipe pipe, int plane_index, bool visibility);
 
+bool kms_has_vblank(int fd);
+
 /*
  * A small modeset API
  */
tests/kms_flip.c +15 -1
index d7c1f9cf..2a158d97 100755
@@ -71,6 +71,7 @@
 #define TEST_SUSPEND		(1 << 26)
 #define TEST_BO_TOOBIG		(1 << 28)
 
+#define TEST_NO_VBLANK		(1 << 29)
 #define TEST_BASIC		(1 << 30)
 
 #define EVENT_FLIP		(1 << 0)
@@ -126,6 +127,18 @@ struct event_state {
 	int seq_step;
 };
 
+static bool vblank_dependence(int flags)
+{
+	int vblank_flags = TEST_VBLANK | TEST_VBLANK_BLOCK |
+			   TEST_VBLANK_ABSOLUTE | TEST_VBLANK_EXPIRED_SEQ |
+			   TEST_CHECK_TS | TEST_VBLANK_RACE | TEST_EBUSY;
+
+	if (flags & vblank_flags)
+		return true;
+
+	return false;
+}
+
 static float timeval_float(const struct timeval *tv)
 {
 	return tv->tv_sec + tv->tv_usec / 1000000.0f;
@@ -494,7 +507,7 @@ static void check_state(const struct test_output *o, const struct event_state *e
 	/* check only valid if no modeset happens in between, that increments by
 	 * (1 << 23) on each step. This bounding matches the one in
 	 * DRM_IOCTL_WAIT_VBLANK. */
-	if (!(o->flags & (TEST_DPMS | TEST_MODESET)))
+	if (!(o->flags & (TEST_DPMS | TEST_MODESET | TEST_NO_VBLANK)))
 		igt_assert_f(es->current_seq - (es->last_seq + o->seq_step) <= 1UL << 23,
 			     "unexpected %s seq %u, should be >= %u\n",
 			     es->name, es->current_seq, es->last_seq + o->seq_step);
@@ -1176,6 +1189,7 @@ static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs,
 	unsigned bo_size = 0;
 	uint64_t tiling;
 	int i;
+	bool vblank = true;
 
 	switch (crtc_count) {
 	case RUN_TEST:
@@ -1259,6 +1273,14 @@ static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs,
 	}
 	igt_assert(fb_is_bound(o, o->fb_ids[0]));
 
Quoted 11 lines
Quoted 11 lines

tests/kms_flip.c static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs, · line 1286

Quoted 11 lines
tests/kms_flip.c +8 -0
+	vblank = kms_has_vblank(drm_fd);
+	if (!vblank) {
+		if (vblank_dependence(o->flags))
+			igt_require_f(vblank, "There is no VBlank\n");
+		else
+			o->flags |= TEST_NO_VBLANK;
+	}
+
 	/* quiescent the hw a bit so ensure we don't miss a single frame */
 	if (o->flags & TEST_CHECK_TS)
 		calibrate_ts(o, crtc_idxs[0]);

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev