From patchwork Fri May 31 08:33:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10969761 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 3E40514C0 for ; Fri, 31 May 2019 08:33:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3029528C6D for ; Fri, 31 May 2019 08:33:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 222ED28C81; Fri, 31 May 2019 08:33:56 +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 9882128C6D for ; Fri, 31 May 2019 08:33:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1625C8929D; Fri, 31 May 2019 08:33:55 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTPS id A19C78929C; Fri, 31 May 2019 08:33:53 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 May 2019 01:33:53 -0700 Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 May 2019 01:33:51 -0700 From: Janusz Krzysztofik To: Arkadiusz Hiler , Petri Latvala Date: Fri, 31 May 2019 10:33:38 +0200 Message-Id: <20190531083338.3029-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 v3] lib/i915/gem_mman: Add a helper for obtaining mappable aperture 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: igt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, Janusz Krzysztofik 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 availabiblity of a supported mappable aperture, an error may be reported by the kernel 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 an IOCTL call which returns a version number of a mappable aperture. It may be used by tests which need to adjust their scope depending on availability of specific version of mappable aperture. Signed-off-by: Janusz Krzysztofik Cc: Antonio Argenziano Cc: Michal Wajdeczko --- Changelog: v2 (internal) -> v3: - make the code less obsucre, more explicit (Antonio), - 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 | 22 ++++++++++++++++++++++ lib/i915/gem_mman.h | 1 + 2 files changed, 23 insertions(+) diff --git a/lib/i915/gem_mman.c b/lib/i915/gem_mman.c index 3cf9a6bb..3a3f3e5c 100644 --- a/lib/i915/gem_mman.c +++ b/lib/i915/gem_mman.c @@ -40,6 +40,28 @@ #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 mappable aperture version. + * + * Returns: mappable aperture version, -1 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, + }; + + ret = ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp); + if (ret == 0) + ret = gtt_version; + 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);