Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2013 Intel Corporation |
| 3 | * |
| 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: |
| 10 | * |
| 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 |
| 13 | * Software. |
| 14 | * |
| 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 |
| 21 | * IN THE SOFTWARE. |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | #define _GNU_SOURCE |
| 26 | #include <sched.h> |
Chris Wilson | d2adbdf | 2016-10-04 13:50:50 +0100 | [diff] [blame] | 27 | #include <sys/poll.h> |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 28 | |
| 29 | #include "igt.h" |
Chris Wilson | 376b813 | 2016-07-03 09:42:38 +0100 | [diff] [blame] | 30 | #include "igt_rand.h" |
Chris Wilson | c74e071 | 2016-05-24 16:24:15 +0100 | [diff] [blame] | 31 | #include "igt_stats.h" |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 32 | |
Tomeu Vizoso | 047c999 | 2016-06-07 10:18:34 +0200 | [diff] [blame] | 33 | #if defined(__x86_64__) || defined(__i386__) |
| 34 | #define cpu_relax() __builtin_ia32_pause() |
| 35 | #else |
| 36 | #define cpu_relax() asm volatile("": : :"memory") |
| 37 | #endif |
| 38 | |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 39 | #ifndef DRM_CAP_CURSOR_WIDTH |
| 40 | #define DRM_CAP_CURSOR_WIDTH 0x8 |
| 41 | #endif |
| 42 | |
| 43 | #ifndef DRM_CAP_CURSOR_HEIGHT |
| 44 | #define DRM_CAP_CURSOR_HEIGHT 0x9 |
| 45 | #endif |
| 46 | |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 47 | IGT_TEST_DESCRIPTION("Stress legacy cursor ioctl"); |
| 48 | |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 49 | static void stress(igt_display_t *display, |
| 50 | int pipe, int num_children, unsigned mode, |
Chris Wilson | cce2ff0 | 2016-05-25 08:34:25 +0100 | [diff] [blame] | 51 | int timeout) |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 52 | { |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 53 | struct drm_mode_cursor arg; |
Chris Wilson | c74e071 | 2016-05-24 16:24:15 +0100 | [diff] [blame] | 54 | uint64_t *results; |
Chris Wilson | f5d370c | 2016-06-04 21:25:17 +0100 | [diff] [blame] | 55 | bool torture; |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 56 | int n; |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 57 | unsigned crtc_id[I915_MAX_PIPES], num_crtcs; |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 58 | |
Chris Wilson | f5d370c | 2016-06-04 21:25:17 +0100 | [diff] [blame] | 59 | torture = false; |
| 60 | if (num_children < 0) { |
| 61 | torture = true; |
| 62 | num_children = -num_children; |
| 63 | } |
| 64 | |
Chris Wilson | c74e071 | 2016-05-24 16:24:15 +0100 | [diff] [blame] | 65 | results = mmap(NULL, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0); |
| 66 | igt_assert(results != MAP_FAILED); |
| 67 | |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 68 | memset(&arg, 0, sizeof(arg)); |
| 69 | arg.flags = DRM_MODE_CURSOR_BO; |
| 70 | arg.crtc_id = 0; |
| 71 | arg.width = 64; |
| 72 | arg.height = 64; |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 73 | arg.handle = kmstest_dumb_create(display->drm_fd, 64, 64, 32, NULL, NULL); |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 74 | |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 75 | if (pipe < 0) { |
| 76 | num_crtcs = display->n_pipes; |
| 77 | for_each_pipe(display, n) { |
| 78 | arg.crtc_id = crtc_id[n] = display->pipes[n].crtc_id; |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 79 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg); |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 80 | } |
| 81 | } else { |
| 82 | num_crtcs = 1; |
| 83 | arg.crtc_id = crtc_id[0] = display->pipes[pipe].crtc_id; |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 84 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg); |
Chris Wilson | cce2ff0 | 2016-05-25 08:34:25 +0100 | [diff] [blame] | 85 | } |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 86 | |
| 87 | arg.flags = mode; |
Chris Wilson | dab6b6b | 2016-05-24 16:14:32 +0100 | [diff] [blame] | 88 | igt_fork(child, num_children) { |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 89 | struct sched_param rt = {.sched_priority = 99 }; |
| 90 | cpu_set_t allowed; |
| 91 | unsigned long count = 0; |
| 92 | |
| 93 | sched_setscheduler(getpid(), SCHED_RR, &rt); |
| 94 | |
| 95 | CPU_ZERO(&allowed); |
| 96 | CPU_SET(child, &allowed); |
| 97 | sched_setaffinity(getpid(), sizeof(cpu_set_t), &allowed); |
| 98 | |
Chris Wilson | 376b813 | 2016-07-03 09:42:38 +0100 | [diff] [blame] | 99 | hars_petruska_f54_1_random_perturb(child); |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 100 | igt_until_timeout(timeout) { |
Chris Wilson | 376b813 | 2016-07-03 09:42:38 +0100 | [diff] [blame] | 101 | arg.crtc_id = crtc_id[hars_petruska_f54_1_random_unsafe() % num_crtcs]; |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 102 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg); |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 103 | count++; |
| 104 | } |
| 105 | |
Chris Wilson | c74e071 | 2016-05-24 16:24:15 +0100 | [diff] [blame] | 106 | igt_debug("[%d] count=%lu\n", child, count); |
| 107 | results[child] = count; |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 108 | } |
Chris Wilson | f5d370c | 2016-06-04 21:25:17 +0100 | [diff] [blame] | 109 | if (torture) { |
| 110 | igt_fork(child, num_children) { |
| 111 | struct sched_param rt = {.sched_priority = 1 }; |
| 112 | cpu_set_t allowed; |
| 113 | unsigned long long count = 0; |
| 114 | |
| 115 | sched_setscheduler(getpid(), SCHED_RR, &rt); |
| 116 | |
| 117 | CPU_ZERO(&allowed); |
| 118 | CPU_SET(child, &allowed); |
| 119 | sched_setaffinity(getpid(), sizeof(cpu_set_t), &allowed); |
| 120 | igt_until_timeout(timeout) { |
| 121 | count++; |
Tomeu Vizoso | 047c999 | 2016-06-07 10:18:34 +0200 | [diff] [blame] | 122 | cpu_relax(); |
Chris Wilson | f5d370c | 2016-06-04 21:25:17 +0100 | [diff] [blame] | 123 | } |
| 124 | igt_debug("[hog:%d] count=%llu\n", child, count); |
| 125 | } |
| 126 | } |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 127 | igt_waitchildren(); |
| 128 | |
Chris Wilson | c74e071 | 2016-05-24 16:24:15 +0100 | [diff] [blame] | 129 | if (num_children > 1) { |
| 130 | igt_stats_t stats; |
| 131 | |
| 132 | igt_stats_init_with_size(&stats, num_children); |
| 133 | results[num_children] = 0; |
| 134 | for (int child = 0; child < num_children; child++) { |
| 135 | igt_stats_push(&stats, results[child]); |
| 136 | results[num_children] += results[child]; |
| 137 | } |
| 138 | igt_info("Total updates %llu (median of %d processes is %.2f)\n", |
| 139 | (long long)results[num_children], |
| 140 | num_children, |
| 141 | igt_stats_get_median(&stats)); |
| 142 | igt_stats_fini(&stats); |
| 143 | } else { |
| 144 | igt_info("Total updates %llu\n", (long long)results[0]); |
| 145 | } |
| 146 | |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 147 | gem_close(display->drm_fd, arg.handle); |
Chris Wilson | c74e071 | 2016-05-24 16:24:15 +0100 | [diff] [blame] | 148 | munmap(results, 4096); |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 149 | } |
| 150 | |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 151 | static igt_output_t *set_fb_on_crtc(igt_display_t *display, int pipe, struct igt_fb *fb_info) |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 152 | { |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 153 | igt_output_t *output; |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 154 | |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 155 | for_each_valid_output_on_pipe(display, pipe, output) { |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 156 | drmModeModeInfoPtr mode; |
| 157 | igt_plane_t *primary; |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 158 | |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 159 | if (output->pending_crtc_idx_mask) |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 160 | continue; |
| 161 | |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 162 | igt_output_set_pipe(output, pipe); |
| 163 | mode = igt_output_get_mode(output); |
| 164 | |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 165 | igt_create_pattern_fb(display->drm_fd, |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 166 | mode->hdisplay, mode->vdisplay, |
| 167 | DRM_FORMAT_XRGB8888, I915_TILING_NONE, fb_info); |
| 168 | |
Robert Foss | a786479 | 2017-01-10 19:21:26 -0500 | [diff] [blame] | 169 | primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY); |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 170 | igt_plane_set_fb(primary, fb_info); |
| 171 | |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 172 | return output; |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 173 | } |
| 174 | |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 175 | return NULL; |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | static void set_cursor_on_pipe(igt_display_t *display, enum pipe pipe, struct igt_fb *fb) |
| 179 | { |
| 180 | igt_plane_t *plane, *cursor = NULL; |
| 181 | |
| 182 | for_each_plane_on_pipe(display, pipe, plane) { |
Robert Foss | a786479 | 2017-01-10 19:21:26 -0500 | [diff] [blame] | 183 | if (plane->type != DRM_PLANE_TYPE_CURSOR) |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 184 | continue; |
| 185 | |
| 186 | cursor = plane; |
| 187 | break; |
| 188 | } |
| 189 | |
| 190 | igt_require(cursor); |
| 191 | igt_plane_set_fb(cursor, fb); |
| 192 | } |
| 193 | |
| 194 | static void populate_cursor_args(igt_display_t *display, enum pipe pipe, |
| 195 | struct drm_mode_cursor *arg, struct igt_fb *fb) |
| 196 | { |
| 197 | arg->crtc_id = display->pipes[pipe].crtc_id; |
| 198 | arg->flags = DRM_MODE_CURSOR_MOVE; |
| 199 | arg->x = 128; |
| 200 | arg->y = 128; |
| 201 | arg->width = fb->width; |
| 202 | arg->height = fb->height; |
| 203 | arg->handle = fb->gem_handle; |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 204 | arg[1] = *arg; |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 205 | } |
| 206 | |
| 207 | static void do_cleanup_display(igt_display_t *display) |
| 208 | { |
| 209 | enum pipe pipe; |
| 210 | igt_output_t *output; |
| 211 | igt_plane_t *plane; |
| 212 | |
| 213 | for_each_pipe(display, pipe) |
| 214 | for_each_plane_on_pipe(display, pipe, plane) |
| 215 | igt_plane_set_fb(plane, NULL); |
| 216 | |
| 217 | for_each_connected_output(display, output) |
| 218 | igt_output_set_pipe(output, PIPE_NONE); |
| 219 | |
| 220 | igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY); |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 221 | } |
| 222 | |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 223 | static enum pipe find_connected_pipe(igt_display_t *display, bool second) |
| 224 | { |
| 225 | enum pipe pipe, first = PIPE_NONE; |
| 226 | igt_output_t *output; |
| 227 | igt_output_t *first_output = NULL; |
| 228 | bool found = false; |
| 229 | |
| 230 | for_each_pipe_with_valid_output(display, pipe, output) { |
| 231 | if (first == pipe || output == first_output) |
| 232 | continue; |
| 233 | |
| 234 | if (second) { |
| 235 | first = pipe; |
| 236 | first_output = output; |
| 237 | second = false; |
| 238 | continue; |
| 239 | } |
| 240 | |
| 241 | found = true; |
| 242 | break; |
| 243 | } |
| 244 | |
| 245 | if (first_output) |
| 246 | igt_require_f(found, "No second valid output found\n"); |
| 247 | else |
Chris Wilson | 1105d9f | 2016-08-23 18:03:51 +0100 | [diff] [blame] | 248 | igt_require_f(found, "No valid outputs found\n"); |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 249 | |
| 250 | return pipe; |
| 251 | } |
| 252 | |
Robert Foss | a786479 | 2017-01-10 19:21:26 -0500 | [diff] [blame] | 253 | static void flip_nonblocking(igt_display_t *display, enum pipe pipe_id, bool atomic, struct igt_fb *fb) |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 254 | { |
Robert Foss | a786479 | 2017-01-10 19:21:26 -0500 | [diff] [blame] | 255 | igt_pipe_t *pipe = &display->pipes[pipe_id]; |
| 256 | igt_plane_t *primary = igt_pipe_get_plane_type(pipe, DRM_PLANE_TYPE_PRIMARY); |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 257 | |
| 258 | if (!atomic) { |
| 259 | /* Schedule a nonblocking flip for the next vblank */ |
Robert Foss | a786479 | 2017-01-10 19:21:26 -0500 | [diff] [blame] | 260 | do_or_die(drmModePageFlip(display->drm_fd, pipe->crtc_id, fb->fb_id, |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 261 | DRM_MODE_PAGE_FLIP_EVENT, fb)); |
| 262 | } else { |
| 263 | igt_plane_set_fb(primary, fb); |
| 264 | igt_display_commit_atomic(display, DRM_MODE_ATOMIC_NONBLOCK | DRM_MODE_PAGE_FLIP_EVENT, fb); |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | enum flip_test { |
| 269 | flip_test_legacy = 0, |
| 270 | flip_test_varying_size, |
| 271 | flip_test_toggle_visibility, |
| 272 | flip_test_atomic, |
| 273 | flip_test_atomic_transitions, |
| 274 | flip_test_atomic_transitions_varying_size, |
| 275 | flip_test_last = flip_test_atomic_transitions_varying_size |
| 276 | }; |
| 277 | |
Maarten Lankhorst | 7baf4ee | 2016-12-21 18:26:54 +0100 | [diff] [blame] | 278 | static bool cursor_slowpath(enum flip_test mode) |
| 279 | { |
| 280 | /* cursor moving doesn't take slowpath, everything else does. */ |
| 281 | if (mode == flip_test_legacy || mode == flip_test_atomic) |
| 282 | return false; |
| 283 | |
| 284 | return true; |
| 285 | } |
| 286 | |
Maarten Lankhorst | da0b6ab | 2017-01-23 16:37:01 +0100 | [diff] [blame] | 287 | /* |
| 288 | * On platforms with two-stage watermark programming |
| 289 | * changing sprite visibility may require a extra vblank wait. |
| 290 | * |
| 291 | * Handle this here. |
| 292 | */ |
| 293 | static bool mode_requires_extra_vblank(enum flip_test mode) |
| 294 | { |
| 295 | if (mode == flip_test_atomic_transitions || |
| 296 | mode == flip_test_atomic_transitions_varying_size) |
| 297 | return true; |
| 298 | |
| 299 | return false; |
| 300 | } |
| 301 | |
Robert Foss | a786479 | 2017-01-10 19:21:26 -0500 | [diff] [blame] | 302 | static void transition_nonblocking(igt_display_t *display, enum pipe pipe_id, |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 303 | struct igt_fb *prim_fb, struct igt_fb *argb_fb, |
| 304 | bool hide_sprite) |
| 305 | { |
Robert Foss | a786479 | 2017-01-10 19:21:26 -0500 | [diff] [blame] | 306 | igt_pipe_t *pipe = &display->pipes[pipe_id]; |
| 307 | igt_plane_t *primary = igt_pipe_get_plane_type(pipe, DRM_PLANE_TYPE_PRIMARY); |
| 308 | igt_plane_t *sprite = igt_pipe_get_plane_type(pipe, DRM_PLANE_TYPE_OVERLAY); |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 309 | |
| 310 | if (hide_sprite) { |
| 311 | igt_plane_set_fb(primary, prim_fb); |
| 312 | igt_plane_set_fb(sprite, NULL); |
| 313 | } else { |
Maarten Lankhorst | a36e627 | 2017-01-16 13:35:39 +0100 | [diff] [blame] | 314 | int ret; |
| 315 | |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 316 | igt_plane_set_fb(primary, NULL); |
| 317 | igt_plane_set_fb(sprite, argb_fb); |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 318 | |
Maarten Lankhorst | a36e627 | 2017-01-16 13:35:39 +0100 | [diff] [blame] | 319 | ret = igt_display_try_commit_atomic(display, DRM_MODE_ATOMIC_NONBLOCK | DRM_MODE_PAGE_FLIP_EVENT, display); |
| 320 | if (!ret) |
| 321 | return; |
| 322 | |
| 323 | igt_assert(ret == -EINVAL); |
| 324 | |
| 325 | igt_plane_set_fb(sprite, prim_fb); |
| 326 | } |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 327 | igt_display_commit_atomic(display, DRM_MODE_ATOMIC_NONBLOCK | DRM_MODE_PAGE_FLIP_EVENT, display); |
| 328 | } |
| 329 | |
| 330 | static void prepare_flip_test(igt_display_t *display, |
| 331 | enum flip_test mode, |
| 332 | enum pipe flip_pipe, |
| 333 | enum pipe cursor_pipe, |
| 334 | struct drm_mode_cursor *arg, |
| 335 | const struct igt_fb *prim_fb, |
| 336 | struct igt_fb *argb_fb, |
| 337 | struct igt_fb *cursor_fb2) |
| 338 | { |
| 339 | argb_fb->gem_handle = 0; |
| 340 | cursor_fb2->gem_handle = 0; |
| 341 | |
| 342 | if (mode == flip_test_varying_size || |
| 343 | mode == flip_test_atomic_transitions_varying_size) { |
| 344 | uint64_t width, height; |
| 345 | |
| 346 | do_or_die(drmGetCap(display->drm_fd, DRM_CAP_CURSOR_WIDTH, &width)); |
| 347 | do_or_die(drmGetCap(display->drm_fd, DRM_CAP_CURSOR_HEIGHT, &height)); |
| 348 | |
| 349 | igt_skip_on(width <= 64 && height <= 64); |
| 350 | igt_create_color_fb(display->drm_fd, width, height, |
| 351 | DRM_FORMAT_ARGB8888, 0, 1., 0., .7, cursor_fb2); |
| 352 | |
| 353 | arg[0].flags = arg[1].flags = DRM_MODE_CURSOR_BO; |
| 354 | arg[1].handle = cursor_fb2->gem_handle; |
| 355 | arg[1].width = width; |
| 356 | arg[1].height = height; |
| 357 | } |
| 358 | |
| 359 | if (mode == flip_test_legacy || |
| 360 | mode == flip_test_atomic) { |
| 361 | arg[1].x = 192; |
| 362 | arg[1].y = 192; |
| 363 | } |
| 364 | |
| 365 | if (mode == flip_test_toggle_visibility) { |
| 366 | arg[0].flags = arg[1].flags = DRM_MODE_CURSOR_BO; |
| 367 | arg[1].handle = 0; |
| 368 | arg[1].width = arg[1].height = 0; |
| 369 | } |
| 370 | |
| 371 | if (mode == flip_test_atomic_transitions || |
| 372 | mode == flip_test_atomic_transitions_varying_size) { |
| 373 | igt_require(display->pipes[flip_pipe].n_planes > 1 && |
Robert Foss | a786479 | 2017-01-10 19:21:26 -0500 | [diff] [blame] | 374 | display->pipes[flip_pipe].planes[1].type != DRM_PLANE_TYPE_CURSOR); |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 375 | |
| 376 | igt_create_color_pattern_fb(display->drm_fd, prim_fb->width, prim_fb->height, |
| 377 | DRM_FORMAT_ARGB8888, 0, .1, .1, .1, argb_fb); |
| 378 | } |
| 379 | } |
| 380 | |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 381 | static void flip(igt_display_t *display, |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 382 | int cursor_pipe, int flip_pipe, |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 383 | int timeout, enum flip_test mode) |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 384 | { |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 385 | struct drm_mode_cursor arg[2]; |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 386 | uint64_t *results; |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 387 | struct igt_fb fb_info, fb_info2, argb_fb, cursor_fb, cursor_fb2; |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 388 | |
| 389 | results = mmap(NULL, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0); |
| 390 | igt_assert(results != MAP_FAILED); |
| 391 | |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 392 | flip_pipe = find_connected_pipe(display, !!flip_pipe); |
| 393 | cursor_pipe = find_connected_pipe(display, !!cursor_pipe); |
| 394 | |
| 395 | igt_info("Using pipe %s for page flip, pipe %s for cursor\n", |
| 396 | kmstest_pipe_name(flip_pipe), kmstest_pipe_name(cursor_pipe)); |
| 397 | |
| 398 | if (mode >= flip_test_atomic) |
| 399 | igt_require(display->is_atomic); |
| 400 | |
| 401 | igt_require(set_fb_on_crtc(display, flip_pipe, &fb_info)); |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 402 | if (flip_pipe != cursor_pipe) |
| 403 | igt_require(set_fb_on_crtc(display, cursor_pipe, &fb_info2)); |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 404 | |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 405 | igt_create_color_fb(display->drm_fd, fb_info.width, fb_info.height, DRM_FORMAT_ARGB8888, 0, .5, .5, .5, &cursor_fb); |
| 406 | |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 407 | igt_create_color_fb(display->drm_fd, 64, 64, DRM_FORMAT_ARGB8888, 0, 1., 1., 1., &cursor_fb); |
| 408 | set_cursor_on_pipe(display, cursor_pipe, &cursor_fb); |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 409 | populate_cursor_args(display, cursor_pipe, arg, &cursor_fb); |
| 410 | |
| 411 | prepare_flip_test(display, mode, flip_pipe, cursor_pipe, arg, &fb_info, &argb_fb, &cursor_fb2); |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 412 | |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 413 | igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY); |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 414 | |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 415 | igt_fork(child, 1) { |
| 416 | unsigned long count = 0; |
| 417 | |
| 418 | igt_until_timeout(timeout) { |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 419 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[(count & 64)/64]); |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 420 | count++; |
| 421 | } |
| 422 | |
| 423 | igt_debug("cursor count=%lu\n", count); |
| 424 | results[0] = count; |
| 425 | } |
| 426 | igt_fork(child, 1) { |
| 427 | unsigned long count = 0; |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 428 | |
| 429 | igt_until_timeout(timeout) { |
| 430 | char buf[128]; |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 431 | |
| 432 | switch (mode) { |
| 433 | default: |
| 434 | flip_nonblocking(display, flip_pipe, mode >= flip_test_atomic, &fb_info); |
| 435 | break; |
| 436 | case flip_test_atomic_transitions: |
| 437 | case flip_test_atomic_transitions_varying_size: |
| 438 | transition_nonblocking(display, flip_pipe, &fb_info, &argb_fb, count & 1); |
| 439 | break; |
| 440 | } |
| 441 | |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 442 | while (read(display->drm_fd, buf, sizeof(buf)) < 0 && |
Chris Wilson | d86d6eb | 2016-06-23 21:07:36 +0100 | [diff] [blame] | 443 | (errno == EINTR || errno == EAGAIN)) |
| 444 | ; |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 445 | count++; |
| 446 | } |
| 447 | |
| 448 | igt_debug("flip count=%lu\n", count); |
| 449 | results[1] = count; |
| 450 | } |
| 451 | igt_waitchildren(); |
| 452 | |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 453 | munmap(results, 4096); |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 454 | |
| 455 | do_cleanup_display(display); |
| 456 | |
| 457 | igt_remove_fb(display->drm_fd, &fb_info); |
| 458 | if (flip_pipe != cursor_pipe) |
| 459 | igt_remove_fb(display->drm_fd, &fb_info2); |
| 460 | igt_remove_fb(display->drm_fd, &cursor_fb); |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 461 | if (argb_fb.gem_handle) |
| 462 | igt_remove_fb(display->drm_fd, &argb_fb); |
| 463 | if (cursor_fb2.gem_handle) |
| 464 | igt_remove_fb(display->drm_fd, &cursor_fb2); |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 465 | } |
| 466 | |
| 467 | static inline uint32_t pipe_select(int pipe) |
| 468 | { |
| 469 | if (pipe > 1) |
| 470 | return pipe << DRM_VBLANK_HIGH_CRTC_SHIFT; |
| 471 | else if (pipe > 0) |
| 472 | return DRM_VBLANK_SECONDARY; |
| 473 | else |
| 474 | return 0; |
| 475 | } |
| 476 | |
| 477 | static unsigned get_vblank(int fd, int pipe, unsigned flags) |
| 478 | { |
| 479 | union drm_wait_vblank vbl; |
| 480 | |
| 481 | memset(&vbl, 0, sizeof(vbl)); |
| 482 | vbl.request.type = DRM_VBLANK_RELATIVE | pipe_select(pipe) | flags; |
| 483 | if (drmIoctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl)) |
| 484 | return 0; |
| 485 | |
| 486 | return vbl.reply.sequence; |
| 487 | } |
| 488 | |
Chris Wilson | 237cb89 | 2016-09-13 11:37:41 +0100 | [diff] [blame] | 489 | enum basic_flip_cursor { |
| 490 | FLIP_BEFORE_CURSOR, |
| 491 | FLIP_AFTER_CURSOR |
| 492 | }; |
| 493 | |
Chris Wilson | d2adbdf | 2016-10-04 13:50:50 +0100 | [diff] [blame] | 494 | static uint32_t *make_busy(int fd, uint32_t target) |
| 495 | { |
| 496 | const int gen = intel_gen(intel_get_drm_devid(fd)); |
| 497 | struct drm_i915_gem_exec_object2 obj[2]; |
| 498 | struct drm_i915_gem_relocation_entry reloc[2]; |
| 499 | struct drm_i915_gem_execbuffer2 execbuf; |
| 500 | uint32_t *batch; |
| 501 | int i; |
| 502 | |
| 503 | memset(&execbuf, 0, sizeof(execbuf)); |
| 504 | execbuf.buffers_ptr = (uintptr_t)obj; |
| 505 | execbuf.buffer_count = 2; |
| 506 | |
| 507 | memset(obj, 0, sizeof(obj)); |
| 508 | obj[0].handle = target; |
| 509 | obj[1].handle = gem_create(fd, 4096); |
| 510 | batch = gem_mmap__wc(fd, obj[1].handle, 0, 4096, PROT_WRITE); |
| 511 | gem_set_domain(fd, obj[1].handle, |
| 512 | I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT); |
| 513 | |
| 514 | |
| 515 | obj[1].relocs_ptr = (uintptr_t)reloc; |
| 516 | obj[1].relocation_count = 2; |
| 517 | memset(reloc, 0, sizeof(reloc)); |
| 518 | |
| 519 | reloc[0].target_handle = obj[1].handle; /* recurse */ |
| 520 | reloc[0].presumed_offset = 0; |
| 521 | reloc[0].offset = sizeof(uint32_t); |
| 522 | reloc[0].delta = 0; |
| 523 | reloc[0].read_domains = I915_GEM_DOMAIN_COMMAND; |
| 524 | reloc[0].write_domain = 0; |
| 525 | |
| 526 | reloc[1].target_handle = target; |
| 527 | reloc[1].presumed_offset = 0; |
| 528 | reloc[1].offset = 1024; |
| 529 | reloc[1].delta = 0; |
| 530 | reloc[1].read_domains = I915_GEM_DOMAIN_COMMAND; |
| 531 | reloc[1].write_domain = I915_GEM_DOMAIN_COMMAND; |
| 532 | |
| 533 | i = 0; |
| 534 | batch[i] = MI_BATCH_BUFFER_START; |
| 535 | if (gen >= 8) { |
| 536 | batch[i] |= 1 << 8 | 1; |
| 537 | batch[++i] = 0; |
| 538 | batch[++i] = 0; |
| 539 | } else if (gen >= 6) { |
| 540 | batch[i] |= 1 << 8; |
| 541 | batch[++i] = 0; |
| 542 | } else { |
| 543 | batch[i] |= 2 << 6; |
| 544 | batch[++i] = 0; |
| 545 | if (gen < 4) { |
| 546 | batch[i] |= 1; |
| 547 | reloc[0].delta = 1; |
| 548 | } |
| 549 | } |
| 550 | i++; |
| 551 | |
| 552 | gem_execbuf(fd, &execbuf); |
| 553 | gem_close(fd, obj[1].handle); |
| 554 | |
| 555 | return batch; |
| 556 | } |
| 557 | |
Chris Wilson | 18cd796 | 2016-10-05 19:31:27 +0100 | [diff] [blame] | 558 | static void cancel_busy(uint32_t *busy) |
Chris Wilson | d2adbdf | 2016-10-04 13:50:50 +0100 | [diff] [blame] | 559 | { |
| 560 | *busy = MI_BATCH_BUFFER_END; |
| 561 | munmap(busy, 4096); |
| 562 | } |
| 563 | |
Chris Wilson | 18cd796 | 2016-10-05 19:31:27 +0100 | [diff] [blame] | 564 | static uint32_t * |
| 565 | make_fb_busy(int fd, const struct igt_fb *fb) |
| 566 | { |
| 567 | uint32_t *busy; |
| 568 | |
| 569 | busy = make_busy(fd, fb->gem_handle); |
| 570 | igt_assert(gem_bo_busy(fd, fb->gem_handle)); |
| 571 | |
| 572 | return busy; |
| 573 | } |
| 574 | |
| 575 | static void finish_fb_busy(uint32_t *busy) |
| 576 | { |
| 577 | cancel_busy(busy); |
| 578 | } |
| 579 | |
Chris Wilson | d2adbdf | 2016-10-04 13:50:50 +0100 | [diff] [blame] | 580 | #define BASIC_BUSY 0x1 |
| 581 | |
Chris Wilson | 237cb89 | 2016-09-13 11:37:41 +0100 | [diff] [blame] | 582 | static void basic_flip_cursor(igt_display_t *display, |
| 583 | enum flip_test mode, |
Chris Wilson | d2adbdf | 2016-10-04 13:50:50 +0100 | [diff] [blame] | 584 | enum basic_flip_cursor order, |
| 585 | unsigned flags) |
Chris Wilson | 237cb89 | 2016-09-13 11:37:41 +0100 | [diff] [blame] | 586 | { |
| 587 | struct drm_mode_cursor arg[2]; |
| 588 | struct drm_event_vblank vbl; |
| 589 | struct igt_fb fb_info, cursor_fb, cursor_fb2, argb_fb; |
| 590 | unsigned vblank_start; |
| 591 | enum pipe pipe = find_connected_pipe(display, false); |
Chris Wilson | d2adbdf | 2016-10-04 13:50:50 +0100 | [diff] [blame] | 592 | uint32_t *busy; |
Chris Wilson | 237cb89 | 2016-09-13 11:37:41 +0100 | [diff] [blame] | 593 | |
| 594 | if (mode >= flip_test_atomic) |
| 595 | igt_require(display->is_atomic); |
| 596 | |
| 597 | igt_require(set_fb_on_crtc(display, pipe, &fb_info)); |
| 598 | |
| 599 | igt_create_color_fb(display->drm_fd, 64, 64, DRM_FORMAT_ARGB8888, 0, 1., 1., 1., &cursor_fb); |
| 600 | set_cursor_on_pipe(display, pipe, &cursor_fb); |
| 601 | populate_cursor_args(display, pipe, arg, &cursor_fb); |
| 602 | |
| 603 | prepare_flip_test(display, mode, pipe, pipe, arg, &fb_info, &argb_fb, &cursor_fb2); |
| 604 | |
| 605 | igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY); |
| 606 | |
| 607 | /* Quick sanity check that we can update a cursor in a single vblank */ |
| 608 | vblank_start = get_vblank(display->drm_fd, pipe, DRM_VBLANK_NEXTONMISS); |
| 609 | igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start); |
| 610 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[0]); |
| 611 | igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start); |
| 612 | |
| 613 | /* Bind the cursor first to warm up */ |
| 614 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[0]); |
| 615 | |
Chris Wilson | d2adbdf | 2016-10-04 13:50:50 +0100 | [diff] [blame] | 616 | busy = NULL; |
| 617 | if (flags & BASIC_BUSY) |
Chris Wilson | 18cd796 | 2016-10-05 19:31:27 +0100 | [diff] [blame] | 618 | busy = make_fb_busy(display->drm_fd, &fb_info); |
Chris Wilson | d2adbdf | 2016-10-04 13:50:50 +0100 | [diff] [blame] | 619 | |
Ville Syrjälä | d08d263 | 2017-03-14 19:32:08 +0200 | [diff] [blame] | 620 | /* Start with a synchronous query to align with the vblank */ |
| 621 | vblank_start = get_vblank(display->drm_fd, pipe, DRM_VBLANK_NEXTONMISS); |
| 622 | |
Chris Wilson | 237cb89 | 2016-09-13 11:37:41 +0100 | [diff] [blame] | 623 | switch (order) { |
| 624 | case FLIP_BEFORE_CURSOR: |
| 625 | switch (mode) { |
| 626 | default: |
| 627 | flip_nonblocking(display, pipe, mode >= flip_test_atomic, &fb_info); |
| 628 | break; |
| 629 | case flip_test_atomic_transitions: |
| 630 | case flip_test_atomic_transitions_varying_size: |
| 631 | transition_nonblocking(display, pipe, &fb_info, &argb_fb, 0); |
| 632 | break; |
| 633 | } |
| 634 | igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start); |
| 635 | |
| 636 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[0]); |
Chris Wilson | 237cb89 | 2016-09-13 11:37:41 +0100 | [diff] [blame] | 637 | break; |
| 638 | |
| 639 | case FLIP_AFTER_CURSOR: |
| 640 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[0]); |
| 641 | igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start); |
| 642 | |
| 643 | switch (mode) { |
| 644 | default: |
| 645 | flip_nonblocking(display, pipe, mode >= flip_test_atomic, &fb_info); |
| 646 | break; |
| 647 | case flip_test_atomic_transitions: |
| 648 | case flip_test_atomic_transitions_varying_size: |
| 649 | transition_nonblocking(display, pipe, &fb_info, &argb_fb, 0); |
| 650 | break; |
| 651 | } |
Chris Wilson | 237cb89 | 2016-09-13 11:37:41 +0100 | [diff] [blame] | 652 | } |
| 653 | |
Maarten Lankhorst | 7baf4ee | 2016-12-21 18:26:54 +0100 | [diff] [blame] | 654 | if (!cursor_slowpath(mode)) |
| 655 | igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start); |
| 656 | else |
| 657 | igt_assert_lte(get_vblank(display->drm_fd, pipe, 0), vblank_start + 1); |
| 658 | |
Chris Wilson | d2adbdf | 2016-10-04 13:50:50 +0100 | [diff] [blame] | 659 | if (busy) { |
| 660 | struct pollfd pfd = { display->drm_fd, POLLIN }; |
| 661 | igt_assert(poll(&pfd, 1, 0) == 0); |
Chris Wilson | 18cd796 | 2016-10-05 19:31:27 +0100 | [diff] [blame] | 662 | finish_fb_busy(busy); |
Chris Wilson | d2adbdf | 2016-10-04 13:50:50 +0100 | [diff] [blame] | 663 | } |
| 664 | |
Chris Wilson | 237cb89 | 2016-09-13 11:37:41 +0100 | [diff] [blame] | 665 | igt_set_timeout(1, "Stuck page flip"); |
| 666 | igt_ignore_warn(read(display->drm_fd, &vbl, sizeof(vbl))); |
Maarten Lankhorst | da0b6ab | 2017-01-23 16:37:01 +0100 | [diff] [blame] | 667 | |
| 668 | if (!mode_requires_extra_vblank(mode)) |
| 669 | igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start + 1); |
| 670 | else |
| 671 | igt_assert_lte(get_vblank(display->drm_fd, pipe, 0), vblank_start + 2); |
| 672 | |
Chris Wilson | 237cb89 | 2016-09-13 11:37:41 +0100 | [diff] [blame] | 673 | igt_reset_timeout(); |
| 674 | |
| 675 | do_cleanup_display(display); |
| 676 | igt_remove_fb(display->drm_fd, &fb_info); |
| 677 | igt_remove_fb(display->drm_fd, &cursor_fb); |
| 678 | |
| 679 | if (argb_fb.gem_handle) |
| 680 | igt_remove_fb(display->drm_fd, &argb_fb); |
| 681 | if (cursor_fb2.gem_handle) |
| 682 | igt_remove_fb(display->drm_fd, &cursor_fb2); |
| 683 | } |
| 684 | |
Maarten Lankhorst | ad71861 | 2016-12-27 13:50:31 +0100 | [diff] [blame] | 685 | static int |
| 686 | get_cursor_updates_per_vblank(igt_display_t *display, enum pipe pipe, |
| 687 | struct drm_mode_cursor *arg) |
| 688 | { |
| 689 | int target; |
| 690 | |
| 691 | for (target = 65536; target; target /= 2) { |
| 692 | unsigned vblank_start = get_vblank(display->drm_fd, pipe, DRM_VBLANK_NEXTONMISS); |
| 693 | |
| 694 | igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start); |
| 695 | |
| 696 | for (int n = 0; n < target; n++) |
| 697 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, arg); |
| 698 | if (get_vblank(display->drm_fd, pipe, 0) == vblank_start) |
| 699 | break; |
| 700 | } |
| 701 | |
| 702 | /* |
| 703 | * Divide by 4, to handle variations in amount of vblanks |
| 704 | * caused by cpufreq throttling. |
| 705 | */ |
| 706 | target /= 4; |
| 707 | igt_require(target > 1); |
| 708 | |
| 709 | igt_debug("Using a target of %d cursor updates per quarter-vblank\n", target); |
| 710 | |
| 711 | return target; |
| 712 | } |
| 713 | |
Chris Wilson | 237cb89 | 2016-09-13 11:37:41 +0100 | [diff] [blame] | 714 | static void flip_vs_cursor(igt_display_t *display, enum flip_test mode, int nloops) |
Maarten Lankhorst | 29516cd | 2016-07-18 11:47:06 +0200 | [diff] [blame] | 715 | { |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 716 | struct drm_mode_cursor arg[2]; |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 717 | struct drm_event_vblank vbl; |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 718 | struct igt_fb fb_info, cursor_fb, cursor_fb2, argb_fb; |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 719 | unsigned vblank_start; |
Maarten Lankhorst | e5e8b7c | 2017-01-03 11:31:04 +0100 | [diff] [blame] | 720 | int target, cpu; |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 721 | enum pipe pipe = find_connected_pipe(display, false); |
Maarten Lankhorst | e5e8b7c | 2017-01-03 11:31:04 +0100 | [diff] [blame] | 722 | volatile unsigned long *shared; |
| 723 | cpu_set_t mask, oldmask; |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 724 | |
| 725 | if (mode >= flip_test_atomic) |
| 726 | igt_require(display->is_atomic); |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 727 | |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 728 | igt_require(set_fb_on_crtc(display, pipe, &fb_info)); |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 729 | |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 730 | igt_create_color_fb(display->drm_fd, 64, 64, DRM_FORMAT_ARGB8888, 0, 1., 1., 1., &cursor_fb); |
Maarten Lankhorst | 29516cd | 2016-07-18 11:47:06 +0200 | [diff] [blame] | 731 | set_cursor_on_pipe(display, pipe, &cursor_fb); |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 732 | populate_cursor_args(display, pipe, arg, &cursor_fb); |
| 733 | |
| 734 | prepare_flip_test(display, mode, pipe, pipe, arg, &fb_info, &argb_fb, &cursor_fb2); |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 735 | |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 736 | igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY); |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 737 | |
Maarten Lankhorst | ad71861 | 2016-12-27 13:50:31 +0100 | [diff] [blame] | 738 | if (nloops) |
| 739 | target = get_cursor_updates_per_vblank(display, pipe, &arg[0]); |
| 740 | else |
Chris Wilson | 3a3c0fa | 2016-08-24 14:55:25 +0100 | [diff] [blame] | 741 | target = 1; |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 742 | |
Maarten Lankhorst | 29516cd | 2016-07-18 11:47:06 +0200 | [diff] [blame] | 743 | vblank_start = get_vblank(display->drm_fd, pipe, DRM_VBLANK_NEXTONMISS); |
| 744 | igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start); |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 745 | for (int n = 0; n < target; n++) |
| 746 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[0]); |
Maarten Lankhorst | 29516cd | 2016-07-18 11:47:06 +0200 | [diff] [blame] | 747 | igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start); |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 748 | |
Maarten Lankhorst | e5e8b7c | 2017-01-03 11:31:04 +0100 | [diff] [blame] | 749 | /* |
| 750 | * There are variations caused by using cpu frequency changing. To |
| 751 | * eliminate those we force this test to run on the same cpu as an |
| 752 | * idle thread that does a busy loop of sched_yield(); The effect is |
| 753 | * that we don't throttle the cpu to a lower frequency, and the |
| 754 | * variations caused by cpu speed changing are eliminated. |
| 755 | */ |
| 756 | if (target > 1) { |
| 757 | shared = mmap(NULL, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0); |
| 758 | igt_assert(shared != MAP_FAILED); |
| 759 | |
| 760 | cpu = sched_getcpu(); |
| 761 | igt_assert(cpu >= 0); |
| 762 | |
| 763 | CPU_ZERO(&mask); |
| 764 | CPU_SET(cpu, &mask); |
| 765 | sched_getaffinity(0, sizeof(oldmask), &oldmask); |
| 766 | sched_setaffinity(0, sizeof(mask), &mask); |
| 767 | |
| 768 | shared[0] = 0; |
| 769 | |
| 770 | igt_fork(child, 1) { |
| 771 | struct sched_param parm = { .sched_priority = 0 }; |
| 772 | |
| 773 | igt_assert(sched_setscheduler(0, SCHED_IDLE, &parm) == 0); |
| 774 | |
| 775 | while (!shared[0]) |
| 776 | sched_yield(); |
| 777 | } |
| 778 | } |
| 779 | |
Chris Wilson | 3a3c0fa | 2016-08-24 14:55:25 +0100 | [diff] [blame] | 780 | do { |
| 781 | /* Bind the cursor first to warm up */ |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 782 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[nloops & 1]); |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 783 | |
Chris Wilson | 3a3c0fa | 2016-08-24 14:55:25 +0100 | [diff] [blame] | 784 | /* Start with a synchronous query to align with the vblank */ |
| 785 | vblank_start = get_vblank(display->drm_fd, pipe, DRM_VBLANK_NEXTONMISS); |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 786 | switch (mode) { |
| 787 | default: |
| 788 | flip_nonblocking(display, pipe, mode >= flip_test_atomic, &fb_info); |
| 789 | break; |
| 790 | case flip_test_atomic_transitions: |
| 791 | case flip_test_atomic_transitions_varying_size: |
| 792 | transition_nonblocking(display, pipe, &fb_info, &argb_fb, (nloops & 2) /2); |
| 793 | break; |
| 794 | } |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 795 | |
Chris Wilson | 3a3c0fa | 2016-08-24 14:55:25 +0100 | [diff] [blame] | 796 | /* The nonblocking flip should not have delayed us */ |
Maarten Lankhorst | 29516cd | 2016-07-18 11:47:06 +0200 | [diff] [blame] | 797 | igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start); |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 798 | for (int n = 0; n < target; n++) |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 799 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[nloops & 1]); |
Maarten Lankhorst | 7baf4ee | 2016-12-21 18:26:54 +0100 | [diff] [blame] | 800 | |
Chris Wilson | 3a3c0fa | 2016-08-24 14:55:25 +0100 | [diff] [blame] | 801 | /* Nor should it have delayed the following cursor update */ |
Maarten Lankhorst | 7baf4ee | 2016-12-21 18:26:54 +0100 | [diff] [blame] | 802 | if (!cursor_slowpath(mode)) |
| 803 | igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start); |
| 804 | else |
| 805 | igt_assert_lte(get_vblank(display->drm_fd, pipe, 0), vblank_start + 1); |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 806 | |
| 807 | igt_set_timeout(1, "Stuck page flip"); |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 808 | igt_ignore_warn(read(display->drm_fd, &vbl, sizeof(vbl))); |
Maarten Lankhorst | da0b6ab | 2017-01-23 16:37:01 +0100 | [diff] [blame] | 809 | |
| 810 | if (!mode_requires_extra_vblank(mode)) |
| 811 | igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start + 1); |
| 812 | else |
| 813 | igt_assert_lte(get_vblank(display->drm_fd, pipe, 0), vblank_start + 2); |
| 814 | |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 815 | igt_reset_timeout(); |
Chris Wilson | 3a3c0fa | 2016-08-24 14:55:25 +0100 | [diff] [blame] | 816 | } while (nloops--); |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 817 | |
Maarten Lankhorst | e5e8b7c | 2017-01-03 11:31:04 +0100 | [diff] [blame] | 818 | if (target > 1) { |
| 819 | shared[0] = 1; |
| 820 | igt_waitchildren(); |
| 821 | munmap((void *)shared, 4096); |
| 822 | sched_setaffinity(0, sizeof(oldmask), &oldmask); |
| 823 | } |
| 824 | |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 825 | do_cleanup_display(display); |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 826 | igt_remove_fb(display->drm_fd, &fb_info); |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 827 | igt_remove_fb(display->drm_fd, &cursor_fb); |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 828 | |
| 829 | if (argb_fb.gem_handle) |
| 830 | igt_remove_fb(display->drm_fd, &argb_fb); |
| 831 | if (cursor_fb2.gem_handle) |
| 832 | igt_remove_fb(display->drm_fd, &cursor_fb2); |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 833 | } |
| 834 | |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 835 | static bool skip_on_unsupported_nonblocking_modeset(igt_display_t *display) |
| 836 | { |
| 837 | enum pipe pipe; |
| 838 | int ret; |
| 839 | |
| 840 | igt_display_commit_atomic(display, DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_ATOMIC_ALLOW_MODESET, NULL); |
| 841 | |
| 842 | ret = igt_display_try_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET | DRM_MODE_ATOMIC_NONBLOCK, NULL); |
| 843 | |
| 844 | if (ret == -EINVAL) |
| 845 | return true; |
| 846 | |
| 847 | igt_assert_eq(ret, 0); |
| 848 | |
| 849 | /* Force the next state to update all crtc's, to synchronize with the nonblocking modeset. */ |
| 850 | for_each_pipe(display, pipe) |
| 851 | display->pipes[pipe].mode_changed = true; |
| 852 | |
| 853 | return false; |
| 854 | } |
| 855 | |
Maarten Lankhorst | 59cdcf1 | 2016-11-02 13:38:48 +0100 | [diff] [blame] | 856 | static void nonblocking_modeset_vs_cursor(igt_display_t *display, int loops) |
| 857 | { |
| 858 | struct igt_fb fb_info, cursor_fb; |
| 859 | igt_output_t *output; |
| 860 | enum pipe pipe = find_connected_pipe(display, false); |
Maarten Lankhorst | 7baf4ee | 2016-12-21 18:26:54 +0100 | [diff] [blame] | 861 | struct drm_mode_cursor arg[2]; |
Maarten Lankhorst | 59cdcf1 | 2016-11-02 13:38:48 +0100 | [diff] [blame] | 862 | bool skip_test; |
| 863 | igt_plane_t *cursor = NULL, *plane; |
| 864 | |
| 865 | igt_require(display->is_atomic); |
| 866 | igt_require((output = set_fb_on_crtc(display, pipe, &fb_info))); |
| 867 | igt_create_color_fb(display->drm_fd, 64, 64, DRM_FORMAT_ARGB8888, 0, 1., 1., 1., &cursor_fb); |
| 868 | set_cursor_on_pipe(display, pipe, &cursor_fb); |
Maarten Lankhorst | 7baf4ee | 2016-12-21 18:26:54 +0100 | [diff] [blame] | 869 | populate_cursor_args(display, pipe, arg, &cursor_fb); |
| 870 | arg[0].flags |= DRM_MODE_CURSOR_BO; |
Maarten Lankhorst | 59cdcf1 | 2016-11-02 13:38:48 +0100 | [diff] [blame] | 871 | |
| 872 | for_each_plane_on_pipe(display, pipe, plane) { |
Robert Foss | a786479 | 2017-01-10 19:21:26 -0500 | [diff] [blame] | 873 | if (plane->type != DRM_PLANE_TYPE_CURSOR) |
Maarten Lankhorst | 59cdcf1 | 2016-11-02 13:38:48 +0100 | [diff] [blame] | 874 | continue; |
| 875 | |
| 876 | cursor = plane; |
| 877 | break; |
| 878 | } |
| 879 | |
| 880 | igt_skip_on(!cursor); |
| 881 | |
| 882 | if ((skip_test = skip_on_unsupported_nonblocking_modeset(display))) |
| 883 | goto cleanup; |
| 884 | |
| 885 | /* |
| 886 | * Start disabled, because skip_on_unsupported_nonblocking_modeset |
| 887 | * will have enabled this pipe. No way around it, since the first |
| 888 | * atomic commit may be unreliable with amount of events sent. |
| 889 | */ |
| 890 | igt_output_set_pipe(output, PIPE_NONE); |
| 891 | igt_display_commit2(display, COMMIT_ATOMIC); |
| 892 | |
| 893 | while (loops--) { |
| 894 | unsigned flags; |
| 895 | struct pollfd pfd = { display->drm_fd, POLLIN }; |
| 896 | struct drm_event_vblank vbl; |
| 897 | |
| 898 | flags = DRM_MODE_ATOMIC_ALLOW_MODESET; |
| 899 | flags |= DRM_MODE_ATOMIC_NONBLOCK; |
| 900 | flags |= DRM_MODE_PAGE_FLIP_EVENT; |
| 901 | |
| 902 | /* |
| 903 | * Test that a cursor update after a nonblocking modeset |
| 904 | * works as intended. It should block until the modeset completes. |
| 905 | */ |
| 906 | |
| 907 | igt_output_set_pipe(output, pipe); |
| 908 | igt_plane_set_fb(cursor, NULL); |
| 909 | igt_display_commit_atomic(display, flags, NULL); |
| 910 | |
| 911 | igt_assert_eq(0, poll(&pfd, 1, 0)); |
| 912 | igt_assert_eq(0, pfd.revents); |
| 913 | |
Maarten Lankhorst | 7baf4ee | 2016-12-21 18:26:54 +0100 | [diff] [blame] | 914 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[0]); |
Maarten Lankhorst | 59cdcf1 | 2016-11-02 13:38:48 +0100 | [diff] [blame] | 915 | |
| 916 | igt_assert_eq(1, poll(&pfd, 1, 0)); |
| 917 | igt_assert_eq(POLLIN, pfd.revents); |
| 918 | |
| 919 | igt_set_timeout(1, "Stuck page flip"); |
| 920 | igt_ignore_warn(read(display->drm_fd, &vbl, sizeof(vbl))); |
| 921 | igt_reset_timeout(); |
| 922 | |
| 923 | igt_output_set_pipe(output, PIPE_NONE); |
| 924 | igt_display_commit_atomic(display, flags, NULL); |
| 925 | |
| 926 | igt_assert_eq(0, poll(&pfd, 1, 0)); |
| 927 | igt_assert_eq(0, pfd.revents); |
| 928 | |
| 929 | /* Same for cursor on disabled crtc. */ |
Maarten Lankhorst | 7baf4ee | 2016-12-21 18:26:54 +0100 | [diff] [blame] | 930 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[0]); |
Maarten Lankhorst | 59cdcf1 | 2016-11-02 13:38:48 +0100 | [diff] [blame] | 931 | |
| 932 | igt_assert_eq(1, poll(&pfd, 1, 0)); |
| 933 | igt_assert_eq(POLLIN, pfd.revents); |
| 934 | |
| 935 | igt_set_timeout(1, "Stuck page flip"); |
| 936 | igt_ignore_warn(read(display->drm_fd, &vbl, sizeof(vbl))); |
| 937 | igt_reset_timeout(); |
| 938 | } |
| 939 | |
| 940 | cleanup: |
| 941 | do_cleanup_display(display); |
| 942 | igt_remove_fb(display->drm_fd, &fb_info); |
| 943 | igt_remove_fb(display->drm_fd, &cursor_fb); |
| 944 | |
| 945 | if (skip_test) |
| 946 | igt_skip("Nonblocking modeset is not supported by this kernel\n"); |
| 947 | } |
| 948 | |
Maarten Lankhorst | 5b8a1ba | 2017-01-18 10:41:37 +0100 | [diff] [blame] | 949 | static void two_screens_flip_vs_cursor(igt_display_t *display, int nloops, bool modeset, bool atomic) |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 950 | { |
| 951 | struct drm_mode_cursor arg[2], arg2[2]; |
| 952 | struct drm_event_vblank vbl; |
| 953 | struct igt_fb fb_info, fb2_info, cursor_fb; |
| 954 | unsigned vblank_start; |
| 955 | enum pipe pipe = find_connected_pipe(display, false); |
| 956 | enum pipe pipe2 = find_connected_pipe(display, true); |
Maarten Lankhorst | 5b8a1ba | 2017-01-18 10:41:37 +0100 | [diff] [blame] | 957 | igt_output_t *output, *output2; |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 958 | bool skip_test = false; |
| 959 | |
Maarten Lankhorst | 5b8a1ba | 2017-01-18 10:41:37 +0100 | [diff] [blame] | 960 | igt_fail_on(modeset && !atomic); |
| 961 | |
| 962 | if (atomic) |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 963 | igt_require(display->is_atomic); |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 964 | |
Maarten Lankhorst | 5b8a1ba | 2017-01-18 10:41:37 +0100 | [diff] [blame] | 965 | igt_require((output = set_fb_on_crtc(display, pipe, &fb_info))); |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 966 | igt_require((output2 = set_fb_on_crtc(display, pipe2, &fb2_info))); |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 967 | |
| 968 | igt_create_color_fb(display->drm_fd, 64, 64, DRM_FORMAT_ARGB8888, 0, 1., 1., 1., &cursor_fb); |
| 969 | set_cursor_on_pipe(display, pipe, &cursor_fb); |
| 970 | populate_cursor_args(display, pipe, arg, &cursor_fb); |
| 971 | |
Maarten Lankhorst | 5b8a1ba | 2017-01-18 10:41:37 +0100 | [diff] [blame] | 972 | arg[1].x = arg[1].y = 192; |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 973 | |
| 974 | set_cursor_on_pipe(display, pipe2, &cursor_fb); |
| 975 | populate_cursor_args(display, pipe2, arg2, &cursor_fb); |
| 976 | |
Maarten Lankhorst | 5b8a1ba | 2017-01-18 10:41:37 +0100 | [diff] [blame] | 977 | arg2[1].x = arg2[1].y = 192; |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 978 | |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 979 | if (modeset && (skip_test = skip_on_unsupported_nonblocking_modeset(display))) |
| 980 | goto cleanup; |
| 981 | |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 982 | igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY); |
| 983 | |
| 984 | vblank_start = get_vblank(display->drm_fd, pipe, DRM_VBLANK_NEXTONMISS); |
| 985 | igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start); |
| 986 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[0]); |
| 987 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg2[0]); |
| 988 | igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start); |
| 989 | |
| 990 | while (nloops--) { |
| 991 | /* Start with a synchronous query to align with the vblank */ |
| 992 | vblank_start = get_vblank(display->drm_fd, pipe, DRM_VBLANK_NEXTONMISS); |
| 993 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[nloops & 1]); |
| 994 | |
Maarten Lankhorst | 5b8a1ba | 2017-01-18 10:41:37 +0100 | [diff] [blame] | 995 | if (!modeset) |
| 996 | flip_nonblocking(display, pipe, false, &fb_info); |
| 997 | else { |
| 998 | /* |
| 999 | * There are 2 design issues that prevent us from doing |
| 1000 | * the test we would like here: |
| 1001 | * |
| 1002 | * - drm_event_vblank doesn't set crtc_id, so if we |
| 1003 | * use events we don't know which pipe fired the event, |
| 1004 | * no way to distinguish. |
| 1005 | * - Doing a modeset may add unrelated pipes, and fail with |
| 1006 | * -EBUSY if a page flip is queued on one of those. |
| 1007 | * |
| 1008 | * Work around it by not setting an event, but doing a synchronous |
| 1009 | * commit to wait for completion, and queue the page flip and modeset |
| 1010 | * in the same commit. |
| 1011 | */ |
| 1012 | |
Robert Foss | a786479 | 2017-01-10 19:21:26 -0500 | [diff] [blame] | 1013 | igt_plane_set_fb(igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY), &fb_info); |
Maarten Lankhorst | 5b8a1ba | 2017-01-18 10:41:37 +0100 | [diff] [blame] | 1014 | igt_output_set_pipe(output2, (nloops & 1) ? PIPE_NONE : pipe2); |
| 1015 | igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET | DRM_MODE_ATOMIC_NONBLOCK, NULL); |
| 1016 | } |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 1017 | |
| 1018 | igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start); |
| 1019 | |
| 1020 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[nloops & 1]); |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 1021 | if (!modeset) { |
| 1022 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg2[nloops & 1]); |
| 1023 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[nloops & 1]); |
| 1024 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg2[nloops & 1]); |
Maarten Lankhorst | 5b8a1ba | 2017-01-18 10:41:37 +0100 | [diff] [blame] | 1025 | |
| 1026 | igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start); |
| 1027 | |
| 1028 | igt_set_timeout(1, "Stuck page flip"); |
| 1029 | igt_ignore_warn(read(display->drm_fd, &vbl, sizeof(vbl))); |
| 1030 | igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start + 1); |
| 1031 | igt_reset_timeout(); |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 1032 | } else { |
Maarten Lankhorst | 5b8a1ba | 2017-01-18 10:41:37 +0100 | [diff] [blame] | 1033 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg2[nloops & 1]); |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 1034 | } |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 1035 | |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 1036 | if (modeset) { |
Maarten Lankhorst | 5b8a1ba | 2017-01-18 10:41:37 +0100 | [diff] [blame] | 1037 | /* wait for pending modeset and page flip to complete, to prevent -EBUSY */ |
| 1038 | display->pipes[pipe].mode_changed = true; |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 1039 | display->pipes[pipe2].mode_changed = true; |
| 1040 | igt_display_commit2(display, COMMIT_ATOMIC); |
| 1041 | } |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 1042 | } |
| 1043 | |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 1044 | cleanup: |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 1045 | do_cleanup_display(display); |
| 1046 | igt_remove_fb(display->drm_fd, &fb_info); |
| 1047 | igt_remove_fb(display->drm_fd, &fb2_info); |
| 1048 | igt_remove_fb(display->drm_fd, &cursor_fb); |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 1049 | |
| 1050 | if (skip_test) |
| 1051 | igt_skip("Nonblocking modeset is not supported by this kernel\n"); |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 1052 | } |
| 1053 | |
Chris Wilson | 237cb89 | 2016-09-13 11:37:41 +0100 | [diff] [blame] | 1054 | static void cursor_vs_flip(igt_display_t *display, enum flip_test mode, int nloops) |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 1055 | { |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 1056 | struct drm_mode_cursor arg[2]; |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 1057 | struct drm_event_vblank vbl; |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 1058 | struct igt_fb fb_info, cursor_fb, cursor_fb2, argb_fb; |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 1059 | unsigned vblank_start, vblank_last; |
| 1060 | volatile unsigned long *shared; |
Maarten Lankhorst | aaf46cb | 2016-08-10 13:13:19 +0200 | [diff] [blame] | 1061 | long target; |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 1062 | enum pipe pipe = find_connected_pipe(display, false); |
Maarten Lankhorst | aaf46cb | 2016-08-10 13:13:19 +0200 | [diff] [blame] | 1063 | igt_output_t *output; |
| 1064 | uint32_t vrefresh; |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 1065 | |
| 1066 | if (mode >= flip_test_atomic) |
| 1067 | igt_require(display->is_atomic); |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 1068 | |
| 1069 | shared = mmap(NULL, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0); |
| 1070 | igt_assert(shared != MAP_FAILED); |
| 1071 | |
Maarten Lankhorst | aaf46cb | 2016-08-10 13:13:19 +0200 | [diff] [blame] | 1072 | igt_require((output = set_fb_on_crtc(display, pipe, &fb_info))); |
| 1073 | vrefresh = igt_output_get_mode(output)->vrefresh; |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 1074 | |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 1075 | igt_create_color_fb(display->drm_fd, 64, 64, DRM_FORMAT_ARGB8888, 0, 1., 1., 1., &cursor_fb); |
Maarten Lankhorst | 29516cd | 2016-07-18 11:47:06 +0200 | [diff] [blame] | 1076 | set_cursor_on_pipe(display, pipe, &cursor_fb); |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 1077 | populate_cursor_args(display, pipe, arg, &cursor_fb); |
| 1078 | |
| 1079 | prepare_flip_test(display, mode, pipe, pipe, arg, &fb_info, &argb_fb, &cursor_fb2); |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 1080 | |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 1081 | igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY); |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 1082 | |
Maarten Lankhorst | ad71861 | 2016-12-27 13:50:31 +0100 | [diff] [blame] | 1083 | target = get_cursor_updates_per_vblank(display, pipe, &arg[0]); |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 1084 | |
| 1085 | for (int i = 0; i < nloops; i++) { |
| 1086 | shared[0] = 0; |
| 1087 | igt_fork(child, 1) { |
| 1088 | unsigned long count = 0; |
| 1089 | while (!shared[0]) { |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 1090 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[i & 1]); |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 1091 | count++; |
| 1092 | } |
| 1093 | igt_debug("child: %lu cursor updates\n", count); |
| 1094 | shared[0] = count; |
| 1095 | } |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 1096 | |
| 1097 | switch (mode) { |
| 1098 | default: |
| 1099 | flip_nonblocking(display, pipe, mode >= flip_test_atomic, &fb_info); |
| 1100 | break; |
| 1101 | case flip_test_atomic_transitions: |
| 1102 | case flip_test_atomic_transitions_varying_size: |
| 1103 | transition_nonblocking(display, pipe, &fb_info, &argb_fb, (i & 2) >> 1); |
| 1104 | break; |
| 1105 | } |
| 1106 | |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 1107 | igt_assert_eq(read(display->drm_fd, &vbl, sizeof(vbl)), sizeof(vbl)); |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 1108 | vblank_start = vblank_last = vbl.sequence; |
Maarten Lankhorst | bc00086 | 2016-12-22 10:54:37 +0100 | [diff] [blame] | 1109 | for (int n = 0; n < vrefresh / 2; n++) { |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 1110 | flip_nonblocking(display, pipe, mode >= flip_test_atomic, &fb_info); |
| 1111 | |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 1112 | igt_assert_eq(read(display->drm_fd, &vbl, sizeof(vbl)), sizeof(vbl)); |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 1113 | if (vbl.sequence != vblank_last + 1) { |
Maarten Lankhorst | 7baf4ee | 2016-12-21 18:26:54 +0100 | [diff] [blame] | 1114 | igt_info("page flip %d was delayed, missed %d frames\n", |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 1115 | n, vbl.sequence - vblank_last - 1); |
| 1116 | } |
| 1117 | vblank_last = vbl.sequence; |
| 1118 | } |
Maarten Lankhorst | aaf46cb | 2016-08-10 13:13:19 +0200 | [diff] [blame] | 1119 | |
Maarten Lankhorst | 7baf4ee | 2016-12-21 18:26:54 +0100 | [diff] [blame] | 1120 | if (!cursor_slowpath(mode)) |
Maarten Lankhorst | bc00086 | 2016-12-22 10:54:37 +0100 | [diff] [blame] | 1121 | igt_assert_lte(vbl.sequence, vblank_start + 5 * vrefresh / 8); |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 1122 | |
| 1123 | shared[0] = 1; |
| 1124 | igt_waitchildren(); |
Maarten Lankhorst | bc00086 | 2016-12-22 10:54:37 +0100 | [diff] [blame] | 1125 | igt_assert_f(shared[0] > vrefresh*target / 2, |
| 1126 | "completed %lu cursor updated in a period of %u flips, " |
| 1127 | "we expect to complete approximately %lu updates, " |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 1128 | "with the threshold set at %lu\n", |
Maarten Lankhorst | bc00086 | 2016-12-22 10:54:37 +0100 | [diff] [blame] | 1129 | shared[0], vrefresh / 2, |
| 1130 | vrefresh*target, vrefresh*target / 2); |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 1131 | } |
| 1132 | |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 1133 | do_cleanup_display(display); |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 1134 | igt_remove_fb(display->drm_fd, &fb_info); |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 1135 | igt_remove_fb(display->drm_fd, &cursor_fb); |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 1136 | munmap((void *)shared, 4096); |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 1137 | if (argb_fb.gem_handle) |
| 1138 | igt_remove_fb(display->drm_fd, &argb_fb); |
| 1139 | if (cursor_fb2.gem_handle) |
| 1140 | igt_remove_fb(display->drm_fd, &cursor_fb2); |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 1141 | } |
| 1142 | |
Maarten Lankhorst | 3966018 | 2017-01-17 17:07:52 +0100 | [diff] [blame] | 1143 | static void two_screens_cursor_vs_flip(igt_display_t *display, int nloops, bool atomic) |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 1144 | { |
Maarten Lankhorst | 3966018 | 2017-01-17 17:07:52 +0100 | [diff] [blame] | 1145 | struct drm_mode_cursor arg[2][2]; |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 1146 | struct drm_event_vblank vbl; |
Maarten Lankhorst | 3966018 | 2017-01-17 17:07:52 +0100 | [diff] [blame] | 1147 | struct igt_fb fb_info[2], cursor_fb; |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 1148 | volatile unsigned long *shared; |
Maarten Lankhorst | 3966018 | 2017-01-17 17:07:52 +0100 | [diff] [blame] | 1149 | int target[2]; |
| 1150 | enum pipe pipe[2] = { |
| 1151 | find_connected_pipe(display, false), |
| 1152 | find_connected_pipe(display, true) |
| 1153 | }; |
| 1154 | igt_output_t *outputs[2]; |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 1155 | |
| 1156 | shared = mmap(NULL, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0); |
| 1157 | igt_assert(shared != MAP_FAILED); |
| 1158 | |
Maarten Lankhorst | 3966018 | 2017-01-17 17:07:52 +0100 | [diff] [blame] | 1159 | if (atomic) |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 1160 | igt_require(display->is_atomic); |
| 1161 | |
Maarten Lankhorst | 3966018 | 2017-01-17 17:07:52 +0100 | [diff] [blame] | 1162 | igt_require((outputs[0] = set_fb_on_crtc(display, pipe[0], &fb_info[0]))); |
| 1163 | igt_require((outputs[1] = set_fb_on_crtc(display, pipe[1], &fb_info[1]))); |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 1164 | |
| 1165 | igt_create_color_fb(display->drm_fd, 64, 64, DRM_FORMAT_ARGB8888, 0, 1., 1., 1., &cursor_fb); |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 1166 | |
Maarten Lankhorst | 3966018 | 2017-01-17 17:07:52 +0100 | [diff] [blame] | 1167 | set_cursor_on_pipe(display, pipe[0], &cursor_fb); |
| 1168 | populate_cursor_args(display, pipe[0], arg[0], &cursor_fb); |
| 1169 | arg[0][1].x = arg[0][1].y = 192; |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 1170 | |
Maarten Lankhorst | 3966018 | 2017-01-17 17:07:52 +0100 | [diff] [blame] | 1171 | set_cursor_on_pipe(display, pipe[1], &cursor_fb); |
| 1172 | populate_cursor_args(display, pipe[1], arg[1], &cursor_fb); |
| 1173 | arg[1][1].x = arg[1][1].y = 192; |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 1174 | |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 1175 | igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY); |
| 1176 | |
Maarten Lankhorst | 3966018 | 2017-01-17 17:07:52 +0100 | [diff] [blame] | 1177 | target[0] = get_cursor_updates_per_vblank(display, pipe[0], &arg[0][0]); |
| 1178 | target[1] = get_cursor_updates_per_vblank(display, pipe[1], &arg[1][0]); |
Maarten Lankhorst | ad71861 | 2016-12-27 13:50:31 +0100 | [diff] [blame] | 1179 | |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 1180 | for (int i = 0; i < nloops; i++) { |
Maarten Lankhorst | 3966018 | 2017-01-17 17:07:52 +0100 | [diff] [blame] | 1181 | unsigned long vrefresh[2]; |
| 1182 | unsigned vblank_start[2], vblank_last[2]; |
| 1183 | int done[2] = {}; |
| 1184 | |
| 1185 | vrefresh[0] = igt_output_get_mode(outputs[0])->vrefresh; |
| 1186 | vrefresh[1] = igt_output_get_mode(outputs[1])->vrefresh; |
| 1187 | |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 1188 | shared[0] = 0; |
Maarten Lankhorst | 3966018 | 2017-01-17 17:07:52 +0100 | [diff] [blame] | 1189 | shared[1] = 0; |
| 1190 | igt_fork(child, 2) { |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 1191 | unsigned long count = 0; |
| 1192 | |
Maarten Lankhorst | 3966018 | 2017-01-17 17:07:52 +0100 | [diff] [blame] | 1193 | while (!shared[child]) { |
| 1194 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[child][(i >> child) & 1]); |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 1195 | count++; |
| 1196 | } |
Maarten Lankhorst | 3966018 | 2017-01-17 17:07:52 +0100 | [diff] [blame] | 1197 | igt_debug("child %i: %lu cursor updates\n", child, count); |
| 1198 | shared[child] = count; |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 1199 | } |
| 1200 | |
Maarten Lankhorst | 3966018 | 2017-01-17 17:07:52 +0100 | [diff] [blame] | 1201 | flip_nonblocking(display, pipe[0], atomic, &fb_info[0]); |
| 1202 | flip_nonblocking(display, pipe[1], atomic, &fb_info[1]); |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 1203 | |
Maarten Lankhorst | 3966018 | 2017-01-17 17:07:52 +0100 | [diff] [blame] | 1204 | for (int n = 0; n < vrefresh[0] / 2 + vrefresh[1] / 2; n++) { |
| 1205 | int child; |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 1206 | |
| 1207 | igt_assert_eq(read(display->drm_fd, &vbl, sizeof(vbl)), sizeof(vbl)); |
Maarten Lankhorst | 3966018 | 2017-01-17 17:07:52 +0100 | [diff] [blame] | 1208 | child = vbl.user_data == (unsigned long)&fb_info[1]; |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 1209 | |
Maarten Lankhorst | 3966018 | 2017-01-17 17:07:52 +0100 | [diff] [blame] | 1210 | if (!done[child]++) |
| 1211 | vblank_start[child] = vbl.sequence; |
| 1212 | else if (vbl.sequence != vblank_last[child] + 1) |
| 1213 | igt_info("page flip %d was delayed, missed %d frames\n", |
| 1214 | done[child], vbl.sequence - vblank_last[child] - 1); |
| 1215 | |
| 1216 | vblank_last[child] = vbl.sequence; |
| 1217 | |
| 1218 | if (done[child] < vrefresh[child] / 2) { |
| 1219 | flip_nonblocking(display, pipe[child], atomic, &fb_info[child]); |
| 1220 | } else { |
| 1221 | igt_assert_lte(vbl.sequence, vblank_start[child] + 5 * vrefresh[child] / 8); |
| 1222 | |
| 1223 | shared[child] = 1; |
| 1224 | } |
| 1225 | } |
| 1226 | |
| 1227 | igt_assert_eq(done[0], vrefresh[0] / 2); |
| 1228 | igt_assert_eq(done[1], vrefresh[1] / 2); |
| 1229 | |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 1230 | igt_waitchildren(); |
Maarten Lankhorst | 3966018 | 2017-01-17 17:07:52 +0100 | [diff] [blame] | 1231 | for (int child = 0; child < 2; child++) |
| 1232 | igt_assert_f(shared[child] > vrefresh[child]*target[child] / 2, |
| 1233 | "completed %lu cursor updated in a period of %lu flips, " |
| 1234 | "we expect to complete approximately %lu updates, " |
| 1235 | "with the threshold set at %lu\n", |
| 1236 | shared[child], vrefresh[child] / 2, |
| 1237 | vrefresh[child]*target[child], vrefresh[child]*target[child] / 2); |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 1238 | } |
| 1239 | |
| 1240 | do_cleanup_display(display); |
Maarten Lankhorst | 3966018 | 2017-01-17 17:07:52 +0100 | [diff] [blame] | 1241 | igt_remove_fb(display->drm_fd, &fb_info[0]); |
| 1242 | igt_remove_fb(display->drm_fd, &fb_info[1]); |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 1243 | igt_remove_fb(display->drm_fd, &cursor_fb); |
| 1244 | munmap((void *)shared, 4096); |
| 1245 | } |
| 1246 | |
Maarten Lankhorst | 7baf4ee | 2016-12-21 18:26:54 +0100 | [diff] [blame] | 1247 | static void flip_vs_cursor_crc(igt_display_t *display, bool atomic) |
Maarten Lankhorst | 954923c | 2016-10-06 12:52:53 +0200 | [diff] [blame] | 1248 | { |
| 1249 | struct drm_mode_cursor arg[2]; |
| 1250 | struct drm_event_vblank vbl; |
| 1251 | struct igt_fb fb_info, cursor_fb; |
| 1252 | unsigned vblank_start; |
| 1253 | enum pipe pipe = find_connected_pipe(display, false); |
| 1254 | igt_pipe_crc_t *pipe_crc; |
| 1255 | igt_crc_t crcs[3]; |
| 1256 | |
| 1257 | if (atomic) |
| 1258 | igt_require(display->is_atomic); |
| 1259 | |
| 1260 | igt_require(set_fb_on_crtc(display, pipe, &fb_info)); |
| 1261 | |
| 1262 | igt_create_color_fb(display->drm_fd, 64, 64, DRM_FORMAT_ARGB8888, 0, 1., 1., 1., &cursor_fb); |
| 1263 | populate_cursor_args(display, pipe, arg, &cursor_fb); |
| 1264 | |
Maarten Lankhorst | 954923c | 2016-10-06 12:52:53 +0200 | [diff] [blame] | 1265 | igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY); |
| 1266 | |
Chris Wilson | 83884e9 | 2017-03-21 17:16:03 +0000 | [diff] [blame] | 1267 | pipe_crc = igt_pipe_crc_new(display->drm_fd, pipe, INTEL_PIPE_CRC_SOURCE_AUTO); |
Maarten Lankhorst | 954923c | 2016-10-06 12:52:53 +0200 | [diff] [blame] | 1268 | |
Maarten Lankhorst | 954923c | 2016-10-06 12:52:53 +0200 | [diff] [blame] | 1269 | set_cursor_on_pipe(display, pipe, &cursor_fb); |
| 1270 | igt_display_commit2(display, COMMIT_UNIVERSAL); |
| 1271 | |
Maarten Lankhorst | 4f08666 | 2016-12-08 10:56:13 +0100 | [diff] [blame] | 1272 | /* Collect reference crcs, crcs[0] last. */ |
| 1273 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[1]); |
| 1274 | igt_pipe_crc_collect_crc(pipe_crc, &crcs[1]); |
Maarten Lankhorst | 954923c | 2016-10-06 12:52:53 +0200 | [diff] [blame] | 1275 | |
Maarten Lankhorst | 4f08666 | 2016-12-08 10:56:13 +0100 | [diff] [blame] | 1276 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[0]); |
Maarten Lankhorst | 954923c | 2016-10-06 12:52:53 +0200 | [diff] [blame] | 1277 | igt_pipe_crc_collect_crc(pipe_crc, &crcs[0]); |
| 1278 | |
| 1279 | /* Disable cursor, and immediately queue a flip. Check if resulting crc is correct. */ |
| 1280 | for (int i = 1; i >= 0; i--) { |
| 1281 | vblank_start = get_vblank(display->drm_fd, pipe, DRM_VBLANK_NEXTONMISS); |
| 1282 | |
| 1283 | flip_nonblocking(display, pipe, atomic, &fb_info); |
| 1284 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[i]); |
| 1285 | |
| 1286 | igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start); |
| 1287 | |
| 1288 | igt_set_timeout(1, "Stuck page flip"); |
| 1289 | igt_ignore_warn(read(display->drm_fd, &vbl, sizeof(vbl))); |
| 1290 | igt_reset_timeout(); |
| 1291 | |
| 1292 | igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start + 1); |
| 1293 | |
| 1294 | igt_pipe_crc_collect_crc(pipe_crc, &crcs[2]); |
| 1295 | |
| 1296 | igt_assert_crc_equal(&crcs[i], &crcs[2]); |
| 1297 | } |
| 1298 | |
| 1299 | do_cleanup_display(display); |
| 1300 | igt_remove_fb(display->drm_fd, &fb_info); |
| 1301 | igt_remove_fb(display->drm_fd, &cursor_fb); |
| 1302 | igt_pipe_crc_free(pipe_crc); |
| 1303 | } |
| 1304 | |
| 1305 | static void flip_vs_cursor_busy_crc(igt_display_t *display, bool atomic) |
Maarten Lankhorst | 4fb2178 | 2016-09-07 17:00:39 +0200 | [diff] [blame] | 1306 | { |
| 1307 | struct drm_mode_cursor arg[2]; |
| 1308 | struct drm_event_vblank vbl; |
Maarten Lankhorst | 4ef3fe9 | 2016-10-05 15:51:00 +0200 | [diff] [blame] | 1309 | struct igt_fb fb_info[2], cursor_fb; |
Maarten Lankhorst | 4fb2178 | 2016-09-07 17:00:39 +0200 | [diff] [blame] | 1310 | unsigned vblank_start; |
| 1311 | enum pipe pipe = find_connected_pipe(display, false); |
| 1312 | igt_pipe_crc_t *pipe_crc; |
Robert Foss | a786479 | 2017-01-10 19:21:26 -0500 | [diff] [blame] | 1313 | igt_pipe_t *pipe_connected = &display->pipes[pipe]; |
| 1314 | igt_plane_t *plane_primary = igt_pipe_get_plane_type(pipe_connected, DRM_PLANE_TYPE_PRIMARY); |
Maarten Lankhorst | 4fb2178 | 2016-09-07 17:00:39 +0200 | [diff] [blame] | 1315 | igt_crc_t crcs[3]; |
| 1316 | |
| 1317 | if (atomic) |
| 1318 | igt_require(display->is_atomic); |
| 1319 | |
Maarten Lankhorst | 4ef3fe9 | 2016-10-05 15:51:00 +0200 | [diff] [blame] | 1320 | igt_require(set_fb_on_crtc(display, pipe, &fb_info[0])); |
| 1321 | igt_create_color_pattern_fb(display->drm_fd, fb_info[0].width, fb_info[0].height, |
| 1322 | DRM_FORMAT_XRGB8888, LOCAL_I915_FORMAT_MOD_X_TILED, .1, .1, .1, &fb_info[1]); |
Maarten Lankhorst | 4fb2178 | 2016-09-07 17:00:39 +0200 | [diff] [blame] | 1323 | |
| 1324 | igt_create_color_fb(display->drm_fd, 64, 64, DRM_FORMAT_ARGB8888, 0, 1., 1., 1., &cursor_fb); |
| 1325 | populate_cursor_args(display, pipe, arg, &cursor_fb); |
| 1326 | |
Maarten Lankhorst | 4fb2178 | 2016-09-07 17:00:39 +0200 | [diff] [blame] | 1327 | igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY); |
| 1328 | |
Chris Wilson | 83884e9 | 2017-03-21 17:16:03 +0000 | [diff] [blame] | 1329 | pipe_crc = igt_pipe_crc_new(display->drm_fd, pipe, INTEL_PIPE_CRC_SOURCE_AUTO); |
Maarten Lankhorst | 4fb2178 | 2016-09-07 17:00:39 +0200 | [diff] [blame] | 1330 | |
Maarten Lankhorst | 4fb2178 | 2016-09-07 17:00:39 +0200 | [diff] [blame] | 1331 | set_cursor_on_pipe(display, pipe, &cursor_fb); |
| 1332 | igt_display_commit2(display, COMMIT_UNIVERSAL); |
| 1333 | |
Maarten Lankhorst | 4f08666 | 2016-12-08 10:56:13 +0100 | [diff] [blame] | 1334 | /* Collect reference crcs, crc[0] last for the loop. */ |
| 1335 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[1]); |
| 1336 | igt_pipe_crc_collect_crc(pipe_crc, &crcs[1]); |
Maarten Lankhorst | 4fb2178 | 2016-09-07 17:00:39 +0200 | [diff] [blame] | 1337 | |
Maarten Lankhorst | 4f08666 | 2016-12-08 10:56:13 +0100 | [diff] [blame] | 1338 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[0]); |
Maarten Lankhorst | 4fb2178 | 2016-09-07 17:00:39 +0200 | [diff] [blame] | 1339 | igt_pipe_crc_collect_crc(pipe_crc, &crcs[0]); |
| 1340 | |
Maarten Lankhorst | 954923c | 2016-10-06 12:52:53 +0200 | [diff] [blame] | 1341 | /* |
| 1342 | * Set fb 1 on primary at least once before flipping to force |
| 1343 | * setting the correct cache level, else we get a stall in the |
| 1344 | * page flip handler. |
| 1345 | */ |
Robert Foss | a786479 | 2017-01-10 19:21:26 -0500 | [diff] [blame] | 1346 | igt_plane_set_fb(plane_primary, &fb_info[1]); |
Maarten Lankhorst | 954923c | 2016-10-06 12:52:53 +0200 | [diff] [blame] | 1347 | igt_display_commit2(display, COMMIT_UNIVERSAL); |
Maarten Lankhorst | 4ef3fe9 | 2016-10-05 15:51:00 +0200 | [diff] [blame] | 1348 | |
Robert Foss | a786479 | 2017-01-10 19:21:26 -0500 | [diff] [blame] | 1349 | igt_plane_set_fb(plane_primary, &fb_info[0]); |
Maarten Lankhorst | 954923c | 2016-10-06 12:52:53 +0200 | [diff] [blame] | 1350 | igt_display_commit2(display, COMMIT_UNIVERSAL); |
Maarten Lankhorst | 4ef3fe9 | 2016-10-05 15:51:00 +0200 | [diff] [blame] | 1351 | |
Maarten Lankhorst | 4fb2178 | 2016-09-07 17:00:39 +0200 | [diff] [blame] | 1352 | /* Disable cursor, and immediately queue a flip. Check if resulting crc is correct. */ |
| 1353 | for (int i = 1; i >= 0; i--) { |
Chris Wilson | 18cd796 | 2016-10-05 19:31:27 +0100 | [diff] [blame] | 1354 | uint32_t *busy; |
Maarten Lankhorst | 4ef3fe9 | 2016-10-05 15:51:00 +0200 | [diff] [blame] | 1355 | |
Maarten Lankhorst | 954923c | 2016-10-06 12:52:53 +0200 | [diff] [blame] | 1356 | busy = make_fb_busy(display->drm_fd, &fb_info[1]); |
Maarten Lankhorst | 4ef3fe9 | 2016-10-05 15:51:00 +0200 | [diff] [blame] | 1357 | |
Maarten Lankhorst | 4fb2178 | 2016-09-07 17:00:39 +0200 | [diff] [blame] | 1358 | vblank_start = get_vblank(display->drm_fd, pipe, DRM_VBLANK_NEXTONMISS); |
| 1359 | |
Maarten Lankhorst | 954923c | 2016-10-06 12:52:53 +0200 | [diff] [blame] | 1360 | flip_nonblocking(display, pipe, atomic, &fb_info[1]); |
Maarten Lankhorst | 4fb2178 | 2016-09-07 17:00:39 +0200 | [diff] [blame] | 1361 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[i]); |
| 1362 | |
| 1363 | igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start); |
| 1364 | |
Maarten Lankhorst | 954923c | 2016-10-06 12:52:53 +0200 | [diff] [blame] | 1365 | igt_pipe_crc_collect_crc(pipe_crc, &crcs[2]); |
Maarten Lankhorst | 4fb2178 | 2016-09-07 17:00:39 +0200 | [diff] [blame] | 1366 | |
Maarten Lankhorst | 954923c | 2016-10-06 12:52:53 +0200 | [diff] [blame] | 1367 | finish_fb_busy(busy); |
Maarten Lankhorst | 4ef3fe9 | 2016-10-05 15:51:00 +0200 | [diff] [blame] | 1368 | |
Maarten Lankhorst | 954923c | 2016-10-06 12:52:53 +0200 | [diff] [blame] | 1369 | igt_set_timeout(1, "Stuck page flip"); |
| 1370 | igt_ignore_warn(read(display->drm_fd, &vbl, sizeof(vbl))); |
| 1371 | igt_reset_timeout(); |
Maarten Lankhorst | 4ef3fe9 | 2016-10-05 15:51:00 +0200 | [diff] [blame] | 1372 | |
Maarten Lankhorst | 954923c | 2016-10-06 12:52:53 +0200 | [diff] [blame] | 1373 | igt_assert_lte(vblank_start + 1, get_vblank(display->drm_fd, pipe, 0)); |
Maarten Lankhorst | 4ef3fe9 | 2016-10-05 15:51:00 +0200 | [diff] [blame] | 1374 | |
Robert Foss | a786479 | 2017-01-10 19:21:26 -0500 | [diff] [blame] | 1375 | igt_plane_set_fb(plane_primary, &fb_info[0]); |
Maarten Lankhorst | 954923c | 2016-10-06 12:52:53 +0200 | [diff] [blame] | 1376 | igt_display_commit2(display, COMMIT_UNIVERSAL); |
Maarten Lankhorst | 4fb2178 | 2016-09-07 17:00:39 +0200 | [diff] [blame] | 1377 | |
| 1378 | igt_assert_crc_equal(&crcs[i], &crcs[2]); |
| 1379 | } |
| 1380 | |
| 1381 | do_cleanup_display(display); |
Maarten Lankhorst | 4ef3fe9 | 2016-10-05 15:51:00 +0200 | [diff] [blame] | 1382 | igt_remove_fb(display->drm_fd, &fb_info[1]); |
| 1383 | igt_remove_fb(display->drm_fd, &fb_info[0]); |
Maarten Lankhorst | 4fb2178 | 2016-09-07 17:00:39 +0200 | [diff] [blame] | 1384 | igt_remove_fb(display->drm_fd, &cursor_fb); |
| 1385 | igt_pipe_crc_free(pipe_crc); |
| 1386 | } |
| 1387 | |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 1388 | igt_main |
| 1389 | { |
Chris Wilson | dab6b6b | 2016-05-24 16:14:32 +0100 | [diff] [blame] | 1390 | const int ncpus = sysconf(_SC_NPROCESSORS_ONLN); |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 1391 | igt_display_t display = { .drm_fd = -1 }; |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 1392 | int i; |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 1393 | |
| 1394 | igt_skip_on_simulation(); |
| 1395 | |
| 1396 | igt_fixture { |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 1397 | display.drm_fd = drm_open_driver_master(DRIVER_ANY); |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 1398 | kmstest_set_vt_graphics_mode(); |
Chris Wilson | cce2ff0 | 2016-05-25 08:34:25 +0100 | [diff] [blame] | 1399 | |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 1400 | igt_display_init(&display, display.drm_fd); |
| 1401 | igt_require(display.n_pipes > 0); |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 1402 | } |
| 1403 | |
Chris Wilson | cce2ff0 | 2016-05-25 08:34:25 +0100 | [diff] [blame] | 1404 | igt_subtest_group { |
Maarten Lankhorst | 1b8d8bc | 2016-07-12 11:55:26 +0200 | [diff] [blame] | 1405 | for (int n = 0; n < I915_MAX_PIPES; n++) { |
Chris Wilson | cce2ff0 | 2016-05-25 08:34:25 +0100 | [diff] [blame] | 1406 | errno = 0; |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 1407 | |
Chris Wilson | 04b8f0e | 2016-05-25 14:53:34 +0100 | [diff] [blame] | 1408 | igt_fixture { |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 1409 | igt_skip_on(n >= display.n_pipes); |
Chris Wilson | 04b8f0e | 2016-05-25 14:53:34 +0100 | [diff] [blame] | 1410 | } |
Chris Wilson | cce2ff0 | 2016-05-25 08:34:25 +0100 | [diff] [blame] | 1411 | |
Maarten Lankhorst | 1b8d8bc | 2016-07-12 11:55:26 +0200 | [diff] [blame] | 1412 | igt_subtest_f("pipe-%s-single-bo", kmstest_pipe_name(n)) |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 1413 | stress(&display, n, 1, DRM_MODE_CURSOR_BO, 20); |
Maarten Lankhorst | 1b8d8bc | 2016-07-12 11:55:26 +0200 | [diff] [blame] | 1414 | igt_subtest_f("pipe-%s-single-move", kmstest_pipe_name(n)) |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 1415 | stress(&display, n, 1, DRM_MODE_CURSOR_MOVE, 20); |
Chris Wilson | cce2ff0 | 2016-05-25 08:34:25 +0100 | [diff] [blame] | 1416 | |
Maarten Lankhorst | 1b8d8bc | 2016-07-12 11:55:26 +0200 | [diff] [blame] | 1417 | igt_subtest_f("pipe-%s-forked-bo", kmstest_pipe_name(n)) |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 1418 | stress(&display, n, ncpus, DRM_MODE_CURSOR_BO, 20); |
Maarten Lankhorst | 1b8d8bc | 2016-07-12 11:55:26 +0200 | [diff] [blame] | 1419 | igt_subtest_f("pipe-%s-forked-move", kmstest_pipe_name(n)) |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 1420 | stress(&display, n, ncpus, DRM_MODE_CURSOR_MOVE, 20); |
Chris Wilson | f5d370c | 2016-06-04 21:25:17 +0100 | [diff] [blame] | 1421 | |
Maarten Lankhorst | 1b8d8bc | 2016-07-12 11:55:26 +0200 | [diff] [blame] | 1422 | igt_subtest_f("pipe-%s-torture-bo", kmstest_pipe_name(n)) |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 1423 | stress(&display, n, -ncpus, DRM_MODE_CURSOR_BO, 20); |
Maarten Lankhorst | 1b8d8bc | 2016-07-12 11:55:26 +0200 | [diff] [blame] | 1424 | igt_subtest_f("pipe-%s-torture-move", kmstest_pipe_name(n)) |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 1425 | stress(&display, n, -ncpus, DRM_MODE_CURSOR_MOVE, 20); |
Chris Wilson | cce2ff0 | 2016-05-25 08:34:25 +0100 | [diff] [blame] | 1426 | } |
| 1427 | } |
| 1428 | |
Maarten Lankhorst | 1b8d8bc | 2016-07-12 11:55:26 +0200 | [diff] [blame] | 1429 | igt_subtest("all-pipes-single-bo") |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 1430 | stress(&display, -1, 1, DRM_MODE_CURSOR_BO, 20); |
Maarten Lankhorst | 1b8d8bc | 2016-07-12 11:55:26 +0200 | [diff] [blame] | 1431 | igt_subtest("all-pipes-single-move") |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 1432 | stress(&display, -1, 1, DRM_MODE_CURSOR_MOVE, 20); |
Chris Wilson | cce2ff0 | 2016-05-25 08:34:25 +0100 | [diff] [blame] | 1433 | |
Maarten Lankhorst | 1b8d8bc | 2016-07-12 11:55:26 +0200 | [diff] [blame] | 1434 | igt_subtest("all-pipes-forked-bo") |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 1435 | stress(&display, -1, ncpus, DRM_MODE_CURSOR_BO, 20); |
Maarten Lankhorst | 1b8d8bc | 2016-07-12 11:55:26 +0200 | [diff] [blame] | 1436 | igt_subtest("all-pipes-forked-move") |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 1437 | stress(&display, -1, ncpus, DRM_MODE_CURSOR_MOVE, 20); |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 1438 | |
Maarten Lankhorst | 1b8d8bc | 2016-07-12 11:55:26 +0200 | [diff] [blame] | 1439 | igt_subtest("all-pipes-torture-bo") |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 1440 | stress(&display, -1, -ncpus, DRM_MODE_CURSOR_BO, 20); |
Maarten Lankhorst | 1b8d8bc | 2016-07-12 11:55:26 +0200 | [diff] [blame] | 1441 | igt_subtest("all-pipes-torture-move") |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 1442 | stress(&display, -1, -ncpus, DRM_MODE_CURSOR_MOVE, 20); |
Chris Wilson | f5d370c | 2016-06-04 21:25:17 +0100 | [diff] [blame] | 1443 | |
Maarten Lankhorst | 59cdcf1 | 2016-11-02 13:38:48 +0100 | [diff] [blame] | 1444 | igt_subtest("nonblocking-modeset-vs-cursor-atomic") |
| 1445 | nonblocking_modeset_vs_cursor(&display, 1); |
| 1446 | |
| 1447 | igt_subtest("long-nonblocking-modeset-vs-cursor-atomic") |
| 1448 | nonblocking_modeset_vs_cursor(&display, 16); |
| 1449 | |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 1450 | igt_subtest("2x-flip-vs-cursor-legacy") |
Maarten Lankhorst | 5b8a1ba | 2017-01-18 10:41:37 +0100 | [diff] [blame] | 1451 | two_screens_flip_vs_cursor(&display, 8, false, false); |
| 1452 | |
| 1453 | igt_subtest("2x-flip-vs-cursor-atomic") |
| 1454 | two_screens_flip_vs_cursor(&display, 4, false, true); |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 1455 | |
| 1456 | igt_subtest("2x-cursor-vs-flip-legacy") |
Maarten Lankhorst | 3966018 | 2017-01-17 17:07:52 +0100 | [diff] [blame] | 1457 | two_screens_cursor_vs_flip(&display, 8, false); |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 1458 | |
| 1459 | igt_subtest("2x-long-flip-vs-cursor-legacy") |
Maarten Lankhorst | 5b8a1ba | 2017-01-18 10:41:37 +0100 | [diff] [blame] | 1460 | two_screens_flip_vs_cursor(&display, 150, false, false); |
| 1461 | |
| 1462 | igt_subtest("2x-long-flip-vs-cursor-atomic") |
| 1463 | two_screens_flip_vs_cursor(&display, 150, false, true); |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 1464 | |
| 1465 | igt_subtest("2x-long-cursor-vs-flip-legacy") |
Maarten Lankhorst | bc00086 | 2016-12-22 10:54:37 +0100 | [diff] [blame] | 1466 | two_screens_cursor_vs_flip(&display, 50, false); |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 1467 | |
| 1468 | igt_subtest("2x-nonblocking-modeset-vs-cursor-atomic") |
Maarten Lankhorst | 5b8a1ba | 2017-01-18 10:41:37 +0100 | [diff] [blame] | 1469 | two_screens_flip_vs_cursor(&display, 8, true, true); |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 1470 | |
Maarten Lankhorst | 3966018 | 2017-01-17 17:07:52 +0100 | [diff] [blame] | 1471 | igt_subtest("2x-cursor-vs-flip-atomic") |
| 1472 | two_screens_cursor_vs_flip(&display, 8, true); |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 1473 | |
| 1474 | igt_subtest("2x-long-nonblocking-modeset-vs-cursor-atomic") |
Maarten Lankhorst | 5b8a1ba | 2017-01-18 10:41:37 +0100 | [diff] [blame] | 1475 | two_screens_flip_vs_cursor(&display, 150, true, true); |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 1476 | |
Maarten Lankhorst | 3966018 | 2017-01-17 17:07:52 +0100 | [diff] [blame] | 1477 | igt_subtest("2x-long-cursor-vs-flip-atomic") |
Maarten Lankhorst | bc00086 | 2016-12-22 10:54:37 +0100 | [diff] [blame] | 1478 | two_screens_cursor_vs_flip(&display, 50, true); |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 1479 | |
Maarten Lankhorst | 4fb2178 | 2016-09-07 17:00:39 +0200 | [diff] [blame] | 1480 | igt_subtest("flip-vs-cursor-crc-legacy") |
Maarten Lankhorst | 954923c | 2016-10-06 12:52:53 +0200 | [diff] [blame] | 1481 | flip_vs_cursor_crc(&display, false); |
Maarten Lankhorst | 4fb2178 | 2016-09-07 17:00:39 +0200 | [diff] [blame] | 1482 | |
| 1483 | igt_subtest("flip-vs-cursor-crc-atomic") |
Maarten Lankhorst | 954923c | 2016-10-06 12:52:53 +0200 | [diff] [blame] | 1484 | flip_vs_cursor_crc(&display, true); |
Maarten Lankhorst | 4ef3fe9 | 2016-10-05 15:51:00 +0200 | [diff] [blame] | 1485 | |
| 1486 | igt_subtest("flip-vs-cursor-busy-crc-legacy") |
Maarten Lankhorst | 954923c | 2016-10-06 12:52:53 +0200 | [diff] [blame] | 1487 | flip_vs_cursor_busy_crc(&display, false); |
Maarten Lankhorst | 4ef3fe9 | 2016-10-05 15:51:00 +0200 | [diff] [blame] | 1488 | |
| 1489 | igt_subtest("flip-vs-cursor-busy-crc-atomic") |
Maarten Lankhorst | 954923c | 2016-10-06 12:52:53 +0200 | [diff] [blame] | 1490 | flip_vs_cursor_busy_crc(&display, true); |
Maarten Lankhorst | 4fb2178 | 2016-09-07 17:00:39 +0200 | [diff] [blame] | 1491 | |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 1492 | for (i = 0; i <= flip_test_last; i++) { |
| 1493 | const char *modes[flip_test_last+1] = { |
| 1494 | "legacy", |
| 1495 | "varying-size", |
| 1496 | "toggle", |
| 1497 | "atomic", |
| 1498 | "atomic-transitions", |
| 1499 | "atomic-transitions-varying-size" |
| 1500 | }; |
| 1501 | const char *prefix = "short-"; |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 1502 | |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 1503 | switch (i) { |
| 1504 | case flip_test_legacy: |
| 1505 | case flip_test_varying_size: |
| 1506 | case flip_test_atomic: |
| 1507 | prefix = "basic-"; |
| 1508 | break; |
| 1509 | default: break; |
| 1510 | } |
Maarten Lankhorst | 1b8d8bc | 2016-07-12 11:55:26 +0200 | [diff] [blame] | 1511 | |
Chris Wilson | 237cb89 | 2016-09-13 11:37:41 +0100 | [diff] [blame] | 1512 | igt_subtest_f("%sflip-before-cursor-%s", prefix, modes[i]) |
Chris Wilson | d2adbdf | 2016-10-04 13:50:50 +0100 | [diff] [blame] | 1513 | basic_flip_cursor(&display, i, FLIP_BEFORE_CURSOR, 0); |
| 1514 | |
Chris Wilson | 83cab8a | 2017-04-27 09:22:54 +0100 | [diff] [blame^] | 1515 | if (!cursor_slowpath(i)) { |
| 1516 | igt_subtest_f("%sbusy-flip-before-cursor-%s", prefix, modes[i]) { |
| 1517 | igt_require_gem(display.drm_fd); |
Maarten Lankhorst | 7baf4ee | 2016-12-21 18:26:54 +0100 | [diff] [blame] | 1518 | basic_flip_cursor(&display, i, FLIP_BEFORE_CURSOR, |
| 1519 | BASIC_BUSY); |
Chris Wilson | 83cab8a | 2017-04-27 09:22:54 +0100 | [diff] [blame^] | 1520 | } |
| 1521 | } |
Chris Wilson | 237cb89 | 2016-09-13 11:37:41 +0100 | [diff] [blame] | 1522 | |
| 1523 | igt_subtest_f("%sflip-after-cursor-%s", prefix, modes[i]) |
Chris Wilson | d2adbdf | 2016-10-04 13:50:50 +0100 | [diff] [blame] | 1524 | basic_flip_cursor(&display, i, FLIP_AFTER_CURSOR, 0); |
Chris Wilson | 237cb89 | 2016-09-13 11:37:41 +0100 | [diff] [blame] | 1525 | |
| 1526 | igt_subtest_f("flip-vs-cursor-%s", modes[i]) |
| 1527 | flip_vs_cursor(&display, i, 150); |
| 1528 | igt_subtest_f("cursor-vs-flip-%s", modes[i]) |
Maarten Lankhorst | bc00086 | 2016-12-22 10:54:37 +0100 | [diff] [blame] | 1529 | cursor_vs_flip(&display, i, 50); |
Maarten Lankhorst | 1b8d8bc | 2016-07-12 11:55:26 +0200 | [diff] [blame] | 1530 | |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 1531 | igt_subtest_f("cursorA-vs-flipA-%s", modes[i]) |
| 1532 | flip(&display, 0, 0, 10, i); |
| 1533 | |
| 1534 | igt_subtest_f("cursorA-vs-flipB-%s", modes[i]) |
| 1535 | flip(&display, 0, 1, 10, i); |
| 1536 | |
| 1537 | igt_subtest_f("cursorB-vs-flipA-%s", modes[i]) |
| 1538 | flip(&display, 1, 0, 10, i); |
| 1539 | |
| 1540 | igt_subtest_f("cursorB-vs-flipB-%s", modes[i]) |
| 1541 | flip(&display, 1, 1, 10, i); |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 1542 | } |
| 1543 | |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 1544 | igt_fixture { |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 1545 | igt_display_fini(&display); |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 1546 | } |
| 1547 | } |