From patchwork Fri Jul 29 09:34:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Antoine X-Patchwork-Id: 9252401 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 3C2A3601C0 for ; Fri, 29 Jul 2016 09:34:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2DC7F2094D for ; Fri, 29 Jul 2016 09:34:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 229F527E5A; Fri, 29 Jul 2016 09:34:55 +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]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CCE222094D for ; Fri, 29 Jul 2016 09:34:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4C49B6E296; Fri, 29 Jul 2016 09:34:47 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTP id 25A036E296 for ; Fri, 29 Jul 2016 09:34:44 +0000 (UTC) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP; 29 Jul 2016 02:34:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,438,1464678000"; d="scan'208";a="741417702" Received: from peterant-linux2.isw.intel.com ([10.102.226.41]) by FMSMGA003.fm.intel.com with ESMTP; 29 Jul 2016 02:34:43 -0700 From: Peter Antoine To: intel-gfx@lists.freedesktop.org Date: Fri, 29 Jul 2016 10:34:35 +0100 Message-Id: <1469784876-33201-4-git-send-email-peter.antoine@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1469784876-33201-1-git-send-email-peter.antoine@intel.com> References: <1469784876-33201-1-git-send-email-peter.antoine@intel.com> Subject: [Intel-gfx] [I-G-T 2/3] igt/gem_mocs_settings: adding RC6 tests 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 This change adds a RC6 test for the MOCS. The MOCS registers are loaded and saved as part of the RC6 cycle but not all the registers are saved/restored. This tests that those registers are correctly restored. Signed-off-by: Peter Antoine --- tests/gem_mocs_settings.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/tests/gem_mocs_settings.c b/tests/gem_mocs_settings.c index 4fb3a02..66d02d9 100644 --- a/tests/gem_mocs_settings.c +++ b/tests/gem_mocs_settings.c @@ -518,6 +518,59 @@ static void run_tests(unsigned mode) intel_register_access_fini(); } +static unsigned int readit(const char *path) +{ + unsigned int ret = 0; + int scanned = 0; + FILE *file; + + file = fopen(path, "r"); + igt_assert(file); + scanned = fscanf(file, "%u", &ret); + igt_assert_eq(scanned, 1); + + fclose(file); + + return ret; +} + +static int read_rc6_residency(void) +{ + unsigned int residency; + const int device = drm_get_card(); + static const char path_format[] = + "/sys/class/drm/card%d/power/rc6_residency_ms"; + char path[sizeof(path_format)]; + int ret; + + ret = snprintf(path, sizeof(path)-1, path_format, device); + + igt_assert_neq(ret, -1); + residency = readit(path); + + return residency; +} + +static void context_rc6_test(void) +{ + int fd = drm_open_driver(DRIVER_INTEL); + int res_ms; + uint32_t ctx_id = gem_context_create(fd); + + igt_debug("RC6 Context Test\n"); + check_control_registers(fd, I915_EXEC_RENDER, ctx_id, false); + check_l3cc_registers(fd, I915_EXEC_RENDER, ctx_id, false); + + res_ms = read_rc6_residency(); + sleep(3); + igt_assert_neq(res_ms, read_rc6_residency()); + + check_control_registers(fd, I915_EXEC_RENDER, ctx_id, false); + check_l3cc_registers(fd, I915_EXEC_RENDER, ctx_id, false); + close(fd); +} + + static void test_requirements(void) { int fd = drm_open_driver_master(DRIVER_INTEL); @@ -537,6 +590,9 @@ igt_main igt_subtest("mocs-settings") run_tests(NONE); + igt_subtest("mocs-rc6") + context_rc6_test(); + igt_subtest("mocs-reset") run_tests(RESET);