Skip to contentSkip to conversation

tests/kms_closefb: add CLOSEFB IOCTL test

PATCH Superseded Simon Ser 4 participants 6 messages Oct 16, 2023 – Oct 18, 2023 Arm/Amlogic Meson SoC support

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Simon Ser

author
#0 lore raw

PATCH 1/1 tests/kms_closefb: add CLOSEFB IOCTL test

CLOSEFB is the same as RMFB but keeps the FB alive as long as any plane is using it. Check the behavior of that IOCTL.

---
 tests/kms_closefb.c | 141 ++++++++++++++++++++++++++++++++++++++++++++
 tests/meson.build   |   1 +
 2 files changed, 142 insertions(+)
 create mode 100644 tests/kms_closefb.c
tests/kms_closefb.c new file +141 -0
new file mode 100644
index 000000000000..26e1670bd29a
@@ -0,0 +1,141 @@
+/*
+ * Copyright © 2023 Simon Ser
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "igt.h"
+#include "drmtest.h"
+#include <errno.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+
+/**
+ * TEST: kms closefb
+ * Category: Display
+ * Description: This tests CLOSEFB behavior. Contrary to RMFB, the
+ *              framebuffers should not be removed from the CRTC.
+ *
+ * SUBTEST: closefb-ioctl
+ * Description: CLOSEFB is supposed to leave all planes intact.
+ */
+
+IGT_TEST_DESCRIPTION("This tests CLOSEFB behavior. Contrary to RMFB, the"
+		     "framebuffers should not be removed from the CRTC.");
+
+// TODO: drop when shipped in kernel header
+#ifndef DRM_IOCTL_MODE_CLOSEFB
+#define DRM_IOCTL_MODE_CLOSEFB DRM_IOWR(0xD0, unsigned int)
+#endif
+
+/* 1. Set primary plane to a known FB.
+ * 2. Make sure GETCRTC returns the correct FB ID.
+ * 3. Call CLOSEFB on the FB.
+ * 4. Make sure GETCRTC returns non-0 FB ID.
+ */
+static void
+test_closefb(int *drm_fd, igt_display_t *display, igt_output_t *output,
+	     enum pipe pipe)
+{
+	struct igt_fb fb;
+	drmModeModeInfo *mode;
+	igt_plane_t *plane;
+	drmModeCrtc *crtc;
+	int ret;
+
+	mode = igt_output_get_mode(output);
+	plane = igt_pipe_get_plane_type(&display->pipes[pipe], DRM_PLANE_TYPE_PRIMARY);
+
+	igt_create_fb(*drm_fd, mode->hdisplay, mode->vdisplay,
+		      DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_LINEAR, &fb);
+	igt_plane_set_fb(plane, &fb);
+	igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);
+
+	crtc = drmModeGetCrtc(*drm_fd, output->config.crtc->crtc_id);
+	igt_assert_eq(crtc->buffer_id, fb.fb_id);
+	drmModeFreeCrtc(crtc);
+
+	ret = drmIoctl(*drm_fd, DRM_IOCTL_MODE_CLOSEFB, &fb.fb_id);
+	igt_assert_eq(ret, 0);
+
+	/* Re-open our DRM FD. Without CLOSEFB, this would implicitly turn off
+	 * the CRTC and remove the FB (see test kms_rmfb@close-fd). */
+	drm_close_driver(*drm_fd);
+	*drm_fd = drm_open_driver_master(DRIVER_ANY);
+	drmSetClientCap(*drm_fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
+	drmSetClientCap(*drm_fd, DRM_CLIENT_CAP_ATOMIC, 1);
+	igt_pipe_refresh(display, pipe, true);
+
+	/* Check that our CRTC still has the FB attached */
+	crtc = drmModeGetCrtc(*drm_fd, output->config.crtc->crtc_id);
+	igt_assert_eq(crtc->buffer_id, fb.fb_id);
+	drmModeFreeCrtc(crtc);
+}
+
+static void
+run_closefb_test(int *drm_fd, igt_display_t *display)
+{
+	igt_output_t *output;
+	enum pipe pipe;
+
+	for_each_pipe_with_single_output(display, pipe, output) {
+		igt_display_reset(display);
+
+		igt_output_set_pipe(output, pipe);
+
+		igt_dynamic_f("pipe-%s-%s", kmstest_pipe_name(pipe),
+			      igt_output_name(output))
+			test_closefb(drm_fd, display, output, pipe);
+	}
+}
+
+igt_main
+{
+	int drm_fd;
+	igt_display_t display;
+	uint32_t fb_id = 0;
+	int ret;
+
+	igt_fixture {
+		drm_fd = drm_open_driver_master(DRIVER_ANY);
+
+		kmstest_set_vt_graphics_mode();
+
+		igt_display_require(&display, drm_fd);
+		igt_display_require_output(&display);
+
+		/* Detect kernel support for CLOSEFB */
+		ret = drmIoctl(drm_fd, DRM_IOCTL_MODE_CLOSEFB, &fb_id);
+		igt_require(ret != 0 && errno == ENOENT);
+	}
+
+	igt_describe("CLOSEFB is supposed to not touch any plane the FB is "
+		     "currently attached to. Check that behavior.");
+	igt_subtest_with_dynamic("closefb-ioctl") {
+		run_closefb_test(&drm_fd, &display);
+	}
+
+	igt_fixture {
+		igt_display_fini(&display);
+		drm_close_driver(drm_fd);
+	}
+}
tests/meson.build +1 -0
index 2c2e1ca9acad..6b1b15973bde 100644
@@ -21,6 +21,7 @@ test_progs = [
 	'kms_atomic_interruptible',
 	'kms_atomic_transition',
 	'kms_bw',
+	'kms_closefb',
 	'kms_color',
 	'kms_concurrent',
 	'kms_content_protection',
Signature · 1 line
2.42.0
#1 lore raw

[igt-dev] ✓ CI.xeBAT: success for tests/kms_closefb: add CLOSEFB IOCTL test

== Series Details ==

== Series Details ==

Series: tests/kms_closefb: add CLOSEFB IOCTL test
URL : https://patchwork.freedesktop.org/series/125174/
State : success

== Summary ==

CI Bug Log - changes from XEIGT_7541_BAT -> XEIGTPW_10007_BAT
====================================================

Summary
-------

**SUCCESS**

No regressions found.

Participating hosts (4 -> 4)
------------------------------

No changes in participating hosts

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

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

### IGT changes ###

#### Possible fixes ####

* igt@kms_cursor_legacy@basic-flip-before-cursor-atomic:
- bat-adlp-7: [FAIL][1] ([i915#2346]) -> [PASS][2]
[1]: https://intel-gfx-ci.01.org/tree/intel-xe/IGT_7541/bat-adlp-7/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10007/bat-adlp-7/igt@[email protected]

* igt@kms_flip@basic-flip-vs-wf_vblank@c-edp1:
- bat-adlp-7: [FAIL][3] ([Intel XE#480]) -> [PASS][4] +1 other test pass
[3]: https://intel-gfx-ci.01.org/tree/intel-xe/IGT_7541/bat-adlp-7/igt@kms_flip@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10007/bat-adlp-7/igt@kms_flip@[email protected]

* {igt@xe_create@create-execqueues-noleak}:
- bat-adlp-7: [FAIL][5] ([Intel XE#524]) -> [PASS][6]
[5]: https://intel-gfx-ci.01.org/tree/intel-xe/IGT_7541/bat-adlp-7/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10007/bat-adlp-7/igt@[email protected]

* igt@xe_exec_reset@virtual-close-fd-no-exec:
- bat-pvc-2: [DMESG-WARN][7] ([Intel XE#696]) -> [PASS][8]
[7]: https://intel-gfx-ci.01.org/tree/intel-xe/IGT_7541/bat-pvc-2/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10007/bat-pvc-2/igt@[email protected]

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

[Intel XE#480]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/480
[Intel XE#524]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/524
[Intel XE#696]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/696
[i915#2346]: https://gitlab.freedesktop.org/drm/intel/issues/2346

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

* IGT: IGT_7541 -> IGTPW_10007
* Linux: xe-435-ab7cd1b4af95baba2d6ce5487d35ffda523e895d -> xe-436-9471d9e9efb920d70538445ffa07193d603b8cdb

IGTPW_10007: 10007
IGT_7541: fcddb77c3f8a77020f7f3b2660a66cae27cfaa2b @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
xe-435-ab7cd1b4af95baba2d6ce5487d35ffda523e895d: ab7cd1b4af95baba2d6ce5487d35ffda523e895d xe-436-9471d9e9efb920d70538445ffa07193d603b8cdb: 9471d9e9efb920d70538445ffa07193d603b8cdb

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10007/index.html

#2 lore raw

[igt-dev] ✗ Fi.CI.BAT: failure for tests/kms_closefb: add CLOSEFB IOCTL test

In reply to Simon Ser
== Series Details ==

== Series Details ==

Series: tests/kms_closefb: add CLOSEFB IOCTL test
URL : https://patchwork.freedesktop.org/series/125174/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_13762 -> IGTPW_10007
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with IGTPW_10007 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes
introduced in IGTPW_10007, please notify your bug team ([email protected]) to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10007/index.html

Participating hosts (33 -> 33)
------------------------------

Additional (1): bat-dg2-9
Missing (1): fi-kbl-soraka

Possible new issues
-------------------

Here are the unknown changes that may have been introduced in IGTPW_10007:

### IGT changes ###

#### Possible regressions ####

* igt@i915_selftest@live@hangcheck:
- fi-skl-guc: [PASS][1] -> [DMESG-FAIL][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13762/fi-skl-guc/igt@i915_selftest@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10007/fi-skl-guc/igt@i915_selftest@[email protected]

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

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

### IGT changes ###

#### Issues hit ####

* igt@debugfs_test@read_all_entries:
- fi-cfl-8109u: [PASS][3] -> [INCOMPLETE][4] ([i915#2295])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13762/fi-cfl-8109u/igt@debugfs_test@read_all_entries.html
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10007/fi-cfl-8109u/igt@debugfs_test@read_all_entries.html

* igt@gem_exec_suspend@basic-s0@lmem0:
- bat-dg2-9: NOTRUN -> [INCOMPLETE][5] ([i915#9275])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10007/bat-dg2-9/igt@gem_exec_suspend@[email protected]

* igt@gem_mmap@basic:
- bat-dg2-9: NOTRUN -> [SKIP][6] ([i915#4083])
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10007/bat-dg2-9/igt@[email protected]

* igt@gem_mmap_gtt@basic:
- bat-dg2-9: NOTRUN -> [SKIP][7] ([i915#4077]) +2 other tests skip
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10007/bat-dg2-9/igt@[email protected]

* igt@gem_render_tiled_blits@basic:
- bat-dg2-9: NOTRUN -> [SKIP][8] ([i915#4079]) +1 other test skip
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10007/bat-dg2-9/igt@[email protected]

* igt@i915_pm_rps@basic-api:
- bat-dg2-9: NOTRUN -> [SKIP][9] ([i915#6621])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10007/bat-dg2-9/igt@[email protected]

* igt@i915_selftest@live@workarounds:
- bat-dg2-11: [PASS][10] -> [DMESG-FAIL][11] ([i915#9500])
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13762/bat-dg2-11/igt@i915_selftest@[email protected]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10007/bat-dg2-11/igt@i915_selftest@[email protected]

* igt@i915_suspend@basic-s3-without-i915:
- bat-mtlp-8: NOTRUN -> [SKIP][12] ([i915#6645])
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10007/bat-mtlp-8/igt@[email protected]

* igt@kms_addfb_basic@addfb25-y-tiled-small-legacy:
- bat-dg2-9: NOTRUN -> [SKIP][13] ([i915#5190])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10007/bat-dg2-9/igt@[email protected]

* igt@kms_addfb_basic@basic-y-tiled-legacy:
- bat-dg2-9: NOTRUN -> [SKIP][14] ([i915#4215] / [i915#5190])
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10007/bat-dg2-9/igt@[email protected]

* igt@kms_addfb_basic@framebuffer-vs-set-tiling:
- bat-dg2-9: NOTRUN -> [SKIP][15] ([i915#4212]) +6 other tests skip
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10007/bat-dg2-9/igt@[email protected]

* igt@kms_addfb_basic@tile-pitch-mismatch:
- bat-dg2-9: NOTRUN -> [SKIP][16] ([i915#4212] / [i915#5608])
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10007/bat-dg2-9/igt@[email protected]

* igt@kms_cursor_legacy@basic-busy-flip-before-cursor-legacy:
- bat-dg2-9: NOTRUN -> [SKIP][17] ([i915#4103] / [i915#4213] / [i915#5608]) +1 other test skip
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10007/bat-dg2-9/igt@[email protected]

* igt@kms_force_connector_basic@force-load-detect:
- bat-dg2-9: NOTRUN -> [SKIP][18] ([fdo#109285])
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10007/bat-dg2-9/igt@[email protected]

* igt@kms_force_connector_basic@prune-stale-modes:
- bat-dg2-9: NOTRUN -> [SKIP][19] ([i915#5274])
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10007/bat-dg2-9/igt@[email protected]

* igt@kms_pipe_crc_basic@nonblocking-crc-frame-sequence:
- bat-dg2-11: NOTRUN -> [SKIP][20] ([i915#1845] / [i915#9197]) +3 other tests skip
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10007/bat-dg2-11/igt@[email protected]

* igt@kms_pipe_crc_basic@read-crc-frame-sequence@pipe-d-edp-1:
- bat-rplp-1: [PASS][21] -> [ABORT][22] ([i915#8668])
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13762/bat-rplp-1/igt@kms_pipe_crc_basic@[email protected]
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10007/bat-rplp-1/igt@kms_pipe_crc_basic@[email protected]

* igt@kms_psr@sprite_plane_onoff:
- bat-dg2-9: NOTRUN -> [SKIP][23] ([i915#1072]) +3 other tests skip
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10007/bat-dg2-9/igt@kms_psr@sprite_plane_onoff.html

* igt@kms_setmode@basic-clone-single-crtc:
- bat-dg2-9: NOTRUN -> [SKIP][24] ([i915#3555] / [i915#4098])
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10007/bat-dg2-9/igt@[email protected]

* igt@prime_vgem@basic-fence-flip:
- bat-dg2-9: NOTRUN -> [SKIP][25] ([i915#3708])
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10007/bat-dg2-9/igt@[email protected]

* igt@prime_vgem@basic-fence-mmap:
- bat-dg2-9: NOTRUN -> [SKIP][26] ([i915#3708] / [i915#4077]) +1 other test skip
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10007/bat-dg2-9/igt@[email protected]

* igt@prime_vgem@basic-write:
- bat-dg2-9: NOTRUN -> [SKIP][27] ([i915#3291] / [i915#3708]) +2 other tests skip
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10007/bat-dg2-9/igt@[email protected]

#### Possible fixes ####

* igt@i915_selftest@live@requests:
- bat-mtlp-8: [ABORT][28] ([i915#9414]) -> [PASS][29]
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13762/bat-mtlp-8/igt@i915_selftest@[email protected]
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10007/bat-mtlp-8/igt@i915_selftest@[email protected]

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

[fdo#109285]: https://bugs.freedesktop.org/show_bug.cgi?id=109285
[i915#1072]: https://gitlab.freedesktop.org/drm/intel/issues/1072
[i915#1845]: https://gitlab.freedesktop.org/drm/intel/issues/1845
[i915#2295]: https://gitlab.freedesktop.org/drm/intel/issues/2295
[i915#3291]: https://gitlab.freedesktop.org/drm/intel/issues/3291
[i915#3555]: https://gitlab.freedesktop.org/drm/intel/issues/3555
[i915#3708]: https://gitlab.freedesktop.org/drm/intel/issues/3708
[i915#4077]: https://gitlab.freedesktop.org/drm/intel/issues/4077
[i915#4079]: https://gitlab.freedesktop.org/drm/intel/issues/4079
[i915#4083]: https://gitlab.freedesktop.org/drm/intel/issues/4083
[i915#4098]: https://gitlab.freedesktop.org/drm/intel/issues/4098
[i915#4103]: https://gitlab.freedesktop.org/drm/intel/issues/4103
[i915#4212]: https://gitlab.freedesktop.org/drm/intel/issues/4212
[i915#4213]: https://gitlab.freedesktop.org/drm/intel/issues/4213
[i915#4215]: https://gitlab.freedesktop.org/drm/intel/issues/4215
[i915#5190]: https://gitlab.freedesktop.org/drm/intel/issues/5190
[i915#5274]: https://gitlab.freedesktop.org/drm/intel/issues/5274
[i915#5354]: https://gitlab.freedesktop.org/drm/intel/issues/5354
[i915#5608]: https://gitlab.freedesktop.org/drm/intel/issues/5608
[i915#6621]: https://gitlab.freedesktop.org/drm/intel/issues/6621
[i915#6645]: https://gitlab.freedesktop.org/drm/intel/issues/6645
[i915#8668]: https://gitlab.freedesktop.org/drm/intel/issues/8668
[i915#9197]: https://gitlab.freedesktop.org/drm/intel/issues/9197
[i915#9275]: https://gitlab.freedesktop.org/drm/intel/issues/9275
[i915#9414]: https://gitlab.freedesktop.org/drm/intel/issues/9414
[i915#9500]: https://gitlab.freedesktop.org/drm/intel/issues/9500

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

* CI: CI-20190529 -> None
* IGT: IGT_7541 -> IGTPW_10007

CI-20190529: 20190529
CI_DRM_13762: 5f3d2f483aa4182d5d6e6629d56f46a1f38168c4 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_10007: 10007
IGT_7541: fcddb77c3f8a77020f7f3b2660a66cae27cfaa2b @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git

Testlist changes
----------------

+igt@kms_closefb@closefb-ioctl
-igt@xe_mmap@cpu-caching-coh
-igt@xe_pat@pat-index-all
-igt@xe_pat@pat-index-common-blt
-igt@xe_pat@pat-index-common-render
-igt@xe_pat@pat-index-xe2-blt
-igt@xe_pat@pat-index-xe2-render
-igt@xe_pat@userptr-coh-none

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10007/index.html

#3 lore raw
In reply to Simon Ser

Hi Simon,

tests/kms_closefb.c

Quoted 16 lines · Simon Ser

CLOSEFB is the same as RMFB but keeps the FB alive as long as any plane is using it. Check the behavior of that IOCTL.

---
 tests/kms_closefb.c | 141 ++++++++++++++++++++++++++++++++++++++++++++
 tests/meson.build   |   1 +
 2 files changed, 142 insertions(+)
 create mode 100644 tests/kms_closefb.c
tests/kms_closefb.c new file +0 -0
new file mode 100644
index 000000000000..26e1670bd29a
@@ -0,0 +1,141 @@

Put SPDX MIT here:
// SPDX-License-Identifier: MIT

tests/kms_closefb.c line 4

Quoted 4 lines
tests/kms_closefb.c new file +4 -0
+/*
+ * Copyright © 2023 Simon Ser
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a

Delete this (SPDX above replaces this).

Quoted 11 lines
tests/kms_closefb.c new file +11 -0
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR

tests/kms_closefb.c line 25

Quoted 10 lines
tests/kms_closefb.c new file +10 -0
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "igt.h"
+#include "drmtest.h"

------------^^^
igt includes should follow after systems ones (below) and should also be sorted alphabetically (drmtest.h before igt.h)

tests/kms_closefb.c line 30

Quoted 5 lines
tests/kms_closefb.c new file +5 -0
+#include <errno.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>

Here put igt includes (after newline).

This is kms test so adding Juha-Pekka and Bhanu on cc.

Regards,
Kamil

Quoted 127 lines
tests/kms_closefb.c new file +111 -0
+
+/**
+ * TEST: kms closefb
+ * Category: Display
+ * Description: This tests CLOSEFB behavior. Contrary to RMFB, the
+ *              framebuffers should not be removed from the CRTC.
+ *
+ * SUBTEST: closefb-ioctl
+ * Description: CLOSEFB is supposed to leave all planes intact.
+ */
+
+IGT_TEST_DESCRIPTION("This tests CLOSEFB behavior. Contrary to RMFB, the"
+		     "framebuffers should not be removed from the CRTC.");
+
+// TODO: drop when shipped in kernel header
+#ifndef DRM_IOCTL_MODE_CLOSEFB
+#define DRM_IOCTL_MODE_CLOSEFB DRM_IOWR(0xD0, unsigned int)
+#endif
+
+/* 1. Set primary plane to a known FB.
+ * 2. Make sure GETCRTC returns the correct FB ID.
+ * 3. Call CLOSEFB on the FB.
+ * 4. Make sure GETCRTC returns non-0 FB ID.
+ */
+static void
+test_closefb(int *drm_fd, igt_display_t *display, igt_output_t *output,
+	     enum pipe pipe)
+{
+	struct igt_fb fb;
+	drmModeModeInfo *mode;
+	igt_plane_t *plane;
+	drmModeCrtc *crtc;
+	int ret;
+
+	mode = igt_output_get_mode(output);
+	plane = igt_pipe_get_plane_type(&display->pipes[pipe], DRM_PLANE_TYPE_PRIMARY);
+
+	igt_create_fb(*drm_fd, mode->hdisplay, mode->vdisplay,
+		      DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_LINEAR, &fb);
+	igt_plane_set_fb(plane, &fb);
+	igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);
+
+	crtc = drmModeGetCrtc(*drm_fd, output->config.crtc->crtc_id);
+	igt_assert_eq(crtc->buffer_id, fb.fb_id);
+	drmModeFreeCrtc(crtc);
+
+	ret = drmIoctl(*drm_fd, DRM_IOCTL_MODE_CLOSEFB, &fb.fb_id);
+	igt_assert_eq(ret, 0);
+
+	/* Re-open our DRM FD. Without CLOSEFB, this would implicitly turn off
+	 * the CRTC and remove the FB (see test kms_rmfb@close-fd). */
+	drm_close_driver(*drm_fd);
+	*drm_fd = drm_open_driver_master(DRIVER_ANY);
+	drmSetClientCap(*drm_fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
+	drmSetClientCap(*drm_fd, DRM_CLIENT_CAP_ATOMIC, 1);
+	igt_pipe_refresh(display, pipe, true);
+
+	/* Check that our CRTC still has the FB attached */
+	crtc = drmModeGetCrtc(*drm_fd, output->config.crtc->crtc_id);
+	igt_assert_eq(crtc->buffer_id, fb.fb_id);
+	drmModeFreeCrtc(crtc);
+}
+
+static void
+run_closefb_test(int *drm_fd, igt_display_t *display)
+{
+	igt_output_t *output;
+	enum pipe pipe;
+
+	for_each_pipe_with_single_output(display, pipe, output) {
+		igt_display_reset(display);
+
+		igt_output_set_pipe(output, pipe);
+
+		igt_dynamic_f("pipe-%s-%s", kmstest_pipe_name(pipe),
+			      igt_output_name(output))
+			test_closefb(drm_fd, display, output, pipe);
+	}
+}
+
+igt_main
+{
+	int drm_fd;
+	igt_display_t display;
+	uint32_t fb_id = 0;
+	int ret;
+
+	igt_fixture {
+		drm_fd = drm_open_driver_master(DRIVER_ANY);
+
+		kmstest_set_vt_graphics_mode();
+
+		igt_display_require(&display, drm_fd);
+		igt_display_require_output(&display);
+
+		/* Detect kernel support for CLOSEFB */
+		ret = drmIoctl(drm_fd, DRM_IOCTL_MODE_CLOSEFB, &fb_id);
+		igt_require(ret != 0 && errno == ENOENT);
+	}
+
+	igt_describe("CLOSEFB is supposed to not touch any plane the FB is "
+		     "currently attached to. Check that behavior.");
+	igt_subtest_with_dynamic("closefb-ioctl") {
+		run_closefb_test(&drm_fd, &display);
+	}
+
+	igt_fixture {
+		igt_display_fini(&display);
+		drm_close_driver(drm_fd);
+	}
+}
tests/meson.build +1 -0
index 2c2e1ca9acad..6b1b15973bde 100644
@@ -21,6 +21,7 @@ test_progs = [
 	'kms_atomic_interruptible',
 	'kms_atomic_transition',
 	'kms_bw',
+	'kms_closefb',
 	'kms_color',
 	'kms_concurrent',
 	'kms_content_protection',
Signature · 1 line
2.42.0
#4 lore raw

Hi Simon,

Quoted 63 lines · Kamil Konieczny

Hi Simon,

tests/kms_closefb.c

Quoted 16 lines · Simon Ser

CLOSEFB is the same as RMFB but keeps the FB alive as long as any plane is using it. Check the behavior of that IOCTL.

---
  tests/kms_closefb.c | 141 ++++++++++++++++++++++++++++++++++++++++++++
  tests/meson.build   |   1 +
  2 files changed, 142 insertions(+)

create mode 100644 tests/kms_closefb.c

tests/kms_closefb.c new file +0 -0
new file mode 100644
index 000000000000..26e1670bd29a
@@ -0,0 +1,141 @@

Put SPDX MIT here:
// SPDX-License-Identifier: MIT

tests/kms_closefb.c line 4

Quoted 4 lines
tests/kms_closefb.c new file +4 -0
+/*
+ * Copyright © 2023 Simon Ser
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a

Delete this (SPDX above replaces this).

Quoted 11 lines
tests/kms_closefb.c new file +11 -0
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR

tests/kms_closefb.c line 25

Quoted 10 lines
tests/kms_closefb.c new file +10 -0
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "igt.h"
+#include "drmtest.h"

------------^^^
igt includes should follow after systems ones (below) and should also be sorted alphabetically (drmtest.h before igt.h)

tests/kms_closefb.c line 30

Quoted 5 lines
tests/kms_closefb.c new file +5 -0
+#include <errno.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>

Here put igt includes (after newline).

Quoted 1 line

This is kms test so adding Juha-Pekka and Bhanu on cc.

On quick look test generally look ok but was the discussion already finished on dri-devel? Will this ioctl be merged as you had on your drm patches or are there still changes expected? Ie. should I look at this version closer or wait for a minute?

/Juha-Pekka

Quoted 128 lines
Quoted 128 lines
tests/kms_closefb.c new file +111 -0
+
+/**
+ * TEST: kms closefb
+ * Category: Display
+ * Description: This tests CLOSEFB behavior. Contrary to RMFB, the
+ *              framebuffers should not be removed from the CRTC.
+ *
+ * SUBTEST: closefb-ioctl
+ * Description: CLOSEFB is supposed to leave all planes intact.
+ */
+
+IGT_TEST_DESCRIPTION("This tests CLOSEFB behavior. Contrary to RMFB, the"
+		     "framebuffers should not be removed from the CRTC.");
+
+// TODO: drop when shipped in kernel header
+#ifndef DRM_IOCTL_MODE_CLOSEFB
+#define DRM_IOCTL_MODE_CLOSEFB DRM_IOWR(0xD0, unsigned int)
+#endif
+
+/* 1. Set primary plane to a known FB.
+ * 2. Make sure GETCRTC returns the correct FB ID.
+ * 3. Call CLOSEFB on the FB.
+ * 4. Make sure GETCRTC returns non-0 FB ID.
+ */
+static void
+test_closefb(int *drm_fd, igt_display_t *display, igt_output_t *output,
+	     enum pipe pipe)
+{
+	struct igt_fb fb;
+	drmModeModeInfo *mode;
+	igt_plane_t *plane;
+	drmModeCrtc *crtc;
+	int ret;
+
+	mode = igt_output_get_mode(output);
+	plane = igt_pipe_get_plane_type(&display->pipes[pipe], DRM_PLANE_TYPE_PRIMARY);
+
+	igt_create_fb(*drm_fd, mode->hdisplay, mode->vdisplay,
+		      DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_LINEAR, &fb);
+	igt_plane_set_fb(plane, &fb);
+	igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);
+
+	crtc = drmModeGetCrtc(*drm_fd, output->config.crtc->crtc_id);
+	igt_assert_eq(crtc->buffer_id, fb.fb_id);
+	drmModeFreeCrtc(crtc);
+
+	ret = drmIoctl(*drm_fd, DRM_IOCTL_MODE_CLOSEFB, &fb.fb_id);
+	igt_assert_eq(ret, 0);
+
+	/* Re-open our DRM FD. Without CLOSEFB, this would implicitly turn off
+	 * the CRTC and remove the FB (see test kms_rmfb@close-fd). */
+	drm_close_driver(*drm_fd);
+	*drm_fd = drm_open_driver_master(DRIVER_ANY);
+	drmSetClientCap(*drm_fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
+	drmSetClientCap(*drm_fd, DRM_CLIENT_CAP_ATOMIC, 1);
+	igt_pipe_refresh(display, pipe, true);
+
+	/* Check that our CRTC still has the FB attached */
+	crtc = drmModeGetCrtc(*drm_fd, output->config.crtc->crtc_id);
+	igt_assert_eq(crtc->buffer_id, fb.fb_id);
+	drmModeFreeCrtc(crtc);
+}
+
+static void
+run_closefb_test(int *drm_fd, igt_display_t *display)
+{
+	igt_output_t *output;
+	enum pipe pipe;
+
+	for_each_pipe_with_single_output(display, pipe, output) {
+		igt_display_reset(display);
+
+		igt_output_set_pipe(output, pipe);
+
+		igt_dynamic_f("pipe-%s-%s", kmstest_pipe_name(pipe),
+			      igt_output_name(output))
+			test_closefb(drm_fd, display, output, pipe);
+	}
+}
+
+igt_main
+{
+	int drm_fd;
+	igt_display_t display;
+	uint32_t fb_id = 0;
+	int ret;
+
+	igt_fixture {
+		drm_fd = drm_open_driver_master(DRIVER_ANY);
+
+		kmstest_set_vt_graphics_mode();
+
+		igt_display_require(&display, drm_fd);
+		igt_display_require_output(&display);
+
+		/* Detect kernel support for CLOSEFB */
+		ret = drmIoctl(drm_fd, DRM_IOCTL_MODE_CLOSEFB, &fb_id);
+		igt_require(ret != 0 && errno == ENOENT);
+	}
+
+	igt_describe("CLOSEFB is supposed to not touch any plane the FB is "
+		     "currently attached to. Check that behavior.");
+	igt_subtest_with_dynamic("closefb-ioctl") {
+		run_closefb_test(&drm_fd, &display);
+	}
+
+	igt_fixture {
+		igt_display_fini(&display);
+		drm_close_driver(drm_fd);
+	}
+}
tests/meson.build +1 -0
index 2c2e1ca9acad..6b1b15973bde 100644
@@ -21,6 +21,7 @@ test_progs = [
  	'kms_atomic_interruptible',
  	'kms_atomic_transition',
  	'kms_bw',
+	'kms_closefb',
  	'kms_color',
  	'kms_concurrent',
  	'kms_content_protection',
Signature · 1 line
2.42.0
author
#5 lore raw
Quoted 4 lines · Juha-Pekka Heikkila

On quick look test generally look ok but was the discussion already finished on dri-devel? Will this ioctl be merged as you had on your drm patches or are there still changes expected? Ie. should I look at this version closer or wait for a minute?

Yes, the IOCTL will probably be merged as-is, it's been discussed with various kernel folks (e.g. Sima Vetter) before-hand.

Thanks for having a look!