From patchwork Tue Dec 12 20:00:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dhinakaran Pandiyan X-Patchwork-Id: 10108227 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 39C386032B for ; Tue, 12 Dec 2017 20:00:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2907529697 for ; Tue, 12 Dec 2017 20:00:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A91F296A9; Tue, 12 Dec 2017 20:00:31 +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=-4.2 required=2.0 tests=BAYES_00, 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 736E529697 for ; Tue, 12 Dec 2017 20:00:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 198AB89CD9; Tue, 12 Dec 2017 20:00:30 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7B1186E248 for ; Tue, 12 Dec 2017 20:00:29 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Dec 2017 12:00:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,395,1508828400"; d="scan'208";a="11992320" Received: from dk-thinkpad-x260.jf.intel.com (HELO localhost.localdomain) ([10.54.75.38]) by fmsmga004.fm.intel.com with ESMTP; 12 Dec 2017 12:00:28 -0800 From: Dhinakaran Pandiyan To: intel-gfx@lists.freedesktop.org Date: Tue, 12 Dec 2017 12:00:14 -0800 Message-Id: <20171212200014.21290-1-dhinakaran.pandiyan@intel.com> X-Mailer: git-send-email 2.11.0 Subject: [Intel-gfx] [CI v2] igt/psr: Test vblank continuity with PSR enabled 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-Virus-Scanned: ClamAV using ClamSMTP PSR allows DMC to put the system to low power states when active, but this can reset the frame counter on some platforms. The frame counter reset leads to a negative diff applied to vblank count. This subtest checks for that. v2: Some optimizations and data type changes. Cc: Rodrigo Vivi Cc: Daniel Vetter Signed-off-by: Dhinakaran Pandiyan --- tests/intel-ci/fast-feedback.testlist | 1 + tests/kms_psr_sink_crc.c | 66 +++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/tests/intel-ci/fast-feedback.testlist b/tests/intel-ci/fast-feedback.testlist index f71a16bc..72338b72 100644 --- a/tests/intel-ci/fast-feedback.testlist +++ b/tests/intel-ci/fast-feedback.testlist @@ -247,6 +247,7 @@ igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b igt@kms_pipe_crc_basic@suspend-read-crc-pipe-c igt@kms_psr_sink_crc@psr_basic +igt@kms_psr_sink_crc@vblank igt@kms_setmode@basic-clone-single-crtc igt@kms_sink_crc_basic igt@pm_backlight@basic-brightness diff --git a/tests/kms_psr_sink_crc.c b/tests/kms_psr_sink_crc.c index 83a69f0b..831368b2 100644 --- a/tests/kms_psr_sink_crc.c +++ b/tests/kms_psr_sink_crc.c @@ -69,6 +69,7 @@ typedef struct { enum operations op; uint32_t devid; uint32_t crtc_id; + enum pipe pipe; igt_display_t display; drm_intel_bufmgr *bufmgr; struct igt_fb fb_green, fb_white; @@ -107,6 +108,7 @@ static void setup_output(data_t *data) if (c->connector_type != DRM_MODE_CONNECTOR_eDP) continue; + data->pipe = pipe; igt_output_set_pipe(output, pipe); data->crtc_id = output->config.crtc->crtc_id; data->output = output; @@ -285,6 +287,63 @@ static void assert_or_manual(bool condition, const char *expected) igt_assert(igt_interactive_debug || condition); } +static unsigned int get_vblank(int fd, unsigned int pipe) +{ + union drm_wait_vblank vbl; + + memset(&vbl, 0, sizeof(vbl)); + vbl.request.type = DRM_VBLANK_RELATIVE | kmstest_get_vbl_flag(pipe); + igt_ioctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl); + + return vbl.reply.sequence; +} + +static void dmc_read_counts(unsigned int fd, unsigned int *count) +{ + char buf[512]; + + igt_debugfs_read(fd, "i915_dmc_info", buf); + igt_assert_eq(sscanf(strstr(buf, "DC3 -> DC5"), "DC3 -> DC5 count: %u", &count[0]), + 1); + igt_assert_eq(sscanf(strstr(buf, "DC5 -> DC6"), "DC5 -> DC6 count: %u", &count[1]), + 1); + igt_debug("DC3->DC5 count=%u, DC5->DC6 count=%u\n", count[0], count[1]); +} + +static void check_vblanks(data_t *data) +{ + unsigned int first_vbl, second_vbl; + int wait = 30; /* Takes about 2.5 seconds for DC_OFF disable */ + char buf[512]; + bool has_dmc; + + first_vbl = get_vblank(data->drm_fd, data->pipe); + + igt_debugfs_read(data->drm_fd, "i915_dmc_info", buf); + has_dmc = strstr(buf, "fw loaded: yes"); + + if (has_dmc) { + unsigned int new_dc[2], old_dc[2]; + + dmc_read_counts(data->drm_fd, new_dc); + do { + memcpy(old_dc, new_dc, sizeof(new_dc)); + usleep(100 * 1000); + dmc_read_counts(data->drm_fd, new_dc); + } while (!memcmp(old_dc, new_dc, sizeof(new_dc)) && --wait); + + igt_assert_f(wait, "Timed out waiting for DC state transition 3s.\n"); + } else { + sleep(3); + } + + second_vbl = get_vblank(data->drm_fd, data->pipe); + igt_debug("vblank count went from %u to %u in %d ms.\n", + first_vbl, second_vbl, has_dmc ? (30 - wait) * 100 : 3000); + + igt_assert_lt(first_vbl, second_vbl); +} + static bool drrs_disabled(data_t *data) { char buf[512]; @@ -572,6 +631,13 @@ int main(int argc, char *argv[]) } } + igt_subtest("vblank") { + setup_test_plane(&data); + igt_assert(wait_psr_entry(&data)); + check_vblanks(&data); + test_cleanup(&data); + } + igt_subtest_f("dpms_off_psr_active") { data.test_plane = DRM_PLANE_TYPE_PRIMARY; data.op = RENDER;