From patchwork Wed May 3 12:25:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mika Kahola X-Patchwork-Id: 9709711 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C545760362 for ; Wed, 3 May 2017 12:26:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B58A2205AF for ; Wed, 3 May 2017 12:26:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA3D72839C; Wed, 3 May 2017 12:26:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 24D91205AF for ; Wed, 3 May 2017 12:26:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4AF9B89C94; Wed, 3 May 2017 12:26:37 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id 87B0D89C94 for ; Wed, 3 May 2017 12:26:36 +0000 (UTC) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 May 2017 05:26:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,283,1491289200"; d="scan'208";a="81949668" Received: from sorvi.fi.intel.com ([10.237.72.182]) by orsmga002.jf.intel.com with ESMTP; 03 May 2017 05:26:34 -0700 From: Mika Kahola To: intel-gfx@lists.freedesktop.org Date: Wed, 3 May 2017 15:25:58 +0300 Message-Id: <1493814358-24967-1-git-send-email-mika.kahola@intel.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v3] tests/kms_atomic_allow_modeset: Add DRM_MODE_ATOMIC_ALLOW_MODESET test 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-Virus-Scanned: ClamAV using ClamSMTP When doing a full atomic modeset, kernel should fail if the flag DRM_MODE_ATOMIC_ALLOW_MODESET is not set. Let's add this test as part of Intel-GPU-Tools. The test procedure is the following: - Try to do atomic commit without DRM_MODE_ATOMIC_ALLOW_MODESET flag. Kernel should reject this request. - Do full modeset/change active property - Enable DRM_MODE_ATOMIC_ALLOW_MODESET and try to do atmic commit. Kernel should now allow atomic modeset. For: VIZ-6955 v2: create own testcase (Maarten) v3: add test for active property change (Maarten) Signed-off-by: Mika Kahola --- tests/Makefile.sources | 1 + tests/kms_atomic_allow_modeset.c | 229 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 230 insertions(+) create mode 100644 tests/kms_atomic_allow_modeset.c diff --git a/tests/Makefile.sources b/tests/Makefile.sources index 9553e4d..220293c 100644 --- a/tests/Makefile.sources +++ b/tests/Makefile.sources @@ -101,6 +101,7 @@ TESTS_progs_M = \ kms_addfb_basic \ kms_atomic \ kms_atomic_transition \ + kms_atomic_allow_modeset \ kms_busy \ kms_ccs \ kms_chv_cursor_fail \ diff --git a/tests/kms_atomic_allow_modeset.c b/tests/kms_atomic_allow_modeset.c new file mode 100644 index 0000000..74e4cb5 --- /dev/null +++ b/tests/kms_atomic_allow_modeset.c @@ -0,0 +1,229 @@ +/* + * 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. + * + */ + +#include "igt.h" + +IGT_TEST_DESCRIPTION("Test that kernel rejects atomic modeset if ALLOW_MODESET flag is not set"); + +static uint64_t get_broadcast_rgb_mode(uint64_t mode) +{ + switch (mode) { + case BROADCAST_RGB_AUTO: + return BROADCAST_RGB_FULL; + case BROADCAST_RGB_FULL: + return BROADCAST_RGB_16_235; + case BROADCAST_RGB_16_235: + return BROADCAST_RGB_AUTO; + default: + return BROADCAST_RGB_AUTO; + } +} + +static void +test_init(igt_display_t *display, struct igt_fb *fb, igt_output_t *output) +{ + drmModeModeInfo *mode; + igt_plane_t *primary; + int id; + + mode = igt_output_get_mode(output); + + id = igt_create_pattern_fb(display->drm_fd, + mode->hdisplay, mode->vdisplay, + DRM_FORMAT_XRGB8888, + LOCAL_I915_FORMAT_MOD_X_TILED, + fb); + igt_assert(id); + + primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY); + igt_assert(primary); + + igt_plane_set_fb(primary, fb); +} + +static void +test_finish(igt_display_t *display, struct igt_fb *fb, igt_output_t *output) +{ + igt_plane_t *primary; + + primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY); + igt_assert(primary); + + igt_remove_fb(display->drm_fd, fb); + + igt_plane_set_fb(primary, NULL); + igt_output_set_pipe(output, PIPE_ANY); + + igt_display_commit2(display, COMMIT_ATOMIC); +} + +static void +test_allow_modeset(igt_display_t *display, enum pipe pipe, igt_output_t *output) +{ + struct igt_fb fb; + int flags = DRM_MODE_ATOMIC_NONBLOCK; + int ret; + + igt_output_set_pipe(output, pipe); + + test_init(display, &fb, output); + + /* + * Try to do atomic commit without DRM_MODE_ATOMIC_ALLOW_MODESET flag. + * Kernel should reject this request. + */ + ret = igt_display_try_commit_atomic(display, flags, NULL); + igt_assert_eq(ret, -EINVAL); + + /* do modeset */ + igt_output_set_pipe(output, pipe); + + /* + * Try to do atomic commit with DRM_MODE_ATOMIC_ALLOW_MODESET flag set. + * The kernel should now accept this request. + */ + flags |= DRM_MODE_ATOMIC_ALLOW_MODESET; + ret = igt_display_try_commit_atomic(display, flags, NULL); + igt_assert_eq(ret, 0); + + test_finish(display, &fb, output); +} + +static void +test_active_property(igt_display_t *display, enum pipe pipe, igt_output_t *output) +{ + struct igt_fb fb; + int flags = DRM_MODE_ATOMIC_NONBLOCK; + int ret; + bool found; + uint32_t id; + uint64_t val1, val2; + uint64_t mode; + + found = kmstest_get_property(display->drm_fd, + output->config.connector->connector_id, + DRM_MODE_OBJECT_CONNECTOR, + "Broadcast RGB", &id, &val1, NULL); + igt_assert(found); + + mode = get_broadcast_rgb_mode(val1); + + igt_output_set_pipe(output, pipe); + + test_init(display, &fb, output); + + /* + * Try to do atomic commit without DRM_MODE_ATOMIC_ALLOW_MODESET flag. + * Kernel should reject this request. + */ + ret = igt_display_try_commit_atomic(display, flags, NULL); + igt_assert_eq(ret, -EINVAL); + + /* change property */ + ret = kmstest_set_connector_broadcast_rgb(display->drm_fd, + output->config.connector, + mode); + igt_assert(ret); + + /* + * Try to do atomic commit with DRM_MODE_ATOMIC_ALLOW_MODESET flag set. + * The kernel should now accept this request. + */ + flags |= DRM_MODE_ATOMIC_ALLOW_MODESET; + ret = igt_display_try_commit_atomic(display, flags, NULL); + igt_assert_eq(ret, 0); + + found = kmstest_get_property(display->drm_fd, + output->config.connector->connector_id, + DRM_MODE_OBJECT_CONNECTOR, + "Broadcast RGB", &id, &val2, NULL); + igt_assert(found); + igt_assert(val1 != val2); + + + /* switch back to RGB auto mode */ + ret = kmstest_set_connector_broadcast_rgb(display->drm_fd, + output->config.connector, + BROADCAST_RGB_AUTO); + igt_assert(ret); + + test_finish(display, &fb, output); +} + +igt_main +{ + igt_output_t *output; + igt_display_t display; + drmModeResPtr res; + + igt_skip_on_simulation(); + + igt_fixture { + display.drm_fd = drm_open_driver_master(DRIVER_ANY); + igt_enable_connectors(); + kmstest_set_vt_graphics_mode(); + igt_display_init(&display, display.drm_fd); + igt_require(display.is_atomic); + + res = drmModeGetResources(display.drm_fd); + kmstest_unset_all_crtcs(display.drm_fd, res); + } + + igt_subtest_f("allow-modeset") { + enum pipe pipe; + int valid_tests = 0; + + for_each_pipe_with_valid_output(&display, pipe, output) { + test_allow_modeset(&display, pipe, output); + + valid_tests++; + break; + } + + igt_require_f(valid_tests, "no valid crtc/connector combinations found\n"); + } + + igt_subtest_f("active-property") { + enum pipe pipe; + int valid_tests = 0; + + for_each_pipe_with_valid_output(&display, pipe, output) { + test_active_property(&display, pipe, output); + + valid_tests++; + break; + } + + igt_require_f(valid_tests, "no valid crtc/connector combinations found\n"); + } + + igt_fixture { + igt_display_fini(&display); + igt_reset_connectors(); + drmModeFreeResources(res); + close(display.drm_fd); + } + + igt_exit(); +}