public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t 1/2] lib/i915/gem_mman: Add functions to get mmap and gtt versions
@ 2019-11-19 18:16 Stuart Summers
  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
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Stuart Summers @ 2019-11-19 18:16 UTC (permalink / raw)
  To: igt-dev

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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2019-11-20  7:41 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-19 18:16 [igt-dev] [PATCH i-g-t 1/2] lib/i915/gem_mman: Add functions to get mmap and gtt versions Stuart Summers
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox