From patchwork Thu May 7 18:56:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Zanoni X-Patchwork-Id: 6360631 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B42C6BEEE5 for ; Thu, 7 May 2015 18:57:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C011720303 for ; Thu, 7 May 2015 18:57:42 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 36C3220376 for ; Thu, 7 May 2015 18:57:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BE62672143; Thu, 7 May 2015 11:57:40 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-qk0-f181.google.com (mail-qk0-f181.google.com [209.85.220.181]) by gabe.freedesktop.org (Postfix) with ESMTP id 7246A72146 for ; Thu, 7 May 2015 11:57:39 -0700 (PDT) Received: by qku63 with SMTP id 63so33961787qku.3 for ; Thu, 07 May 2015 11:57:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mDFFNkmAq7y+U6ceC/FIlmQk1Cc0dZzAxvp4MFwR9Oo=; b=TRZ9goeHCuhXMwMwh6BYsY6cssPBgmnraxXmYwS29JzQ6llxXAZGbDK1Vs2tllBSv/ +r9oMWL2FgpfcsTHjI0FkZpnGa+7usWHvfbDDJfrHS59XNbdNNLq8ppLUktcJoZo44FB pYbj0nb4iwujEvJp4EnoFYbMpt0xBvSj4fuA592rUF1uXGIkimXJEkZmZJQ4hXA5BU99 HezvQU7k5j3hcDVpuSoo8Y9ROQ9eXMx9ey2k6aKK9dTA6PkxGrReL1BUAsfpsXI9JTeV Q3L/R6iAzQpG8ELBmfiL8rQCw85kSnxoR9r0f0rS2ozagTxtYmcJrrvytwd1fsjXI8e3 KBZw== X-Received: by 10.55.21.31 with SMTP id f31mr38998qkh.95.1431025059033; Thu, 07 May 2015 11:57:39 -0700 (PDT) Received: from localhost.localdomain ([187.121.142.45]) by mx.google.com with ESMTPSA id a8sm1955331qkh.43.2015.05.07.11.57.36 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 May 2015 11:57:38 -0700 (PDT) From: Paulo Zanoni To: intel-gfx@lists.freedesktop.org Date: Thu, 7 May 2015 15:56:36 -0300 Message-Id: <1431024996-2267-9-git-send-email-przanoni@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1431024996-2267-1-git-send-email-przanoni@gmail.com> References: <1431024996-2267-1-git-send-email-przanoni@gmail.com> Cc: Daniel Vetter , Paulo Zanoni Subject: [Intel-gfx] [PATCH igt 8/8] tests/kms_fb_crc: fix the reference CRC checking 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-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, 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 From: Paulo Zanoni Now we get the reference CRCs on separate untiled FBs just to make sure FBC is not there to mess the CRC computation. We also get the reference CRCs for buffers that were drawn in the same way that we draw them during the tests, so we can finally get rid of that FIXME comment we have! With this, kms_fbc_crc now actually tests something instead of just wasting CPU cycles... Fixes regression introduced by: commit 562bbe12f6fb75811a746c742a28d32a17b26aa9 Author: Daniel Vetter Date: Fri Feb 27 22:04:18 2015 +0100 tests: Remove usage of igt_crc_equal and _non_null Cc: Daniel Vetter Signed-off-by: Paulo Zanoni --- tests/kms_fbc_crc.c | 117 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 82 insertions(+), 35 deletions(-) diff --git a/tests/kms_fbc_crc.c b/tests/kms_fbc_crc.c index b52ac29..37221ac 100644 --- a/tests/kms_fbc_crc.c +++ b/tests/kms_fbc_crc.c @@ -56,7 +56,7 @@ enum test_mode { typedef struct { int drm_fd; - igt_crc_t ref_crc[2]; + igt_crc_t ref_crc[4]; igt_pipe_crc_t *pipe_crc; drm_intel_bufmgr *bufmgr; drm_intel_context *ctx[2]; @@ -234,13 +234,32 @@ static bool wait_for_fbc_enabled(data_t *data) static void check_crc(data_t *data, enum test_mode mode) { igt_pipe_crc_t *pipe_crc = data->pipe_crc; - igt_crc_t crc; + igt_crc_t crc, *ref_crc; + + switch (mode) { + case TEST_PAGE_FLIP: + ref_crc = &data->ref_crc[1]; + break; + case TEST_MMAP_CPU: + case TEST_MMAP_GTT: + case TEST_BLT: + case TEST_RENDER: + case TEST_CONTEXT: + ref_crc = &data->ref_crc[2]; + break; + case TEST_PAGE_FLIP_AND_MMAP_CPU: + case TEST_PAGE_FLIP_AND_MMAP_GTT: + case TEST_PAGE_FLIP_AND_BLT: + case TEST_PAGE_FLIP_AND_RENDER: + case TEST_PAGE_FLIP_AND_CONTEXT: + ref_crc = &data->ref_crc[3]; + break; + default: + igt_assert(false); + } igt_pipe_crc_collect_crc(pipe_crc, &crc); - if (mode == TEST_PAGE_FLIP) - igt_assert_crc_equal(&crc, &data->ref_crc[1]); - else - ;/* FIXME: missing reference CRCs */ + igt_assert_crc_equal(&crc, ref_crc); } static void test_crc(data_t *data, enum test_mode mode) @@ -321,27 +340,71 @@ static bool prepare_crtc(data_t *data) return true; } +static void create_fbs(data_t *data, bool tiled, struct igt_fb *fbs) +{ + int rc; + drmModeModeInfo *mode = igt_output_get_mode(data->output); + uint64_t tiling = tiled ? LOCAL_I915_FORMAT_MOD_X_TILED : + LOCAL_DRM_FORMAT_MOD_NONE; + + rc = igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, + DRM_FORMAT_XRGB8888, tiling, + 0.0, 0.0, 0.0, &fbs[0]); + igt_assert(rc); + rc = igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, + DRM_FORMAT_XRGB8888, tiling, + 0.1, 0.1, 0.1, &fbs[1]); + igt_assert(rc); +} + +/* Since we want to be really safe that the CRCs are actually what we really + * want, use untiled FBs, so FBC won't happen to disrupt things. Also do the + * drawing before setting the modes, just to be sure. */ +static void get_ref_crcs(data_t *data) +{ + igt_display_t *display = &data->display; + struct igt_fb fbs[4]; + int i; + + create_fbs(data, false, &fbs[0]); + create_fbs(data, false, &fbs[2]); + + fill_mmap_gtt(data, fbs[2].gem_handle, 0xff); + fill_mmap_gtt(data, fbs[3].gem_handle, 0xff); + + for (i = 0; i < 4; i++) { + igt_plane_set_fb(data->primary, &fbs[i]); + igt_display_commit(display); + igt_wait_for_vblank(data->drm_fd, data->pipe); + igt_assert(!fbc_enabled(data)); + igt_pipe_crc_collect_crc(data->pipe_crc, &data->ref_crc[i]); + igt_assert(!fbc_enabled(data)); + } + + igt_plane_set_fb(data->primary, &data->fb[1]); + igt_display_commit(display); + + for (i = 0; i < 4; i++) + igt_remove_fb(data->drm_fd, &fbs[i]); +} + static bool prepare_test(data_t *data, enum test_mode test_mode) { igt_display_t *display = &data->display; igt_output_t *output = data->output; - drmModeModeInfo *mode; igt_pipe_crc_t *pipe_crc; - int rc; data->primary = igt_output_get_plane(data->output, IGT_PLANE_PRIMARY); - mode = igt_output_get_mode(data->output); - rc = igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, - DRM_FORMAT_XRGB8888, - LOCAL_I915_FORMAT_MOD_X_TILED, - 0.0, 0.0, 0.0, &data->fb[0]); - igt_assert(rc); - rc = igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, - DRM_FORMAT_XRGB8888, - LOCAL_I915_FORMAT_MOD_X_TILED, - 0.1, 0.1, 0.1, &data->fb[1]); - igt_assert(rc); + create_fbs(data, true, data->fb); + + igt_pipe_crc_free(data->pipe_crc); + data->pipe_crc = NULL; + pipe_crc = igt_pipe_crc_new(data->pipe, + INTEL_PIPE_CRC_SOURCE_AUTO); + data->pipe_crc = pipe_crc; + + get_ref_crcs(data); /* scanout = fb[1] */ igt_plane_set_fb(data->primary, &data->fb[1]); @@ -359,19 +422,6 @@ static bool prepare_test(data_t *data, enum test_mode test_mode) return false; } - igt_pipe_crc_free(data->pipe_crc); - data->pipe_crc = NULL; - - pipe_crc = igt_pipe_crc_new(data->pipe, - INTEL_PIPE_CRC_SOURCE_AUTO); - - data->pipe_crc = pipe_crc; - - igt_wait_for_vblank(data->drm_fd, data->pipe); - - /* get reference crc for fb[1] */ - igt_pipe_crc_collect_crc(pipe_crc, &data->ref_crc[1]); - if (test_mode == TEST_CONTEXT || test_mode == TEST_PAGE_FLIP_AND_CONTEXT) { data->ctx[0] = drm_intel_gem_context_create(data->bufmgr); igt_assert(data->ctx[0]); @@ -405,9 +455,6 @@ static bool prepare_test(data_t *data, enum test_mode test_mode) igt_wait_for_vblank(data->drm_fd, data->pipe); - /* get reference crc for fb[0] */ - igt_pipe_crc_collect_crc(pipe_crc, &data->ref_crc[0]); - return true; }