From patchwork Wed Jan 20 17:48:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Micha=C5=82_Winiarski?= X-Patchwork-Id: 8073371 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 AEE95BEEE5 for ; Wed, 20 Jan 2016 17:49:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D1168204DE for ; Wed, 20 Jan 2016 17:49:08 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id CB6EE204D5 for ; Wed, 20 Jan 2016 17:49:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D20E46E99C; Wed, 20 Jan 2016 09:49:06 -0800 (PST) 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 A82AB6E99C for ; Wed, 20 Jan 2016 09:49:04 -0800 (PST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP; 20 Jan 2016 09:48:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,322,1449561600"; d="scan'208";a="731201750" Received: from irsmsx103.ger.corp.intel.com ([163.33.3.157]) by orsmga003.jf.intel.com with ESMTP; 20 Jan 2016 09:48:41 -0800 Received: from mwiniars-desk1.ger.corp.intel.com (172.28.173.39) by IRSMSX103.ger.corp.intel.com (163.33.3.157) with Microsoft SMTP Server id 14.3.248.2; Wed, 20 Jan 2016 17:48:40 +0000 From: =?UTF-8?q?Micha=C5=82=20Winiarski?= To: Date: Wed, 20 Jan 2016 18:48:26 +0100 Message-ID: <1453312106-6407-2-git-send-email-michal.winiarski@intel.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1453312106-6407-1-git-send-email-michal.winiarski@intel.com> References: <1453312106-6407-1-git-send-email-michal.winiarski@intel.com> MIME-Version: 1.0 X-Originating-IP: [172.28.173.39] Subject: [Intel-gfx] [PATCH i-g-t 2/2] lib/ioctl_wrappers: Add gem_has_softpin 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 We can move it from softpin test into lib, and since softpin support is highly unlikely to go away in-between getparam ioctl calls, let's just do a single call and store the value. Signed-off-by: Micha? Winiarski Reviewed-by: Chris Wilson --- lib/ioctl_wrappers.c | 29 +++++++++++++++++++++++++++++ lib/ioctl_wrappers.h | 1 + tests/gem_softpin.c | 22 +--------------------- 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c index 6099657..e641526 100644 --- a/lib/ioctl_wrappers.c +++ b/lib/ioctl_wrappers.c @@ -1256,6 +1256,35 @@ uint64_t gem_mappable_aperture_size(void) return pci_dev->regions[bar].size; } +#define LOCAL_I915_PARAM_HAS_EXEC_SOFTPIN 37 +/** + * gem_has_softpin: + * @fd: open i915 drm file descriptor + * + * Feature test macro to query whether the softpinning functionality is + * supported. + * + * Returns: Whether softpin support is available + */ +bool gem_has_softpin(int fd) +{ + static int has_softpin = -1; + + if (has_softpin < 0) { + struct drm_i915_getparam gp; + + memset(&gp, 0, sizeof(gp)); + gp.param = LOCAL_I915_PARAM_HAS_EXEC_SOFTPIN; + gp.value = &has_softpin; + + has_softpin = 0; + ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp)); + errno = 0; + } + + return has_softpin; +} + /** * gem_require_caching: * @fd: open i915 drm file descriptor diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h index 2a282de..9003b6d 100644 --- a/lib/ioctl_wrappers.h +++ b/lib/ioctl_wrappers.h @@ -133,6 +133,7 @@ int gem_available_fences(int fd); uint64_t gem_available_aperture_size(int fd); uint64_t gem_aperture_size(int fd); uint64_t gem_mappable_aperture_size(void); +bool gem_has_softpin(int fd); /* check functions which auto-skip tests by calling igt_skip() */ void gem_require_caching(int fd); diff --git a/tests/gem_softpin.c b/tests/gem_softpin.c index f188559..9889c26 100644 --- a/tests/gem_softpin.c +++ b/tests/gem_softpin.c @@ -31,26 +31,6 @@ #define EXEC_OBJECT_PINNED (1<<4) #define EXEC_OBJECT_SUPPORTS_48B_ADDRESS (1<<3) -/* has_softpin_support - * Finds if softpin feature is supported - * @fd DRM fd -*/ -static bool has_softpin_support(int fd) -{ - struct drm_i915_getparam gp; - int val = 0; - - memset(&gp, 0, sizeof(gp)); - gp.param = 37; /* I915_PARAM_HAS_EXEC_SOFTPIN */ - gp.value = &val; - - if (drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp)) - return 0; - - errno = 0; - return (val == 1); -} - /* gen8_canonical_addr * Used to convert any address into canonical form, i.e. [63:48] == [47]. * Based on kernel's sign_extend64 implementation. @@ -427,7 +407,7 @@ igt_main igt_fixture { fd = drm_open_driver(DRIVER_INTEL); - igt_require(has_softpin_support(fd)); + igt_require(gem_has_softpin(fd)); } igt_subtest("invalid")