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> |
| 27 | |
| 28 | #include "igt.h" |
Chris Wilson | 376b813 | 2016-07-03 09:42:38 +0100 | [diff] [blame] | 29 | #include "igt_rand.h" |
Chris Wilson | c74e071 | 2016-05-24 16:24:15 +0100 | [diff] [blame] | 30 | #include "igt_stats.h" |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 31 | |
Tomeu Vizoso | 047c999 | 2016-06-07 10:18:34 +0200 | [diff] [blame] | 32 | #if defined(__x86_64__) || defined(__i386__) |
| 33 | #define cpu_relax() __builtin_ia32_pause() |
| 34 | #else |
| 35 | #define cpu_relax() asm volatile("": : :"memory") |
| 36 | #endif |
| 37 | |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 38 | #ifndef DRM_CAP_CURSOR_WIDTH |
| 39 | #define DRM_CAP_CURSOR_WIDTH 0x8 |
| 40 | #endif |
| 41 | |
| 42 | #ifndef DRM_CAP_CURSOR_HEIGHT |
| 43 | #define DRM_CAP_CURSOR_HEIGHT 0x9 |
| 44 | #endif |
| 45 | |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 46 | IGT_TEST_DESCRIPTION("Stress legacy cursor ioctl"); |
| 47 | |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 48 | static void stress(igt_display_t *display, |
| 49 | int pipe, int num_children, unsigned mode, |
Chris Wilson | cce2ff0 | 2016-05-25 08:34:25 +0100 | [diff] [blame] | 50 | int timeout) |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 51 | { |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 52 | struct drm_mode_cursor arg; |
Chris Wilson | c74e071 | 2016-05-24 16:24:15 +0100 | [diff] [blame] | 53 | uint64_t *results; |
Chris Wilson | f5d370c | 2016-06-04 21:25:17 +0100 | [diff] [blame] | 54 | bool torture; |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 55 | int n; |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 56 | unsigned crtc_id[I915_MAX_PIPES], num_crtcs; |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 57 | |
Chris Wilson | f5d370c | 2016-06-04 21:25:17 +0100 | [diff] [blame] | 58 | torture = false; |
| 59 | if (num_children < 0) { |
| 60 | torture = true; |
| 61 | num_children = -num_children; |
| 62 | } |
| 63 | |
Chris Wilson | c74e071 | 2016-05-24 16:24:15 +0100 | [diff] [blame] | 64 | results = mmap(NULL, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0); |
| 65 | igt_assert(results != MAP_FAILED); |
| 66 | |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 67 | memset(&arg, 0, sizeof(arg)); |
| 68 | arg.flags = DRM_MODE_CURSOR_BO; |
| 69 | arg.crtc_id = 0; |
| 70 | arg.width = 64; |
| 71 | arg.height = 64; |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 72 | 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] | 73 | |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 74 | if (pipe < 0) { |
| 75 | num_crtcs = display->n_pipes; |
| 76 | for_each_pipe(display, n) { |
| 77 | arg.crtc_id = crtc_id[n] = display->pipes[n].crtc_id; |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 78 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg); |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 79 | } |
| 80 | } else { |
| 81 | num_crtcs = 1; |
| 82 | arg.crtc_id = crtc_id[0] = display->pipes[pipe].crtc_id; |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 83 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg); |
Chris Wilson | cce2ff0 | 2016-05-25 08:34:25 +0100 | [diff] [blame] | 84 | } |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 85 | |
| 86 | arg.flags = mode; |
Chris Wilson | dab6b6b | 2016-05-24 16:14:32 +0100 | [diff] [blame] | 87 | igt_fork(child, num_children) { |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 88 | struct sched_param rt = {.sched_priority = 99 }; |
| 89 | cpu_set_t allowed; |
| 90 | unsigned long count = 0; |
| 91 | |
| 92 | sched_setscheduler(getpid(), SCHED_RR, &rt); |
| 93 | |
| 94 | CPU_ZERO(&allowed); |
| 95 | CPU_SET(child, &allowed); |
| 96 | sched_setaffinity(getpid(), sizeof(cpu_set_t), &allowed); |
| 97 | |
Chris Wilson | 376b813 | 2016-07-03 09:42:38 +0100 | [diff] [blame] | 98 | hars_petruska_f54_1_random_perturb(child); |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 99 | igt_until_timeout(timeout) { |
Chris Wilson | 376b813 | 2016-07-03 09:42:38 +0100 | [diff] [blame] | 100 | 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] | 101 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg); |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 102 | count++; |
| 103 | } |
| 104 | |
Chris Wilson | c74e071 | 2016-05-24 16:24:15 +0100 | [diff] [blame] | 105 | igt_debug("[%d] count=%lu\n", child, count); |
| 106 | results[child] = count; |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 107 | } |
Chris Wilson | f5d370c | 2016-06-04 21:25:17 +0100 | [diff] [blame] | 108 | if (torture) { |
| 109 | igt_fork(child, num_children) { |
| 110 | struct sched_param rt = {.sched_priority = 1 }; |
| 111 | cpu_set_t allowed; |
| 112 | unsigned long long count = 0; |
| 113 | |
| 114 | sched_setscheduler(getpid(), SCHED_RR, &rt); |
| 115 | |
| 116 | CPU_ZERO(&allowed); |
| 117 | CPU_SET(child, &allowed); |
| 118 | sched_setaffinity(getpid(), sizeof(cpu_set_t), &allowed); |
| 119 | igt_until_timeout(timeout) { |
| 120 | count++; |
Tomeu Vizoso | 047c999 | 2016-06-07 10:18:34 +0200 | [diff] [blame] | 121 | cpu_relax(); |
Chris Wilson | f5d370c | 2016-06-04 21:25:17 +0100 | [diff] [blame] | 122 | } |
| 123 | igt_debug("[hog:%d] count=%llu\n", child, count); |
| 124 | } |
| 125 | } |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 126 | igt_waitchildren(); |
| 127 | |
Chris Wilson | c74e071 | 2016-05-24 16:24:15 +0100 | [diff] [blame] | 128 | if (num_children > 1) { |
| 129 | igt_stats_t stats; |
| 130 | |
| 131 | igt_stats_init_with_size(&stats, num_children); |
| 132 | results[num_children] = 0; |
| 133 | for (int child = 0; child < num_children; child++) { |
| 134 | igt_stats_push(&stats, results[child]); |
| 135 | results[num_children] += results[child]; |
| 136 | } |
| 137 | igt_info("Total updates %llu (median of %d processes is %.2f)\n", |
| 138 | (long long)results[num_children], |
| 139 | num_children, |
| 140 | igt_stats_get_median(&stats)); |
| 141 | igt_stats_fini(&stats); |
| 142 | } else { |
| 143 | igt_info("Total updates %llu\n", (long long)results[0]); |
| 144 | } |
| 145 | |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 146 | gem_close(display->drm_fd, arg.handle); |
Chris Wilson | c74e071 | 2016-05-24 16:24:15 +0100 | [diff] [blame] | 147 | munmap(results, 4096); |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 148 | } |
| 149 | |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 150 | 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] | 151 | { |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 152 | igt_output_t *output; |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 153 | |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 154 | for_each_valid_output_on_pipe(display, pipe, output) { |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 155 | drmModeModeInfoPtr mode; |
| 156 | igt_plane_t *primary; |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 157 | |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 158 | if (output->pending_crtc_idx_mask) |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 159 | continue; |
| 160 | |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 161 | igt_output_set_pipe(output, pipe); |
| 162 | mode = igt_output_get_mode(output); |
| 163 | |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 164 | igt_create_pattern_fb(display->drm_fd, |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 165 | mode->hdisplay, mode->vdisplay, |
| 166 | DRM_FORMAT_XRGB8888, I915_TILING_NONE, fb_info); |
| 167 | |
| 168 | primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY); |
| 169 | igt_plane_set_fb(primary, fb_info); |
| 170 | |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 171 | return output; |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 172 | } |
| 173 | |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 174 | return NULL; |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | static void set_cursor_on_pipe(igt_display_t *display, enum pipe pipe, struct igt_fb *fb) |
| 178 | { |
| 179 | igt_plane_t *plane, *cursor = NULL; |
| 180 | |
| 181 | for_each_plane_on_pipe(display, pipe, plane) { |
| 182 | if (!plane->is_cursor) |
| 183 | continue; |
| 184 | |
| 185 | cursor = plane; |
| 186 | break; |
| 187 | } |
| 188 | |
| 189 | igt_require(cursor); |
| 190 | igt_plane_set_fb(cursor, fb); |
| 191 | } |
| 192 | |
| 193 | static void populate_cursor_args(igt_display_t *display, enum pipe pipe, |
| 194 | struct drm_mode_cursor *arg, struct igt_fb *fb) |
| 195 | { |
| 196 | arg->crtc_id = display->pipes[pipe].crtc_id; |
| 197 | arg->flags = DRM_MODE_CURSOR_MOVE; |
| 198 | arg->x = 128; |
| 199 | arg->y = 128; |
| 200 | arg->width = fb->width; |
| 201 | arg->height = fb->height; |
| 202 | arg->handle = fb->gem_handle; |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 203 | arg[1] = *arg; |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | static void do_cleanup_display(igt_display_t *display) |
| 207 | { |
| 208 | enum pipe pipe; |
| 209 | igt_output_t *output; |
| 210 | igt_plane_t *plane; |
| 211 | |
| 212 | for_each_pipe(display, pipe) |
| 213 | for_each_plane_on_pipe(display, pipe, plane) |
| 214 | igt_plane_set_fb(plane, NULL); |
| 215 | |
| 216 | for_each_connected_output(display, output) |
| 217 | igt_output_set_pipe(output, PIPE_NONE); |
| 218 | |
| 219 | igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY); |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 220 | } |
| 221 | |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 222 | static enum pipe find_connected_pipe(igt_display_t *display, bool second) |
| 223 | { |
| 224 | enum pipe pipe, first = PIPE_NONE; |
| 225 | igt_output_t *output; |
| 226 | igt_output_t *first_output = NULL; |
| 227 | bool found = false; |
| 228 | |
| 229 | for_each_pipe_with_valid_output(display, pipe, output) { |
| 230 | if (first == pipe || output == first_output) |
| 231 | continue; |
| 232 | |
| 233 | if (second) { |
| 234 | first = pipe; |
| 235 | first_output = output; |
| 236 | second = false; |
| 237 | continue; |
| 238 | } |
| 239 | |
| 240 | found = true; |
| 241 | break; |
| 242 | } |
| 243 | |
| 244 | if (first_output) |
| 245 | igt_require_f(found, "No second valid output found\n"); |
| 246 | else |
Chris Wilson | 1105d9f | 2016-08-23 18:03:51 +0100 | [diff] [blame] | 247 | igt_require_f(found, "No valid outputs found\n"); |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 248 | |
| 249 | return pipe; |
| 250 | } |
| 251 | |
| 252 | static void flip_nonblocking(igt_display_t *display, enum pipe pipe, bool atomic, struct igt_fb *fb) |
| 253 | { |
| 254 | igt_plane_t *primary = &display->pipes[pipe].planes[IGT_PLANE_PRIMARY]; |
| 255 | |
| 256 | if (!atomic) { |
| 257 | /* Schedule a nonblocking flip for the next vblank */ |
| 258 | do_or_die(drmModePageFlip(display->drm_fd, display->pipes[pipe].crtc_id, fb->fb_id, |
| 259 | DRM_MODE_PAGE_FLIP_EVENT, fb)); |
| 260 | } else { |
| 261 | igt_plane_set_fb(primary, fb); |
| 262 | igt_display_commit_atomic(display, DRM_MODE_ATOMIC_NONBLOCK | DRM_MODE_PAGE_FLIP_EVENT, fb); |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | enum flip_test { |
| 267 | flip_test_legacy = 0, |
| 268 | flip_test_varying_size, |
| 269 | flip_test_toggle_visibility, |
| 270 | flip_test_atomic, |
| 271 | flip_test_atomic_transitions, |
| 272 | flip_test_atomic_transitions_varying_size, |
| 273 | flip_test_last = flip_test_atomic_transitions_varying_size |
| 274 | }; |
| 275 | |
| 276 | static void transition_nonblocking(igt_display_t *display, enum pipe pipe, |
| 277 | struct igt_fb *prim_fb, struct igt_fb *argb_fb, |
| 278 | bool hide_sprite) |
| 279 | { |
| 280 | igt_plane_t *primary = &display->pipes[pipe].planes[IGT_PLANE_PRIMARY]; |
| 281 | igt_plane_t *sprite = &display->pipes[pipe].planes[IGT_PLANE_2]; |
| 282 | |
| 283 | if (hide_sprite) { |
| 284 | igt_plane_set_fb(primary, prim_fb); |
| 285 | igt_plane_set_fb(sprite, NULL); |
| 286 | } else { |
| 287 | igt_plane_set_fb(primary, NULL); |
| 288 | igt_plane_set_fb(sprite, argb_fb); |
| 289 | } |
| 290 | |
| 291 | igt_display_commit_atomic(display, DRM_MODE_ATOMIC_NONBLOCK | DRM_MODE_PAGE_FLIP_EVENT, display); |
| 292 | } |
| 293 | |
| 294 | static void prepare_flip_test(igt_display_t *display, |
| 295 | enum flip_test mode, |
| 296 | enum pipe flip_pipe, |
| 297 | enum pipe cursor_pipe, |
| 298 | struct drm_mode_cursor *arg, |
| 299 | const struct igt_fb *prim_fb, |
| 300 | struct igt_fb *argb_fb, |
| 301 | struct igt_fb *cursor_fb2) |
| 302 | { |
| 303 | argb_fb->gem_handle = 0; |
| 304 | cursor_fb2->gem_handle = 0; |
| 305 | |
| 306 | if (mode == flip_test_varying_size || |
| 307 | mode == flip_test_atomic_transitions_varying_size) { |
| 308 | uint64_t width, height; |
| 309 | |
| 310 | do_or_die(drmGetCap(display->drm_fd, DRM_CAP_CURSOR_WIDTH, &width)); |
| 311 | do_or_die(drmGetCap(display->drm_fd, DRM_CAP_CURSOR_HEIGHT, &height)); |
| 312 | |
| 313 | igt_skip_on(width <= 64 && height <= 64); |
| 314 | igt_create_color_fb(display->drm_fd, width, height, |
| 315 | DRM_FORMAT_ARGB8888, 0, 1., 0., .7, cursor_fb2); |
| 316 | |
| 317 | arg[0].flags = arg[1].flags = DRM_MODE_CURSOR_BO; |
| 318 | arg[1].handle = cursor_fb2->gem_handle; |
| 319 | arg[1].width = width; |
| 320 | arg[1].height = height; |
| 321 | } |
| 322 | |
| 323 | if (mode == flip_test_legacy || |
| 324 | mode == flip_test_atomic) { |
| 325 | arg[1].x = 192; |
| 326 | arg[1].y = 192; |
| 327 | } |
| 328 | |
| 329 | if (mode == flip_test_toggle_visibility) { |
| 330 | arg[0].flags = arg[1].flags = DRM_MODE_CURSOR_BO; |
| 331 | arg[1].handle = 0; |
| 332 | arg[1].width = arg[1].height = 0; |
| 333 | } |
| 334 | |
| 335 | if (mode == flip_test_atomic_transitions || |
| 336 | mode == flip_test_atomic_transitions_varying_size) { |
| 337 | igt_require(display->pipes[flip_pipe].n_planes > 1 && |
| 338 | !display->pipes[flip_pipe].planes[IGT_PLANE_2].is_cursor); |
| 339 | |
| 340 | igt_create_color_pattern_fb(display->drm_fd, prim_fb->width, prim_fb->height, |
| 341 | DRM_FORMAT_ARGB8888, 0, .1, .1, .1, argb_fb); |
| 342 | } |
| 343 | } |
| 344 | |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 345 | static void flip(igt_display_t *display, |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 346 | int cursor_pipe, int flip_pipe, |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 347 | int timeout, enum flip_test mode) |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 348 | { |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 349 | struct drm_mode_cursor arg[2]; |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 350 | uint64_t *results; |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 351 | 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] | 352 | |
| 353 | results = mmap(NULL, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0); |
| 354 | igt_assert(results != MAP_FAILED); |
| 355 | |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 356 | flip_pipe = find_connected_pipe(display, !!flip_pipe); |
| 357 | cursor_pipe = find_connected_pipe(display, !!cursor_pipe); |
| 358 | |
| 359 | igt_info("Using pipe %s for page flip, pipe %s for cursor\n", |
| 360 | kmstest_pipe_name(flip_pipe), kmstest_pipe_name(cursor_pipe)); |
| 361 | |
| 362 | if (mode >= flip_test_atomic) |
| 363 | igt_require(display->is_atomic); |
| 364 | |
| 365 | igt_require(set_fb_on_crtc(display, flip_pipe, &fb_info)); |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 366 | if (flip_pipe != cursor_pipe) |
| 367 | igt_require(set_fb_on_crtc(display, cursor_pipe, &fb_info2)); |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 368 | |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 369 | igt_create_color_fb(display->drm_fd, fb_info.width, fb_info.height, DRM_FORMAT_ARGB8888, 0, .5, .5, .5, &cursor_fb); |
| 370 | |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 371 | igt_create_color_fb(display->drm_fd, 64, 64, DRM_FORMAT_ARGB8888, 0, 1., 1., 1., &cursor_fb); |
| 372 | set_cursor_on_pipe(display, cursor_pipe, &cursor_fb); |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 373 | populate_cursor_args(display, cursor_pipe, arg, &cursor_fb); |
| 374 | |
| 375 | 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] | 376 | |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 377 | igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY); |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 378 | |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 379 | igt_fork(child, 1) { |
| 380 | unsigned long count = 0; |
| 381 | |
| 382 | igt_until_timeout(timeout) { |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 383 | 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] | 384 | count++; |
| 385 | } |
| 386 | |
| 387 | igt_debug("cursor count=%lu\n", count); |
| 388 | results[0] = count; |
| 389 | } |
| 390 | igt_fork(child, 1) { |
| 391 | unsigned long count = 0; |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 392 | |
| 393 | igt_until_timeout(timeout) { |
| 394 | char buf[128]; |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 395 | |
| 396 | switch (mode) { |
| 397 | default: |
| 398 | flip_nonblocking(display, flip_pipe, mode >= flip_test_atomic, &fb_info); |
| 399 | break; |
| 400 | case flip_test_atomic_transitions: |
| 401 | case flip_test_atomic_transitions_varying_size: |
| 402 | transition_nonblocking(display, flip_pipe, &fb_info, &argb_fb, count & 1); |
| 403 | break; |
| 404 | } |
| 405 | |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 406 | while (read(display->drm_fd, buf, sizeof(buf)) < 0 && |
Chris Wilson | d86d6eb | 2016-06-23 21:07:36 +0100 | [diff] [blame] | 407 | (errno == EINTR || errno == EAGAIN)) |
| 408 | ; |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 409 | count++; |
| 410 | } |
| 411 | |
| 412 | igt_debug("flip count=%lu\n", count); |
| 413 | results[1] = count; |
| 414 | } |
| 415 | igt_waitchildren(); |
| 416 | |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 417 | munmap(results, 4096); |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 418 | |
| 419 | do_cleanup_display(display); |
| 420 | |
| 421 | igt_remove_fb(display->drm_fd, &fb_info); |
| 422 | if (flip_pipe != cursor_pipe) |
| 423 | igt_remove_fb(display->drm_fd, &fb_info2); |
| 424 | igt_remove_fb(display->drm_fd, &cursor_fb); |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 425 | if (argb_fb.gem_handle) |
| 426 | igt_remove_fb(display->drm_fd, &argb_fb); |
| 427 | if (cursor_fb2.gem_handle) |
| 428 | igt_remove_fb(display->drm_fd, &cursor_fb2); |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 429 | } |
| 430 | |
| 431 | static inline uint32_t pipe_select(int pipe) |
| 432 | { |
| 433 | if (pipe > 1) |
| 434 | return pipe << DRM_VBLANK_HIGH_CRTC_SHIFT; |
| 435 | else if (pipe > 0) |
| 436 | return DRM_VBLANK_SECONDARY; |
| 437 | else |
| 438 | return 0; |
| 439 | } |
| 440 | |
| 441 | static unsigned get_vblank(int fd, int pipe, unsigned flags) |
| 442 | { |
| 443 | union drm_wait_vblank vbl; |
| 444 | |
| 445 | memset(&vbl, 0, sizeof(vbl)); |
| 446 | vbl.request.type = DRM_VBLANK_RELATIVE | pipe_select(pipe) | flags; |
| 447 | if (drmIoctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl)) |
| 448 | return 0; |
| 449 | |
| 450 | return vbl.reply.sequence; |
| 451 | } |
| 452 | |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 453 | static void basic_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] | 454 | { |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 455 | struct drm_mode_cursor arg[2]; |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 456 | struct drm_event_vblank vbl; |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 457 | struct igt_fb fb_info, cursor_fb, cursor_fb2, argb_fb; |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 458 | unsigned vblank_start; |
| 459 | int target; |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 460 | enum pipe pipe = find_connected_pipe(display, false); |
| 461 | |
| 462 | if (mode >= flip_test_atomic) |
| 463 | igt_require(display->is_atomic); |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 464 | |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 465 | igt_require(set_fb_on_crtc(display, pipe, &fb_info)); |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 466 | |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 467 | 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] | 468 | set_cursor_on_pipe(display, pipe, &cursor_fb); |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 469 | populate_cursor_args(display, pipe, arg, &cursor_fb); |
| 470 | |
| 471 | 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] | 472 | |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 473 | igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY); |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 474 | |
Chris Wilson | 3a3c0fa | 2016-08-24 14:55:25 +0100 | [diff] [blame^] | 475 | if (nloops) { |
| 476 | target = 4096; |
| 477 | do { |
| 478 | vblank_start = get_vblank(display->drm_fd, pipe, DRM_VBLANK_NEXTONMISS); |
| 479 | igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start); |
| 480 | for (int n = 0; n < target; n++) |
| 481 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[0]); |
| 482 | target /= 2; |
| 483 | if (get_vblank(display->drm_fd, pipe, 0) == vblank_start) |
| 484 | break; |
| 485 | } while (target); |
| 486 | igt_require(target > 1); |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 487 | |
Chris Wilson | 3a3c0fa | 2016-08-24 14:55:25 +0100 | [diff] [blame^] | 488 | igt_debug("Using a target of %d cursor updates per half-vblank\n", target); |
| 489 | } else |
| 490 | target = 1; |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 491 | |
Maarten Lankhorst | 29516cd | 2016-07-18 11:47:06 +0200 | [diff] [blame] | 492 | vblank_start = get_vblank(display->drm_fd, pipe, DRM_VBLANK_NEXTONMISS); |
| 493 | igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start); |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 494 | for (int n = 0; n < target; n++) |
| 495 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[0]); |
Maarten Lankhorst | 29516cd | 2016-07-18 11:47:06 +0200 | [diff] [blame] | 496 | igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start); |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 497 | |
Chris Wilson | 3a3c0fa | 2016-08-24 14:55:25 +0100 | [diff] [blame^] | 498 | do { |
| 499 | /* Bind the cursor first to warm up */ |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 500 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[nloops & 1]); |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 501 | |
Chris Wilson | 3a3c0fa | 2016-08-24 14:55:25 +0100 | [diff] [blame^] | 502 | /* Start with a synchronous query to align with the vblank */ |
| 503 | vblank_start = get_vblank(display->drm_fd, pipe, DRM_VBLANK_NEXTONMISS); |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 504 | switch (mode) { |
| 505 | default: |
| 506 | flip_nonblocking(display, pipe, mode >= flip_test_atomic, &fb_info); |
| 507 | break; |
| 508 | case flip_test_atomic_transitions: |
| 509 | case flip_test_atomic_transitions_varying_size: |
| 510 | transition_nonblocking(display, pipe, &fb_info, &argb_fb, (nloops & 2) /2); |
| 511 | break; |
| 512 | } |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 513 | |
Chris Wilson | 3a3c0fa | 2016-08-24 14:55:25 +0100 | [diff] [blame^] | 514 | /* The nonblocking flip should not have delayed us */ |
Maarten Lankhorst | 29516cd | 2016-07-18 11:47:06 +0200 | [diff] [blame] | 515 | igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start); |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 516 | for (int n = 0; n < target; n++) |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 517 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[nloops & 1]); |
Chris Wilson | 3a3c0fa | 2016-08-24 14:55:25 +0100 | [diff] [blame^] | 518 | /* Nor should it have delayed the following cursor update */ |
Maarten Lankhorst | 29516cd | 2016-07-18 11:47:06 +0200 | [diff] [blame] | 519 | igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start); |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 520 | |
| 521 | igt_set_timeout(1, "Stuck page flip"); |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 522 | igt_ignore_warn(read(display->drm_fd, &vbl, sizeof(vbl))); |
Maarten Lankhorst | 29516cd | 2016-07-18 11:47:06 +0200 | [diff] [blame] | 523 | igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start + 1); |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 524 | igt_reset_timeout(); |
Chris Wilson | 3a3c0fa | 2016-08-24 14:55:25 +0100 | [diff] [blame^] | 525 | } while (nloops--); |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 526 | |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 527 | do_cleanup_display(display); |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 528 | igt_remove_fb(display->drm_fd, &fb_info); |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 529 | igt_remove_fb(display->drm_fd, &cursor_fb); |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 530 | |
| 531 | if (argb_fb.gem_handle) |
| 532 | igt_remove_fb(display->drm_fd, &argb_fb); |
| 533 | if (cursor_fb2.gem_handle) |
| 534 | igt_remove_fb(display->drm_fd, &cursor_fb2); |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 535 | } |
| 536 | |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 537 | static bool skip_on_unsupported_nonblocking_modeset(igt_display_t *display) |
| 538 | { |
| 539 | enum pipe pipe; |
| 540 | int ret; |
| 541 | |
| 542 | igt_display_commit_atomic(display, DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_ATOMIC_ALLOW_MODESET, NULL); |
| 543 | |
| 544 | ret = igt_display_try_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET | DRM_MODE_ATOMIC_NONBLOCK, NULL); |
| 545 | |
| 546 | if (ret == -EINVAL) |
| 547 | return true; |
| 548 | |
| 549 | igt_assert_eq(ret, 0); |
| 550 | |
| 551 | /* Force the next state to update all crtc's, to synchronize with the nonblocking modeset. */ |
| 552 | for_each_pipe(display, pipe) |
| 553 | display->pipes[pipe].mode_changed = true; |
| 554 | |
| 555 | return false; |
| 556 | } |
| 557 | |
| 558 | static void two_screens_flip_vs_cursor(igt_display_t *display, int nloops, bool modeset) |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 559 | { |
| 560 | struct drm_mode_cursor arg[2], arg2[2]; |
| 561 | struct drm_event_vblank vbl; |
| 562 | struct igt_fb fb_info, fb2_info, cursor_fb; |
| 563 | unsigned vblank_start; |
| 564 | enum pipe pipe = find_connected_pipe(display, false); |
| 565 | enum pipe pipe2 = find_connected_pipe(display, true); |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 566 | igt_output_t *output2; |
| 567 | bool skip_test = false; |
| 568 | |
| 569 | if (modeset) |
| 570 | igt_require(display->is_atomic); |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 571 | |
| 572 | igt_require(set_fb_on_crtc(display, pipe, &fb_info)); |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 573 | igt_require((output2 = set_fb_on_crtc(display, pipe2, &fb2_info))); |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 574 | |
| 575 | igt_create_color_fb(display->drm_fd, 64, 64, DRM_FORMAT_ARGB8888, 0, 1., 1., 1., &cursor_fb); |
| 576 | set_cursor_on_pipe(display, pipe, &cursor_fb); |
| 577 | populate_cursor_args(display, pipe, arg, &cursor_fb); |
| 578 | |
| 579 | arg[0].flags = arg[1].flags = DRM_MODE_CURSOR_BO; |
| 580 | arg[1].handle = 0; |
| 581 | arg[1].width = arg[1].height = 0; |
| 582 | |
| 583 | set_cursor_on_pipe(display, pipe2, &cursor_fb); |
| 584 | populate_cursor_args(display, pipe2, arg2, &cursor_fb); |
| 585 | |
| 586 | arg2[0].flags = arg2[1].flags = DRM_MODE_CURSOR_BO; |
| 587 | arg2[0].handle = 0; |
| 588 | arg2[0].width = arg2[0].height = 0; |
| 589 | |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 590 | if (modeset && (skip_test = skip_on_unsupported_nonblocking_modeset(display))) |
| 591 | goto cleanup; |
| 592 | |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 593 | igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY); |
| 594 | |
| 595 | vblank_start = get_vblank(display->drm_fd, pipe, DRM_VBLANK_NEXTONMISS); |
| 596 | igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start); |
| 597 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[0]); |
| 598 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg2[0]); |
| 599 | igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start); |
| 600 | |
| 601 | while (nloops--) { |
| 602 | /* Start with a synchronous query to align with the vblank */ |
| 603 | vblank_start = get_vblank(display->drm_fd, pipe, DRM_VBLANK_NEXTONMISS); |
| 604 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[nloops & 1]); |
| 605 | |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 606 | |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 607 | flip_nonblocking(display, pipe, false, &fb_info); |
| 608 | |
| 609 | igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start); |
| 610 | |
| 611 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[nloops & 1]); |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 612 | if (!modeset) { |
| 613 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg2[nloops & 1]); |
| 614 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[nloops & 1]); |
| 615 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg2[nloops & 1]); |
| 616 | } else { |
| 617 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[nloops & 1]); |
| 618 | |
| 619 | igt_output_set_pipe(output2, (nloops & 1) ? PIPE_NONE : pipe2); |
| 620 | igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET | DRM_MODE_ATOMIC_NONBLOCK, NULL); |
| 621 | |
| 622 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[nloops & 1]); |
| 623 | } |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 624 | |
| 625 | igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start); |
| 626 | |
| 627 | igt_set_timeout(1, "Stuck page flip"); |
| 628 | igt_ignore_warn(read(display->drm_fd, &vbl, sizeof(vbl))); |
| 629 | igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start + 1); |
| 630 | igt_reset_timeout(); |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 631 | |
| 632 | if (modeset) { |
| 633 | /* wait for pending modeset to complete, to prevent -EBUSY */ |
| 634 | display->pipes[pipe2].mode_changed = true; |
| 635 | igt_display_commit2(display, COMMIT_ATOMIC); |
| 636 | } |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 637 | } |
| 638 | |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 639 | cleanup: |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 640 | do_cleanup_display(display); |
| 641 | igt_remove_fb(display->drm_fd, &fb_info); |
| 642 | igt_remove_fb(display->drm_fd, &fb2_info); |
| 643 | igt_remove_fb(display->drm_fd, &cursor_fb); |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 644 | |
| 645 | if (skip_test) |
| 646 | igt_skip("Nonblocking modeset is not supported by this kernel\n"); |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 647 | } |
| 648 | |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 649 | static void basic_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] | 650 | { |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 651 | struct drm_mode_cursor arg[2]; |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 652 | struct drm_event_vblank vbl; |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 653 | struct igt_fb fb_info, cursor_fb, cursor_fb2, argb_fb; |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 654 | unsigned vblank_start, vblank_last; |
| 655 | volatile unsigned long *shared; |
Maarten Lankhorst | aaf46cb | 2016-08-10 13:13:19 +0200 | [diff] [blame] | 656 | long target; |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 657 | enum pipe pipe = find_connected_pipe(display, false); |
Maarten Lankhorst | aaf46cb | 2016-08-10 13:13:19 +0200 | [diff] [blame] | 658 | igt_output_t *output; |
| 659 | uint32_t vrefresh; |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 660 | |
| 661 | if (mode >= flip_test_atomic) |
| 662 | igt_require(display->is_atomic); |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 663 | |
| 664 | shared = mmap(NULL, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0); |
| 665 | igt_assert(shared != MAP_FAILED); |
| 666 | |
Maarten Lankhorst | aaf46cb | 2016-08-10 13:13:19 +0200 | [diff] [blame] | 667 | igt_require((output = set_fb_on_crtc(display, pipe, &fb_info))); |
| 668 | vrefresh = igt_output_get_mode(output)->vrefresh; |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 669 | |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 670 | 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] | 671 | set_cursor_on_pipe(display, pipe, &cursor_fb); |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 672 | populate_cursor_args(display, pipe, arg, &cursor_fb); |
| 673 | |
| 674 | 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] | 675 | |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 676 | igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY); |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 677 | |
| 678 | target = 4096; |
| 679 | do { |
Maarten Lankhorst | 29516cd | 2016-07-18 11:47:06 +0200 | [diff] [blame] | 680 | vblank_start = get_vblank(display->drm_fd, pipe, DRM_VBLANK_NEXTONMISS); |
| 681 | igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start); |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 682 | for (int n = 0; n < target; n++) |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 683 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[0]); |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 684 | target /= 2; |
Maarten Lankhorst | 29516cd | 2016-07-18 11:47:06 +0200 | [diff] [blame] | 685 | if (get_vblank(display->drm_fd, pipe, 0) == vblank_start) |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 686 | break; |
| 687 | } while (target); |
| 688 | igt_require(target > 1); |
| 689 | |
Maarten Lankhorst | aaf46cb | 2016-08-10 13:13:19 +0200 | [diff] [blame] | 690 | igt_debug("Using a target of %ld cursor updates per half-vblank (%u)\n", |
| 691 | target, vrefresh); |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 692 | |
| 693 | for (int i = 0; i < nloops; i++) { |
| 694 | shared[0] = 0; |
| 695 | igt_fork(child, 1) { |
| 696 | unsigned long count = 0; |
| 697 | while (!shared[0]) { |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 698 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[i & 1]); |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 699 | count++; |
| 700 | } |
| 701 | igt_debug("child: %lu cursor updates\n", count); |
| 702 | shared[0] = count; |
| 703 | } |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 704 | |
| 705 | switch (mode) { |
| 706 | default: |
| 707 | flip_nonblocking(display, pipe, mode >= flip_test_atomic, &fb_info); |
| 708 | break; |
| 709 | case flip_test_atomic_transitions: |
| 710 | case flip_test_atomic_transitions_varying_size: |
| 711 | transition_nonblocking(display, pipe, &fb_info, &argb_fb, (i & 2) >> 1); |
| 712 | break; |
| 713 | } |
| 714 | |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 715 | igt_assert_eq(read(display->drm_fd, &vbl, sizeof(vbl)), sizeof(vbl)); |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 716 | vblank_start = vblank_last = vbl.sequence; |
Maarten Lankhorst | aaf46cb | 2016-08-10 13:13:19 +0200 | [diff] [blame] | 717 | for (int n = 0; n < vrefresh; n++) { |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 718 | flip_nonblocking(display, pipe, mode >= flip_test_atomic, &fb_info); |
| 719 | |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 720 | igt_assert_eq(read(display->drm_fd, &vbl, sizeof(vbl)), sizeof(vbl)); |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 721 | if (vbl.sequence != vblank_last + 1) { |
| 722 | igt_warn("page flip %d was delayed, missed %d frames\n", |
| 723 | n, vbl.sequence - vblank_last - 1); |
| 724 | } |
| 725 | vblank_last = vbl.sequence; |
| 726 | } |
Maarten Lankhorst | aaf46cb | 2016-08-10 13:13:19 +0200 | [diff] [blame] | 727 | |
| 728 | if (mode != flip_test_atomic_transitions && |
| 729 | mode != flip_test_atomic_transitions_varying_size) |
| 730 | igt_assert_eq(vbl.sequence, vblank_start + vrefresh); |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 731 | |
| 732 | shared[0] = 1; |
| 733 | igt_waitchildren(); |
Maarten Lankhorst | aaf46cb | 2016-08-10 13:13:19 +0200 | [diff] [blame] | 734 | igt_assert_f(shared[0] > vrefresh*target, |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 735 | "completed %lu cursor updated in a period of 60 flips, " |
| 736 | "we expect to complete approximately %lu updateds, " |
| 737 | "with the threshold set at %lu\n", |
Maarten Lankhorst | aaf46cb | 2016-08-10 13:13:19 +0200 | [diff] [blame] | 738 | shared[0], 2ul*vrefresh*target, vrefresh*target); |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 739 | } |
| 740 | |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 741 | do_cleanup_display(display); |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 742 | igt_remove_fb(display->drm_fd, &fb_info); |
Maarten Lankhorst | cf84a94 | 2016-07-18 11:04:27 +0200 | [diff] [blame] | 743 | igt_remove_fb(display->drm_fd, &cursor_fb); |
Chris Wilson | 88c1f7c | 2016-06-23 22:53:23 +0100 | [diff] [blame] | 744 | munmap((void *)shared, 4096); |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 745 | if (argb_fb.gem_handle) |
| 746 | igt_remove_fb(display->drm_fd, &argb_fb); |
| 747 | if (cursor_fb2.gem_handle) |
| 748 | igt_remove_fb(display->drm_fd, &cursor_fb2); |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 749 | } |
| 750 | |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 751 | static void two_screens_cursor_vs_flip(igt_display_t *display, int nloops, bool modeset) |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 752 | { |
| 753 | struct drm_mode_cursor arg[2], arg2[2]; |
| 754 | struct drm_event_vblank vbl; |
| 755 | struct igt_fb fb_info, fb2_info, cursor_fb; |
| 756 | unsigned vblank_start, vblank_last; |
| 757 | volatile unsigned long *shared; |
| 758 | int target; |
| 759 | enum pipe pipe = find_connected_pipe(display, false); |
| 760 | enum pipe pipe2 = find_connected_pipe(display, true); |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 761 | igt_output_t *output2; |
| 762 | bool skip_test = false; |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 763 | |
| 764 | shared = mmap(NULL, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0); |
| 765 | igt_assert(shared != MAP_FAILED); |
| 766 | |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 767 | if (modeset) |
| 768 | igt_require(display->is_atomic); |
| 769 | |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 770 | igt_require(set_fb_on_crtc(display, pipe, &fb_info)); |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 771 | igt_require((output2 = set_fb_on_crtc(display, pipe2, &fb2_info))); |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 772 | |
| 773 | igt_create_color_fb(display->drm_fd, 64, 64, DRM_FORMAT_ARGB8888, 0, 1., 1., 1., &cursor_fb); |
| 774 | set_cursor_on_pipe(display, pipe, &cursor_fb); |
| 775 | populate_cursor_args(display, pipe, arg, &cursor_fb); |
| 776 | |
| 777 | arg[0].flags = arg[1].flags = DRM_MODE_CURSOR_BO; |
| 778 | arg[1].handle = 0; |
| 779 | arg[1].width = arg[1].height = 0; |
| 780 | |
| 781 | set_cursor_on_pipe(display, pipe2, &cursor_fb); |
| 782 | populate_cursor_args(display, pipe2, arg2, &cursor_fb); |
| 783 | |
| 784 | arg2[0].flags = arg2[1].flags = DRM_MODE_CURSOR_BO; |
| 785 | arg2[0].handle = 0; |
| 786 | arg2[0].width = arg2[0].height = 0; |
| 787 | |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 788 | if (modeset && (skip_test = skip_on_unsupported_nonblocking_modeset(display))) |
| 789 | goto cleanup; |
| 790 | |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 791 | igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY); |
| 792 | |
| 793 | target = 4096; |
| 794 | do { |
| 795 | vblank_start = get_vblank(display->drm_fd, pipe, DRM_VBLANK_NEXTONMISS); |
| 796 | igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start); |
| 797 | |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 798 | if (!modeset) |
| 799 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg2[0]); |
| 800 | |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 801 | for (int n = 0; n < target; n++) { |
| 802 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[0]); |
| 803 | } |
| 804 | target /= 2; |
| 805 | if (get_vblank(display->drm_fd, pipe, 0) == vblank_start) |
| 806 | break; |
| 807 | } while (target); |
| 808 | igt_require(target > 1); |
| 809 | |
| 810 | igt_debug("Using a target of %d cursor updates per half-vblank\n", |
| 811 | target); |
| 812 | |
| 813 | for (int i = 0; i < nloops; i++) { |
| 814 | shared[0] = 0; |
| 815 | igt_fork(child, 1) { |
| 816 | unsigned long count = 0; |
| 817 | |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 818 | if (!modeset) |
| 819 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg2[i & 1]); |
| 820 | else { |
| 821 | igt_output_set_pipe(output2, (i & 1) ? pipe2 : PIPE_NONE); |
| 822 | igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET | |
| 823 | DRM_MODE_ATOMIC_NONBLOCK, NULL); |
| 824 | } |
| 825 | |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 826 | while (!shared[0]) { |
| 827 | do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[i & 1]); |
| 828 | count++; |
| 829 | } |
| 830 | igt_debug("child: %lu cursor updates\n", count); |
| 831 | shared[0] = count; |
| 832 | } |
| 833 | |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 834 | flip_nonblocking(display, pipe, modeset, &fb_info); |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 835 | |
| 836 | igt_assert_eq(read(display->drm_fd, &vbl, sizeof(vbl)), sizeof(vbl)); |
| 837 | vblank_start = vblank_last = vbl.sequence; |
| 838 | for (int n = 0; n < 60; n++) { |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 839 | flip_nonblocking(display, pipe, modeset, &fb_info); |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 840 | |
| 841 | igt_assert_eq(read(display->drm_fd, &vbl, sizeof(vbl)), sizeof(vbl)); |
| 842 | if (vbl.sequence != vblank_last + 1) { |
| 843 | igt_warn("page flip %d was delayed, missed %d frames\n", |
| 844 | n, vbl.sequence - vblank_last - 1); |
| 845 | } |
| 846 | vblank_last = vbl.sequence; |
| 847 | } |
| 848 | igt_assert_eq(vbl.sequence, vblank_start + 60); |
| 849 | |
| 850 | shared[0] = 1; |
| 851 | igt_waitchildren(); |
| 852 | igt_assert_f(shared[0] > 60*target, |
| 853 | "completed %lu cursor updated in a period of 60 flips, " |
| 854 | "we expect to complete approximately %lu updateds, " |
| 855 | "with the threshold set at %lu\n", |
| 856 | shared[0], 2*60ul*target, 60ul*target); |
| 857 | } |
| 858 | |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 859 | cleanup: |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 860 | do_cleanup_display(display); |
| 861 | igt_remove_fb(display->drm_fd, &fb_info); |
| 862 | igt_remove_fb(display->drm_fd, &fb2_info); |
| 863 | igt_remove_fb(display->drm_fd, &cursor_fb); |
| 864 | munmap((void *)shared, 4096); |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 865 | |
| 866 | if (skip_test) |
| 867 | igt_skip("Nonblocking modeset is not supported by this kernel\n"); |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 868 | } |
| 869 | |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 870 | igt_main |
| 871 | { |
Chris Wilson | dab6b6b | 2016-05-24 16:14:32 +0100 | [diff] [blame] | 872 | const int ncpus = sysconf(_SC_NPROCESSORS_ONLN); |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 873 | igt_display_t display = { .drm_fd = -1 }; |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 874 | int i; |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 875 | |
| 876 | igt_skip_on_simulation(); |
| 877 | |
| 878 | igt_fixture { |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 879 | display.drm_fd = drm_open_driver_master(DRIVER_ANY); |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 880 | kmstest_set_vt_graphics_mode(); |
Chris Wilson | cce2ff0 | 2016-05-25 08:34:25 +0100 | [diff] [blame] | 881 | |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 882 | igt_display_init(&display, display.drm_fd); |
| 883 | igt_require(display.n_pipes > 0); |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 884 | } |
| 885 | |
Chris Wilson | cce2ff0 | 2016-05-25 08:34:25 +0100 | [diff] [blame] | 886 | igt_subtest_group { |
Maarten Lankhorst | 1b8d8bc | 2016-07-12 11:55:26 +0200 | [diff] [blame] | 887 | for (int n = 0; n < I915_MAX_PIPES; n++) { |
Chris Wilson | cce2ff0 | 2016-05-25 08:34:25 +0100 | [diff] [blame] | 888 | errno = 0; |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 889 | |
Chris Wilson | 04b8f0e | 2016-05-25 14:53:34 +0100 | [diff] [blame] | 890 | igt_fixture { |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 891 | igt_skip_on(n >= display.n_pipes); |
Chris Wilson | 04b8f0e | 2016-05-25 14:53:34 +0100 | [diff] [blame] | 892 | } |
Chris Wilson | cce2ff0 | 2016-05-25 08:34:25 +0100 | [diff] [blame] | 893 | |
Maarten Lankhorst | 1b8d8bc | 2016-07-12 11:55:26 +0200 | [diff] [blame] | 894 | igt_subtest_f("pipe-%s-single-bo", kmstest_pipe_name(n)) |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 895 | stress(&display, n, 1, DRM_MODE_CURSOR_BO, 20); |
Maarten Lankhorst | 1b8d8bc | 2016-07-12 11:55:26 +0200 | [diff] [blame] | 896 | igt_subtest_f("pipe-%s-single-move", kmstest_pipe_name(n)) |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 897 | stress(&display, n, 1, DRM_MODE_CURSOR_MOVE, 20); |
Chris Wilson | cce2ff0 | 2016-05-25 08:34:25 +0100 | [diff] [blame] | 898 | |
Maarten Lankhorst | 1b8d8bc | 2016-07-12 11:55:26 +0200 | [diff] [blame] | 899 | igt_subtest_f("pipe-%s-forked-bo", kmstest_pipe_name(n)) |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 900 | stress(&display, n, ncpus, DRM_MODE_CURSOR_BO, 20); |
Maarten Lankhorst | 1b8d8bc | 2016-07-12 11:55:26 +0200 | [diff] [blame] | 901 | igt_subtest_f("pipe-%s-forked-move", kmstest_pipe_name(n)) |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 902 | stress(&display, n, ncpus, DRM_MODE_CURSOR_MOVE, 20); |
Chris Wilson | f5d370c | 2016-06-04 21:25:17 +0100 | [diff] [blame] | 903 | |
Maarten Lankhorst | 1b8d8bc | 2016-07-12 11:55:26 +0200 | [diff] [blame] | 904 | igt_subtest_f("pipe-%s-torture-bo", kmstest_pipe_name(n)) |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 905 | stress(&display, n, -ncpus, DRM_MODE_CURSOR_BO, 20); |
Maarten Lankhorst | 1b8d8bc | 2016-07-12 11:55:26 +0200 | [diff] [blame] | 906 | igt_subtest_f("pipe-%s-torture-move", kmstest_pipe_name(n)) |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 907 | stress(&display, n, -ncpus, DRM_MODE_CURSOR_MOVE, 20); |
Chris Wilson | cce2ff0 | 2016-05-25 08:34:25 +0100 | [diff] [blame] | 908 | } |
| 909 | } |
| 910 | |
Maarten Lankhorst | 1b8d8bc | 2016-07-12 11:55:26 +0200 | [diff] [blame] | 911 | igt_subtest("all-pipes-single-bo") |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 912 | stress(&display, -1, 1, DRM_MODE_CURSOR_BO, 20); |
Maarten Lankhorst | 1b8d8bc | 2016-07-12 11:55:26 +0200 | [diff] [blame] | 913 | igt_subtest("all-pipes-single-move") |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 914 | stress(&display, -1, 1, DRM_MODE_CURSOR_MOVE, 20); |
Chris Wilson | cce2ff0 | 2016-05-25 08:34:25 +0100 | [diff] [blame] | 915 | |
Maarten Lankhorst | 1b8d8bc | 2016-07-12 11:55:26 +0200 | [diff] [blame] | 916 | igt_subtest("all-pipes-forked-bo") |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 917 | stress(&display, -1, ncpus, DRM_MODE_CURSOR_BO, 20); |
Maarten Lankhorst | 1b8d8bc | 2016-07-12 11:55:26 +0200 | [diff] [blame] | 918 | igt_subtest("all-pipes-forked-move") |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 919 | stress(&display, -1, ncpus, DRM_MODE_CURSOR_MOVE, 20); |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 920 | |
Maarten Lankhorst | 1b8d8bc | 2016-07-12 11:55:26 +0200 | [diff] [blame] | 921 | igt_subtest("all-pipes-torture-bo") |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 922 | stress(&display, -1, -ncpus, DRM_MODE_CURSOR_BO, 20); |
Maarten Lankhorst | 1b8d8bc | 2016-07-12 11:55:26 +0200 | [diff] [blame] | 923 | igt_subtest("all-pipes-torture-move") |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 924 | stress(&display, -1, -ncpus, DRM_MODE_CURSOR_MOVE, 20); |
Chris Wilson | f5d370c | 2016-06-04 21:25:17 +0100 | [diff] [blame] | 925 | |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 926 | igt_subtest("2x-flip-vs-cursor-legacy") |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 927 | two_screens_flip_vs_cursor(&display, 8, false); |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 928 | |
| 929 | igt_subtest("2x-cursor-vs-flip-legacy") |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 930 | two_screens_cursor_vs_flip(&display, 4, false); |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 931 | |
| 932 | igt_subtest("2x-long-flip-vs-cursor-legacy") |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 933 | two_screens_flip_vs_cursor(&display, 150, false); |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 934 | |
| 935 | igt_subtest("2x-long-cursor-vs-flip-legacy") |
Maarten Lankhorst | dba9667 | 2016-08-01 14:44:17 +0200 | [diff] [blame] | 936 | two_screens_cursor_vs_flip(&display, 150, false); |
| 937 | |
| 938 | igt_subtest("2x-nonblocking-modeset-vs-cursor-atomic") |
| 939 | two_screens_flip_vs_cursor(&display, 8, true); |
| 940 | |
| 941 | igt_subtest("2x-cursor-vs-nonblocking-modeset-atomic") |
| 942 | two_screens_cursor_vs_flip(&display, 4, true); |
| 943 | |
| 944 | igt_subtest("2x-long-nonblocking-modeset-vs-cursor-atomic") |
| 945 | two_screens_flip_vs_cursor(&display, 150, true); |
| 946 | |
| 947 | igt_subtest("2x-long-cursor-vs-nonblocking-modeset-atomic") |
| 948 | two_screens_cursor_vs_flip(&display, 150, true); |
Maarten Lankhorst | 9654d51 | 2016-07-25 10:53:54 +0200 | [diff] [blame] | 949 | |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 950 | for (i = 0; i <= flip_test_last; i++) { |
| 951 | const char *modes[flip_test_last+1] = { |
| 952 | "legacy", |
| 953 | "varying-size", |
| 954 | "toggle", |
| 955 | "atomic", |
| 956 | "atomic-transitions", |
| 957 | "atomic-transitions-varying-size" |
| 958 | }; |
| 959 | const char *prefix = "short-"; |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 960 | |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 961 | switch (i) { |
| 962 | case flip_test_legacy: |
| 963 | case flip_test_varying_size: |
| 964 | case flip_test_atomic: |
| 965 | prefix = "basic-"; |
| 966 | break; |
| 967 | default: break; |
| 968 | } |
Maarten Lankhorst | 1b8d8bc | 2016-07-12 11:55:26 +0200 | [diff] [blame] | 969 | |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 970 | igt_subtest_f("%sflip-vs-cursor-%s", prefix, modes[i]) |
Chris Wilson | 3a3c0fa | 2016-08-24 14:55:25 +0100 | [diff] [blame^] | 971 | basic_flip_vs_cursor(&display, i, 0); |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 972 | igt_subtest_f("long-flip-vs-cursor-%s", modes[i]) |
| 973 | basic_flip_vs_cursor(&display, i, 150); |
| 974 | igt_subtest_f("%scursor-vs-flip-%s", prefix, modes[i]) |
| 975 | basic_cursor_vs_flip(&display, i, 4); |
| 976 | igt_subtest_f("long-cursor-vs-flip-%s", modes[i]) |
| 977 | basic_cursor_vs_flip(&display, i, 150); |
Maarten Lankhorst | 1b8d8bc | 2016-07-12 11:55:26 +0200 | [diff] [blame] | 978 | |
Maarten Lankhorst | 69aa8a4 | 2016-07-19 13:07:32 +0200 | [diff] [blame] | 979 | igt_subtest_f("cursorA-vs-flipA-%s", modes[i]) |
| 980 | flip(&display, 0, 0, 10, i); |
| 981 | |
| 982 | igt_subtest_f("cursorA-vs-flipB-%s", modes[i]) |
| 983 | flip(&display, 0, 1, 10, i); |
| 984 | |
| 985 | igt_subtest_f("cursorB-vs-flipA-%s", modes[i]) |
| 986 | flip(&display, 1, 0, 10, i); |
| 987 | |
| 988 | igt_subtest_f("cursorB-vs-flipB-%s", modes[i]) |
| 989 | flip(&display, 1, 1, 10, i); |
Chris Wilson | 162d456 | 2016-06-22 15:41:23 +0100 | [diff] [blame] | 990 | } |
| 991 | |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 992 | igt_fixture { |
Maarten Lankhorst | 6b98587 | 2016-07-13 14:59:02 +0200 | [diff] [blame] | 993 | igt_display_fini(&display); |
Chris Wilson | 9579e54 | 2016-05-23 21:56:01 +0100 | [diff] [blame] | 994 | } |
| 995 | } |