public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t 1/3] lib/ioctl_wrapper: Add i915_get_param helper
@ 2018-11-23 14:27 Lukasz Kalamarz
  2018-11-23 14:27 ` [igt-dev] [PATCH i-g-t 2/3] tests: Use drm_get_param where applicable Lukasz Kalamarz
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Lukasz Kalamarz @ 2018-11-23 14:27 UTC (permalink / raw)
  To: igt-dev

getparam is used in few places across IGT, but no helper function
is used to reduce code duplication.

Signed-off-by: Lukasz Kalamarz <lukasz.kalamarz@intel.com>

Cc: Michal Winiarski <michal.winiarski@intel.com>
Cc: Katarzyna Dec <katarzyna.dec@intel.com>
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
---
 lib/ioctl_wrappers.c | 13 +++++++++++++
 lib/ioctl_wrappers.h |  1 +
 2 files changed, 14 insertions(+)

diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 9f255508..8fea9fa9 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -468,6 +468,19 @@ void gem_sync(int fd, uint32_t handle)
 	errno = 0;
 }
 
+int drm_get_param(int fd, uint32_t param)
+{
+	int value;
+	drm_i915_getparam_t gp = {
+		.param = param,
+		.value = &value
+	};
+
+	if (igt_ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp) == -1)
+		return NULL;
+
+	return value;
+}
 
 bool gem_create__has_stolen_support(int fd)
 {
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index b22b36b0..90174d13 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -74,6 +74,7 @@ int __gem_set_domain(int fd, uint32_t handle, uint32_t read, uint32_t write);
 void gem_set_domain(int fd, uint32_t handle, uint32_t read, uint32_t write);
 int gem_wait(int fd, uint32_t handle, int64_t *timeout_ns);
 void gem_sync(int fd, uint32_t handle);
+int drm_get_param(int fd, uint32_t param);
 bool gem_create__has_stolen_support(int fd);
 uint32_t __gem_create_stolen(int fd, uint64_t size);
 uint32_t gem_create_stolen(int fd, uint64_t size);
-- 
2.17.2

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

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

* [igt-dev] [PATCH i-g-t 2/3] tests: Use drm_get_param where applicable
  2018-11-23 14:27 [igt-dev] [PATCH i-g-t 1/3] lib/ioctl_wrapper: Add i915_get_param helper Lukasz Kalamarz
@ 2018-11-23 14:27 ` Lukasz Kalamarz
  2018-11-23 14:27 ` [igt-dev] [PATCH i-g-t 3/3] lib: Use drm_get_param where it is applicable Lukasz Kalamarz
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Lukasz Kalamarz @ 2018-11-23 14:27 UTC (permalink / raw)
  To: igt-dev

Across several tests we check values of a given parameters.
With implementation of drm_get_param we can drop duplicated
lines and use helper function instead.

Signed-off-by: Lukasz Kalamarz <lukasz.kalamarz@intel.com>

Cc: Michal Winiarski <michal.winiarski@intel.com>
Cc: Katarzyna Dec <katarzyna.dec@intel.com>
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
---
 tests/i915/gem_busy.c          |  8 ++------
 tests/i915/gem_cs_tlb.c        | 10 ++--------
 tests/i915/gem_ctx_isolation.c |  7 +------
 tests/i915/gem_exec_async.c    |  6 ++----
 tests/i915/gem_exec_capture.c  |  5 +----
 tests/i915/gem_exec_fence.c    | 14 ++------------
 tests/i915/gem_exec_flush.c    |  5 +----
 tests/i915/gem_exec_params.c   | 16 ++++++----------
 tests/i915/gem_exec_parse.c    |  7 ++-----
 tests/i915/gem_exec_suspend.c  |  7 +------
 tests/i915/gem_mmap_gtt.c      |  7 ++-----
 tests/i915/gem_mmap_wc.c       |  7 +------
 tests/i915/hangman.c           |  5 +----
 tests/prime_vgem.c             |  7 ++-----
 14 files changed, 26 insertions(+), 85 deletions(-)

diff --git a/tests/i915/gem_busy.c b/tests/i915/gem_busy.c
index 76b44a5d..6cc8e45b 100644
--- a/tests/i915/gem_busy.c
+++ b/tests/i915/gem_busy.c
@@ -28,6 +28,7 @@
 #include "igt.h"
 #include "igt_rand.h"
 #include "igt_vgem.h"
+#include "ioctl_wrappers.h"
 #include "i915/gem_ring.h"
 
 #define LOCAL_EXEC_NO_RELOC (1<<11)
@@ -401,14 +402,9 @@ static void close_race(int fd)
 
 static bool has_semaphores(int fd)
 {
-	struct drm_i915_getparam gp;
 	int val = -1;
 
-	memset(&gp, 0, sizeof(gp));
-	gp.param = I915_PARAM_HAS_SEMAPHORES;
-	gp.value = &val;
-
-	drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+	val = drm_get_param(fd, I915_PARAM_HAS_SEMAPHORES);
 	errno = 0;
 
 	return val > 0;
diff --git a/tests/i915/gem_cs_tlb.c b/tests/i915/gem_cs_tlb.c
index 51e1c4e1..891cd551 100644
--- a/tests/i915/gem_cs_tlb.c
+++ b/tests/i915/gem_cs_tlb.c
@@ -58,17 +58,11 @@ IGT_TEST_DESCRIPTION("Check whether we correctly invalidate the cs tlb.");
 
 static bool has_softpin(int fd)
 {
-	struct drm_i915_getparam gp;
 	int val = 0;
 
-	memset(&gp, 0, sizeof(gp));
-	gp.param = 37; /* I915_PARAM_HAS_EXEC_SOFTPIN */
-	gp.value = &val;
-
-	if (drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp))
-		return 0;
-
+	val = drm_get_param(fd, 37); /* I915_PARAM_HAS_EXEC_SOFTPIN */
 	errno = 0;
+
 	return (val == 1);
 }
 
diff --git a/tests/i915/gem_ctx_isolation.c b/tests/i915/gem_ctx_isolation.c
index 058cf3ec..27c8429d 100644
--- a/tests/i915/gem_ctx_isolation.c
+++ b/tests/i915/gem_ctx_isolation.c
@@ -671,14 +671,9 @@ static void preservation(int fd,
 
 static unsigned int __has_context_isolation(int fd)
 {
-	struct drm_i915_getparam gp;
 	int value = 0;
 
-	memset(&gp, 0, sizeof(gp));
-	gp.param = 50; /* I915_PARAM_HAS_CONTEXT_ISOLATION */
-	gp.value = &value;
-
-	igt_ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+	value = drm_get_param(fd, 50); /* I915_PARAM_HAS_CONTEXT_ISOLATION */
 	errno = 0;
 
 	return value;
diff --git a/tests/i915/gem_exec_async.c b/tests/i915/gem_exec_async.c
index 9a06af7e..6b5a5d25 100644
--- a/tests/i915/gem_exec_async.c
+++ b/tests/i915/gem_exec_async.c
@@ -22,6 +22,7 @@
  */
 
 #include "igt.h"
+#include "ioctl_wrappers.h"
 
 #define LOCAL_OBJECT_ASYNC (1 << 6)
 #define LOCAL_PARAM_HAS_EXEC_ASYNC 43
@@ -173,12 +174,9 @@ static void one(int fd, unsigned ring, uint32_t flags)
 
 static bool has_async_execbuf(int fd)
 {
-	drm_i915_getparam_t gp;
 	int async = -1;
 
-	gp.param = LOCAL_PARAM_HAS_EXEC_ASYNC;
-	gp.value = &async;
-	drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+	async = drm_get_param(fd, LOCAL_PARAM_HAS_EXEC_ASYNC);
 
 	return async > 0;
 }
diff --git a/tests/i915/gem_exec_capture.c b/tests/i915/gem_exec_capture.c
index 3e4a4377..72cf8ef4 100644
--- a/tests/i915/gem_exec_capture.c
+++ b/tests/i915/gem_exec_capture.c
@@ -189,12 +189,9 @@ static void userptr(int fd, int dir)
 
 static bool has_capture(int fd)
 {
-	drm_i915_getparam_t gp;
 	int async = -1;
 
-	gp.param = LOCAL_PARAM_HAS_EXEC_CAPTURE;
-	gp.value = &async;
-	drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+	async = drm_get_param(fd, LOCAL_PARAM_HAS_EXEC_CAPTURE);
 
 	return async > 0;
 }
diff --git a/tests/i915/gem_exec_fence.c b/tests/i915/gem_exec_fence.c
index ba46595d..ee143a5f 100644
--- a/tests/i915/gem_exec_fence.c
+++ b/tests/i915/gem_exec_fence.c
@@ -803,14 +803,9 @@ static void test_fence_flip(int i915)
 
 static bool has_submit_fence(int fd)
 {
-	struct drm_i915_getparam gp;
 	int value = 0;
 
-	memset(&gp, 0, sizeof(gp));
-	gp.param = 0xdeadbeef ^ 51; /* I915_PARAM_HAS_EXEC_SUBMIT_FENCE */
-	gp.value = &value;
-
-	ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));
+	value = drm_get_param(fd, 0xdeadbeef ^ 51); /* I915_PARAM_HAS_EXEC_SUBMIT_FENCE */
 	errno = 0;
 
 	return value;
@@ -825,14 +820,9 @@ static bool has_syncobj(int fd)
 
 static bool exec_has_fence_array(int fd)
 {
-	struct drm_i915_getparam gp;
 	int value = 0;
 
-	memset(&gp, 0, sizeof(gp));
-	gp.param = 49; /* I915_PARAM_HAS_EXEC_FENCE_ARRAY */
-	gp.value = &value;
-
-	ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));
+	value = drm_get_param(fd, 49); /* I915_PARAM_HAS_EXEC_FENCE_ARRAY */
 	errno = 0;
 
 	return value;
diff --git a/tests/i915/gem_exec_flush.c b/tests/i915/gem_exec_flush.c
index f820b2a8..bdc9257d 100644
--- a/tests/i915/gem_exec_flush.c
+++ b/tests/i915/gem_exec_flush.c
@@ -359,11 +359,8 @@ static void batch(int fd, unsigned ring, int nchild, int timeout,
 
 	if (flags & CMDPARSER) {
 		int cmdparser = -1;
-                drm_i915_getparam_t gp;
 
-		gp.param = I915_PARAM_CMD_PARSER_VERSION;
-		gp.value = &cmdparser;
-		drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+		cmdparser = drm_get_param(fd, I915_PARAM_CMD_PARSER_VERSION);
 		igt_require(cmdparser > 0);
 	}
 
diff --git a/tests/i915/gem_exec_params.c b/tests/i915/gem_exec_params.c
index 49c56a8d..5f443961 100644
--- a/tests/i915/gem_exec_params.c
+++ b/tests/i915/gem_exec_params.c
@@ -79,22 +79,18 @@ static bool has_ring(int fd, unsigned ring_exec_flags)
 static bool has_exec_batch_first(int fd)
 {
 	int val = -1;
-	struct drm_i915_getparam gp = {
-		.param = 48,
-		.value = &val,
-	};
-	ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+
+	val = drm_get_param(fd, 48);
+
 	return val > 0;
 }
 
 static bool has_resource_streamer(int fd)
 {
 	int val = -1;
-	struct drm_i915_getparam gp = {
-		.param = I915_PARAM_HAS_RESOURCE_STREAMER,
-		.value = &val,
-	};
-	ioctl(fd, DRM_IOCTL_I915_GETPARAM , &gp);
+
+	val = drm_get_param(fd, I915_PARAM_HAS_RESOURCE_STREAMER);
+
 	return val > 0;
 }
 
diff --git a/tests/i915/gem_exec_parse.c b/tests/i915/gem_exec_parse.c
index b653b1bd..15315438 100644
--- a/tests/i915/gem_exec_parse.c
+++ b/tests/i915/gem_exec_parse.c
@@ -61,12 +61,9 @@ static int parser_version;
 static int command_parser_version(int fd)
 {
 	int version = -1;
-	drm_i915_getparam_t gp;
 
-	gp.param = I915_PARAM_CMD_PARSER_VERSION;
-	gp.value = &version;
-
-	if (drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp) == 0)
+	version = drm_get_param(fd, I915_PARAM_CMD_PARSER_VERSION);
+	if (version >= 1)
 		return version;
 
 	return -1;
diff --git a/tests/i915/gem_exec_suspend.c b/tests/i915/gem_exec_suspend.c
index 43c52d10..b44af299 100644
--- a/tests/i915/gem_exec_suspend.c
+++ b/tests/i915/gem_exec_suspend.c
@@ -73,14 +73,9 @@ static void test_all(int fd, unsigned flags)
 
 static bool has_semaphores(int fd)
 {
-	struct drm_i915_getparam gp;
 	int val = -1;
 
-	memset(&gp, 0, sizeof(gp));
-	gp.param = I915_PARAM_HAS_SEMAPHORES;
-	gp.value = &val;
-
-	drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+	val = drm_get_param(fd, I915_PARAM_HAS_SEMAPHORES);
 	errno = 0;
 
 	return val > 0;
diff --git a/tests/i915/gem_mmap_gtt.c b/tests/i915/gem_mmap_gtt.c
index f6353555..ad2befc3 100644
--- a/tests/i915/gem_mmap_gtt.c
+++ b/tests/i915/gem_mmap_gtt.c
@@ -312,12 +312,9 @@ test_write_gtt(int fd)
 static bool is_coherent(int i915)
 {
 	int val = 1; /* by default, we assume GTT is coherent, hence the test */
-	struct drm_i915_getparam gp = {
-		gp.param = 52, /* GTT_COHERENT */
-		gp.value = &val,
-	};
 
-	ioctl(i915, DRM_IOCTL_I915_GETPARAM, &gp);
+	val = drm_get_param(fd, 52); /* GTT_COHERENT */
+
 	return val;
 }
 
diff --git a/tests/i915/gem_mmap_wc.c b/tests/i915/gem_mmap_wc.c
index 110883eb..73b2166b 100644
--- a/tests/i915/gem_mmap_wc.c
+++ b/tests/i915/gem_mmap_wc.c
@@ -85,7 +85,6 @@ create_pointer(int fd)
 static void
 test_invalid_flags(int fd)
 {
-	struct drm_i915_getparam gp;
 	struct local_i915_gem_mmap_v2 arg;
 	uint64_t flag = I915_MMAP_WC;
 	int val = -1;
@@ -95,12 +94,8 @@ test_invalid_flags(int fd)
 	arg.offset = 0;
 	arg.size = 4096;
 
-	memset(&gp, 0, sizeof(gp));
-	gp.param = 30; /* MMAP_VERSION */
-	gp.value = &val;
-
 	/* Do we have the new mmap_ioctl? */
-	drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+	val = drm_get_param(fd, 30); /* MMAP_VERSION */
 
 	if (val >= 1) {
 		/*
diff --git a/tests/i915/hangman.c b/tests/i915/hangman.c
index 6ddae491..09316226 100644
--- a/tests/i915/hangman.c
+++ b/tests/i915/hangman.c
@@ -112,11 +112,8 @@ static FILE *open_error(void)
 static bool uses_cmd_parser(void)
 {
 	int parser_version = 0;
-	drm_i915_getparam_t gp;
 
-	gp.param = I915_PARAM_CMD_PARSER_VERSION;
-	gp.value = &parser_version;
-	drmIoctl(device, DRM_IOCTL_I915_GETPARAM, &gp);
+	parser_version = drm_get_param(device, I915_PARAM_CMD_PARSER_VERSION);
 
 	return parser_version > 0;
 }
diff --git a/tests/prime_vgem.c b/tests/prime_vgem.c
index 60bb951c..77c47de6 100644
--- a/tests/prime_vgem.c
+++ b/tests/prime_vgem.c
@@ -266,12 +266,9 @@ static void test_shrink(int vgem, int i915)
 static bool is_coherent(int i915)
 {
 	int val = 1; /* by default, we assume GTT is coherent, hence the test */
-	struct drm_i915_getparam gp = {
-		gp.param = 52, /* GTT_COHERENT */
-		gp.value = &val,
-	};
 
-	ioctl(i915, DRM_IOCTL_I915_GETPARAM, &gp);
+	val = drm_get_param(fd, 52); /* GTT_COHERENT */
+
 	return val;
 }
 
-- 
2.17.2

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

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

* [igt-dev] [PATCH i-g-t 3/3] lib: Use drm_get_param where it is applicable
  2018-11-23 14:27 [igt-dev] [PATCH i-g-t 1/3] lib/ioctl_wrapper: Add i915_get_param helper Lukasz Kalamarz
  2018-11-23 14:27 ` [igt-dev] [PATCH i-g-t 2/3] tests: Use drm_get_param where applicable Lukasz Kalamarz
