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