From patchwork Thu Jun 13 02:16:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 10991033 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 E5FAA14C0 for ; Thu, 13 Jun 2019 02:16:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF36128A05 for ; Thu, 13 Jun 2019 02:16:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C3B5D28B1D; Thu, 13 Jun 2019 02:16:11 +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 26B9B28A05 for ; Thu, 13 Jun 2019 02:16:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 72FA9891AC; Thu, 13 Jun 2019 02:16:10 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by gabe.freedesktop.org (Postfix) with ESMTPS id 82972891AC; Thu, 13 Jun 2019 02:16:09 +0000 (UTC) Received: by mail-qk1-x744.google.com with SMTP id t8so8059060qkt.1; Wed, 12 Jun 2019 19:16:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=sM/dlpl65O3bWbkz29VE31eshzNZKqc67yXiUq+rpqo=; b=kYxpWK0TBX9w3+ZdgH23we+35C5bj6xUw1Sdnen8Iw+U3NSg5S9U5YOStx8Jgu19aS xxVmBm2VNUGSrpeq1cdFa1r2bhPqTQwfnIz5IMFfKDTWSxozTxN+cbMv0yf5J8Wh7VW7 iODxvxE3cQsy+xyrvgMX1bgLRaLlNGp+1Zb5aJgmPNzWqUTlwLj3LIDTaiSH24r+QBlq m7ew46aagBlHWRamFgt64lA0O9r3Ak+aRlPg59Ni2J+FmbBxOHn6rAVFtJ7ZdCM3jh2p xlNPiXNUI/jAZBz8jStl1hfC82PZ9cbgn+GHj02RDDtx3H59H4WKbXaMuyRIVQeu3yFs SR+Q== X-Gm-Message-State: APjAAAWGLV2SsbUZteMYJ19uQpiLA1Bk+6T64RI2sEf0WacTfZ+tufuo harCkij2Jw4IXprdSQwmkw4= X-Google-Smtp-Source: APXvYqzKyB2VA6ePeAvfu3o5BCDOY8bogihBYh6+8Skf5/930ntBRPifl9J0G5CDyofEYYB4FJvE2A== X-Received: by 2002:a05:620a:1097:: with SMTP id g23mr17145910qkk.185.1560392168556; Wed, 12 Jun 2019 19:16:08 -0700 (PDT) Received: from smtp.gmail.com ([187.121.151.146]) by smtp.gmail.com with ESMTPSA id k5sm705337qkc.75.2019.06.12.19.16.04 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 12 Jun 2019 19:16:08 -0700 (PDT) From: Brian Starkey X-Google-Original-From: Brian Starkey Date: Wed, 12 Jun 2019 23:16:02 -0300 To: Brian Starkey , Liviu Dudau , Petri Latvala , Arkadiusz Hiler , Daniel Vetter Message-ID: <28eefeec574b63511909dace7df3b7e6f13c3ed1.1560374714.git.rodrigosiqueiramelo@gmail.com> References: MIME-Version: 1.0 In-Reply-To: User-Agent: NeoMutt/20180716 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=sM/dlpl65O3bWbkz29VE31eshzNZKqc67yXiUq+rpqo=; b=YGlULtv+wEHnhJpb+FUYQOtkckkOt+J6IFbyXFPTCcHE/4eYRbyPCybrn1rm99WZYn P1ZZh1DfMaH/JshN7b010QCsCUya8E5vTN+0Qkw/uulWKWoybnaFA4FgBnuY3lolHUGY NN9RtFRCmOVh+qAZ/YDc00yDu/P22kcx6s2+hxcsjsrbKDIjYl8XvSO9686OU/FzUjRq IjmjdRTrxBsC98oHdhmUoPdUZNpEqDfL7NOVhdGlfxuKKn90JxLN0SIEZ2sOitbhdmbR AvVtMEzjOMHyvCZYac5VMOfaab0aU3WxauVHgQZUc6K/Ir6/vCwbOS9SmGRlsll8vEOz sygA== Subject: [Intel-gfx] [PATCH V6 i-g-t 1/6] lib/igt_kms: Add writeback support 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, nd Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Add support in igt_kms for writeback connectors, with the ability to attach framebuffers. v5: Rebase and add DRM_CLIENT_CAP_WRITEBACK_CONNECTORS before drmModeGetResources() Signed-off-by: Brian Starkey [rebased and updated to the latest igt style] Signed-off-by: Liviu Dudau Reviewed-by: Liviu Dudau Reviewed-by: Simon Ser --- lib/igt_kms.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++ lib/igt_kms.h | 6 ++++++ 2 files changed, 63 insertions(+) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index da188a39..140db346 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -325,6 +325,9 @@ const char * const igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = { [IGT_CONNECTOR_BROADCAST_RGB] = "Broadcast RGB", [IGT_CONNECTOR_CONTENT_PROTECTION] = "Content Protection", [IGT_CONNECTOR_VRR_CAPABLE] = "vrr_capable", + [IGT_CONNECTOR_WRITEBACK_PIXEL_FORMATS] = "WRITEBACK_PIXEL_FORMATS", + [IGT_CONNECTOR_WRITEBACK_FB_ID] = "WRITEBACK_FB_ID", + [IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR] = "WRITEBACK_OUT_FENCE_PTR", }; /* @@ -557,6 +560,7 @@ static const struct type_name connector_type_names[] = { { DRM_MODE_CONNECTOR_VIRTUAL, "Virtual" }, { DRM_MODE_CONNECTOR_DSI, "DSI" }, { DRM_MODE_CONNECTOR_DPI, "DPI" }, + { DRM_MODE_CONNECTOR_WRITEBACK, "Writeback" }, {} }; @@ -1889,6 +1893,12 @@ static void igt_output_reset(igt_output_t *output) if (igt_output_has_prop(output, IGT_CONNECTOR_BROADCAST_RGB)) igt_output_set_prop_value(output, IGT_CONNECTOR_BROADCAST_RGB, BROADCAST_RGB_FULL); + if (igt_output_has_prop(output, IGT_CONNECTOR_WRITEBACK_FB_ID)) + igt_output_set_prop_value(output, IGT_CONNECTOR_WRITEBACK_FB_ID, 0); + if (igt_output_has_prop(output, IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR)) { + igt_output_clear_prop_changed(output, IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR); + output->writeback_out_fence_fd = -1; + } } /** @@ -1901,6 +1911,8 @@ static void igt_output_reset(igt_output_t *output) * For outputs: * - %IGT_CONNECTOR_CRTC_ID * - %IGT_CONNECTOR_BROADCAST_RGB (if applicable) + * - %IGT_CONNECTOR_WRITEBACK_FB_ID + * - %IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR * - igt_output_override_mode() to default. * * For pipes: @@ -1970,6 +1982,8 @@ void igt_display_require(igt_display_t *display, int drm_fd) display->drm_fd = drm_fd; + drmSetClientCap(drm_fd, DRM_CLIENT_CAP_WRITEBACK_CONNECTORS, 1); + resources = drmModeGetResources(display->drm_fd); if (!resources) goto out; @@ -2263,6 +2277,11 @@ static void igt_output_fini(igt_output_t *output) kmstest_free_connector_config(&output->config); free(output->name); output->name = NULL; + + if (output->writeback_out_fence_fd != -1) { + close(output->writeback_out_fence_fd); + output->writeback_out_fence_fd = -1; + } } /** @@ -3325,6 +3344,11 @@ static void igt_atomic_prepare_connector_commit(igt_output_t *output, drmModeAto output->props[i], output->values[i])); } + + if (output->writeback_out_fence_fd != -1) { + close(output->writeback_out_fence_fd); + output->writeback_out_fence_fd = -1; + } } /* @@ -3447,6 +3471,16 @@ display_commit_changed(igt_display_t *display, enum igt_commit_style s) else /* no modeset in universal commit, no change to crtc. */ output->changed &= 1 << IGT_CONNECTOR_CRTC_ID; + + if (s == COMMIT_ATOMIC) { + if (igt_output_is_prop_changed(output, IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR)) + igt_assert(output->writeback_out_fence_fd >= 0); + + output->values[IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR] = 0; + output->values[IGT_CONNECTOR_WRITEBACK_FB_ID] = 0; + igt_output_clear_prop_changed(output, IGT_CONNECTOR_WRITEBACK_FB_ID); + igt_output_clear_prop_changed(output, IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR); + } } if (display->first_commit) { @@ -4119,6 +4153,29 @@ void igt_pipe_request_out_fence(igt_pipe_t *pipe) igt_pipe_obj_set_prop_value(pipe, IGT_CRTC_OUT_FENCE_PTR, (ptrdiff_t)&pipe->out_fence_fd); } +/** + * igt_output_set_writeback_fb: + * @output: Target output + * @fb: Target framebuffer + * + * This function sets the given @fb to be used as the target framebuffer for the + * writeback engine at the next atomic commit. It will also request a writeback + * out fence that will contain the fd number of the out fence created by KMS if + * the given @fb is valid. + */ +void igt_output_set_writeback_fb(igt_output_t *output, struct igt_fb *fb) +{ + igt_display_t *display = output->display; + + LOG(display, "%s: output_set_writeback_fb(%d)\n", output->name, fb ? fb->fb_id : 0); + + igt_output_set_prop_value(output, IGT_CONNECTOR_WRITEBACK_FB_ID, fb ? fb->fb_id : 0); + /* only request a writeback out fence if the framebuffer is valid */ + if (fb) + igt_output_set_prop_value(output, IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR, + (ptrdiff_t)&output->writeback_out_fence_fd); +} + /** * igt_wait_for_vblank_count: * @drm_fd: A drm file descriptor diff --git a/lib/igt_kms.h b/lib/igt_kms.h index a448a003..cacc6b90 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -123,6 +123,9 @@ enum igt_atomic_connector_properties { IGT_CONNECTOR_BROADCAST_RGB, IGT_CONNECTOR_CONTENT_PROTECTION, IGT_CONNECTOR_VRR_CAPABLE, + IGT_CONNECTOR_WRITEBACK_PIXEL_FORMATS, + IGT_CONNECTOR_WRITEBACK_FB_ID, + IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR, IGT_NUM_CONNECTOR_PROPS }; @@ -364,6 +367,8 @@ typedef struct { bool use_override_mode; drmModeModeInfo override_mode; + int32_t writeback_out_fence_fd; + /* bitmask of changed properties */ uint64_t changed; @@ -414,6 +419,7 @@ igt_plane_t *igt_output_get_plane_type_index(igt_output_t *output, igt_output_t *igt_output_from_connector(igt_display_t *display, drmModeConnector *connector); const drmModeModeInfo *igt_std_1024_mode_get(void); +void igt_output_set_writeback_fb(igt_output_t *output, struct igt_fb *fb); igt_plane_t *igt_pipe_get_plane_type(igt_pipe_t *pipe, int plane_type); int igt_pipe_count_plane_type(igt_pipe_t *pipe, int plane_type); From patchwork Thu Jun 13 02:16:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 10991035 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 2091214C0 for ; Thu, 13 Jun 2019 02:16:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 07945287FD for ; Thu, 13 Jun 2019 02:16:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EFE3228957; Thu, 13 Jun 2019 02:16:46 +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 42A3128A05 for ; Thu, 13 Jun 2019 02:16:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B91A089272; Thu, 13 Jun 2019 02:16:45 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by gabe.freedesktop.org (Postfix) with ESMTPS id 13D6C891C7; Thu, 13 Jun 2019 02:16:44 +0000 (UTC) Received: by mail-ed1-x543.google.com with SMTP id k8so14127306eds.7; Wed, 12 Jun 2019 19:16:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=mcXXuANyx3jnZr4FekSkrPEn6XOrEpHFvt3VfwGmwrk=; b=uV7KpmsjBvPmWfuIFVgq6rKrfHdckG3w4VJEaGxlHPS/D2m8cWIwAOOKd9kpG4CGHg tBZtCq60y1PttAC5Wp7/+mTeEAUUPluCciUSskmCS05nCLiH+dnVXFOKVW7ARxfep3jM cui2LtDz2/aoRl6t8RuVni7UX3Uq0k0/tjAquTbSmw+4k+O0fQsLFGQyGqm0BhkryIq8 nr1u7EN8cqvxVOMuaDTAv5HUFyXNT8SKwLya8TWsSOFEBTpWxWZ1xnHsJ34JWLszr8n1 kKMhCkKo57Cify+7nZPg921+jcxxciA0Ts2jcVEf+5i1CIwryUGxEaMncnF2IRaHhTnd rUQg== X-Gm-Message-State: APjAAAV8Dr00Lk7HGRLIh2WImYWSWKaPk+XibpYwcPS1PdFkcHKLXYra fa7lo2XLiwVuO94D0U8I1Xc= X-Google-Smtp-Source: APXvYqwFMg6/aDo4H/DNHdgjXRcVV6Zk3RIPYMRdS4G1LvhS3UHaNOQqUUq+TSdAQVmUJP8rYkOVGA== X-Received: by 2002:a50:cbc4:: with SMTP id l4mr58515454edi.264.1560392202225; Wed, 12 Jun 2019 19:16:42 -0700 (PDT) Received: from smtp.gmail.com ([187.121.151.146]) by smtp.gmail.com with ESMTPSA id s57sm458392edd.54.2019.06.12.19.16.38 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 12 Jun 2019 19:16:41 -0700 (PDT) From: Brian Starkey X-Google-Original-From: Brian Starkey Date: Wed, 12 Jun 2019 23:16:35 -0300 To: Brian Starkey , Liviu Dudau , Petri Latvala , Arkadiusz Hiler , Daniel Vetter Message-ID: <296f249138cb4f55466294b07a7aba25801ff146.1560374714.git.rodrigosiqueiramelo@gmail.com> References: MIME-Version: 1.0 In-Reply-To: User-Agent: NeoMutt/20180716 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=mcXXuANyx3jnZr4FekSkrPEn6XOrEpHFvt3VfwGmwrk=; b=SntovYtCv84xk+o4lyCyHrpUNT1xM+gep/hEo89hBsUjBsXFOK78e3b3XVjH3jCKeZ +myDF6gBM9wtmLahh0wiHHWwFaS5/ZTrk9dBQ7+TgRix8vV2BfBeIFxi0fGx01CoE9pN lLPkCFCWbdxKcI4XoQmbAFU195ahtRDgzx6J2zqB6Se5NBAh7IdGT6WznfGX6OMpZ1We MjrcP5rThPAtGHbOBlDyYqPcYUTIYA8J6ZhX0pUQgKkyzEwpHJRHlWIe6HLQUJoy23Hh 7x/OpVEdz6CSTAp55qgtL7OGPfQolgBYsFdTvmUqi5gI5BxiFbKqpQHU9OZmjWP3e9g0 108g== Subject: [Intel-gfx] [PATCH V6 i-g-t 2/6] kms_writeback: Add initial writeback tests 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, nd Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Add tests for the WRITEBACK_PIXEL_FORMATS, WRITEBACK_OUT_FENCE_PTR and WRITEBACK_FB_ID properties on writeback connectors, ensuring their behaviour is correct. Signed-off-by: Brian Starkey [rebased and updated do_writeback_test() function to address feedback] Signed-off-by: Liviu Dudau --- tests/Makefile.sources | 1 + tests/kms_writeback.c | 314 +++++++++++++++++++++++++++++++++++++++++ tests/meson.build | 1 + 3 files changed, 316 insertions(+) create mode 100644 tests/kms_writeback.c diff --git a/tests/Makefile.sources b/tests/Makefile.sources index 027ed82f..03cc8efa 100644 --- a/tests/Makefile.sources +++ b/tests/Makefile.sources @@ -77,6 +77,7 @@ TESTS_progs = \ kms_universal_plane \ kms_vblank \ kms_vrr \ + kms_writeback \ meta_test \ perf \ perf_pmu \ diff --git a/tests/kms_writeback.c b/tests/kms_writeback.c new file mode 100644 index 00000000..66ef48a6 --- /dev/null +++ b/tests/kms_writeback.c @@ -0,0 +1,314 @@ +/* + * (C) COPYRIGHT 2017 ARM Limited. All rights reserved. + * + * 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 +#include +#include +#include + +#include "igt.h" +#include "igt_core.h" +#include "igt_fb.h" + +static drmModePropertyBlobRes *get_writeback_formats_blob(igt_output_t *output) +{ + drmModePropertyBlobRes *blob = NULL; + uint64_t blob_id; + int ret; + + ret = kmstest_get_property(output->display->drm_fd, + output->config.connector->connector_id, + DRM_MODE_OBJECT_CONNECTOR, + igt_connector_prop_names[IGT_CONNECTOR_WRITEBACK_PIXEL_FORMATS], + NULL, &blob_id, NULL); + if (ret) + blob = drmModeGetPropertyBlob(output->display->drm_fd, blob_id); + + igt_assert(blob); + + return blob; +} + +static bool check_writeback_config(igt_display_t *display, igt_output_t *output) +{ + igt_fb_t input_fb, output_fb; + igt_plane_t *plane; + uint32_t writeback_format = DRM_FORMAT_XRGB8888; + uint64_t tiling = igt_fb_mod_to_tiling(0); + int width, height, ret; + drmModeModeInfo override_mode = { + .clock = 25175, + .hdisplay = 640, + .hsync_start = 656, + .hsync_end = 752, + .htotal = 800, + .hskew = 0, + .vdisplay = 480, + .vsync_start = 490, + .vsync_end = 492, + .vtotal = 525, + .vscan = 0, + .vrefresh = 60, + .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC, + .name = {"640x480-60"}, + }; + igt_output_override_mode(output, &override_mode); + + width = override_mode.hdisplay; + height = override_mode.vdisplay; + + ret = igt_create_fb(display->drm_fd, width, height, DRM_FORMAT_XRGB8888, tiling, &input_fb); + igt_assert(ret >= 0); + + ret = igt_create_fb(display->drm_fd, width, height, writeback_format, tiling, &output_fb); + igt_assert(ret >= 0); + + plane = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY); + igt_plane_set_fb(plane, &input_fb); + igt_output_set_writeback_fb(output, &output_fb); + + ret = igt_display_try_commit_atomic(display, DRM_MODE_ATOMIC_TEST_ONLY | + DRM_MODE_ATOMIC_ALLOW_MODESET, NULL); + igt_plane_set_fb(plane, NULL); + igt_remove_fb(display->drm_fd, &input_fb); + igt_remove_fb(display->drm_fd, &output_fb); + + return !ret; +} + +static igt_output_t *kms_writeback_get_output(igt_display_t *display) +{ + int i; + + for (i = 0; i < display->n_outputs; i++) { + igt_output_t *output = &display->outputs[i]; + int j; + + if (output->config.connector->connector_type != DRM_MODE_CONNECTOR_WRITEBACK) + continue; + + kmstest_force_connector(display->drm_fd, output->config.connector, FORCE_CONNECTOR_ON); + + for (j = 0; j < igt_display_get_n_pipes(display); j++) { + igt_output_set_pipe(output, j); + + if (check_writeback_config(display, output)) { + igt_debug("Using connector %u:%s on pipe %d\n", + output->config.connector->connector_id, + output->name, j); + return output; + } + } + + /* Restore any connectors we don't use, so we don't trip on them later */ + kmstest_force_connector(display->drm_fd, output->config.connector, FORCE_CONNECTOR_UNSPECIFIED); + } + + return NULL; +} + +static void check_writeback_fb_id(igt_output_t *output) +{ + uint64_t check_fb_id; + + check_fb_id = igt_output_get_prop(output, IGT_CONNECTOR_WRITEBACK_FB_ID); + igt_assert(check_fb_id == 0); +} + +static int do_writeback_test(igt_output_t *output, uint32_t flags, + uint32_t fb_id, int32_t *out_fence_ptr, + bool ptr_valid) +{ + int ret; + igt_display_t *display = output->display; + struct kmstest_connector_config *config = &output->config; + + igt_output_set_prop_value(output, IGT_CONNECTOR_CRTC_ID, config->crtc->crtc_id); + igt_output_set_prop_value(output, IGT_CONNECTOR_WRITEBACK_FB_ID, fb_id); + igt_output_set_prop_value(output, IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR, (uint64_t)out_fence_ptr); + + if (ptr_valid) + *out_fence_ptr = 0; + + ret = igt_display_try_commit_atomic(display, flags, NULL); + + if (ptr_valid) + igt_assert(*out_fence_ptr == -1); + + /* WRITEBACK_FB_ID must always read as zero */ + check_writeback_fb_id(output); + + return ret; +} + +static void invalid_out_fence(igt_output_t *output, igt_fb_t *valid_fb, igt_fb_t *invalid_fb) +{ + int i, ret; + int32_t out_fence; + struct { + uint32_t fb_id; + bool ptr_valid; + int32_t *out_fence_ptr; + } invalid_tests[] = { + { + /* No output buffer, but the WRITEBACK_OUT_FENCE_PTR set. */ + .fb_id = 0, + .ptr_valid = true, + .out_fence_ptr = &out_fence, + }, + { + /* Invalid output buffer. */ + .fb_id = invalid_fb->fb_id, + .ptr_valid = true, + .out_fence_ptr = &out_fence, + }, + { + /* Invalid WRITEBACK_OUT_FENCE_PTR. */ + .fb_id = valid_fb->fb_id, + .ptr_valid = false, + .out_fence_ptr = (int32_t *)0x8, + }, + }; + + for (i = 0; i < ARRAY_SIZE(invalid_tests); i++) { + ret = do_writeback_test(output, DRM_MODE_ATOMIC_ALLOW_MODESET, + invalid_tests[i].fb_id, + invalid_tests[i].out_fence_ptr, + invalid_tests[i].ptr_valid); + igt_assert(ret != 0); + } +} + +static void writeback_fb_id(igt_output_t *output, igt_fb_t *valid_fb, igt_fb_t *invalid_fb) +{ + + int ret; + + /* Valid output buffer */ + ret = do_writeback_test(output, DRM_MODE_ATOMIC_ALLOW_MODESET, + valid_fb->fb_id, NULL, false); + igt_assert(ret == 0); + + /* Invalid object for WRITEBACK_FB_ID */ + ret = do_writeback_test(output, DRM_MODE_ATOMIC_ALLOW_MODESET, + output->id, NULL, false); + igt_assert(ret == -EINVAL); + + /* Zero WRITEBACK_FB_ID */ + ret = do_writeback_test(output, DRM_MODE_ATOMIC_ALLOW_MODESET, + 0, NULL, false); + igt_assert(ret == 0); +} + +igt_main +{ + igt_display_t display; + igt_output_t *output; + igt_plane_t *plane; + igt_fb_t input_fb; + drmModeModeInfo mode; + int ret; + + memset(&display, 0, sizeof(display)); + + igt_fixture { + display.drm_fd = drm_open_driver_master(DRIVER_ANY); + igt_display_require(&display, display.drm_fd); + + kmstest_set_vt_graphics_mode(); + + igt_display_require(&display, display.drm_fd); + + igt_require(display.is_atomic); + + output = kms_writeback_get_output(&display); + igt_require(output); + + if (output->use_override_mode) + memcpy(&mode, &output->override_mode, sizeof(mode)); + else + memcpy(&mode, &output->config.default_mode, sizeof(mode)); + + plane = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY); + igt_require(plane); + + ret = igt_create_fb(display.drm_fd, mode.hdisplay, + mode.vdisplay, + DRM_FORMAT_XRGB8888, + igt_fb_mod_to_tiling(0), + &input_fb); + igt_assert(ret >= 0); + igt_plane_set_fb(plane, &input_fb); + } + + igt_subtest("writeback-pixel-formats") { + drmModePropertyBlobRes *formats_blob = get_writeback_formats_blob(output); + const char *valid_chars = "0123456 ABCGNRUVXY"; + unsigned int i; + char *c; + + /* + * We don't have a comprehensive list of formats, so just check + * that the blob length is sensible and that it doesn't contain + * any outlandish characters + */ + igt_assert(!(formats_blob->length % 4)); + c = formats_blob->data; + for (i = 0; i < formats_blob->length; i++) + igt_assert_f(strchr(valid_chars, c[i]), + "Unexpected character %c\n", c[i]); + } + + igt_subtest("writeback-invalid-out-fence") { + igt_fb_t invalid_fb; + ret = igt_create_fb(display.drm_fd, mode.hdisplay / 2, + mode.vdisplay / 2, + DRM_FORMAT_XRGB8888, + igt_fb_mod_to_tiling(0), + &invalid_fb); + igt_require(ret > 0); + + invalid_out_fence(output, &input_fb, &invalid_fb); + + igt_remove_fb(display.drm_fd, &invalid_fb); + } + + igt_subtest("writeback-fb-id") { + igt_fb_t output_fb; + ret = igt_create_fb(display.drm_fd, mode.hdisplay, mode.vdisplay, + DRM_FORMAT_XRGB8888, + igt_fb_mod_to_tiling(0), + &output_fb); + igt_require(ret > 0); + + writeback_fb_id(output, &input_fb, &output_fb); + + igt_remove_fb(display.drm_fd, &output_fb); + } + + igt_fixture { + igt_remove_fb(display.drm_fd, &input_fb); + igt_display_fini(&display); + } +} diff --git a/tests/meson.build b/tests/meson.build index f168fbba..9c77cfcd 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -63,6 +63,7 @@ test_progs = [ 'kms_universal_plane', 'kms_vblank', 'kms_vrr', + 'kms_writeback', 'meta_test', 'panfrost_get_param', 'panfrost_gem_new', From patchwork Thu Jun 13 02:17:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 10991037 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 B5B2913AF for ; Thu, 13 Jun 2019 02:17:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9FB4928B4F for ; Thu, 13 Jun 2019 02:17:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D453289F9; Thu, 13 Jun 2019 02:17:17 +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 05A4B28A05 for ; Thu, 13 Jun 2019 02:17:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8C997891AC; Thu, 13 Jun 2019 02:17:16 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by gabe.freedesktop.org (Postfix) with ESMTPS id B5102891AC; Thu, 13 Jun 2019 02:17:15 +0000 (UTC) Received: by mail-ed1-x542.google.com with SMTP id z25so28772797edq.9; Wed, 12 Jun 2019 19:17:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=aG+gBxGCt9SGfYnzwvvDJZ5Ed0nsdccKzUuvWUlfui8=; b=gzikZUJ69YA8NdA68YcTEAYBh8R4/fvuZImbblijf+KQRXYOtS5eAwlEac+yoagRj+ U/GtxMQNVCdembwVzH8F63S1Mi9M6eHhyGC13dvDKf272n/xe00vpAARN+mq4Z2QSb3q /y0w/5Y8OA/zXENRRouUGKsK1n8fS0aDdYmoqEHgR6Zl48sJFF48pzOUH8ajCPPLX/KH FfpAjeY+jc0GAHC4iMBIt39ihnmIrpaF+JxpeOnHZQAjEeFD2QDHqINS6rsE/I1SyC3w 8VweSDX+sspLJTIHF0BbbfH1G4ckFj3Xoor/S4rZVho78KiFQudUlQOYCv8ZvIB3/sLF 0rXg== X-Gm-Message-State: APjAAAUVR6z03wJGfCtkEASjsbqzGXTscX1X04jJP4NBA6QSjraGPYxL my4t2Q+dKsSO0mT4I6uYVByLP4dRsP0= X-Google-Smtp-Source: APXvYqwNrzC00jGQ7TwvUOcZn1kHLWr5LYJNp5oGLwP4n8khMSDZLEAfXMjXfjA4uVA4sCJsWc9f7Q== X-Received: by 2002:a50:86b7:: with SMTP id r52mr63781924eda.100.1560392234377; Wed, 12 Jun 2019 19:17:14 -0700 (PDT) Received: from smtp.gmail.com ([187.121.151.146]) by smtp.gmail.com with ESMTPSA id q19sm278377eja.59.2019.06.12.19.17.10 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 12 Jun 2019 19:17:13 -0700 (PDT) From: Brian Starkey X-Google-Original-From: Brian Starkey Date: Wed, 12 Jun 2019 23:17:08 -0300 To: Brian Starkey , Liviu Dudau , Petri Latvala , Arkadiusz Hiler , Daniel Vetter Message-ID: <539f9b55a8269d3eb20d7d211f701d1a301d5b9d.1560374714.git.rodrigosiqueiramelo@gmail.com> References: MIME-Version: 1.0 In-Reply-To: User-Agent: NeoMutt/20180716 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=aG+gBxGCt9SGfYnzwvvDJZ5Ed0nsdccKzUuvWUlfui8=; b=ELGfkAMBiuGwqFkgfKJMkcuQsTLzbn0+u6KdDVswiOg1JlGaC6HxPEmLTFx+hA22ky tFaFt/pqiw07Bz+BrupDEddM2njcttHue33VGdLnTj31dsBFDnxoTv6ZUiYk6MzOdPwQ fO8mv08jlbIXCkkPTU8Zq3vnUHdnnq1oX/v0uZUm1tVyZFmb7H4CQ/Atay2DNYYEnNJi OJvCUj46xb3JpnGkbvMv+xadwuuLuZK4X5KDH8fPq0qjC4k1A7og69pjQvPsyl6aqHb6 5Yb+7Icc1Ju1kP3E6GwrBgoLjm2E2bcmzq6HoVz04QQ8NK35mLFELs6A/ERF2w4eNaEA Oehw== Subject: [Intel-gfx] [PATCH V6 i-g-t 3/6] lib: Add function to hash a framebuffer 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, nd Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP To use writeback buffers as a CRC source, we need to be able to hash them. Implement a simple FVA-1a hashing routine for this purpose. Doing a bytewise hash on the framebuffer directly can be very slow if the memory is noncached. By making a copy of each line in the FB first (which can take advantage of word-access speedup), we can do the hash on a cached copy, which is much faster (10x speedup on my platform). v6: use igt_memcpy_from_wc() instead of plain memcpy, as suggested by Chris Wilson Signed-off-by: Brian Starkey [rebased and updated to the most recent API] Signed-off-by: Liviu Dudau Reviewed-by: Simon Ser --- lib/igt_fb.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/igt_fb.h | 3 +++ 2 files changed, 69 insertions(+) diff --git a/lib/igt_fb.c b/lib/igt_fb.c index 9d4f905e..d07dae39 100644 --- a/lib/igt_fb.c +++ b/lib/igt_fb.c @@ -3256,6 +3256,72 @@ bool igt_fb_supported_format(uint32_t drm_format) return false; } +/* + * This implements the FNV-1a hashing algorithm instead of CRC, for + * simplicity + * http://www.isthe.com/chongo/tech/comp/fnv/index.html + * + * hash = offset_basis + * for each octet_of_data to be hashed + * hash = hash xor octet_of_data + * hash = hash * FNV_prime + * return hash + * + * 32 bit offset_basis = 2166136261 + * 32 bit FNV_prime = 224 + 28 + 0x93 = 16777619 + */ +int igt_fb_get_crc(struct igt_fb *fb, igt_crc_t *crc) +{ +#define FNV1a_OFFSET_BIAS 2166136261 +#define FNV1a_PRIME 16777619 + uint32_t hash; + void *map; + char *ptr, *line = NULL; + int x, y, cpp = igt_drm_format_to_bpp(fb->drm_format) / 8; + uint32_t stride = calc_plane_stride(fb, 0); + + if (fb->is_dumb) + map = kmstest_dumb_map_buffer(fb->fd, fb->gem_handle, fb->size, + PROT_READ); + else + map = gem_mmap__gtt(fb->fd, fb->gem_handle, fb->size, + PROT_READ); + ptr = map; + + /* + * Framebuffers are often uncached, which can make byte-wise accesses + * very slow. We copy each line of the FB into a local buffer to speed + * up the hashing. + */ + line = malloc(stride); + if (!line) { + munmap(map, fb->size); + return -ENOMEM; + } + + hash = FNV1a_OFFSET_BIAS; + + for (y = 0; y < fb->height; y++, ptr += stride) { + + igt_memcpy_from_wc(line, ptr, stride); + + for (x = 0; x < fb->width * cpp; x++) { + hash ^= line[x]; + hash *= FNV1a_PRIME; + } + } + + crc->n_words = 1; + crc->crc[0] = hash; + + free(line); + munmap(map, fb->size); + + return 0; +#undef FNV1a_OFFSET_BIAS +#undef FNV1a_PRIME +} + /** * igt_format_is_yuv: * @drm_format: drm fourcc diff --git a/lib/igt_fb.h b/lib/igt_fb.h index adefebe1..a2741c05 100644 --- a/lib/igt_fb.h +++ b/lib/igt_fb.h @@ -37,6 +37,7 @@ #include #include "igt_color_encoding.h" +#include "igt_debugfs.h" /* * Internal format to denote a buffer compatible with pixman's @@ -194,5 +195,7 @@ int igt_format_plane_bpp(uint32_t drm_format, int plane); void igt_format_array_fill(uint32_t **formats_array, unsigned int *count, bool allow_yuv); +int igt_fb_get_crc(struct igt_fb *fb, igt_crc_t *crc); + #endif /* __IGT_FB_H__ */ From patchwork Thu Jun 13 02:17:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 10991039 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 7BDED13AF for ; Thu, 13 Jun 2019 02:18:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 619FD2837D for ; Thu, 13 Jun 2019 02:18:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5183528B2A; Thu, 13 Jun 2019 02:18:00 +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 DA29728A05 for ; Thu, 13 Jun 2019 02:17:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 33622891C7; Thu, 13 Jun 2019 02:17:59 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by gabe.freedesktop.org (Postfix) with ESMTPS id C202A891AC; Thu, 13 Jun 2019 02:17:57 +0000 (UTC) Received: by mail-ed1-x544.google.com with SMTP id g13so28764794edu.5; Wed, 12 Jun 2019 19:17:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Gug75hIH0ZhFtBga5UuBgX8YCo0+zu4rEPYsZ6NirMw=; b=OKznpAg39BjUPWhmWFJVNeFXZxz+Kp9Rlf678Ftzw77Iy14HnqpH0zml6qg+7Sb4Pi riZ42njE+V8wDH8shXctg5S1W5dseqK0GMm4nueDnjmlQvenDhnASSa8urUnIqnr+5Fi 1y4+S5i98gQft4FWuG5qoFtWUYpN0kn4+TIM5Kq/aI1ZGCG2rWKfWKMkTl7wGoRyZY8Z o9TYWGGWFbaQsOaOXsypORQgATaJv7Shpv6K0YVtSOiTg1/joTdPF52Ttp0ZAIHbS1xZ WLmQOB69vU7yp1pO5vdJmbxhTg1UbKtidlOXpfdbhpk77ZEXDrhMihyREJmlVOoF75pu MbEQ== X-Gm-Message-State: APjAAAWt5IuR6xvYOXknLMSi8ZoDLr0DHwtFTDaLyKhRjA9dXm+IdXZw UbPOhg+WPuDBuHQGjxdjO5wTg4jZB+Q= X-Google-Smtp-Source: APXvYqxJktR4JBLopWJKzFZPSxAIzh3dY7F1eE76Jx98Bc00DjepR2KJlMKk2i2KFB+dONBLpfvpaA== X-Received: by 2002:a17:906:37c2:: with SMTP id o2mr45282460ejc.209.1560392276398; Wed, 12 Jun 2019 19:17:56 -0700 (PDT) Received: from smtp.gmail.com ([187.121.151.146]) by smtp.gmail.com with ESMTPSA id n14sm278774ejb.14.2019.06.12.19.17.52 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 12 Jun 2019 19:17:55 -0700 (PDT) From: Brian Starkey X-Google-Original-From: Brian Starkey Date: Wed, 12 Jun 2019 23:17:50 -0300 To: Brian Starkey , Liviu Dudau , Petri Latvala , Arkadiusz Hiler , Daniel Vetter Message-ID: References: MIME-Version: 1.0 In-Reply-To: User-Agent: NeoMutt/20180716 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Gug75hIH0ZhFtBga5UuBgX8YCo0+zu4rEPYsZ6NirMw=; b=Aj2gzLYreFpo7BA851WQ/C5dCQTvbLwEIzLOGUEWgMETWzlKKjiu2wWKsJ9xaLFcih NjYYwXhZ0eSBJLkpCqpSVnOs5bykWZZmtkMoi2JkB9RkgsLtSzYrjNveM5LWy4fq9L3W XfUGX7RHu9K3635xarAe7UADjULpn8yWJMFGppf4bYUyoHSn2CB2iS8FYt9Y9PVLoIbk fR/9IFml4o5q3VA2u/TWFaZTO9Ztch/IdNAtKOHckoZK4EiuYnsMvYSVC6idVI2/X1RU IG+9Cu0WCYJ3KdH5Hpk0JBByxsygUztNM0H3aRcqY8cUi3d2Chm+/E/hCSrmKwc3KBVq cjMg== Subject: [Intel-gfx] [PATCH V6 i-g-t 4/6] kms_writeback: Add writeback-check-output 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, nd Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Add a test which makes commits using the writeback connector, and checks the output buffer hash to make sure it is/isn't written as appropriate. Signed-off-by: Brian Starkey --- tests/kms_writeback.c | 124 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) diff --git a/tests/kms_writeback.c b/tests/kms_writeback.c index 66ef48a6..0f20dadd 100644 --- a/tests/kms_writeback.c +++ b/tests/kms_writeback.c @@ -30,6 +30,7 @@ #include "igt.h" #include "igt_core.h" #include "igt_fb.h" +#include "sw_sync.h" static drmModePropertyBlobRes *get_writeback_formats_blob(igt_output_t *output) { @@ -221,6 +222,116 @@ static void writeback_fb_id(igt_output_t *output, igt_fb_t *valid_fb, igt_fb_t * igt_assert(ret == 0); } +static void fill_fb(igt_fb_t *fb, double color[3]) +{ + cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb); + igt_assert(cr); + + igt_paint_color(cr, 0, 0, fb->width, fb->height, + color[0], color[1], color[2]); +} + +static void get_and_wait_out_fence(igt_output_t *output) +{ + int ret; + + igt_assert(output->writeback_out_fence_fd >= 0); + + ret = sync_fence_wait(output->writeback_out_fence_fd, 1000); + igt_assert(ret == 0); + close(output->writeback_out_fence_fd); + output->writeback_out_fence_fd = -1; +} + +static void writeback_sequence(igt_output_t *output, igt_plane_t *plane, + igt_fb_t *in_fb, igt_fb_t *out_fbs[], int n_commits) +{ + int i, color_idx = 0; + double in_fb_colors[2][3] = { + { 1.0, 0.0, 0.0 }, + { 0.0, 1.0, 0.0 }, + }; + double clear_color[3] = { 1.0, 1.0, 1.0 }; + igt_crc_t cleared_crc, out_expected; + + for (i = 0; i < n_commits; i++, color_idx++) { + /* Change the input color each time */ + fill_fb(in_fb, in_fb_colors[color_idx % 2]); + + if (out_fbs[i]) { + igt_crc_t out_before; + + /* Get the expected CRC */ + fill_fb(out_fbs[i], in_fb_colors[color_idx % 2]); + igt_fb_get_crc(out_fbs[i], &out_expected); + + fill_fb(out_fbs[i], clear_color); + if (i == 0) + igt_fb_get_crc(out_fbs[i], &cleared_crc); + igt_fb_get_crc(out_fbs[i], &out_before); + igt_assert_crc_equal(&cleared_crc, &out_before); + } + + /* Commit */ + igt_plane_set_fb(plane, in_fb); + igt_output_set_writeback_fb(output, out_fbs[i]); + + igt_display_commit_atomic(output->display, + DRM_MODE_ATOMIC_ALLOW_MODESET, + NULL); + if (out_fbs[i]) + get_and_wait_out_fence(output); + + /* Make sure the old output buffer is untouched */ + if (i > 0 && out_fbs[i - 1] && (out_fbs[i] != out_fbs[i - 1])) { + igt_crc_t out_prev; + igt_fb_get_crc(out_fbs[i - 1], &out_prev); + igt_assert_crc_equal(&cleared_crc, &out_prev); + } + + /* Make sure this output buffer is written */ + if (out_fbs[i]) { + igt_crc_t out_after; + igt_fb_get_crc(out_fbs[i], &out_after); + igt_assert_crc_equal(&out_expected, &out_after); + + /* And clear it, for the next time */ + fill_fb(out_fbs[i], clear_color); + } + } +} + +static void writeback_check_output(igt_output_t *output, igt_plane_t *plane, + igt_fb_t *input_fb, igt_fb_t *output_fb) +{ + igt_fb_t *out_fbs[2] = { 0 }; + igt_fb_t second_out_fb; + int ret; + + /* One commit, with a writeback. */ + writeback_sequence(output, plane, input_fb, &output_fb, 1); + + /* Two commits, the second with no writeback */ + out_fbs[0] = output_fb; + writeback_sequence(output, plane, input_fb, out_fbs, 2); + + /* Two commits, both with writeback */ + out_fbs[1] = output_fb; + writeback_sequence(output, plane, input_fb, out_fbs, 2); + + ret = igt_create_fb(output_fb->fd, output_fb->width, output_fb->height, + DRM_FORMAT_XRGB8888, + igt_fb_mod_to_tiling(0), + &second_out_fb); + igt_require(ret > 0); + + /* Two commits, with different writeback buffers */ + out_fbs[1] = &second_out_fb; + writeback_sequence(output, plane, input_fb, out_fbs, 2); + + igt_remove_fb(output_fb->fd, &second_out_fb); +} + igt_main { igt_display_t display; @@ -307,6 +418,19 @@ igt_main igt_remove_fb(display.drm_fd, &output_fb); } + igt_subtest("writeback-check-output") { + igt_fb_t output_fb; + ret = igt_create_fb(display.drm_fd, mode.hdisplay, mode.vdisplay, + DRM_FORMAT_XRGB8888, + igt_fb_mod_to_tiling(0), + &output_fb); + igt_require(ret > 0); + + writeback_check_output(output, plane, &input_fb, &output_fb); + + igt_remove_fb(display.drm_fd, &output_fb); + } + igt_fixture { igt_remove_fb(display.drm_fd, &input_fb); igt_display_fini(&display); From patchwork Thu Jun 13 02:18:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 10991041 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 6E9D313AF for ; Thu, 13 Jun 2019 02:18:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58695287FD for ; Thu, 13 Jun 2019 02:18:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4CE0B289F9; Thu, 13 Jun 2019 02:18:45 +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 D38E0287FD for ; Thu, 13 Jun 2019 02:18:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6EE838926E; Thu, 13 Jun 2019 02:18:43 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) by gabe.freedesktop.org (Postfix) with ESMTPS id D080D891C7; Thu, 13 Jun 2019 02:18:41 +0000 (UTC) Received: by mail-ed1-x541.google.com with SMTP id k21so25426739edq.3; Wed, 12 Jun 2019 19:18:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=/jj9TEcyZrSKuYTZPQQ59Ky24PAfbxRvOUX+EZhuCrg=; b=T6Tm5vk8EBFbHDtTjkKXPn0k8qsa54Od1ZR9ne3f7or+qcDyhH6/1wHCKWg/igk3eO XzCj0e0mcjR1GyXV1y6DOAQALerYNvrIDie6jV5qHPVIElb9uJmWmVIQZQINHvLH+Vyv mMaaECnYkytHZqfIvW95+OAO1u3nUfIJ1lUnXVVOZKmzpq9kL8Ch2DjcMKjULEj7X/Jo 1w48vW6Op5rctWozi1afci9VtVfi/b8vezY6lyu7nkPDKIc/kBNK+qzfRMK1gZOP5hpD dZSiPe8j4wM9VzGprCy07OUTb5eIvDE8SmrD755Z7guELqn8IteLL9qDQvgVMFdFxWmj VDDw== X-Gm-Message-State: APjAAAVPfxreKH7Ork0QfVAVzScKcFkkLQPF9QzSAanxtM7dEuthe0f6 1/pDv8lf6phym8/gMBBHd+g= X-Google-Smtp-Source: APXvYqykwkC9A0Z9DhgNyW5qiSfysoYtUOXOMnKqsATYHDSXQlWtBPyHZdOsTSS4q3gwVNa1OQf1VQ== X-Received: by 2002:a17:906:a950:: with SMTP id hh16mr73997307ejb.136.1560392320448; Wed, 12 Jun 2019 19:18:40 -0700 (PDT) Received: from smtp.gmail.com ([187.121.151.146]) by smtp.gmail.com with ESMTPSA id f36sm193549ede.47.2019.06.12.19.18.36 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 12 Jun 2019 19:18:39 -0700 (PDT) From: Brian Starkey X-Google-Original-From: Brian Starkey Date: Wed, 12 Jun 2019 23:18:34 -0300 To: Brian Starkey , Liviu Dudau , Petri Latvala , Arkadiusz Hiler , Daniel Vetter Message-ID: <9f4a3f1d1c9df084ec2bf8e9b7475bbeda5f0985.1560374714.git.rodrigosiqueiramelo@gmail.com> References: MIME-Version: 1.0 In-Reply-To: User-Agent: NeoMutt/20180716 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=/jj9TEcyZrSKuYTZPQQ59Ky24PAfbxRvOUX+EZhuCrg=; b=FyzQaPTDGxlo5SOM4FvIbgPrUgr8AJy+LNYhKdAuNkW/5ZnXbQfZbRmWDziBboUfRV vtMJkChIgkQXUX5ejuIlqFiPRHKpFNa9p+2HZqvUWLwjZRf1kK0WyLhGeYczuKIobA2n yLDBmTTRwnTD3InCGaURMea6v6iqIsiNP8NOUuzXqW8EZRKzsUOjCSY6i+1H47tIlKX4 Ti3opJUjZv5CrW3X2HqXFVWCpqzkv48Dtk9rmko+NyU5ZDtlZ3EhMXe15s9zZAIzQjxA /Zv4OLeN0v6KL0CqdtXiuOFb3DO4pTuTyyd92bGsDzQdv+KHerNCCyWsPWxWKIRUGJDK cBjw== Subject: [Intel-gfx] [PATCH V6 i-g-t 5/6] lib/igt_kms: Add igt_output_clone_pipe for cloning 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, nd Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP An output can be added as a clone of any other output(s) attached to a pipe using igt_output_clone_pipe() v5: Drop field out_fence_requested from struct igt_pipe (Brian Starkey) Signed-off-by: Brian Starkey --- lib/igt_kms.c | 100 +++++++++++++++++++++++++++++++------------------- lib/igt_kms.h | 4 ++ 2 files changed, 66 insertions(+), 38 deletions(-) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index 140db346..b85a0404 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -1765,6 +1765,17 @@ static void igt_display_log_shift(igt_display_t *display, int shift) igt_assert(display->log_shift >= 0); } +static int igt_output_idx(igt_output_t *output) +{ + int i; + + for (i = 0; i < output->display->n_outputs; i++) + if (&output->display->outputs[i] == output) + return i; + + return -1; +} + static void igt_output_refresh(igt_output_t *output) { igt_display_t *display = output->display; @@ -2317,42 +2328,6 @@ void igt_display_fini(igt_display_t *display) display->planes = NULL; } -static void igt_display_refresh(igt_display_t *display) -{ - igt_output_t *output; - int i; - - unsigned long pipes_in_use = 0; - - /* Check that two outputs aren't trying to use the same pipe */ - for (i = 0; i < display->n_outputs; i++) { - output = &display->outputs[i]; - - if (output->pending_pipe != PIPE_NONE) { - if (pipes_in_use & (1 << output->pending_pipe)) - goto report_dup; - - pipes_in_use |= 1 << output->pending_pipe; - } - - if (output->force_reprobe) - igt_output_refresh(output); - } - - return; - -report_dup: - for (; i > 0; i--) { - igt_output_t *b = &display->outputs[i - 1]; - - igt_assert_f(output->pending_pipe != - b->pending_pipe, - "%s and %s are both trying to use pipe %s\n", - igt_output_name(output), igt_output_name(b), - kmstest_pipe_name(output->pending_pipe)); - } -} - static igt_pipe_t *igt_output_get_driving_pipe(igt_output_t *output) { igt_display_t *display = output->display; @@ -2376,6 +2351,40 @@ static igt_pipe_t *igt_output_get_driving_pipe(igt_output_t *output) return &display->pipes[pipe]; } +static void igt_display_refresh(igt_display_t *display) +{ + igt_output_t *output; + igt_pipe_t *pipe; + int i; + + unsigned long pipes_in_use = 0; + unsigned long pending_crtc_idx_mask; + + /* Check that outputs and pipes agree wrt. cloning */ + for (i = 0; i < display->n_outputs; i++) { + output = &display->outputs[i]; + pending_crtc_idx_mask = 1 << output->pending_pipe; + + pipe = igt_output_get_driving_pipe(output); + if (pipe) { + igt_assert_f(pipe->outputs & (1 << igt_output_idx(output)), + "Output %s not expected to be using pipe %s\n", + igt_output_name(output), + kmstest_pipe_name(pipe->pipe)); + + if (pipes_in_use & pending_crtc_idx_mask) + LOG(display, "Output %s clones pipe %s\n", + igt_output_name(output), + kmstest_pipe_name(pipe->pipe)); + } + + pipes_in_use |= pending_crtc_idx_mask; + + if (output->force_reprobe) + igt_output_refresh(output); + } +} + static igt_plane_t *igt_pipe_get_plane(igt_pipe_t *pipe, int plane_idx) { igt_require_f(plane_idx >= 0 && plane_idx < pipe->n_planes, @@ -3766,6 +3775,7 @@ void igt_output_override_mode(igt_output_t *output, const drmModeModeInfo *mode) output->use_override_mode = !!mode; if (pipe) { + igt_debug("overriding pipe mode in %s way\n", output->display->is_atomic ? "atomic" : "legacy"); if (output->display->is_atomic) igt_pipe_obj_replace_prop_blob(pipe, IGT_CRTC_MODE_ID, igt_output_get_mode(output), sizeof(*mode)); else @@ -3773,6 +3783,16 @@ void igt_output_override_mode(igt_output_t *output, const drmModeModeInfo *mode) } } +void igt_output_clone_pipe(igt_output_t *output, enum pipe pipe) +{ + igt_display_t *display = output->display; + uint32_t current_clones = display->pipes[pipe].outputs; + + igt_output_set_pipe(output, pipe); + + display->pipes[pipe].outputs |= current_clones; +} + /* * igt_output_set_pipe: * @output: Target output for which the pipe is being set to @@ -3789,11 +3809,15 @@ void igt_output_set_pipe(igt_output_t *output, enum pipe pipe) igt_assert(output->name); - if (output->pending_pipe != PIPE_NONE) + if (output->pending_pipe != PIPE_NONE) { old_pipe = igt_output_get_driving_pipe(output); + old_pipe->outputs &= ~(1 << igt_output_idx(output)); + } - if (pipe != PIPE_NONE) + if (pipe != PIPE_NONE) { pipe_obj = &display->pipes[pipe]; + pipe_obj->outputs = (1 << igt_output_idx(output)); + } LOG(display, "%s: set_pipe(%s)\n", igt_output_name(output), kmstest_pipe_name(pipe)); diff --git a/lib/igt_kms.h b/lib/igt_kms.h index cacc6b90..676839bb 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -354,6 +354,8 @@ struct igt_pipe { uint32_t crtc_id; int32_t out_fence_fd; + + uint32_t outputs; }; typedef struct { @@ -411,6 +413,8 @@ const char *igt_output_name(igt_output_t *output); drmModeModeInfo *igt_output_get_mode(igt_output_t *output); void igt_output_override_mode(igt_output_t *output, const drmModeModeInfo *mode); void igt_output_set_pipe(igt_output_t *output, enum pipe pipe); +void igt_output_clone_pipe(igt_output_t *output, enum pipe pipe); + igt_plane_t *igt_output_get_plane(igt_output_t *output, int plane_idx); igt_plane_t *igt_output_get_plane_type(igt_output_t *output, int plane_type); int igt_output_count_plane_type(igt_output_t *output, int plane_type); From patchwork Thu Jun 13 02:19:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 10991045 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 BD17813AF for ; Thu, 13 Jun 2019 02:19:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A000F28A0B for ; Thu, 13 Jun 2019 02:19:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E2CD28A08; Thu, 13 Jun 2019 02:19:13 +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 2D02A28A0B for ; Thu, 13 Jun 2019 02:19:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4DC5089296; Thu, 13 Jun 2019 02:19:10 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by gabe.freedesktop.org (Postfix) with ESMTPS id B8443891AC; Thu, 13 Jun 2019 02:19:08 +0000 (UTC) Received: by mail-ed1-x544.google.com with SMTP id z25so28778287edq.9; Wed, 12 Jun 2019 19:19:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=cllX64Dw/hhsJxsGolxrZB/NK6wL+pKC8OwL/popBDg=; b=amYGgptFW3ZkFx+ONyFSMz6BI9u7/rpoyQT8fWQlufkMvAyPPRhidcl9aq9L26QpBN peiuzPNhS/dugOu1zsRZfFwHjIKHV3Yg03GJhJf8DENSdaaJd7R/nklQMg7/4uxQLzzE pb8j8rFQgpAGou7cdInfFVEofV4JlwpKY7H6ZA/8bZaV45b6LRLI6UM9IQkiCJ40ftrw 8BOJPSRlHXb27sYAxDbXvZM+ra9QLSEfcTuc7jPehUkznUIp0viGbjTJjhq3y36d9mKA DZcFBpkIUpF/hscGVdm3jXRj8imTtOmpSG1VAre/5Y1K9hXi1XXNUA/fu13Ex0UGzZOE 0Tgw== X-Gm-Message-State: APjAAAVZcA82qnHH4jAZnK5ReON5me8XPtAHLaac7aiX9NpU6Su6WF9r 843DrQj3sCAZXEIT3WBlXWJuU9y7bvY= X-Google-Smtp-Source: APXvYqwkh7fTXUX7EguW0zgc5hIJDyb7jQiS2JvgIheDce9Dsfdue7tp1j816Rdy8L4Jp/Sm1Gy1sA== X-Received: by 2002:a50:b3d0:: with SMTP id t16mr22876994edd.158.1560392347369; Wed, 12 Jun 2019 19:19:07 -0700 (PDT) Received: from smtp.gmail.com ([187.121.151.146]) by smtp.gmail.com with ESMTPSA id s11sm270611ejo.51.2019.06.12.19.19.03 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 12 Jun 2019 19:19:06 -0700 (PDT) From: Brian Starkey X-Google-Original-From: Brian Starkey Date: Wed, 12 Jun 2019 23:19:01 -0300 To: Brian Starkey , Liviu Dudau , Petri Latvala , Arkadiusz Hiler , Daniel Vetter Message-ID: <454e4369191d599d038196429af4a242f4f0e5fb.1560374714.git.rodrigosiqueiramelo@gmail.com> References: MIME-Version: 1.0 In-Reply-To: User-Agent: NeoMutt/20180716 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=cllX64Dw/hhsJxsGolxrZB/NK6wL+pKC8OwL/popBDg=; b=CFS9TcjTapFrv7T3VuvLMYioyrrr+OHnu9iOt2u9fIWSbkLHDYStFqjzm6JNl98DRP hFK7r8aSPxp4W88BCMkFYa3i0XoUycvhgiiDcbazRi+2XOiRXU768Zk8d9b8IXG2/WXC qO/IHmtVTvoNQwKb5uW1V/qdHCaVu/omk+h+aXnMZEaJBJJZxkuvwL0meuoZYWNn3eot PA+pLrLfoazvb3lbJNXO6oJ6M6BadSb+agnJbyZs1MazkvAzEGug5vaxFk0ONBeOmNO4 IXPHbq42VPVIhcbM9b1b0TID9FwcRGcUR5WvjXMZvQy8eHpWbXP4gdL8BljKBTYu6/K+ mkew== Subject: [Intel-gfx] [PATCH V6 i-g-t 6/6] kms_writeback: Add tests using a cloned output 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, nd Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Update the connector search to also optionally attempt to find a non-writeback connector to clone to. Add a subtest which is the same as writeback-check-output, but also clones to the second connector. Signed-off-by: Brian Starkey [rebased and addressed comments by Maarten] Signed-off-by: Liviu Dudau --- tests/kms_writeback.c | 64 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 5 deletions(-) diff --git a/tests/kms_writeback.c b/tests/kms_writeback.c index 0f20dadd..ae536bbf 100644 --- a/tests/kms_writeback.c +++ b/tests/kms_writeback.c @@ -51,7 +51,8 @@ static drmModePropertyBlobRes *get_writeback_formats_blob(igt_output_t *output) return blob; } -static bool check_writeback_config(igt_display_t *display, igt_output_t *output) +static bool check_writeback_config(igt_display_t *display, igt_output_t *output, + int pipe, igt_output_t **clone) { igt_fb_t input_fb, output_fb; igt_plane_t *plane; @@ -91,6 +92,30 @@ static bool check_writeback_config(igt_display_t *display, igt_output_t *output) ret = igt_display_try_commit_atomic(display, DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_ATOMIC_ALLOW_MODESET, NULL); + if (!ret && clone) { + /* Try and find a clone */ + int i, newret; + *clone = NULL; + + for (i = 0; i < display->n_outputs; i++) { + igt_output_t *second_output = &display->outputs[i]; + if (output != second_output && + igt_pipe_connector_valid(pipe, second_output)) { + + igt_output_clone_pipe(second_output, pipe); + igt_output_override_mode(output, &override_mode); + newret = igt_display_try_commit_atomic(display, DRM_MODE_ATOMIC_TEST_ONLY | + DRM_MODE_ATOMIC_ALLOW_MODESET, NULL); + igt_output_set_pipe(second_output, PIPE_NONE); + igt_debug("try_commit_atomic clone returned %d\n", newret); + if (!newret) { + *clone = second_output; + igt_debug("Selected clone %s\n", (*clone)->name); + break; + } + } + } + } igt_plane_set_fb(plane, NULL); igt_remove_fb(display->drm_fd, &input_fb); igt_remove_fb(display->drm_fd, &output_fb); @@ -98,7 +123,8 @@ static bool check_writeback_config(igt_display_t *display, igt_output_t *output) return !ret; } -static igt_output_t *kms_writeback_get_output(igt_display_t *display) +static igt_output_t *kms_writeback_get_output(igt_display_t *display, enum pipe *pipe, + igt_output_t **clone) { int i; @@ -114,10 +140,16 @@ static igt_output_t *kms_writeback_get_output(igt_display_t *display) for (j = 0; j < igt_display_get_n_pipes(display); j++) { igt_output_set_pipe(output, j); - if (check_writeback_config(display, output)) { + if (check_writeback_config(display, output, j, clone)) { igt_debug("Using connector %u:%s on pipe %d\n", output->config.connector->connector_id, output->name, j); + if (clone && *clone) + igt_debug("Cloning to connector %u:%s\n", + (*clone)->config.connector->connector_id, + (*clone)->name); + if (pipe) + *pipe = j; return output; } } @@ -335,10 +367,11 @@ static void writeback_check_output(igt_output_t *output, igt_plane_t *plane, igt_main { igt_display_t display; - igt_output_t *output; + igt_output_t *output, *clone; igt_plane_t *plane; igt_fb_t input_fb; drmModeModeInfo mode; + enum pipe pipe; int ret; memset(&display, 0, sizeof(display)); @@ -353,7 +386,7 @@ igt_main igt_require(display.is_atomic); - output = kms_writeback_get_output(&display); + output = kms_writeback_get_output(&display, &pipe, &clone); igt_require(output); if (output->use_override_mode) @@ -431,6 +464,27 @@ igt_main igt_remove_fb(display.drm_fd, &output_fb); } + igt_subtest("writeback-check-output-clone") { + igt_fb_t output_fb; + + igt_require(clone); + + ret = igt_create_fb(display.drm_fd, mode.hdisplay, mode.vdisplay, + DRM_FORMAT_XRGB8888, + igt_fb_mod_to_tiling(0), + &output_fb); + igt_require(ret > 0); + + igt_output_clone_pipe(clone, pipe); + igt_output_override_mode(clone, &mode); + + writeback_check_output(output, plane, &input_fb, &output_fb); + + igt_output_set_pipe(clone, PIPE_NONE); + + igt_remove_fb(display.drm_fd, &output_fb); + } + igt_fixture { igt_remove_fb(display.drm_fd, &input_fb); igt_display_fini(&display);