All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stuart Summers <stuart.summers@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 1/2] lib/i915/gem_mman: Add functions to get mmap and gtt versions
Date: Tue, 19 Nov 2019 10:16:18 -0800	[thread overview]
Message-ID: <20191119181619.11674-1-stuart.summers@intel.com> (raw)

Move these checks out to separate functions to make the code
more readable and reuseable.

Signed-off-by: Stuart Summers <stuart.summers@intel.com>
---
 lib/i915/gem_mman.c | 42 +++++++++++++++++++++++++++---------------
 1 file changed, 27 insertions(+), 15 deletions(-)

diff --git a/lib/i915/gem_mman.c b/lib/i915/gem_mman.c
index 6256627b..a0e34aef 100644
--- a/lib/i915/gem_mman.c
+++ b/lib/i915/gem_mman.c
@@ -101,29 +101,41 @@ int gem_munmap(void *ptr, uint64_t size)
 	return ret;
 }
 
+static int get_gtt_version(int fd)
+{
+	struct drm_i915_getparam gp;
+	int gtt_version = -1;
+
+	memset(&gp, 0, sizeof(gp));
+	gp.param = I915_PARAM_MMAP_GTT_VERSION;
+	gp.value = &gtt_version;
+	ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+
+	return gtt_version;
+}
+
+static int get_mmap_version(int fd)
+{
+	struct drm_i915_getparam gp;
+	int mmap_version = -1;
+
+	memset(&gp, 0, sizeof(gp));
+	gp.param = I915_PARAM_MMAP_VERSION;
+	gp.value = &mmap_version;
+	ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+
+	return mmap_version;
+}
+
 bool gem_mmap__has_wc(int fd)
 {
 	static int has_wc = -1;
 
 	if (has_wc == -1) {
-		struct drm_i915_getparam gp;
-		int mmap_version = -1;
-		int gtt_version = -1;
-
 		has_wc = 0;
 
-		memset(&gp, 0, sizeof(gp));
-		gp.param = I915_PARAM_MMAP_GTT_VERSION;
-		gp.value = &gtt_version;
-		ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
-
-		memset(&gp, 0, sizeof(gp));
-		gp.param = I915_PARAM_MMAP_VERSION;
-		gp.value = &mmap_version;
-		ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
-
 		/* Do we have the new mmap_ioctl with DOMAIN_WC? */
-		if (mmap_version >= 1 && gtt_version >= 2) {
+		if (get_mmap_version(fd) >= 1 && get_gtt_version(fd) >= 2) {
 			struct drm_i915_gem_mmap arg;
 
 			/* Does this device support wc-mmaps ? */
-- 
2.21.0.5.gaeb582a983

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

             reply	other threads:[~2019-11-19 18:16 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-19 18:16 Stuart Summers [this message]
2019-11-19 18:16 ` [igt-dev] [PATCH i-g-t 2/2] lib/i915/gem_mman: mmap to the CPU instead of the GTT in some tests Stuart Summers
2019-11-19 18:23   ` Chris Wilson
2019-11-19 18:23   ` Vanshidhar Konda
2019-11-19 18:25   ` Chris Wilson
2019-11-19 18:58     ` Summers, Stuart
2019-11-19 19:20       ` Chris Wilson
2019-11-19 22:00         ` Summers, Stuart
2019-11-19 22:28           ` Chris Wilson
2019-11-19 22:55             ` Summers, Stuart
2019-11-19 19:05 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/2] lib/i915/gem_mman: Add functions to get mmap and gtt versions Patchwork
2019-11-20  7:41 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191119181619.11674-1-stuart.summers@intel.com \
    --to=stuart.summers@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.