From patchwork Tue Jan 26 14:03:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zanoni, Paulo R" X-Patchwork-Id: 8122821 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 2B3F9BEEE5 for ; Tue, 26 Jan 2016 14:04:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 50BB020256 for ; Tue, 26 Jan 2016 14:04:09 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 741BD2021F for ; Tue, 26 Jan 2016 14:04:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EE9E76E5CE; Tue, 26 Jan 2016 06:04:05 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTP id 7CB846E5CE for ; Tue, 26 Jan 2016 06:04:04 -0800 (PST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP; 26 Jan 2016 06:03:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,350,1449561600"; d="scan'208";a="734491201" Received: from svosulli-mobl3.amr.corp.intel.com (HELO panetone.amr.corp.intel.com) ([10.252.193.19]) by orsmga003.jf.intel.com with ESMTP; 26 Jan 2016 06:03:43 -0800 From: Paulo Zanoni To: intel-gfx@lists.freedesktop.org Date: Tue, 26 Jan 2016 12:03:20 -0200 Message-Id: <1453817000-24929-2-git-send-email-paulo.r.zanoni@intel.com> X-Mailer: git-send-email 2.7.0.rc3 In-Reply-To: <1453817000-24929-1-git-send-email-paulo.r.zanoni@intel.com> References: <1453817000-24929-1-git-send-email-paulo.r.zanoni@intel.com> Cc: Paulo Zanoni Subject: [Intel-gfx] [PATCH igt 2/2] tests/pm_rpm: find an appropriate CRTC instead of hardcoding CRTC 0 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.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 BSW does not allow CRTC 0 to be used on every connector, so we need to write code to actually find a suitable CRTC. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93124 Signed-off-by: Paulo Zanoni --- tests/pm_rpm.c | 52 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 10 deletions(-) This is supposed to fix a BAT failure. I got no response from bug reporters or QA so far - sent the patch on Jan 06 - and I don't have a BSW machine. But I think this patch may solve it, so let's put it on the list in case someone can verify it fixes the bug. diff --git a/tests/pm_rpm.c b/tests/pm_rpm.c index bc81144..22dc2b4 100644 --- a/tests/pm_rpm.c +++ b/tests/pm_rpm.c @@ -224,12 +224,33 @@ static void disable_or_dpms_all_screens(struct mode_set_data *data, bool dpms) igt_assert(wait_for_suspended()); \ } while (0) +static uint32_t find_crtc_for_connector(drmModeResPtr res, + drmModeConnectorPtr connector) +{ + drmModeEncoderPtr e; + uint32_t crtc_id = 0; + int i, j; + + for (i = 0; i < connector->count_encoders && !crtc_id; i++) { + e = drmModeGetEncoder(drm_fd, connector->encoders[i]); + + for (j = 0; (e->possible_crtcs >> j) && !crtc_id; j++) + if (e->possible_crtcs & (1 << j)) + crtc_id = res->crtcs[j]; + + drmModeFreeEncoder(e); + } + + igt_assert(crtc_id); + return crtc_id; +} + static bool init_modeset_params_for_type(struct mode_set_data *data, struct modeset_params *params, enum screen_type type) { int i; - uint32_t connector_id = 0; + drmModeConnectorPtr connector = NULL; drmModeModeInfoPtr mode = NULL; for (i = 0; i < data->res->count_connectors; i++) { @@ -244,21 +265,21 @@ static bool init_modeset_params_for_type(struct mode_set_data *data, continue; if (c->connection == DRM_MODE_CONNECTED && c->count_modes) { - connector_id = c->connector_id; + connector = c; mode = &c->modes[0]; break; } } - if (!connector_id) + if (!connector) return false; igt_create_pattern_fb(drm_fd, mode->hdisplay, mode->vdisplay, DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE, ¶ms->fb); - params->crtc_id = data->res->crtcs[0]; - params->connector_id = connector_id; + params->crtc_id = find_crtc_for_connector(data->res, connector); + params->connector_id = connector->connector_id; params->mode = mode; return true; @@ -1599,7 +1620,6 @@ static void test_one_plane(bool dpms, uint32_t plane_id, disable_all_screens_and_wait(&ms_data); - igt_require(default_mode_params); crtc_id = default_mode_params->crtc_id; switch (plane_type) { @@ -1681,12 +1701,26 @@ static void test_one_plane(bool dpms, uint32_t plane_id, igt_assert(wait_for_suspended()); } +static int get_crtc_idx(drmModeResPtr res, uint32_t crtc_id) +{ + int i; + + for (i = 0; i < res->count_crtcs; i++) + if (res->crtcs[i] == crtc_id) + return i; + + igt_assert(false); +} + /* This one also triggered WARNs on our driver at some point in time. */ static void planes_subtest(bool universal, bool dpms) { - int i, rc, planes_tested = 0; + int i, rc, planes_tested = 0, crtc_idx; drmModePlaneResPtr planes; + igt_require(default_mode_params); + crtc_idx = get_crtc_idx(ms_data.res, default_mode_params->crtc_id); + if (universal) { rc = drmSetClientCap(drm_fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1); @@ -1700,9 +1734,7 @@ static void planes_subtest(bool universal, bool dpms) plane = drmModeGetPlane(drm_fd, planes->planes[i]); igt_assert(plane); - /* We just pick the first CRTC on the list, so we can test for - * 0x1 as the index. */ - if (plane->possible_crtcs & 0x1) { + if (plane->possible_crtcs & (1 << crtc_idx)) { enum plane_type type; type = universal ? get_plane_type(plane->plane_id) :