From patchwork Thu Mar 9 09:19:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Kahola X-Patchwork-Id: 9612775 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 A9156602B4 for ; Thu, 9 Mar 2017 09:20:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9729F2849A for ; Thu, 9 Mar 2017 09:20:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 89BE428479; Thu, 9 Mar 2017 09:20:02 +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 0E1AF28479 for ; Thu, 9 Mar 2017 09:20:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4BF446EB87; Thu, 9 Mar 2017 09:20:01 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4B5816EB87 for ; Thu, 9 Mar 2017 09:20:00 +0000 (UTC) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Mar 2017 01:19:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,268,1486454400"; d="scan'208";a="942347184" Received: from sorvi.fi.intel.com ([10.237.72.182]) by orsmga003.jf.intel.com with ESMTP; 09 Mar 2017 01:19:58 -0800 From: Mika Kahola To: intel-gfx@lists.freedesktop.org Date: Thu, 9 Mar 2017 11:19:07 +0200 Message-Id: <1489051147-16790-1-git-send-email-mika.kahola@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [Intel-gfx] [PATCH i-g-t v2] tests/kms_atomic: test that TEST_ONLY does not clobber state 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: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP We need to make sure that TEST_ONLY really only touches the free-standing state objects and nothing else. Test approach here is the following: - Create a config and submit it with TEST_ONLY. - do dpms off/on cycle with the current config to reconfigure hw - read back all legacy state to make sure none of that is clobbered v2: use ATOMIC_RELAX_NONE instead of CRTC_RELAX_MODE when checking crtc or plane state (Maarten) rename subtest and function that executes this test (Maarten) Signed-off-by: Mika Kahola Reviewed-by: Maarten Lankhorst --- tests/kms_atomic.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/tests/kms_atomic.c b/tests/kms_atomic.c index d6273f4..6375fed 100644 --- a/tests/kms_atomic.c +++ b/tests/kms_atomic.c @@ -831,6 +831,25 @@ static uint32_t plane_get_igt_format(struct kms_atomic_plane_state *plane) return ret; } +static void +set_dpms(int fd, int mode) +{ + int i; + drmModeConnector *connector; + uint32_t id; + drmModeRes *resources = drmModeGetResources(fd); + + for (i = 0; i < resources->count_connectors; i++) { + id = resources->connectors[i]; + + connector = drmModeGetConnectorCurrent(fd, id); + + kmstest_set_connector_dpms(fd, connector, mode); + + drmModeFreeConnector(connector); + } +} + static void plane_overlay(struct kms_atomic_crtc_state *crtc, struct kms_atomic_plane_state *plane_old) { @@ -930,6 +949,57 @@ static void plane_primary(struct kms_atomic_crtc_state *crtc, drmModeAtomicFree(req); } +/* test to ensure that DRM_MODE_ATOMIC_TEST_ONLY really only touches the + * free-standing state objects and nothing else. + */ +static void test_only(struct kms_atomic_crtc_state *crtc, + struct kms_atomic_plane_state *plane_old) +{ + struct drm_mode_modeinfo *mode = crtc->mode.data; + struct kms_atomic_plane_state plane = *plane_old; + uint32_t format = plane_get_igt_format(&plane); + drmModeAtomicReq *req = drmModeAtomicAlloc(); + struct igt_fb fb; + int ret; + + igt_require(format != 0); + + plane.src_x = 0; + plane.src_y = 0; + plane.src_w = mode->hdisplay << 16; + plane.src_h = mode->vdisplay << 16; + plane.crtc_x = 0; + plane.crtc_y = 0; + plane.crtc_w = mode->hdisplay; + plane.crtc_h = mode->vdisplay; + plane.crtc_id = crtc->obj; + plane.fb_id = igt_create_pattern_fb(plane.state->desc->fd, + plane.crtc_w, plane.crtc_h, + format, I915_TILING_NONE, &fb); + + drmModeAtomicSetCursor(req, 0); + crtc_populate_req(crtc, req); + plane_populate_req(&plane, req); + ret = drmModeAtomicCommit(crtc->state->desc->fd, req, + DRM_MODE_ATOMIC_TEST_ONLY, NULL); + + igt_assert_eq(ret, 0); + + /* go through dpms off/on cycle */ + set_dpms(crtc->state->desc->fd, DRM_MODE_DPMS_OFF); + set_dpms(crtc->state->desc->fd, DRM_MODE_DPMS_ON); + + /* check the state */ + crtc_check_current_state(crtc, plane_old, ATOMIC_RELAX_NONE); + plane_check_current_state(plane_old, ATOMIC_RELAX_NONE); + + /* Re-enable the plane through the legacy CRTC/primary-plane API, and + * verify through atomic. */ + crtc_commit_legacy(crtc, plane_old, CRTC_RELAX_MODE); + + drmModeAtomicFree(req); +} + static void plane_cursor(struct kms_atomic_crtc_state *crtc, struct kms_atomic_plane_state *plane_old) { @@ -1427,6 +1497,18 @@ igt_main atomic_state_free(scratch); } + igt_subtest("test_only") { + struct kms_atomic_state *scratch = atomic_state_dup(current); + struct kms_atomic_crtc_state *crtc = find_crtc(scratch, true); + struct kms_atomic_plane_state *plane = + find_plane(scratch, PLANE_TYPE_PRIMARY, crtc); + + igt_require(crtc); + igt_require(plane); + test_only(crtc, plane); + atomic_state_free(scratch); + } + igt_subtest("plane_cursor_legacy") { struct kms_atomic_state *scratch = atomic_state_dup(current); struct kms_atomic_crtc_state *crtc = find_crtc(scratch, true);