From patchwork Thu Apr 18 14:01:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 10907427 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6D639922 for ; Thu, 18 Apr 2019 14:01:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5447528A9B for ; Thu, 18 Apr 2019 14:01:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4887928AAA; Thu, 18 Apr 2019 14:01:56 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,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 DF9FE28A9B for ; Thu, 18 Apr 2019 14:01:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F0F136E14C; Thu, 18 Apr 2019 14:01:54 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by gabe.freedesktop.org (Postfix) with ESMTPS id AAC956E14B; Thu, 18 Apr 2019 14:01:53 +0000 (UTC) Received: by mail-qt1-x844.google.com with SMTP id w5so2221628qtb.11; Thu, 18 Apr 2019 07:01:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:user-agent; bh=vlVFJxSEG1fNiei14L/tMpRyAAadPRkWvlFVizrvKDs=; b=NuKzoon5+p56RBtpE+A5th464M5d2B9Gdrly7nGCra8wdTDOpnFteSH9oim6IQB4pH PFrXs2xWyijNPqipUa0WKnPKaZb3vG4SGx0TRs6ih7aReP9UyIrn84pagOGRPbxSFNQ+ qIU/lY+TuTzWyZ1gmOddx57RfbPiDDnFM/4eXZiVkbh6auz6tKUiVL1RCwFWl/eYHXbp jqsbp8M3VcT1IHsbizr/p5N+NY8+PhrRndeHXG6WtWI6DdBPqaXrToLYphVCLnnUBnRI SeIFv5tKeo5q78Z7SLlsrF0+AZlK2Hn4NlocmSmZiQjxbW8pnrBR90O+WUEMk9B33eoS IESw== X-Gm-Message-State: APjAAAWaK6BI+ZPQJKS98zOl6FQg6jMwCyMgkDpxwV/WIN5UvSMMIrnX 218weqm9ywhDWIaJXGZCx2e0jF+wzvgZeQ== X-Google-Smtp-Source: APXvYqxlB0sB6C5bDUHkT5fmTz652oyp4ZozPNUTV5caeZavF9m8aQZsT5GVB75XETJi/dOErenLCA== X-Received: by 2002:ac8:2cb0:: with SMTP id 45mr77059058qtw.92.1555596112693; Thu, 18 Apr 2019 07:01:52 -0700 (PDT) Received: from smtp.gmail.com ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id t30sm1036721qkj.56.2019.04.18.07.01.50 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 18 Apr 2019 07:01:52 -0700 (PDT) Date: Thu, 18 Apr 2019 11:01:49 -0300 From: Rodrigo Siqueira To: Petri Latvala , Arkadiusz Hiler , Daniel Vetter , Chris Wilson , Ville =?utf-8?b?U3lyasOkbMOk?= Message-ID: <20190418140149.rne4jbrpmijrtv3q@smtp.gmail.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20180716 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:user-agent; bh=vlVFJxSEG1fNiei14L/tMpRyAAadPRkWvlFVizrvKDs=; b=WCqiSRmju0Ff0W69B/Vaep4sUeS5P9YNEOjPWBVhLT3tRuJvypLs3VqkElHeAodKi3 6e6+pgiHAQT4mEnsQHNWD+t4lGmeAZTxOZ5cnr6uCmfgQpjgZIQ9QKpaRTUqByvQI1Po 1RnfBsTOPSJ1tlLQCNMttApBnUl4f6l9yQytaqPOt4iIU35/+pJ5KZr1A3YCTTP4YbiK tQv/dK7VrRX1U0d8qeZoO0M3k2kFINjIPEyJcWETWcM4l0e1mE8ti/QP5r9PT8yGrlOI O2RLSn4IaRKcK1xDUHlZ6cCoauDrXNWm01+c9/GlbCRgqoOyhqPumOHHgqLaZepaF/aH Upxg== Subject: [Intel-gfx] [RESEND PATCH v6 i-g-t] tests/kms_flip: Skip VBlank tests in modules without VBlank X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: igt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP The kms_flip test relies on VBlank support, and this situation may exclude some virtual drivers to take advantage of this set of tests. This commit adds a mechanism that checks if a module has VBlank. If the target module has VBlank support, kms_flip will run all the VBlank tests; otherwise, the VBlank tests will be skipped. Additionally, this commit improves the test coverage by checks if the function drmWaitVBlank() returns EOPNOTSUPP (i.e., no VBlank support). V5: Drop the DRM_VBLANK_NEXTONMISS (Chris Wilson) V4: Replace DRM_VBLANK_ABSOLUTE by DRM_VBLANK_RELATIVE and DRM_VBLANK_NEXTONMISS V3: Add documentation (Daniel Vetter) V2: Add new branch coverage to check if VBlank is enabled or not and update commit message V1: Chris Wilson - Change function name from igt_there_is_vblank to kms_has_vblank - Move vblank function check from igt_aux to igt_kms - Utilizes memset in dummy_vbl variable - Directly return the result of drmWaitVBlank() Signed-off-by: Rodrigo Siqueira --- Updates: 1. Rebase the code with the last updates from the master. 2. Patch tested on VC4, Bochs, VKMS, and i915. lib/igt_kms.c | 20 ++++++++++++++++++++ lib/igt_kms.h | 2 ++ tests/kms_flip.c | 22 ++++++++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index df9aafd2..0bdd1e40 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -1656,6 +1656,26 @@ void igt_assert_plane_visible(int fd, enum pipe pipe, int plane_index, bool visi igt_assert_eq(visible, visibility); } +/** + * kms_has_vblank: + * @fd: DRM fd + * + * Get the VBlank errno after an attempt to call drmWaitVBlank(). This + * function is useful for checking if a driver has support or not for VBlank. + * + * Returns: true if target driver has VBlank support, otherwise return false. + */ +bool kms_has_vblank(int fd) +{ + drmVBlank dummy_vbl; + + memset(&dummy_vbl, 0, sizeof(drmVBlank)); + dummy_vbl.request.type = DRM_VBLANK_RELATIVE; + + drmWaitVBlank(fd, &dummy_vbl); + return (errno != EOPNOTSUPP); +} + /* * A small modeset API */ diff --git a/lib/igt_kms.h b/lib/igt_kms.h index 38bdc08f..b0ff79ab 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -230,6 +230,8 @@ void kmstest_wait_for_pageflip(int fd); unsigned int kmstest_get_vblank(int fd, int pipe, unsigned int flags); void igt_assert_plane_visible(int fd, enum pipe pipe, int plane_index, bool visibility); +bool kms_has_vblank(int fd); + /* * A small modeset API */ diff --git a/tests/kms_flip.c b/tests/kms_flip.c index 6287ce14..4e0471a9 100755 --- a/tests/kms_flip.c +++ b/tests/kms_flip.c @@ -71,6 +71,7 @@ #define TEST_SUSPEND (1 << 26) #define TEST_BO_TOOBIG (1 << 28) +#define TEST_NO_VBLANK (1 << 29) #define TEST_BASIC (1 << 30) #define EVENT_FLIP (1 << 0) @@ -126,6 +127,18 @@ struct event_state { int seq_step; }; +static bool vblank_dependence(int flags) +{ + int vblank_flags = TEST_VBLANK | TEST_VBLANK_BLOCK | + TEST_VBLANK_ABSOLUTE | TEST_VBLANK_EXPIRED_SEQ | + TEST_CHECK_TS | TEST_VBLANK_RACE; + + if (flags & vblank_flags) + return true; + + return false; +} + static float timeval_float(const struct timeval *tv) { return tv->tv_sec + tv->tv_usec / 1000000.0f; @@ -1176,6 +1189,7 @@ static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs, unsigned bo_size = 0; uint64_t tiling; int i; + bool vblank = true; switch (crtc_count) { case RUN_TEST: @@ -1259,6 +1273,14 @@ static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs, } igt_assert(fb_is_bound(o, o->fb_ids[0])); + vblank = kms_has_vblank(drm_fd); + if (!vblank) { + if (vblank_dependence(o->flags)) + igt_require_f(vblank, "There is no VBlank\n"); + else + o->flags |= TEST_NO_VBLANK; + } + /* quiescent the hw a bit so ensure we don't miss a single frame */ if (o->flags & TEST_CHECK_TS) calibrate_ts(o, crtc_idxs[0]);