@ 2018-11-23 14:27 ` Lukasz Kalamarz
  2018-11-23 14:56 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/3] lib/ioctl_wrapper: Add i915_get_param helper Patchwork
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Lukasz Kalamarz @ 2018-11-23 14:27 UTC (permalink / raw)
  To: igt-dev

With usage of implemented drm_get_param helper function, we can
remove some duplicated code lines across few libs.

Signed-off-by: Lukasz Kalamarz <lukasz.kalamarz@intel.com>

Cc: Michal Winiarski <michal.winiarski@intel.com>
Cc: Katarzyna Dec <katarzyna.dec@intel.com>
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
---
 lib/drmtest.c             |  7 ++---
 lib/i915/gem_scheduler.c  |  8 +----
 lib/i915/gem_submission.c | 10 +++---
 lib/igt_gt.c              |  7 ++---
 lib/intel_chipset.c       |  6 +---
 lib/ioctl_wrappers.c      | 65 ++++++---------------------------------
 6 files changed, 21 insertions(+), 82 deletions(-)

diff --git a/lib/drmtest.c b/lib/drmtest.c
index fee9d33a..81383fd4 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -107,14 +107,11 @@ bool is_i915_device(int fd)
 
 static bool has_known_intel_chipset(int fd)
 {
-	struct drm_i915_getparam gp;
 	int devid = 0;
 
-	memset(&gp, 0, sizeof(gp));
-	gp.param = I915_PARAM_CHIPSET_ID;
-	gp.value = &devid;
+	devid = drm_get_param(fd, I915_PARAM_CHIPSET_ID);
 
-	if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp)))
+	if (devid <= 0)
 		return false;
 
 	if (!intel_gen(devid))
diff --git a/lib/i915/gem_scheduler.c b/lib/i915/gem_scheduler.c
index ad156306..7366c8eb 100644
--- a/lib/i915/gem_scheduler.c
+++ b/lib/i915/gem_scheduler.c
@@ -52,14 +52,8 @@ unsigned gem_scheduler_capability(int fd)
 	static int caps = -1;
 
 	if (caps < 0) {
-		struct drm_i915_getparam gp;
-
-		memset(&gp, 0, sizeof(gp));
-		gp.param = LOCAL_I915_PARAM_HAS_SCHEDULER;
-		gp.value = &caps;
-
 		caps = 0;
-		ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));
+		caps = drm_get_params(fd, LOCAL_I915_PARAM_HAS_SCHEDULER);
 		errno = 0;
 	}
 
diff --git a/lib/i915/gem_submission.c b/lib/i915/gem_submission.c
index 2fd460d5..d6bc80e2 100644
--- a/lib/i915/gem_submission.c
+++ b/lib/i915/gem_submission.c
@@ -53,12 +53,12 @@
 static bool has_semaphores(int fd, int dir)
 {
 	int val = 0;
-	struct drm_i915_getparam gp = {
-		gp.param = I915_PARAM_HAS_SEMAPHORES,
-		gp.value = &val,
-	};
-	if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp) < 0)
+
+	val = drm_get_params(fd, I915_PARAM_HAS_SEMAPHORES);
+
+	if (val < 0)
 		val = igt_sysfs_get_boolean(dir, "semaphores");
+
 	return val;
 }
 
diff --git a/lib/igt_gt.c b/lib/igt_gt.c
index a2061924..18cd922b 100644
--- a/lib/igt_gt.c
+++ b/lib/igt_gt.c
@@ -57,14 +57,11 @@ static bool has_gpu_reset(int fd)
 {
 	static int once = -1;
 	if (once < 0) {
-		struct drm_i915_getparam gp;
 		int val = 0;
 
-		memset(&gp, 0, sizeof(gp));
-		gp.param = 35; /* HAS_GPU_RESET */
-		gp.value = &val;
+		val = drm_get_param(fd, 35); /* HAS_GPU_RESET */
 
-		if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp))
+		if (val > 0)
 			once = intel_gen(intel_get_drm_devid(fd)) >= 5;
 		else
 			once = val > 0;
diff --git a/lib/intel_chipset.c b/lib/intel_chipset.c
index 4748a3fb..a9245a90 100644
--- a/lib/intel_chipset.c
+++ b/lib/intel_chipset.c
@@ -125,7 +125,6 @@ intel_get_pci_device(void)
 uint32_t
 intel_get_drm_devid(int fd)
 {
-	struct drm_i915_getparam gp;
 	const char *override;
 	int devid = 0;
 
@@ -135,10 +134,7 @@ intel_get_drm_devid(int fd)
 	if (override)
 		return strtol(override, NULL, 0);
 
-	memset(&gp, 0, sizeof(gp));
-	gp.param = I915_PARAM_CHIPSET_ID;
-	gp.value = &devid;
-	ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));
+	devid = drm_get_param(fd, I915_PARAM_CHIPSET_ID);
 
 	return devid;
 }
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 8fea9fa9..1d4404ee 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -485,16 +485,12 @@ int drm_get_param(int fd, uint32_t param)
 bool gem_create__has_stolen_support(int fd)
 {
 	static int has_stolen_support = -1;
-	struct drm_i915_getparam gp;
 	int val = -1;
 
 	if (has_stolen_support < 0) {
-		memset(&gp, 0, sizeof(gp));
-		gp.param = 38; /* CREATE_VERSION */
-		gp.value = &val;
+		val = drm_get_param(fd, 38); /* CREATE_VERSION */
 
 		/* Do we have the extended gem_create_ioctl? */
-		ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
 		has_stolen_support = val >= 2;
 	}
 
@@ -720,15 +716,8 @@ bool gem_mmap__has_wc(int fd)
 
 		has_wc = 0;
 
-		memset(&gp, 0, sizeof(gp));
-		gp.param = 40; /* MMAP_GTT_VERSION */
-		gp.value = &gtt_version;
-		ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
-
-		memset(&gp, 0, sizeof(gp));
-		gp.param = 30; /* MMAP_VERSION */
-		gp.value = &mmap_version;
-		ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+		gtt_version = drm_get_param(fd, 40); /* MMAP_GTT_VERSION */
+		mmap_version = drm_get_param(fd, 30); /* MMAP_VERSION */
 
 		/* Do we have the new mmap_ioctl with DOMAIN_WC? */
 		if (mmap_version >= 1 && gtt_version >= 2) {
@@ -973,17 +962,11 @@ bool gem_bo_busy(int fd, uint32_t handle)
  */
 static int gem_gtt_type(int fd)
 {
-	struct drm_i915_getparam gp;
 	int val = 0;
 
-	memset(&gp, 0, sizeof(gp));
-	gp.param = 18; /* HAS_ALIASING_PPGTT */
-	gp.value = &val;
-
-	if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp)))
-		return 0;
-
+	val = drm_get_param(fd, 18); /* HAS_ALIASING_PPGTT */
 	errno = 0;
+
 	return val;
 }
 
@@ -1027,13 +1010,9 @@ bool gem_uses_full_ppgtt(int fd)
  */
 int gem_gpu_reset_type(int fd)
 {
-	struct drm_i915_getparam gp;
 	int gpu_reset_type = -1;
 
-	memset(&gp, 0, sizeof(gp));
-	gp.param = I915_PARAM_HAS_GPU_RESET;
-	gp.value = &gpu_reset_type;
-	drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+	gpu_reset_type = drm_get_param(fd, I915_PARAM_HAS_GPU_RESET);
 
 	return gpu_reset_type;
 }
@@ -1081,14 +1060,8 @@ int gem_available_fences(int fd)
 	static int num_fences = -1;
 
 	if (num_fences < 0) {
-		struct drm_i915_getparam gp;
-
-		memset(&gp, 0, sizeof(gp));
-		gp.param = I915_PARAM_NUM_FENCES_AVAIL;
-		gp.value = &num_fences;
-
 		num_fences = 0;
-		ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));
+		num_fences = drm_get_param(fd, I915_PARAM_NUM_FENCES_AVAIL);
 		errno = 0;
 	}
 
@@ -1100,14 +1073,8 @@ bool gem_has_llc(int fd)
 	static int has_llc = -1;
 
 	if (has_llc < 0) {
-		struct drm_i915_getparam gp;
-
-		memset(&gp, 0, sizeof(gp));
-		gp.param = I915_PARAM_HAS_LLC;
-		gp.value = &has_llc;
-
 		has_llc = 0;
-		ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));
+		has_llc = drm_get_param(fd, I915_PARAM_HAS_LLC);
 		errno = 0;
 	}
 
@@ -1357,14 +1324,8 @@ bool gem_has_softpin(int fd)
 	static int has_softpin = -1;
 
 	if (has_softpin < 0) {
-		struct drm_i915_getparam gp;
-
-		memset(&gp, 0, sizeof(gp));
-		gp.param = I915_PARAM_HAS_EXEC_SOFTPIN;
-		gp.value = &has_softpin;
-
 		has_softpin = 0;
-		ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));
+		has_softpin = drm_get_param(fd, I915_PARAM_HAS_EXEC_SOFTPIN);
 		errno = 0;
 	}
 
@@ -1385,14 +1346,8 @@ bool gem_has_exec_fence(int fd)
 	static int has_exec_fence = -1;
 
 	if (has_exec_fence < 0) {
-		struct drm_i915_getparam gp;
-
-		memset(&gp, 0, sizeof(gp));
-		gp.param = I915_PARAM_HAS_EXEC_FENCE;
-		gp.value = &has_exec_fence;
-
 		has_exec_fence = 0;
-		ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));
+		has_exec_fence = drm_get_param(fd, I915_PARAM_HAS_EXEC_FENCE);
 		errno = 0;
 	}
 
-- 
2.17.2

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

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

* [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/3] lib/ioctl_wrapper: Add i915_get_param helper
  2018-11-23 14:27 [igt-dev] [PATCH i-g-t 1/3] lib/ioctl_wrapper: Add i915_get_param helper Lukasz Kalamarz
  2018-11-23 14:27 ` [igt-dev] [PATCH i-g-t 2/3] tests: Use drm_get_param where applicable Lukasz Kalamarz
  2018-11-23 14:27 ` [igt-dev] [PATCH i-g-t 3/3] lib: Use drm_get_param where it is applicable Lukasz Kalamarz
@ 2018-11-23 14:56 ` Patchwork
  2018-11-23 15:25 ` [igt-dev] [PATCH i-g-t v2 1/3] " Lukasz Kalamarz
  2018-11-23 15:37 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,v2,3/3] lib: Use drm_get_param where it is applicable (rev4) Patchwork
  4 siblings, 0 replies; 11+ messages in thread
From: Patchwork @ 2018-11-23 14:56 UTC (permalink / raw)
  To: Lukasz Kalamarz; +Cc: igt-dev

== Series Details ==

Series: series starting with [i-g-t,1/3] lib/ioctl_wrapper: Add i915_get_param helper
URL   : https://patchwork.freedesktop.org/series/52951/
State : failure

== Summary ==

IGT patchset build failed on latest successful build
9dc7c41d1c600133d6e3e63f1941c2e75d23bd3b tests/sw_sync: use igt_fork_helper

ninja: Entering directory `build'
[1/798] Generating version.h with a custom command.
[2/798] Compiling C object 'lib/igt-drmtest_c@sta/drmtest.c.o'.
[3/798] Linking static target lib/libigt-drmtest_c.a.
[4/798] Compiling C object 'lib/igt-i915_gem_context_c@sta/i915_gem_context.c.o'.
[5/798] Linking static target lib/libigt-i915_gem_context_c.a.
[6/798] Compiling C object 'lib/igt-i915_gem_scheduler_c@sta/i915_gem_scheduler.c.o'.
FAILED: lib/igt-i915_gem_scheduler_c@sta/i915_gem_scheduler.c.o 
ccache cc  -Ilib/igt-i915_gem_scheduler_c@sta -Ilib -I../lib -I. -I../ -I../lib/stubs/syscalls -I../include/drm-uapi -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/opt/igt/include -I/opt/igt/include/libdrm -I/usr/include/x86_64-linux-gnu -I/usr/include -I/home/cidrm/kernel_headers/include -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O0 -g -D_GNU_SOURCE -include config.h -Wbad-function-cast -Wdeclaration-after-statement -Wformat=2 -Wimplicit-fallthrough=0 -Wlogical-op -Wmissing-declarations -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-prototypes -Wuninitialized -Wunused -Wno-clobbered -Wno-maybe-uninitialized -Wno-missing-field-initializers -Wno-pointer-arith -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter -Wno-unused-result -Werror=address -Werror=array-bounds -Werror=implicit -Werror=init-self -Werror=int-to-pointer-cast -Werror=main -Werror=missing-braces -Werror=nonnull -Werror=pointer-to-int-cast -Werror=return-type -Werror=sequence-point -Werror=trigraphs -Werror=write-strings -fPIC -pthread '-DIGT_DATADIR="/opt/igt/share/igt-gpu-tools"' '-DIGT_SRCDIR="/home/cidrm/igt-gpu-tools/tests"' '-DIGT_LOG_DOMAIN="i915/gem_scheduler"' -MD -MQ 'lib/igt-i915_gem_scheduler_c@sta/i915_gem_scheduler.c.o' -MF 'lib/igt-i915_gem_scheduler_c@sta/i915_gem_scheduler.c.o.d' -o 'lib/igt-i915_gem_scheduler_c@sta/i915_gem_scheduler.c.o' -c ../lib/i915/gem_scheduler.c
../lib/i915/gem_scheduler.c: In function ‘gem_scheduler_capability’:
../lib/i915/gem_scheduler.c:56:10: error: implicit declaration of function ‘drm_get_params’; did you mean ‘drm_get_param’? [-Werror=implicit-function-declaration]
   caps = drm_get_params(fd, LOCAL_I915_PARAM_HAS_SCHEDULER);
          ^~~~~~~~~~~~~~
          drm_get_param
