1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431
|
/*
* Copyright © 2017 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
/**
* TEST: kms atomic interruptible
* Category: Display
* Description: Tests that interrupt various atomic ioctls.
* Driver requirement: i915, xe
* Mega feature: General Display Features
*/
#include <signal.h>
#include "igt.h"
#include "drmtest.h"
#include "sw_sync.h"
/**
* SUBTEST: %s-setmode
* Description: Tests the interrupt properties of %arg[1] modeset
*
* arg[1]:
*
* @atomic: atomic
* @legacy: legacy
*/
/**
* SUBTEST: legacy-cursor
* Description: Tests the interrupt properties for Cursor
*
* SUBTEST: legacy-dpms
* Description: Tests the interrupt properties for DPMS
*
* SUBTEST: legacy-pageflip
* Description: Tests the interrupt properties for page flip
*
* SUBTEST: universal-setplane-%s
* Description: Tests the interrupt properties for %arg[1]
*
* arg[1]:
*
* @cursor: Cursor plane
* @primary: Primary plane
*/
IGT_TEST_DESCRIPTION("Tests that interrupt various atomic ioctls.");
enum plane_test_type
{
test_legacy_modeset,
test_atomic_modeset,
test_legacy_dpms,
test_setplane,
test_setcursor,
test_pageflip
};
static int block_plane(igt_display_t *display, igt_output_t *output, enum plane_test_type test_type, igt_plane_t *plane)
{
int timeline = sw_sync_timeline_create();
igt_fork(child, 1) {
/* Ignore the signal helper, we need to block indefinitely on the fence. */
signal(SIGCONT, SIG_IGN);
if (test_type == test_legacy_modeset || test_type == test_atomic_modeset) {
igt_output_set_pipe(output, PIPE_NONE);
}
igt_plane_set_fence_fd(plane, sw_sync_timeline_create_fence(timeline, 1));
igt_display_commit2(display, COMMIT_ATOMIC);
}
return timeline;
}
static void unblock(int block)
{
sw_sync_timeline_inc(block, 1);
close(block);
}
static void ev_page_flip(int fd, unsigned seq, unsigned tv_sec, unsigned tv_usec, void *user_data)
{
igt_debug("Retrieved vblank seq: %u on unk\n", seq);
}
static drmEventContext drm_events = {
.version = 2,
.page_flip_handler = ev_page_flip
};
static void run_plane_test(igt_display_t *display, enum pipe pipe, igt_output_t *output,
enum plane_test_type test_type, unsigned plane_type)
{
drmModeModeInfo *mode;
igt_fb_t fb, fb2;
igt_plane_t *primary, *plane;
int block;
igt_info("Using (pipe %s + %s) to run the subtest.\n",
kmstest_pipe_name(pipe), igt_output_name(output));
/*
* Make sure we start with everything disabled to force a real modeset.
* igt_display_require only sets sw state, and assumes the first test
* doesn't care about hw state.
*/
igt_display_reset(display);
igt_display_commit2(display, COMMIT_ATOMIC);
igt_output_set_pipe(output, pipe);
primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
plane = igt_output_get_plane_type(output, plane_type);
mode = igt_output_get_mode(output);
igt_create_fb(display->drm_fd, mode->hdisplay, mode->vdisplay,
DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_LINEAR, &fb);
switch (plane_type) {
case DRM_PLANE_TYPE_PRIMARY:
igt_create_fb(display->drm_fd, mode->hdisplay, mode->vdisplay,
DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_LINEAR, &fb2);
break;
case DRM_PLANE_TYPE_CURSOR:
igt_create_fb(display->drm_fd, 64, 64,
DRM_FORMAT_ARGB8888, DRM_FORMAT_MOD_LINEAR, &fb2);
break;
}
if (test_type != test_legacy_modeset && test_type != test_atomic_modeset) {
igt_plane_set_fb(primary, &fb);
igt_display_commit2(display, COMMIT_ATOMIC);
}
igt_plane_set_fb(plane, &fb2);
block = block_plane(display, output, test_type, plane);
/* wait for the block to complete in block_plane */
sleep(1);
igt_fork(child, 1) {
signal(SIGCONT, SIG_IGN);
/* unblock after 5 seconds to allow the ioctl to complete,
* instead of failing with -EINTR.
*/
igt_assert(sleep(5) == 0);
unblock(block);
}
/* run the test */
igt_while_interruptible(true) {
switch (test_type) {
case test_legacy_modeset: {
struct drm_mode_crtc crtc = {
.set_connectors_ptr = (uint64_t)(uintptr_t)&output->id,
.count_connectors = 1,
.crtc_id = primary->pipe->crtc_id,
.fb_id = fb2.fb_id,
.mode_valid = 1,
.mode = *(struct drm_mode_modeinfo*)mode,
};
do_ioctl(display->drm_fd, DRM_IOCTL_MODE_SETCRTC, &crtc);
break;
}
case test_atomic_modeset: {
uint32_t objs[3] = {
plane->pipe->crtc_id,
output->id,
plane->drm_plane->plane_id
};
uint32_t count_props[3] = { 2, 1, 6 };
uint32_t props[] = {
/* crtc: 2 props */
plane->pipe->props[IGT_CRTC_MODE_ID],
plane->pipe->props[IGT_CRTC_ACTIVE],
/* connector: 1 prop */
output->props[IGT_CONNECTOR_CRTC_ID],
/* plane: remainder props */
plane->props[IGT_PLANE_CRTC_ID],
plane->props[IGT_PLANE_FB_ID],
plane->props[IGT_PLANE_SRC_W],
plane->props[IGT_PLANE_SRC_H],
plane->props[IGT_PLANE_CRTC_W],
plane->props[IGT_PLANE_CRTC_H]
};
uint64_t prop_vals[] = {
/* crtc */
0, /* mode_id, filled in below */
true,
/* connector */
plane->pipe->crtc_id,
/* plane */
plane->pipe->crtc_id,
fb2.fb_id,
IGT_FIXED(fb2.width, 0),
IGT_FIXED(fb2.height, 0),
fb2.width,
fb2.height
};
uint32_t mode_blob;
struct drm_mode_atomic atm = {
.flags = DRM_MODE_ATOMIC_ALLOW_MODESET,
.count_objs = 3, /* crtc, connector, plane */
.objs_ptr = (uint64_t)(uintptr_t)&objs,
.count_props_ptr = (uint64_t)(uintptr_t)&count_props,
.props_ptr = (uint64_t)(uintptr_t)&props,
.prop_values_ptr = (uint64_t)(uintptr_t)&prop_vals,
};
do_or_die(drmModeCreatePropertyBlob(display->drm_fd, mode, sizeof(*mode), &mode_blob));
prop_vals[0] = mode_blob;
do_ioctl(display->drm_fd, DRM_IOCTL_MODE_ATOMIC, &atm);
do_or_die(drmModeDestroyPropertyBlob(display->drm_fd, mode_blob));
break;
}
case test_legacy_dpms: {
struct drm_mode_connector_set_property prop = {
.value = DRM_MODE_DPMS_OFF,
.prop_id = output->props[IGT_CONNECTOR_DPMS],
.connector_id = output->id,
};
do_ioctl(display->drm_fd, DRM_IOCTL_MODE_SETPROPERTY, &prop);
break;
}
case test_setcursor: {
struct drm_mode_cursor cur = {
.flags = DRM_MODE_CURSOR_BO,
.crtc_id = plane->pipe->crtc_id,
.width = fb2.width,
.height = fb2.height,
.handle = fb2.gem_handle,
};
do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &cur);
break;
}
case test_setplane: {
struct drm_mode_set_plane setplane = {
.plane_id = plane->drm_plane->plane_id,
.crtc_id = plane->pipe->crtc_id,
.fb_id = fb2.fb_id,
.crtc_w = fb2.width,
.crtc_h = fb2.height,
.src_w = IGT_FIXED(fb2.width, 0),
.src_h = IGT_FIXED(fb2.height, 0),
};
do_ioctl(display->drm_fd, DRM_IOCTL_MODE_SETPLANE, &setplane);
break;
}
case test_pageflip: {
struct drm_mode_crtc_page_flip pageflip = {
.crtc_id = plane->pipe->crtc_id,
.fb_id = fb2.fb_id,
.flags = DRM_MODE_PAGE_FLIP_EVENT,
};
do_ioctl(display->drm_fd, DRM_IOCTL_MODE_PAGE_FLIP, &pageflip);
drmHandleEvent(display->drm_fd, &drm_events);
break;
}
}
}
igt_waitchildren();
/* The mode is unset by the forked helper, force a refresh here */
if (test_type == test_legacy_modeset || test_type == test_atomic_modeset)
igt_pipe_refresh(display, pipe, true);
igt_plane_set_fb(plane, NULL);
igt_plane_set_fb(primary, NULL);
igt_output_set_pipe(output, PIPE_NONE);
igt_display_commit2(display, COMMIT_ATOMIC);
igt_remove_fb(display->drm_fd, &fb);
}
static bool pipe_output_combo_valid(igt_display_t *display,
enum pipe pipe, igt_output_t *output)
{
bool ret = true;
igt_display_reset(display);
igt_output_set_pipe(output, pipe);
if (!intel_pipe_output_combo_valid(display))
ret = false;
igt_output_set_pipe(output, PIPE_NONE);
return ret;
}
igt_main
{
igt_display_t display;
igt_output_t *output;
enum pipe pipe;
igt_fixture {
display.drm_fd = drm_open_driver_master(DRIVER_ANY);
kmstest_set_vt_graphics_mode();
igt_display_require(&display, display.drm_fd);
igt_require(display.is_atomic);
igt_display_require_output(&display);
igt_require_sw_sync();
}
igt_describe("Tests the interrupt properties of legacy modeset");
igt_subtest_with_dynamic("legacy-setmode") {
for_each_pipe_with_valid_output(&display, pipe, output) {
if (!pipe_output_combo_valid(&display, pipe, output))
continue;
igt_dynamic_f("pipe-%s-%s", kmstest_pipe_name(pipe), igt_output_name(output))
run_plane_test(&display, pipe, output, test_legacy_modeset, DRM_PLANE_TYPE_PRIMARY);
break;
}
}
igt_describe("Tests the interrupt properties of atomic modeset");
igt_subtest_with_dynamic("atomic-setmode") {
for_each_pipe_with_valid_output(&display, pipe, output) {
if (!pipe_output_combo_valid(&display, pipe, output))
continue;
igt_dynamic_f("pipe-%s-%s", kmstest_pipe_name(pipe), igt_output_name(output))
run_plane_test(&display, pipe, output, test_atomic_modeset, DRM_PLANE_TYPE_PRIMARY);
break;
}
}
igt_describe("Tests the interrupt properties for DPMS");
igt_subtest_with_dynamic("legacy-dpms") {
for_each_pipe_with_valid_output(&display, pipe, output) {
if (!pipe_output_combo_valid(&display, pipe, output))
continue;
igt_dynamic_f("pipe-%s-%s", kmstest_pipe_name(pipe), igt_output_name(output))
run_plane_test(&display, pipe, output, test_legacy_dpms, DRM_PLANE_TYPE_PRIMARY);
break;
}
}
igt_describe("Tests the interrupt properties for pageflip");
igt_subtest_with_dynamic("legacy-pageflip") {
for_each_pipe_with_valid_output(&display, pipe, output) {
if (!pipe_output_combo_valid(&display, pipe, output))
continue;
igt_dynamic_f("pipe-%s-%s", kmstest_pipe_name(pipe), igt_output_name(output))
run_plane_test(&display, pipe, output, test_pageflip, DRM_PLANE_TYPE_PRIMARY);
break;
}
}
igt_describe("Tests the interrupt properties for cursor");
igt_subtest_with_dynamic("legacy-cursor") {
for_each_pipe_with_valid_output(&display, pipe, output) {
if (!pipe_output_combo_valid(&display, pipe, output))
continue;
igt_dynamic_f("pipe-%s-%s", kmstest_pipe_name(pipe), igt_output_name(output))
run_plane_test(&display, pipe, output, test_setcursor, DRM_PLANE_TYPE_CURSOR);
break;
}
}
igt_describe("Tests the interrupt properties for primary plane");
igt_subtest_with_dynamic("universal-setplane-primary") {
for_each_pipe_with_valid_output(&display, pipe, output) {
if (!pipe_output_combo_valid(&display, pipe, output))
continue;
igt_dynamic_f("pipe-%s-%s", kmstest_pipe_name(pipe), igt_output_name(output))
run_plane_test(&display, pipe, output, test_setplane, DRM_PLANE_TYPE_PRIMARY);
break;
}
}
igt_describe("Tests the interrupt properties for cursor plane");
igt_subtest_with_dynamic("universal-setplane-cursor") {
for_each_pipe_with_valid_output(&display, pipe, output) {
if (!pipe_output_combo_valid(&display, pipe, output))
continue;
igt_dynamic_f("pipe-%s-%s", kmstest_pipe_name(pipe), igt_output_name(output))
run_plane_test(&display, pipe, output, test_setplane, DRM_PLANE_TYPE_CURSOR);
break;
}
}
/* TODO: legacy gamma_set/get, object set/getprop, getcrtc, getconnector */
igt_fixture {
igt_display_fini(&display);
drm_close_driver(display.drm_fd);
}
}
|