From patchwork Fri May 31 10:30:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10969937 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 5CECB112C for ; Fri, 31 May 2019 10:30:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BDA728CB3 for ; Fri, 31 May 2019 10:30:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4008028C1A; Fri, 31 May 2019 10:30:49 +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 C45BF28C3B for ; Fri, 31 May 2019 10:30:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0ECC8890B9; Fri, 31 May 2019 10:30:47 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id BFE53890B9; Fri, 31 May 2019 10:30:45 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 May 2019 03:30:43 -0700 Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 May 2019 03:30:41 -0700 From: Janusz Krzysztofik To: Arkadiusz Hiler , Petri Latvala Date: Fri, 31 May 2019 12:30:34 +0200 Message-Id: <20190531103034.10173-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 v5] 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: v4 -> v5: - change sign of errno before it is returned (Chris - thanks!), - validate -errno with igt_assume() (Chris - thanks!), - follow coding style suggested by Chris - thanks! To be honest, I think Chris should be somehow officially credited in the commit tags for his contributions but I'm not sure how. Would a Suggested-by: clause be OK, or Co-develped-by: maybe? 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..27c437da 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 result = -EIO; + struct drm_i915_getparam gp = { + .param = I915_PARAM_MMAP_GTT_VERSION, + .value = &result, + }; + + if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp)) { + result = -errno; + igt_assume(result); + } + + errno = 0; + return result; +} + /** * __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);