../lib/i915/gem_scheduler.c:56:10: warning: nested extern declaration of ‘drm_get_params’ [-Wnested-externs]
cc1: some warnings being treated as errors
ninja: build stopped: subcommand failed.

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

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

* [igt-dev] [PATCH i-g-t v2 1/3] lib/ioctl_wrapper: Add i915_get_param helper
  2018-11-23 14:27 [igt-dev] [PATCH i-g-t 1/3] lib/ioctl_wrapper: Add i915_get_param helper Lukasz Kalamarz
                   ` (2 preceding siblings ...)
  2018-11-23 14:56 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/3] lib/ioctl_wrapper: Add i915_get_param helper Patchwork
@ 2018-11-23 15:25 ` Lukasz Kalamarz
  2018-11-23 15:25   ` [igt-dev] [PATCH i-g-t v2 2/3] tests: Use drm_get_param where applicable Lukasz Kalamarz
                     ` (3 more replies)
  2018-11-23 15:37 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,v2,3/3] lib: Use drm_get_param where it is applicable (rev4) Patchwork
  4 siblings, 4 replies; 11+ messages in thread
From: Lukasz Kalamarz @ 2018-11-23 15:25 UTC (permalink / raw)
  To: igt-dev

getparam is used in few places across IGT, but no helper function
is used to reduce code duplication.

