From patchwork Tue Jan 5 16:17:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lukasz Fiedorowicz X-Patchwork-Id: 7956151 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B1F109F3E6 for ; Tue, 5 Jan 2016 16:20:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DDF5520220 for ; Tue, 5 Jan 2016 16:20:27 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id AB64720219 for ; Tue, 5 Jan 2016 16:20:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 06B3B6E1E6; Tue, 5 Jan 2016 08:20:26 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTP id 94A796E1E6 for ; Tue, 5 Jan 2016 08:20:25 -0800 (PST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP; 05 Jan 2016 08:20:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,525,1444719600"; d="scan'208";a="628405693" Received: from lfiedoro-desk1.ger.corp.intel.com (HELO lfiedoro-desk1.igk.intel.com) ([10.237.138.163]) by FMSMGA003.fm.intel.com with ESMTP; 05 Jan 2016 08:20:09 -0800 From: Lukasz Fiedorowicz To: intel-gfx@lists.freedesktop.org Date: Tue, 5 Jan 2016 17:17:07 +0100 Message-Id: <1452010627-15643-1-git-send-email-lukasz.fiedorowicz@intel.com> X-Mailer: git-send-email 2.4.3 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t] tests/gem_guc_loading: Adding simple GuC loading test 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: , 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 Test check GuC debugfs file for successful loading confirmation Signed-off-by: Lukasz Fiedorowicz Reviewed-by: Alex Dai --- tests/Makefile.sources | 1 + tests/gem_guc_loading.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 tests/gem_guc_loading.c diff --git a/tests/Makefile.sources b/tests/Makefile.sources index d594038..331234f 100644 --- a/tests/Makefile.sources +++ b/tests/Makefile.sources @@ -36,6 +36,7 @@ TESTS_progs_M = \ gem_flink_basic \ gem_flink_race \ gem_linear_blits \ + gem_guc_loading \ gem_madvise \ gem_mmap \ gem_mmap_gtt \ diff --git a/tests/gem_guc_loading.c b/tests/gem_guc_loading.c new file mode 100644 index 0000000..fd53a46 --- /dev/null +++ b/tests/gem_guc_loading.c @@ -0,0 +1,89 @@ +/* + * Copyright © 2015 Intel Corporation + * + * 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. + * + * Authors: + * Lukasz Fiedorowicz + * + */ + +#include +#include +#include +#include + +#include "igt.h" + +IGT_TEST_DESCRIPTION("GuC firmware loading test."); + +#define LOAD_STATUS_BUF_SIZE 96 + +enum guc_status { GUC_ENABLED, GUC_DISABLED }; + +int guc_status_fd; + +static void open_guc_status(void) +{ + guc_status_fd = igt_debugfs_open("i915_guc_load_status", O_RDONLY); + igt_assert_f(guc_status_fd >= 0, "Can't open i915_guc_load_status\n"); +} + +static enum guc_status get_guc_status(void) +{ + char buf[LOAD_STATUS_BUF_SIZE]; + + FILE *fp = fdopen(guc_status_fd, "r"); + igt_assert_f(fp != NULL, "Can't open i915_guc_load_status file\n"); + + while (fgets(buf, LOAD_STATUS_BUF_SIZE, fp)) + if ((strstr(buf, "\tload: SUCCESS\n"))) + return GUC_ENABLED; + + return GUC_DISABLED; +} + +static void close_guc_status(void) +{ + close(guc_status_fd); +} + +static void test_guc_loaded() +{ + igt_assert_f(get_guc_status() == GUC_ENABLED, "GuC is disabled\n"); +} + +igt_main +{ + int gfx_fd = 0; + int gen = 0; + + igt_fixture + { + gfx_fd = drm_open_driver(DRIVER_INTEL); + gen = intel_gen(intel_get_drm_devid(gfx_fd)); + igt_require(gen >= 9); + open_guc_status(); + } + + igt_subtest("guc_loaded") test_guc_loaded(); + + igt_fixture close_guc_status(); +}