2 * Copyright © 2014 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
31 #include "igt_debugfs.h"
33 #include "intel_chipset.h"
34 #include "intel_batchbuffer.h"
35 #include "ioctl_wrappers.h"
39 igt_display_t display;
43 * This test tries to provoke the kernel to leak a pending page flip event
44 * when the fd is closed before the flip has completed. The test itself won't
45 * fail even if the kernel leaks the event, but the resulting dmesg WARN
46 * will cause piglit to report a failure.
48 static bool test(data_t *data, enum pipe pipe, igt_output_t *output)
51 drmModeModeInfo *mode;
55 /* select the pipe we want to use */
56 igt_output_set_pipe(output, pipe);
57 igt_display_commit(&data->display);
60 igt_output_set_pipe(output, PIPE_ANY);
61 igt_display_commit(&data->display);
65 primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
66 mode = igt_output_get_mode(output);
68 igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay,
71 0.0, 0.0, 0.0, &fb[0]);
73 igt_plane_set_fb(primary, &fb[0]);
74 igt_display_commit2(&data->display, COMMIT_LEGACY);
78 ret = drmDropMaster(data->drm_fd);
81 ret = drmSetMaster(fd);
84 igt_create_color_fb(fd, mode->hdisplay, mode->vdisplay,
87 0.0, 0.0, 0.0, &fb[1]);
88 ret = drmModePageFlip(fd, output->config.crtc->crtc_id,
89 fb[1].fb_id, DRM_MODE_PAGE_FLIP_EVENT,
96 ret = drmSetMaster(data->drm_fd);
99 igt_plane_set_fb(primary, NULL);
100 igt_output_set_pipe(output, PIPE_ANY);
101 igt_display_commit(&data->display);
103 igt_remove_fb(data->drm_fd, &fb[0]);
111 igt_output_t *output;
115 igt_skip_on_simulation();
117 data.drm_fd = drm_open_any();
118 igt_set_vt_graphics_mode();
120 igt_display_init(&data.display, data.drm_fd);
122 for (pipe = 0; pipe < 3; pipe++) {
123 for_each_connected_output(&data.display, output) {
124 if (test(&data, pipe, output))
129 igt_require_f(valid_tests, "no valid crtc/connector combinations found\n");
131 igt_display_fini(&data.display);