Signed-off-by: Lukasz Kalamarz <lukasz.kalamarz@intel.com>

Cc: Michal Winiarski <michal.winiarski@intel.com>
Cc: Katarzyna Dec <katarzyna.dec@intel.com>
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
---
 lib/ioctl_wrappers.c | 13 +++++++++++++
 lib/ioctl_wrappers.h |  1 +
 2 files changed, 14 insertions(+)

diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 9f255508..8fea9fa9 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -468,6 +468,19 @@ void gem_sync(int fd, uint32_t handle)
 	errno = 0;
 }
 
+int drm_get_param(int fd, uint32_t param)
+{
+	int value;
+	drm_i915_getparam_t gp = {
+		.param = param,
+		.value = &value
+	};
+
+	if (igt_ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp) == -1)
+		return NULL;
+
+	return value;
+}
 
 bool gem_create__has_stolen_support(int fd)
 {
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index b22b36b0..90174d13 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -74,6 +74,7 @@ int __gem_set_domain(int fd, uint32_t handle, uint32_t read, uint32_t write);
 void gem_set_domain(int fd, uint32_t handle, uint32_t read, uint32_t write);
 int gem_wait(int fd, uint32_t handle, int64_t *timeout_ns);
 void gem_sync(int fd, uint32_t handle);
+int drm_get_param(int fd, uint32_t param);
 bool gem_create__has_stolen_support(int fd);
 uint32_t __gem_create_stolen(int fd, uint64_t size);
 uint32_t gem_create_stolen(int fd, uint64_t size);
-- 
2.17.2

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

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

* [igt-dev] [PATCH i-g-t v2 2/3] tests: Use drm_get_param where applicable
  2018-11-23 15:25 ` [igt-dev] [PATCH i-g-t v2 1/3] " Lukasz Kalamarz
@ 2018-11-23 15:25   ` Lukasz Kalamarz
  2018-11-23 15:25   ` [igt-dev] [PATCH i-g-t v2 3/3] lib: Use drm_get_param where it is applicable Lukasz Kalamarz
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 11+ messages in thread
From: Lukasz Kalamarz @ 2018-11-23 15:25 UTC (permalink / raw)
  To: igt-dev

Across several tests we check values of a given parameters.
With implementation of drm_get_param we can drop duplicated
lines and use helper function instead.
v2: Fixed errors in argument (fd are named as i915)

Signed-off-by: Lukasz Kalamarz <lukasz.kalamarz@intel.com>

Cc: Michal Winiarski <michal.winiarski@intel.com>
Cc: Katarzyna Dec <katarzyna.dec@intel.com>
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
---
 tests/i915/gem_busy.c          |  8 ++------
 tests/i915/gem_cs_tlb.c        | 10 ++--------
 tests/i915/gem_ctx_isolation.c |  7 +------
 tests/i915/gem_exec_async.c    |  6 ++----
 tests/i915/gem_exec_capture.c  |  5 +----
 tests/i915/gem_exec_fence.c    | 14 ++------------
 tests/i915/gem_exec_flush.c    |  5 +----
 tests/i915/gem_exec_params.c   | 16 ++++++----------
 tests/i915/gem_exec_parse.c    |  7 ++-----
 tests/i915/gem_exec_suspend.c  |  7 +------
 tests/i915/gem_mmap_gtt.c      |  7 ++-----
 tests/i915/gem_mmap_wc.c       |  7 +------
 tests/i915/hangman.c           |  5 +----
 tests/prime_vgem.c             |  7 ++-----
 14 files changed, 26 insertions(+), 85 deletions(-)

diff --git a/tests/i915/gem_busy.c b/tests/i915/gem_busy.c
index 76b44a5d..6cc8e45b 100644
--- a/tests/i915/gem_busy.c
+++ b/tests/i915/gem_busy.c
@@ -28,6 +28,7 @@
 #include "igt.h"
 #include "igt_rand.h"
 #include "igt_vgem.h"
+#include "ioctl_wrappers.h"
 #include "i915/gem_ring.h"
 
 #define LOCAL_EXEC_NO_RELOC (1<<11)
@@ -401,14 +402,9 @@ static void close_race(int fd)
 
 static bool has_semaphores(int fd)
 {
-	struct drm_i915_getparam gp;
 	int val = -1;
 
-	memset(&gp, 0, sizeof(gp));
-	gp.param = I915_PARAM_HAS_SEMAPHORES;
-	gp.value = &val;
-
-	drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+	val = drm_get_param(fd, I915_PARAM_HAS_SEMAPHORES);
 	errno = 0;
 
 	return val > 0;
diff --git a/tests/i915/gem_cs_tlb.c b/tests/i915/gem_cs_tlb.c
index 51e1c4e1..891cd551 100644
--- a/tests/i915/gem_cs_tlb.c
+++ b/tests/i915/gem_cs_tlb.c
@@ -58,17 +58,11 @@ IGT_TEST_DESCRIPTION("Check whether we correctly invalidate the cs tlb.");
 
 static bool has_softpin(int fd)
 {
-	struct drm_i915_getparam gp;
 	int val = 0;
 
-	memset(&gp, 0, sizeof(gp));
-	gp.param = 37; /* I915_PARAM_HAS_EXEC_SOFTPIN */
-	gp.value = &val;
-
-	if (drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp))
-		return 0;
-
+	val = drm_get_param(fd, 37); /* I915_PARAM_HAS_EXEC_SOFTPIN */
 	errno = 0;
+
 	return (val == 1);
 }
 
diff --git a/tests/i915/gem_ctx_isolation.c b/tests/i915/gem_ctx_isolation.c
index 058cf3ec..27c8429d 100644
--- a/tests/i915/gem_ctx_isolation.c
+++ b/tests/i915/gem_ctx_isolation.c
@@ -671,14 +671,9 @@ static void preservation(int fd,
 
 static unsigned int __has_context_isolation(int fd)
 {
-	struct drm_i915_getparam gp;
 	int value = 0;
 
-	memset(&gp, 0, sizeof(gp));
-	gp.param = 50; /* I915_PARAM_HAS_CONTEXT_ISOLATION */
-	gp.value = &value;
-
-	igt_ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+	value = drm_get_param(fd, 50); /* I915_PARAM_HAS_CONTEXT_ISOLATION */
 	errno = 0;
 
 	return value;
diff --git a/tests/i915/gem_exec_async.c b/tests/i915/gem_exec_async.c
index 9a06af7e..6b5a5d25 100644
--- a/tests/i915/gem_exec_async.c
+++ b/tests/i915/gem_exec_async.c
@@ -22,6 +22,7 @@
  */
 
 #include "igt.h"
+#include "ioctl_wrappers.h"
 
 #define LOCAL_OBJECT_ASYNC (1 << 6)
 #define LOCAL_PARAM_HAS_EXEC_ASYNC 43
@@ -173,12 +174,9 @@ static void one(int fd, unsigned ring, uint32_t flags)
 
 static bool has_async_execbuf(int fd)
 {
-	drm_i915_getparam_t gp;
 	int async = -1;
 
-	gp.param = LOCAL_PARAM_HAS_EXEC_ASYNC;
-	gp.value = &async;
-	drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+	async = drm_get_param(fd, LOCAL_PARAM_HAS_EXEC_ASYNC);
 
 	return async > 0;
 }
diff --git a/tests/i915/gem_exec_capture.c b/tests/i915/gem_exec_capture.c
index 3e4a4377..72cf8ef4 100644
--- a/tests/i915/gem_exec_capture.c
+++ b/tests/i915/gem_exec_capture.c
@@ -189,12 +189,9 @@ static void userptr(int fd, int dir)
 
 static bool has_capture(int fd)
 {
-	drm_i915_getparam_t gp;
 	int async = -1;
 
-	gp.param = LOCAL_PARAM_HAS_EXEC_CAPTURE;
-	gp.value = &async;
-	drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+	async = drm_get_param(fd, LOCAL_PARAM_HAS_EXEC_CAPTURE);
 
 	return async > 0;
 }
diff --git a/tests/i915/gem_exec_fence.c b/tests/i915/gem_exec_fence.c
index ba46595d..ee143a5f 100644
--- a/tests/i915/gem_exec_fence.c
+++ b/tests/i915/gem_exec_fence.c
@@ -803,14 +803,9 @@ static void test_fence_flip(int i915)
 
 static bool has_submit_fence(int fd)
 {
-	struct drm_i915_getparam gp;
 	int value = 0;
 
-	memset(&gp, 0, sizeof(gp));
-	gp.param = 0xdeadbeef ^ 51; /* I915_PARAM_HAS_EXEC_SUBMIT_FENCE */
-	gp.value = &value;
-
-	ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));
+	value = drm_get_param(fd, 0xdeadbeef ^ 51); /* I915_PARAM_HAS_EXEC_SUBMIT_FENCE */
 	errno = 0;
 
 	return value;
@@ -825,14 +820,9 @@ static bool has_syncobj(int fd)
 
 static bool exec_has_fence_array(int fd)
 {
-	struct drm_i915_getparam gp;
 	int value = 0;
 
-	memset(&gp, 0, sizeof(gp));
-	gp.param = 49; /* I915_PARAM_HAS_EXEC_FENCE_ARRAY */
-	gp.value = &value;
-
-	ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));
+	value = drm_get_param(fd, 49); /* I915_PARAM_HAS_EXEC_FENCE_ARRAY */
 	errno = 0;
 
 	return value;
diff --git a/tests/i915/gem_exec_flush.c b/tests/i915/gem_exec_flush.c
index f820b2a8..bdc9257d 100644
--- a/tests/i915/gem_exec_flush.c
+++ b/tests/i915/gem_exec_flush.c
@@ -359,11 +359,8 @@ static void batch(int fd, unsigned ring, int nchild, int timeout,
 
 	if (flags & CMDPARSER) {
 		int cmdparser = -1;
-                drm_i915_getparam_t gp;
 
-		gp.param = I915_PARAM_CMD_PARSER_VERSION;
-		gp.value = &cmdparser;
-		drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+		cmdparser = drm_get_param(fd, I915_PARAM_CMD_PARSER_VERSION);
 		igt_require(cmdparser > 0);
 	}
 
diff --git a/tests/i915/gem_exec_params.c b/tests/i915/gem_exec_params.c
index 49c56a8d..5f443961 100644
--- a/tests/i915/gem_exec_params.c
+++ b/tests/i915/gem_exec_params.c
@@ -79,22 +79,18 @@ static bool has_ring(int fd, unsigned ring_exec_flags)
 static bool has_exec_batch_first(int fd)
 {
 	int val = -1;
-	struct drm_i915_getparam gp = {
-		.param = 48,
-		.value = &val,
-	};
-	ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+
+	val = drm_get_param(fd, 48);
+
 	return val > 0;
 }
 
 static bool has_resource_streamer(int fd)
 {
 	int val = -1;
-	struct drm_i915_getparam gp = {
-		.param = I915_PARAM_HAS_RESOURCE_STREAMER,
-		.value = &val,
-	};
-	ioctl(fd, DRM_IOCTL_I915_GETPARAM , &gp);
+
+	val = drm_get_param(fd, I915_PARAM_HAS_RESOURCE_STREAMER);
+
 	return val > 0;
 }
 
diff --git a/tests/i915/gem_exec_parse.c b/tests/i915/gem_exec_parse.c
index b653b1bd..15315438 100644
--- a/tests/i915/gem_exec_parse.c
+++ b/tests/i915/gem_exec_parse.c
@@ -61,12 +61,9 @@ static int parser_version;
 static int command_parser_version(int fd)
 {
 	int version = -1;
-	drm_i915_getparam_t gp;
 
-	gp.param = I915_PARAM_CMD_PARSER_VERSION;
-	gp.value = &version;
-
-	if (drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp) == 0)
+	version = drm_get_param(fd, I915_PARAM_CMD_PARSER_VERSION);
+	if (version >= 1)
 		return version;
 
 	return -1;
diff --git a/tests/i915/gem_exec_suspend.c b/tests/i915/gem_exec_suspend.c
index 43c52d10..b44af299 100644
--- a/tests/i915/gem_exec_suspend.c
+++ b/tests/i915/gem_exec_suspend.c
@@ -73,14 +73,9 @@ static void test_all(int fd, unsigned flags)
 
 static bool has_semaphores(int fd)
 {
-	struct drm_i915_getparam gp;
 	int val = -1;
 
-	memset(&gp, 0, sizeof(gp));
-	gp.param = I915_PARAM_HAS_SEMAPHORES;
-	gp.value = &val;
-
-	drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+	val = drm_get_param(fd, I915_PARAM_HAS_SEMAPHORES);
 	errno = 0;
 
 	return val > 0;
diff --git a/tests/i915/gem_mmap_gtt.c b/tests/i915/gem_mmap_gtt.c
index f6353555..396694e6 100644
--- a/tests/i915/gem_mmap_gtt.c
+++ b/tests/i915/gem_mmap_gtt.c
@@ -312,12 +312,9 @@ test_write_gtt(int fd)
 static bool is_coherent(int i915)
 {
 	int val = 1; /* by default, we assume GTT is coherent, hence the test */
-	struct drm_i915_getparam gp = {
-		gp.param = 52, /* GTT_COHERENT */
-		gp.value = &val,
-	};
 
-	ioctl(i915, DRM_IOCTL_I915_GETPARAM, &gp);
+	val = drm_get_param(i915, 52); /* GTT_COHERENT */
+
 	return val;
 }
 
diff --git a/tests/i915/gem_mmap_wc.c b/tests/i915/gem_mmap_wc.c
index 110883eb..73b2166b 100644
--- a/tests/i915/gem_mmap_wc.c
+++ b/tests/i915/gem_mmap_wc.c
@@ -85,7 +85,6 @@ create_pointer(int fd)
 static void
 test_invalid_flags(int fd)
 {
-	struct drm_i915_getparam gp;
 	struct local_i915_gem_mmap_v2 arg;
 	uint64_t flag = I915_MMAP_WC;
 	int val = -1;
@@ -95,12 +94,8 @@ test_invalid_flags(int fd)
 	arg.offset = 0;
 	arg.size = 4096;
 
-	memset(&gp, 0, sizeof(gp));
-	gp.param = 30; /* MMAP_VERSION */
-	gp.value = &val;
-
 	/* Do we have the new mmap_ioctl? */
-	drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+	val = drm_get_param(fd, 30); /* MMAP_VERSION */
 
 	if (val >= 1) {
 		/*
diff --git a/tests/i915/hangman.c b/tests/i915/hangman.c
index 6ddae491..09316226 100644
--- a/tests/i915/hangman.c
+++ b/tests/i915/hangman.c
@@ -112,11 +112,8 @@ static FILE *open_error(void)
 static bool uses_cmd_parser(void)
 {
 	int parser_version = 0;
-	drm_i915_getparam_t gp;
 
-	gp.param = I915_PARAM_CMD_PARSER_VERSION;
-	gp.value = &parser_version;
-	drmIoctl(device, DRM_IOCTL_I915_GETPARAM, &gp);
+	parser_version = drm_get_param(device, I915_PARAM_CMD_PARSER_VERSION);
 
 	return parser_version > 0;
 }
diff --git a/tests/prime_vgem.c b/tests/prime_vgem.c
index 60bb951c..759299da 100644
--- a/tests/prime_vgem.c
+++ b/tests/prime_vgem.c
@@ -266,12 +266,9 @@ static void test_shrink(int vgem, int i915)
 static bool is_coherent(int i915)
 {
 	int val = 1; /* by default, we assume GTT is coherent, hence the test */
-	struct drm_i915_getparam gp = {
-		gp.param = 52, /* GTT_COHERENT */
-		gp.value = &val,
-	};
 
-	ioctl(i915, DRM_IOCTL_I915_GETPARAM, &gp);
+	val = drm_get_param(i915, 52); /* GTT_COHERENT */
+
 	return val;
 }
 
-- 
2.17.2

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

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

* [igt-dev] [PATCH i-g-t v2 3/3] lib: Use drm_get_param where it is applicable
  2018-11-23 15:25 ` [igt-dev] [PATCH i-g-t v2 1/3] " Lukasz Kalamarz
  2018-11-23 15:25   ` [igt-dev] [PATCH i-g-t v2 2/3] tests: Use drm_get_param where applicable Lukasz Kalamarz
@ 2018-11-23 15:25   ` Lukasz Kalamarz
  2018-11-26  9:11     ` Katarzyna Dec
  2018-11-26  6:18   ` [igt-dev] [PATCH i-g-t v2 1/3] lib/ioctl_wrapper: Add i915_get_param helper Katarzyna Dec
  2018-11-26 12:58   ` Petri Latvala
  3 siblings, 1 reply; 11+ messages in thread
From: Lukasz Kalamarz @ 2018-11-23 15:25 UTC (permalink / raw)
  To: igt-dev

With usage of implemented drm_get_param helper function, we can
remove some duplicated code lines across few libs.

v2: Fix typos and missing include

Signed-off-by: Lukasz Kalamarz <lukasz.kalamarz@intel.com>

Cc: Michal Winiarski <michal.winiarski@intel.com>
Cc: Katarzyna Dec <katarzyna.dec@intel.com>
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
---
 lib/drmtest.c             |  7 ++---
 lib/i915/gem_scheduler.c  |  8 +----
 lib/i915/gem_submission.c | 10 +++---
 lib/igt_gt.c              |  7 ++---
 lib/intel_chipset.c       |  7 ++---
 lib/ioctl_wrappers.c      | 65 ++++++---------------------------------
 6 files changed, 22 insertions(+), 82 deletions(-)

diff --git a/lib/drmtest.c b/lib/drmtest.c
index fee9d33a..81383fd4 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -107,14 +107,11 @@ bool is_i915_device(int fd)
 
 static bool has_known_intel_chipset(int fd)
 {
-	struct drm_i915_getparam gp;
 	int devid = 0;
 
-	memset(&gp, 0, sizeof(gp));
-	gp.param = I915_PARAM_CHIPSET_ID;
-	gp.value = &devid;
+	devid = drm_get_param(fd, I915_PARAM_CHIPSET_ID);
 
-	if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp)))
+	if (devid <= 0)
 		return false;
 
 	if (!intel_gen(devid))
diff --git a/lib/i915/gem_scheduler.c b/lib/i915/gem_scheduler.c
index ad156306..079559a2 100644
--- a/lib/i915/gem_scheduler.c
+++ b/lib/i915/gem_scheduler.c
@@ -52,14 +52,8 @@ unsigned gem_scheduler_capability(int fd)
 	static int caps = -1;
 
 	if (caps < 0) {
-		struct drm_i915_getparam gp;
-
-		memset(&gp, 0, sizeof(gp));
-		gp.param = LOCAL_I915_PARAM_HAS_SCHEDULER;
-		gp.value = &caps;
-
 		caps = 0;
-		ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));
+		caps = drm_get_param(fd, LOCAL_I915_PARAM_HAS_SCHEDULER);
 		errno = 0;
 	}
 
diff --git a/lib/i915/gem_submission.c b/lib/i915/gem_submission.c
index 2fd460d5..583bb133 100644
--- a/lib/i915/gem_submission.c
+++ b/lib/i915/gem_submission.c
@@ -53,12 +53,12 @@
 static bool has_semaphores(int fd, int dir)
 {
 	int val = 0;
-	struct drm_i915_getparam gp = {
-		gp.param = I915_PARAM_HAS_SEMAPHORES,
-		gp.value = &val,
-	};
-	if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp) < 0)
+
+	val = drm_get_param(fd, I915_PARAM_HAS_SEMAPHORES);
+
+	if (val < 0)
 		val = igt_sysfs_get_boolean(dir, "semaphores");
+
 	return val;
 }
 
diff --git a/lib/igt_gt.c b/lib/igt_gt.c
index a2061924..18cd922b 100644
--- a/lib/igt_gt.c
+++ b/lib/igt_gt.c
@@ -57,14 +57,11 @@ static bool has_gpu_reset(int fd)
 {
 	static int once = -1;
 	if (once < 0) {
-		struct drm_i915_getparam gp;
 		int val = 0;
 
-		memset(&gp, 0, sizeof(gp));
-		gp.param = 35; /* HAS_GPU_RESET */
-		gp.value = &val;
+		val = drm_get_param(fd, 35); /* HAS_GPU_RESET */
 
-		if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp))
+		if (val > 0)
 			once = intel_gen(intel_get_drm_devid(fd)) >= 5;
 		else
 			once = val > 0;
diff --git a/lib/intel_chipset.c b/lib/intel_chipset.c
index 4748a3fb..da354fb6 100644
--- a/lib/intel_chipset.c
+++ b/lib/intel_chipset.c
@@ -41,6 +41,7 @@
 #include "drmtest.h"
 #include "intel_chipset.h"
 #include "igt_core.h"
+#include "ioctl_wrappers.h"
 
 /**
  * SECTION:intel_chipset
@@ -125,7 +126,6 @@ intel_get_pci_device(void)
 uint32_t
 intel_get_drm_devid(int fd)
 {
-	struct drm_i915_getparam gp;
 	const char *override;
 	int devid = 0;
 
@@ -135,10 +135,7 @@ intel_get_drm_devid(int fd)
 	if (override)
 		return strtol(override, NULL, 0);
 
-	memset(&gp, 0, sizeof(gp));
-	gp.param = I915_PARAM_CHIPSET_ID;
-	gp.value = &devid;
-	ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));
+	devid = drm_get_param(fd, I915_PARAM_CHIPSET_ID);
 
 	return devid;
 }
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 8fea9fa9..1d4404ee 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -485,16 +485,12 @@ int drm_get_param(int fd, uint32_t param)
 bool gem_create__has_stolen_support(int fd)
 {
 	static int has_stolen_support = -1;
-	struct drm_i915_getparam gp;
 	int val = -1;
 
 	if (has_stolen_support < 0) {
-		memset(&gp, 0, sizeof(gp));
-		gp.param = 38; /* CREATE_VERSION */
-		gp.value = &val;
+		val = drm_get_param(fd, 38); /* CREATE_VERSION */
 
 		/* Do we have the extended gem_create_ioctl? */
-		ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
 		has_stolen_support = val >= 2;
 	}
 
@@ -720,15 +716,8 @@ bool gem_mmap__has_wc(int fd)
 
 		has_wc = 0;
 
-		memset(&gp, 0, sizeof(gp));
-		gp.param = 40; /* MMAP_GTT_VERSION */
-		gp.value = &gtt_version;
-		ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
-
-		memset(&gp, 0, sizeof(gp));
-		gp.param = 30; /* MMAP_VERSION */
-		gp.value = &mmap_version;
-		ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+		gtt_version = drm_get_param(fd, 40); /* MMAP_GTT_VERSION */
+		mmap_version = drm_get_param(fd, 30); /* MMAP_VERSION */
 
 		/* Do we have the new mmap_ioctl with DOMAIN_WC? */
 		if (mmap_version >= 1 && gtt_version >= 2) {
@@ -973,17 +962,11 @@ bool gem_bo_busy(int fd, uint32_t handle)
  */
 static int gem_gtt_type(int fd)
 {
-	struct drm_i915_getparam gp;
 	int val = 0;
 
-	memset(&gp, 0, sizeof(gp));
-	gp.param = 18; /* HAS_ALIASING_PPGTT */
-	gp.value = &val;
-
-	if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp)))
-		return 0;
-
+	val = drm_get_param(fd, 18); /* HAS_ALIASING_PPGTT */
 	errno = 0;
+
 	return val;
 }
 
@@ -1027,13 +1010,9 @@ bool gem_uses_full_ppgtt(int fd)
  */
 int gem_gpu_reset_type(int fd)
 {
-	struct drm_i915_getparam gp;
 	int gpu_reset_type = -1;
 
-	memset(&gp, 0, sizeof(gp));
-	gp.param = I915_PARAM_HAS_GPU_RESET;
-	gp.value = &gpu_reset_type;
-	drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+	gpu_reset_type = drm_get_param(fd, I915_PARAM_HAS_GPU_RESET);
 
 	return gpu_reset_type;
 }
@@ -1081,14 +1060,8 @@ int gem_available_fences(int fd)
 	static int num_fences = -1;
 
 	if (num_fences < 0) {
-		struct drm_i915_getparam gp;
-
-		memset(&gp, 0, sizeof(gp));
-		gp.param = I915_PARAM_NUM_FENCES_AVAIL;
-		gp.value = &num_fences;
-
 		num_fences = 0;
-		ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));
+		num_fences = drm_get_param(fd, I915_PARAM_NUM_FENCES_AVAIL);
 		errno = 0;
 	}
 
@@ -1100,14 +1073,8 @@ bool gem_has_llc(int fd)
 	static int has_llc = -1;
 
 	if (has_llc < 0) {
-		struct drm_i915_getparam gp;
-
-		memset(&gp, 0, sizeof(gp));
-		gp.param = I915_PARAM_HAS_LLC;
-		gp.value = &has_llc;
-
 		has_llc = 0;
-		ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));
+		has_llc = drm_get_param(fd, I915_PARAM_HAS_LLC);
 		errno = 0;
 	}
 
@@ -1357,14 +1324,8 @@ bool gem_has_softpin(int fd)
 	static int has_softpin = -1;
 
 	if (has_softpin < 0) {
-		struct drm_i915_getparam gp;
-
-		memset(&gp, 0, sizeof(gp));
-		gp.param = I915_PARAM_HAS_EXEC_SOFTPIN;
-		gp.value = &has_softpin;
-
 		has_softpin = 0;
-		ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));
+		has_softpin = drm_get_param(fd, I915_PARAM_HAS_EXEC_SOFTPIN);
 		errno = 0;
 	}
 
@@ -1385,14 +1346,8 @@ bool gem_has_exec_fence(int fd)
 	static int has_exec_fence = -1;
 
 	if (has_exec_fence < 0) {
-		struct drm_i915_getparam gp;
-
-		memset(&gp, 0, sizeof(gp));
-		gp.param = I915_PARAM_HAS_EXEC_FENCE;
-		gp.value = &has_exec_fence;
-
 		has_exec_fence = 0;
-		ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));
+		has_exec_fence = drm_get_param(fd, I915_PARAM_HAS_EXEC_FENCE);
 		errno = 0;
 	}
 
-- 
2.17.2

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

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

* [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,v2,3/3] lib: Use drm_get_param where it is applicable (rev4)
  2018-11-23 14:27 [igt-dev] [PATCH i-g-t 1/3] lib/ioctl_wrapper: Add i915_get_param helper Lukasz Kalamarz
                   ` (3 preceding siblings ...)
  2018-11-23 15:25 ` [igt-dev] [PATCH i-g-t v2 1/3] " Lukasz Kalamarz
@ 2018-11-23 15:37 ` Patchwork
  4 siblings, 0 replies; 11+ messages in thread
From: Patchwork @ 2018-11-23 15:37 UTC (permalink / raw)
  To: Lukasz Kalamarz; +Cc: igt-dev

== Series Details ==

Series: series starting with [i-g-t,v2,3/3] lib: Use drm_get_param where it is applicable (rev4)
URL   : https://patchwork.freedesktop.org/series/52951/
State : failure

== Summary ==

Applying: lib: Use drm_get_param where it is applicable
Applying: tests: Use drm_get_param where applicable
Applying: lib: Use drm_get_param where it is applicable
Using index info to reconstruct a base tree...
M	lib/drmtest.c
M	lib/i915/gem_scheduler.c
M	lib/i915/gem_submission.c
M	lib/igt_gt.c
M	lib/intel_chipset.c
M	lib/ioctl_wrappers.c
Falling back to patching base and 3-way merge...
Auto-merging lib/i915/gem_submission.c
CONFLICT (content): Merge conflict in lib/i915/gem_submission.c
Auto-merging lib/i915/gem_scheduler.c
CONFLICT (content): Merge conflict in lib/i915/gem_scheduler.c
Patch failed at 0003 lib: Use drm_get_param where it is applicable
Use 'git am --show-current-patch' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

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

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

* Re: [igt-dev] [PATCH i-g-t v2 1/3] lib/ioctl_wrapper: Add i915_get_param helper
  2018-11-23 15:25 ` [igt-dev] [PATCH i-g-t v2 1/3] " Lukasz Kalamarz
  2018-11-23 15:25   ` [igt-dev] [PATCH i-g-t v2 2/3] tests: Use drm_get_param where applicable Lukasz Kalamarz
  2018-11-23 15:25   ` [igt-dev] [PATCH i-g-t v2 3/3] lib: Use drm_get_param where it is applicable Lukasz Kalamarz
@ 2018-11-26  6:18   ` Katarzyna Dec
  2018-11-26 12:58   ` Petri Latvala
  3 siblings, 0 replies; 11+ messages in thread
From: Katarzyna Dec @ 2018-11-26  6:18 UTC (permalink / raw)
  To: Lukasz Kalamarz; +Cc: igt-dev

On Fri, Nov 23, 2018 at 04:25:07PM +0100, Lukasz Kalamarz wrote:
> getparam is used in few places across IGT, but no helper function
> is used to reduce code duplication.
> 
> Signed-off-by: Lukasz Kalamarz <lukasz.kalamarz@intel.com>
> 
> Cc: Michal Winiarski <michal.winiarski@intel.com>
> Cc: Katarzyna Dec <katarzyna.dec@intel.com>
> Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
> ---
>  lib/ioctl_wrappers.c | 13 +++++++++++++
>  lib/ioctl_wrappers.h |  1 +
>  2 files changed, 14 insertions(+)
> 
> diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
> index 9f255508..8fea9fa9 100644
> --- a/lib/ioctl_wrappers.c
> +++ b/lib/ioctl_wrappers.c
> @@ -468,6 +468,19 @@ void gem_sync(int fd, uint32_t handle)
>  	errno = 0;
>  }
>  
> +int drm_get_param(int fd, uint32_t param)
> +{
> +	int value;
> +	drm_i915_getparam_t gp = {
> +		.param = param,
> +		.value = &value
> +	};
> +
> +	if (igt_ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp) == -1)
> +		return NULL;
Whole function returns int and here you are returning NULL. Compiler warns 
about it. Maybe -EINVAL or something similar?

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

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

* Re: [igt-dev] [PATCH i-g-t v2 3/3] lib: Use drm_get_param where it is applicable
  2018-11-23 15:25   ` [igt-dev] [PATCH i-g-t v2 3/3] lib: Use drm_get_param where it is applicable Lukasz Kalamarz
@ 2018-11-26  9:11     ` Katarzyna Dec
  0 siblings, 0 replies; 11+ messages in thread
From: Katarzyna Dec @ 2018-11-26  9:11 UTC (permalink / raw)
  To: Lukasz Kalamarz; +Cc: igt-dev

On Fri, Nov 23, 2018 at 04:25:09PM +0100, Lukasz Kalamarz wrote:
> With usage of implemented drm_get_param helper function, we can
> remove some duplicated code lines across few libs.
> 
> v2: Fix typos and missing include

Unfortunately this version is also broken - error on builing.
Kasia
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* Re: [igt-dev] [PATCH i-g-t v2 1/3] lib/ioctl_wrapper: Add i915_get_param helper
  2018-11-23 15:25 ` [igt-dev] [PATCH i-g-t v2 1/3] " Lukasz Kalamarz
                     ` (2 preceding siblings ...)
  2018-11-26  6:18   ` [igt-dev] [PATCH i-g-t v2 1/3] lib/ioctl_wrapper: Add i915_get_param helper Katarzyna Dec
@ 2018-11-26 12:58   ` Petri Latvala
  3 siblings, 0 replies; 11+ messages in thread
From: Petri Latvala @ 2018-11-26 12:58 UTC (permalink / raw)
  To: Lukasz Kalamarz; +Cc: igt-dev

On Fri, Nov 23, 2018 at 04:25:07PM +0100, Lukasz Kalamarz wrote:
> getparam is used in few places across IGT, but no helper function
> is used to reduce code duplication.
> 
> Signed-off-by: Lukasz Kalamarz <lukasz.kalamarz@intel.com>
> 
> Cc: Michal Winiarski <michal.winiarski@intel.com>
> Cc: Katarzyna Dec <katarzyna.dec@intel.com>
> Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
> ---
>  lib/ioctl_wrappers.c | 13 +++++++++++++
>  lib/ioctl_wrappers.h |  1 +
>  2 files changed, 14 insertions(+)
> 
> diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
> index 9f255508..8fea9fa9 100644
> --- a/lib/ioctl_wrappers.c
> +++ b/lib/ioctl_wrappers.c
> @@ -468,6 +468,19 @@ void gem_sync(int fd, uint32_t handle)
>  	errno = 0;
>  }
>  
> +int drm_get_param(int fd, uint32_t param)
> +{
> +	int value;
> +	drm_i915_getparam_t gp = {
> +		.param = param,
> +		.value = &value
> +	};
> +
> +	if (igt_ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp) == -1)
> +		return NULL;
> +
> +	return value;
> +}


Docs would be lovely.


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

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

end of thread, other threads:[~2018-11-26 12:58 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-23 14:27 [igt-dev] [PATCH i-g-t 1/3] lib/ioctl_wrapper: Add i915_get_param helper Lukasz Kalamarz
2018-11-23 14:27 ` [igt-dev] [PATCH i-g-t 2/3] tests: Use drm_get_param where applicable Lukasz Kalamarz
2018-11-23 14:27 ` [igt-dev] [PATCH i-g-t 3/3] lib: Use drm_get_param where it is applicable Lukasz Kalamarz
2018-11-23 14:56 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/3] lib/ioctl_wrapper: Add i915_get_param helper Patchwork
2018-11-23 15:25 ` [igt-dev] [PATCH i-g-t v2 1/3] " Lukasz Kalamarz
2018-11-23 15:25   ` [igt-dev] [PATCH i-g-t v2 2/3] tests: Use drm_get_param where applicable Lukasz Kalamarz
2018-11-23 15:25   ` [igt-dev] [PATCH i-g-t v2 3/3] lib: Use drm_get_param where it is applicable Lukasz Kalamarz
2018-11-26  9:11     ` Katarzyna Dec
2018-11-26  6:18   ` [igt-dev] [PATCH i-g-t v2 1/3] lib/ioctl_wrapper: Add i915_get_param helper Katarzyna Dec
2018-11-26 12:58   ` Petri Latvala
2018-11-23 15:37 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,v2,3/3] lib: Use drm_get_param where it is applicable (rev4) Patchwork

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