From patchwork Fri May 31 09:29:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10969807 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F0CB0112C for ; Fri, 31 May 2019 09:30:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E22462808F for ; Fri, 31 May 2019 09:30:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D6B5928C50; Fri, 31 May 2019 09:30:00 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 C54872808F for ; Fri, 31 May 2019 09:29:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 62C31892CA; Fri, 31 May 2019 09:29:57 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0F808892CA; Fri, 31 May 2019 09:29:56 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 May 2019 02:29:55 -0700 Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 May 2019 02:29:53 -0700 From: Janusz Krzysztofik To: Arkadiusz Hiler , Petri Latvala Date: Fri, 31 May 2019 11:29:16 +0200 Message-Id: <20190531092916.23662-1-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v4] lib/i915/gem_mman: Add a helper for obtaining MMAP_GTT interface version X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Janusz Krzysztofik , intel-gfx@lists.freedesktop.org, igt-dev@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: Janusz Krzysztofik If a test calls a function which depends on availability of a specific version of MMAP_GTT interface, an error may occur on unsupported hardware. That may negatively affect results reported by a test framework even if that test ignores the failure and succeedes. This helper wraps up an IOCTL call which returns a version number of MMAP_GTT interface. It may be used by tests which should adjust their scope depending on availability of a specific version of MMAP_GTT interface. Signed-off-by: Janusz Krzysztofik Cc: Antonio Argenziano Cc: Michal Wajdeczko --- Changelog: v3 -> v4: - return errno value on failure (Chris - thanks!), - clear errno before return, as other helpers do, - reword the helper documentation and commit message again (Chris - thanks!). v2 (internal) -> v3: - make the code less obsucre, more explicit (Antonio - thanks!), - reword the helper documentation and commit message. v1 (internal) -> v2 (internal): - minimize future potential conflicts with https://patchwork.freedesktop.org/patch/294053/?series=58551&rev=1 (no progress with than one so not waiting for it any longer): - convert the helper to a drop-in replacement of the one from the above mentioned patch, returning mappable aperture version, not only information on its availability, - drop any other wrappers, - document the helper, - reword commit message. lib/i915/gem_mman.c | 25 +++++++++++++++++++++++++ lib/i915/gem_mman.h | 1 + 2 files changed, 26 insertions(+) diff --git a/lib/i915/gem_mman.c b/lib/i915/gem_mman.c index 3cf9a6bb..2c3d6971 100644 --- a/lib/i915/gem_mman.c +++ b/lib/i915/gem_mman.c @@ -40,6 +40,31 @@ #define VG(x) do {} while (0) #endif +/** + * gem_mmap__gtt_version: + * @fd: open i915 drm file descriptor + * + * This functions wraps up an IOCTL to obtain MMAP_GTT interface version + * + * Returns: MMAP_GTT interface version, kernel error code on failure. + */ +int gem_mmap__gtt_version(int fd) +{ + int gtt_version, ret; + struct drm_i915_getparam gp = { + .param = I915_PARAM_MMAP_GTT_VERSION, + .value = >t_version, + }; + + if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp)) + ret = errno; + else + ret = gtt_version; + + errno = 0; + return ret; +} + /** * __gem_mmap__gtt: * @fd: open i915 drm file descriptor diff --git a/lib/i915/gem_mman.h b/lib/i915/gem_mman.h index f7242ed7..ab12e566 100644 --- a/lib/i915/gem_mman.h +++ b/lib/i915/gem_mman.h @@ -25,6 +25,7 @@ #ifndef GEM_MMAN_H #define GEM_MMAN_H +int gem_mmap__gtt_version(int fd); void *gem_mmap__gtt(int fd, uint32_t handle, uint64_t size, unsigned prot); void *gem_mmap__cpu(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot);