From patchwork Tue Jun 23 15:07:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Zanoni X-Patchwork-Id: 6662641 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 D18E7C05AC for ; Tue, 23 Jun 2015 18:06:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C839820672 for ; Tue, 23 Jun 2015 18:06:22 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 894DC20685 for ; Tue, 23 Jun 2015 18:06:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4C6656EA2F; Tue, 23 Jun 2015 11:06:20 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-qc0-f174.google.com (mail-qc0-f174.google.com [209.85.216.174]) by gabe.freedesktop.org (Postfix) with ESMTP id E258D6EA2F for ; Tue, 23 Jun 2015 11:06:18 -0700 (PDT) Received: by qcet6 with SMTP id t6so5150465qce.3 for ; Tue, 23 Jun 2015 11:06:18 -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=urTJWCoQ1joTW+sIkaXnZ5M35DQwSrmruJcA4kN4npg=; b=ZjIFaPv8SwtNoXaMQkaexuhTqthCjEzpCov/hEdmx7SU2Q6sFJH33Nx/bizq6Y/Y03 R2uov3ToocNd2VwCD51DeOrZzGvfYLymofTX3yGIWhZsmADDN4XUisfksor9keVpuZeQ jMGqisn8UgThZt/YoXK3HL840vCOFsm6JcYcGMRtu5//a0Z76I0YOLFXaHZMmEdyOzrO snVnBjdru/BnYj5o/CJlsJHJ321ra3MlQbtw9R9eO08+P5LAnBj6x0wpsA6D5stELGwC VQEaSGjb/U3C2XvCvauwz4NmSTLhDHcCQaV9qBGcHwid+xI6vCCt6qJNMzcWMzCeAj0+ PQrw== X-Received: by 10.140.89.104 with SMTP id u95mr1784353qgd.15.1435082778396; Tue, 23 Jun 2015 11:06:18 -0700 (PDT) Received: from localhost.localdomain (r130-pw-tresbarras.ibys.com.br. [189.76.1.243]) by mx.google.com with ESMTPSA id d8sm809774qka.21.2015.06.23.11.06.16 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 23 Jun 2015 11:06:17 -0700 (PDT) From: Paulo Zanoni To: intel-gfx@lists.freedesktop.org Date: Tue, 23 Jun 2015 12:07:09 -0300 Message-Id: <1435072029-3187-1-git-send-email-przanoni@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1434616228-28358-1-git-send-email-daniel.vetter@ffwll.ch> References: <1434616228-28358-1-git-send-email-daniel.vetter@ffwll.ch> Cc: Daniel Vetter , Paulo Zanoni Subject: [Intel-gfx] [PATCH igt] tests/kms_frontbuffer_tracking: add modesetfrombusy 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: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 This test exercies the dev_priv->fb_tracking.busy_bits bug I recently found and Daniel fixed. Cc: Daniel Vetter Signed-off-by: Paulo Zanoni --- tests/kms_frontbuffer_tracking.c | 113 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) diff --git a/tests/kms_frontbuffer_tracking.c b/tests/kms_frontbuffer_tracking.c index 72455c3..70007eb 100644 --- a/tests/kms_frontbuffer_tracking.c +++ b/tests/kms_frontbuffer_tracking.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "drmtest.h" #include "igt_aux.h" @@ -259,6 +260,19 @@ struct { struct igt_fb big; } fbs; +struct { + pthread_t thread; + bool stop; + + uint32_t handle; + uint32_t size; + uint32_t stride; + int width; + int height; +} busy_thread = { + .stop = true, +}; + static drmModeModeInfoPtr get_connector_smallest_mode(drmModeConnectorPtr c) { int i; @@ -876,6 +890,41 @@ static void disable_features(void) psr_disable(); } +static void *busy_thread_func(void *data) +{ + while (!busy_thread.stop) + igt_draw_rect(drm.fd, drm.bufmgr, NULL, busy_thread.handle, + busy_thread.size, busy_thread.stride, + IGT_DRAW_BLT, 0, 0, busy_thread.width, + busy_thread.height, 0xFF); + + pthread_exit(0); +} + +static void start_busy_thread(struct igt_fb *fb) +{ + int rc; + + igt_assert(busy_thread.stop == true); + busy_thread.stop = false; + busy_thread.handle = fb->gem_handle; + busy_thread.size = fb->size; + busy_thread.stride = fb->stride; + busy_thread.width = fb->width; + busy_thread.height = fb->height; + + rc = pthread_create(&busy_thread.thread, NULL, busy_thread_func, NULL); + igt_assert(rc == 0); +} + +static void stop_busy_thread(void) +{ + if (!busy_thread.stop) { + busy_thread.stop = true; + igt_assert(pthread_join(busy_thread.thread, NULL) == 0); + } +} + static void print_crc(const char *str, struct both_crcs *crc) { int i; @@ -1199,6 +1248,8 @@ static void setup_environment(void) static void teardown_environment(void) { + stop_busy_thread(); + teardown_crcs(); teardown_psr(); teardown_fbc(); @@ -1481,6 +1532,8 @@ static void prepare_subtest(const struct test_mode *t, { check_test_requirements(t); + stop_busy_thread(); + disable_features(); set_crtc_fbs(t); @@ -1964,6 +2017,50 @@ static void fullscreen_plane_subtest(const struct test_mode *t) igt_remove_fb(drm.fd, &fullscreen_fb); } +/** + * modesetfrombusy - modeset from a busy buffer to a non-busy buffer + * + * METHOD + * Set a mode, make the frontbuffer busy using BLT writes, do a modeset to a + * non-busy buffer, then check if the features are enabled. The goal of this + * test is to exercise a bug we had on the frontbuffer tracking infrastructure + * code. + * + * EXPECTED RESULTS + * No assertions fail. + * + * FAILURES + * If you're failing this test, then you probably need "drm/i915: Clear + * fb_tracking.busy_bits also for synchronous flips" or any other patch that + * properly updates dev_priv->fb_tracking.busy_bits when we're alternating + * between buffers with different busyness. + */ +static void modesetfrombusy_subtest(const struct test_mode *t) +{ + struct draw_pattern_info *pattern = &pattern1; + struct modeset_params *params = pick_params(t); + struct igt_fb fb2; + + prepare_subtest(t, pattern); + + igt_create_fb(drm.fd, params->fb.fb->width, params->fb.fb->height, + DRM_FORMAT_XRGB8888, LOCAL_I915_FORMAT_MOD_X_TILED, &fb2); + igt_draw_fill_fb(drm.fd, &fb2, 0xFF); + + start_busy_thread(params->fb.fb); + usleep(10000); + + unset_all_crtcs(); + params->fb.fb = &fb2; + set_mode_for_params(params); + + do_assertions(0); + + stop_busy_thread(); + + igt_remove_fb(drm.fd, &fb2); +} + static int opt_handler(int option, int option_index, void *data) { switch (option) { @@ -2248,6 +2345,22 @@ int main(int argc, char *argv[]) multidraw_subtest(&t); TEST_MODE_ITER_END + TEST_MODE_ITER_BEGIN(t) + if (t.pipes != PIPE_SINGLE) + continue; + if (t.screen != SCREEN_PRIM) + continue; + if (t.plane != PLANE_PRI) + continue; + if (t.fbs != FBS_SINGLE) + continue; + if (t.method != IGT_DRAW_MMAP_CPU) + continue; + + igt_subtest_f("%s-modesetfrombusy", feature_str(t.feature)) + modesetfrombusy_subtest(&t); + TEST_MODE_ITER_END + /* * TODO: ideas for subtests: * - Add a new enum to struct test_mode that allows us to specify the