From patchwork Thu Dec 18 17:55:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: jeff.mcgee@intel.com X-Patchwork-Id: 5515541 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 647609F1CD for ; Thu, 18 Dec 2014 17:38:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4855A208FD for ; Thu, 18 Dec 2014 17:38:25 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id B9486208F3 for ; Thu, 18 Dec 2014 17:38:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 429886EA30; Thu, 18 Dec 2014 09:38:19 -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 35BD86EA30 for ; Thu, 18 Dec 2014 09:38:18 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 18 Dec 2014 09:38:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,602,1413270000"; d="scan'208";a="650000116" Received: from jeffdesk.fso.intel.com ([10.5.53.102]) by fmsmga002.fm.intel.com with ESMTP; 18 Dec 2014 09:37:58 -0800 From: jeff.mcgee@intel.com To: intel-gfx@lists.freedesktop.org Date: Thu, 18 Dec 2014 11:55:43 -0600 Message-Id: <1418925343-10724-1-git-send-email-jeff.mcgee@intel.com> X-Mailer: git-send-email 2.2.0 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH] tests/core_getparams: Create new test core_getparams 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, T_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 From: Jeff McGee New test core_getparams consists of 4 subtests, each one testing the ability of userspace to query the correct value of a GT config attribute: slice total, subslice total, EU total, and threads per EU. drm/i915 implementation of these queries is required for Gen8+ devices (non-simulated). For: VIZ-4636 Signed-off-by: Jeff McGee --- tests/.gitignore | 1 + tests/Makefile.sources | 1 + tests/core_getparams.c | 223 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 225 insertions(+) create mode 100644 tests/core_getparams.c diff --git a/tests/.gitignore b/tests/.gitignore index b770a8b..2895e51 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -1,6 +1,7 @@ # Please keep sorted alphabetically core_get_client_auth core_getclient +core_getparams core_getstats core_getversion drm_import_export diff --git a/tests/Makefile.sources b/tests/Makefile.sources index d15a68b..4f085b6 100644 --- a/tests/Makefile.sources +++ b/tests/Makefile.sources @@ -15,6 +15,7 @@ NOUVEAU_TESTS_M = \ TESTS_progs_M = \ core_get_client_auth \ + core_getparams \ drv_suspend \ drv_hangman \ gem_bad_reloc \ diff --git a/tests/core_getparams.c b/tests/core_getparams.c new file mode 100644 index 0000000..2aa05c8 --- /dev/null +++ b/tests/core_getparams.c @@ -0,0 +1,223 @@ +/* + * Copyright © 2014 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: + * Jeff McGee + * + */ + +#include +#include +#include +#include "drmtest.h" +#include "intel_chipset.h" +#include "intel_bufmgr.h" + +int drm_fd; +int devid; + +static void +init(void) +{ + drm_fd = drm_open_any(); + devid = intel_get_drm_devid(drm_fd); +} + +static void +deinit(void) +{ + close(drm_fd); +} + +static void +slice_total(void) +{ + unsigned int slice_total = 0; + int ret; + + ret = drm_intel_get_slice_total(drm_fd, &slice_total); + + if (ret) { + /* + * These devices are not required to implement the + * interface. If they do not, -ENODEV must be returned. + */ + if ((intel_gen(devid) < 8) || + igt_run_in_simulation()) { + igt_assert(ret == -ENODEV); + igt_info("slice total: unknown\n"); + /* + * All other devices must implement the interface, so + * fail them if we are here. + */ + } else { + igt_assert(ret != EINVAL); /* request not recognized? */ + igt_assert(ret != ENODEV); /* device not supported? */ + igt_assert(ret == 0); /* other error? */ + } + } else { + /* + * On success, just make sure the returned count value is + * non-zero. The validity of the count value for the given + * device is not checked. + */ + igt_assert(slice_total != 0); + igt_info("slice total: %u\n", slice_total); + } +} + +static void +subslice_total(void) +{ + unsigned int subslice_total = 0; + int ret; + + ret = drm_intel_get_subslice_total(drm_fd, &subslice_total); + + if (ret) { + /* + * These devices are not required to implement the + * interface. If they do not, -ENODEV must be returned. + */ + if ((intel_gen(devid) < 8) || + igt_run_in_simulation()) { + igt_assert(ret == -ENODEV); + igt_info("subslice total: unknown\n"); + /* + * All other devices must implement the interface, so + * fail them if we are here. + */ + } else { + igt_assert(ret != EINVAL); /* request not recognized? */ + igt_assert(ret != ENODEV); /* device not supported? */ + igt_assert(ret == 0); /* other error? */ + } + } else { + /* + * On success, just make sure the returned count value is + * non-zero. The validity of the count value for the given + * device is not checked. + */ + igt_assert(subslice_total != 0); + igt_info("subslice total: %u\n", subslice_total); + } +} + +static void +eu_total(void) +{ + unsigned int eu_total = 0; + int ret; + + ret = drm_intel_get_eu_total(drm_fd, &eu_total); + + if (ret) { + /* + * These devices are not required to implement the + * interface. If they do not, -ENODEV must be returned. + */ + if ((intel_gen(devid) < 8) || + igt_run_in_simulation()) { + igt_assert(ret == -ENODEV); + igt_info("EU total: unknown\n"); + /* + * All other devices must implement the interface, so + * fail them if we are here. + */ + } else { + igt_assert(ret != EINVAL); /* request not recognized? */ + igt_assert(ret != ENODEV); /* device not supported? */ + igt_assert(ret == 0); /* other error? */ + } + } else { + /* + * On success, just make sure the returned count value is + * non-zero. The validity of the count value for the given + * device is not checked. + */ + igt_assert(eu_total != 0); + igt_info("EU total: %u\n", eu_total); + } +} + +static void +threads_per_eu(void) +{ + unsigned int threads_per_eu = 0; + int ret; + + ret = drm_intel_get_threads_per_eu(drm_fd, &threads_per_eu); + + if (ret) { + /* + * These devices are not required to implement the + * interface. If they do not, -ENODEV must be returned. + */ + if ((intel_gen(devid) < 8) || + igt_run_in_simulation()) { + igt_assert(ret == -ENODEV); + igt_info("threads per EU: unknown\n"); + /* + * All other devices must implement the interface, so + * fail them if we are here. + */ + } else { + igt_assert(ret != EINVAL); /* request not recognized? */ + igt_assert(ret != ENODEV); /* device not supported? */ + igt_assert(ret == 0); /* other error? */ + } + } else { + /* + * On success, just make sure the returned count value is + * non-zero. The validity of the count value for the given + * device is not checked. + */ + igt_assert(threads_per_eu != 0); + igt_info("threads per EU: %u\n", threads_per_eu); + } +} + +static void +exit_handler(int sig) +{ + deinit(); +} + +igt_main +{ + igt_fixture { + igt_install_exit_handler(exit_handler); + init(); + } + + igt_subtest("slice-total") + slice_total(); + + igt_subtest("subslice-total") + subslice_total(); + + igt_subtest("eu-total") + eu_total(); + + igt_subtest("threads-per-eu") + threads_per_eu(); +}