From patchwork Tue Jan 20 04:05:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matt Roper X-Patchwork-Id: 5663801 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 034879F8A6 for ; Tue, 20 Jan 2015 04:05:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 62159203A5 for ; Tue, 20 Jan 2015 04:05:37 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 1C92C2037D for ; Tue, 20 Jan 2015 04:05:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 979DF6E5BF; Mon, 19 Jan 2015 20:05:35 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTP id 737566E5BF for ; Mon, 19 Jan 2015 20:05:34 -0800 (PST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP; 19 Jan 2015 20:02:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,862,1389772800"; d="scan'208";a="442543196" Received: from mdroper-hswdev.fm.intel.com (HELO mdroper-hswdev) ([10.1.134.215]) by FMSMGA003.fm.intel.com with ESMTP; 19 Jan 2015 19:52:19 -0800 Received: from mattrope by mdroper-hswdev with local (Exim 4.82) (envelope-from ) id 1YDQ4M-0008Mr-0B; Mon, 19 Jan 2015 20:05:34 -0800 From: Matt Roper To: intel-gfx@lists.freedesktop.org Date: Mon, 19 Jan 2015 20:05:13 -0800 Message-Id: <1421726713-32115-4-git-send-email-matthew.d.roper@intel.com> X-Mailer: git-send-email 1.8.5.1 In-Reply-To: <1421726713-32115-1-git-send-email-matthew.d.roper@intel.com> References: <1421726713-32115-1-git-send-email-matthew.d.roper@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 3/3] tests: Introduce kms_nuclear X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP A very simple testcase to exercise nuclear pageflip. We'll definitely want to expand upon this in the future, but this is a good starting point to sanity check nuclear pageflip support. Signed-off-by: Matt Roper --- tests/Makefile.sources | 1 + tests/kms_nuclear.c | 318 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 319 insertions(+) create mode 100644 tests/kms_nuclear.c diff --git a/tests/Makefile.sources b/tests/Makefile.sources index 74deec3..9ab0ff4 100644 --- a/tests/Makefile.sources +++ b/tests/Makefile.sources @@ -70,6 +70,7 @@ TESTS_progs_M = \ kms_flip_event_leak \ kms_flip_tiling \ kms_mmio_vs_cs_flip \ + kms_nuclear \ kms_pipe_crc_basic \ kms_plane \ kms_psr_sink_crc \ diff --git a/tests/kms_nuclear.c b/tests/kms_nuclear.c new file mode 100644 index 0000000..31bfbfe --- /dev/null +++ b/tests/kms_nuclear.c @@ -0,0 +1,318 @@ +/* + * Copyright © 2015 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. + */ + +#include +#include +#include +#include + +#include "drmtest.h" +#include "igt_debugfs.h" +#include "igt_kms.h" + +typedef struct { + int drm_fd; + igt_display_t display; +} data_t; + +typedef struct { + data_t *data; + igt_pipe_crc_t *pipe_crc; + igt_crc_t crc_1, crc_2, crc_3, crc_4, crc_5, crc_6, crc_7, crc_8, + crc_9, crc_10; + struct igt_fb red_fb, blue_fb, black_fb, yellow_fb; + drmModeModeInfo *mode; +} functional_test_t; + +typedef struct { + data_t *data; + drmModeResPtr moderes; + struct igt_fb blue_fb, oversized_fb, undersized_fb; +} sanity_test_t; + +typedef struct { + data_t *data; + struct igt_fb red_fb, blue_fb; +} pageflip_test_t; + +static void +functional_test_init(functional_test_t *test, igt_output_t *output, enum pipe pipe) +{ + data_t *data = test->data; + drmModeModeInfo *mode; + + test->pipe_crc = igt_pipe_crc_new(pipe, INTEL_PIPE_CRC_SOURCE_AUTO); + + igt_output_set_pipe(output, pipe); + + mode = igt_output_get_mode(output); + igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, + DRM_FORMAT_XRGB8888, + false, /* tiled */ + 0.0, 0.0, 0.0, + &test->black_fb); + igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, + DRM_FORMAT_XRGB8888, + false, /* tiled */ + 0.0, 0.0, 1.0, + &test->blue_fb); + igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, + DRM_FORMAT_XRGB8888, + false, /* tiled */ + 1.0, 1.0, 0.0, + &test->yellow_fb); + igt_create_color_fb(data->drm_fd, 100, 100, + DRM_FORMAT_XRGB8888, + false, /* tiled */ + 1.0, 0.0, 0.0, + &test->red_fb); + + test->mode = mode; +} + +static void +functional_test_fini(functional_test_t *test, igt_output_t *output) +{ + igt_pipe_crc_free(test->pipe_crc); + + igt_remove_fb(test->data->drm_fd, &test->black_fb); + igt_remove_fb(test->data->drm_fd, &test->blue_fb); + igt_remove_fb(test->data->drm_fd, &test->red_fb); + igt_remove_fb(test->data->drm_fd, &test->yellow_fb); + + igt_output_set_pipe(output, PIPE_ANY); + igt_display_commit2(&test->data->display, COMMIT_LEGACY); +} + +/* + * Nuclear pageflip functional testing. + * - Black primary plane via traditional interfaces, red sprite, grab CRC:1. + * - Blue primary plane via traditional interfaces, red sprite, grab CRC:2. + * - Yellow primary via traditional interfaces + * - Blue primary plane, red sprite via universal planes, grab CRC:3 and compare + * with CRC:2 (should be the same) + * - Disable primary plane, grab CRC:4 (should be same as CRC:1) + * - Reenable primary, grab CRC:5 (should be same as CRC:2 and CRC:3) + * - Yellow primary, no sprite + * - Disable CRTC + * - Program red sprite (while CRTC off) + * - Program blue primary (while CRTC off) + * - Enable CRTC, grab CRC:6 (should be same as CRC:2) + */ +static void +functional_test_pipe(data_t *data, enum pipe pipe, igt_output_t *output) +{ + functional_test_t test = { .data = data }; + igt_display_t *display = &data->display; + igt_plane_t *primary, *sprite; + + igt_skip_on(pipe >= display->n_pipes); + + igt_info("Testing connector %s using pipe %s\n", igt_output_name(output), + kmstest_pipe_name(pipe)); + + functional_test_init(&test, output, pipe); + + primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY); + sprite = igt_output_get_plane(output, IGT_PLANE_2); + if (!sprite) { + functional_test_fini(&test, output); + igt_skip("No sprite plane available\n"); + } + + igt_plane_set_position(sprite, 100, 100); + + /* Step 1: Legacy API's, black primary, red sprite (CRC 1) */ + igt_plane_set_fb(primary, &test.black_fb); + igt_plane_set_fb(sprite, &test.red_fb); + igt_display_commit2(display, COMMIT_LEGACY); + igt_pipe_crc_collect_crc(test.pipe_crc, &test.crc_1); + + /* Step 2: Legacy API', blue primary, red sprite (CRC 2) */ + igt_plane_set_fb(primary, &test.blue_fb); + igt_plane_set_fb(sprite, &test.red_fb); + igt_display_commit2(display, COMMIT_LEGACY); + igt_pipe_crc_collect_crc(test.pipe_crc, &test.crc_2); + + /* Step 3: Legacy API's, yellow primary (CRC 3) */ + igt_plane_set_fb(primary, &test.yellow_fb); + igt_display_commit2(display, COMMIT_LEGACY); + igt_pipe_crc_collect_crc(test.pipe_crc, &test.crc_3); + + /* Step 4: Nuclear pageflip, blue primary, red sprite (CRC 4) */ + igt_plane_set_fb(primary, &test.blue_fb); + igt_plane_set_fb(sprite, &test.red_fb); + igt_display_commit2(display, COMMIT_NUCLEAR); + igt_pipe_crc_collect_crc(test.pipe_crc, &test.crc_4); + + /* Step 5: Nuclear pageflip, disable primary plane (CRC 5) */ + igt_plane_set_fb(primary, NULL); + igt_display_commit2(display, COMMIT_NUCLEAR); + igt_pipe_crc_collect_crc(test.pipe_crc, &test.crc_5); + + /* Step 6: Nuclear pageflip, re-enable primary with blue (CRC 6) */ + igt_plane_set_fb(primary, &test.blue_fb); + igt_display_commit2(display, COMMIT_NUCLEAR); + igt_pipe_crc_collect_crc(test.pipe_crc, &test.crc_6); + + /* Step 7: Disable CRTC */ + igt_plane_set_fb(primary, NULL); + igt_display_commit2(display, COMMIT_LEGACY); + + /* Blue bg + red sprite should be same under both types of API's */ + igt_assert(igt_crc_equal(&test.crc_2, &test.crc_4)); + + /* Disabling primary plane should be same as black primary */ + igt_assert(igt_crc_equal(&test.crc_1, &test.crc_5)); + + /* Re-enabling primary should return to blue properly */ + igt_assert(igt_crc_equal(&test.crc_2, &test.crc_6)); + + igt_plane_set_fb(primary, NULL); + igt_plane_set_fb(sprite, NULL); + + functional_test_fini(&test, output); +} + +static void +sanity_test_init(sanity_test_t *test, igt_output_t *output, enum pipe pipe) +{ + data_t *data = test->data; + drmModeModeInfo *mode; + + igt_output_set_pipe(output, pipe); + + mode = igt_output_get_mode(output); + igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, + DRM_FORMAT_XRGB8888, + false, /* tiled */ + 0.0, 0.0, 1.0, + &test->blue_fb); + igt_create_color_fb(data->drm_fd, + mode->hdisplay + 100, mode->vdisplay + 100, + DRM_FORMAT_XRGB8888, + false, /* tiled */ + 0.0, 0.0, 1.0, + &test->oversized_fb); + igt_create_color_fb(data->drm_fd, + mode->hdisplay - 100, mode->vdisplay - 100, + DRM_FORMAT_XRGB8888, + false, /* tiled */ + 0.0, 0.0, 1.0, + &test->undersized_fb); + + test->moderes = drmModeGetResources(data->drm_fd); +} + +static void +sanity_test_fini(sanity_test_t *test, igt_output_t *output) +{ + drmModeFreeResources(test->moderes); + + igt_remove_fb(test->data->drm_fd, &test->oversized_fb); + igt_remove_fb(test->data->drm_fd, &test->undersized_fb); + igt_remove_fb(test->data->drm_fd, &test->blue_fb); + + igt_output_set_pipe(output, PIPE_ANY); + igt_display_commit2(&test->data->display, COMMIT_LEGACY); +} + +static void +sanity_test_pipe(data_t *data, enum pipe pipe, igt_output_t *output) +{ + sanity_test_t test = { .data = data }; + igt_plane_t *primary; + int ret = 0; + + igt_output_set_pipe(output, pipe); + + sanity_test_init(&test, output, pipe); + + primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY); + + /* Use legacy API to set a mode with a blue FB */ + igt_plane_set_fb(primary, &test.blue_fb); + igt_display_commit2(&data->display, COMMIT_LEGACY); + + /* + * Try to use nuclear pageflip API to set primary plane that + * doesn't cover CRTC (should fail). + */ + igt_plane_set_fb(primary, &test.undersized_fb); + ret = igt_display_try_commit2(&data->display, COMMIT_NUCLEAR); + igt_assert(ret == -EINVAL); + + /* Same as above, but different plane positioning. */ + igt_plane_set_position(primary, 100, 100); + ret = igt_display_try_commit2(&data->display, COMMIT_NUCLEAR); + igt_assert(ret == -EINVAL); + + igt_plane_set_position(primary, 0, 0); + igt_plane_set_fb(primary, NULL); + sanity_test_fini(&test, output); +} + +static void +run_tests_for_pipe(data_t *data, enum pipe pipe) +{ + igt_output_t *output; + + igt_subtest_f("nuclear-pageflip-pipe-%s-functional", + kmstest_pipe_name(pipe)) + for_each_connected_output(&data->display, output) + functional_test_pipe(data, pipe, output); + + igt_subtest_f("nuclear-pageflip-pipe-%s-sanity", + kmstest_pipe_name(pipe)) + for_each_connected_output(&data->display, output) + sanity_test_pipe(data, pipe, output); +} + +static data_t data; + +igt_main +{ + int num_pipes; + + igt_skip_on_simulation(); + + igt_fixture { + data.drm_fd = drm_open_any_master(); + + kmstest_set_vt_graphics_mode(); + + igt_require_pipe_crc(); + igt_display_init(&data.display, data.drm_fd); + + igt_require(data.display.has_universal_planes); + igt_require(data.display.has_atomic_props); + } + + num_pipes = igt_display_get_n_pipes(&data.display); + for (int pipe = 0; pipe < num_pipes; pipe++) + run_tests_for_pipe(&data, pipe); + + igt_fixture { + igt_display_fini(&data.display); + } +}