All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t v2 0/2] tests/i915-query: new tests for listing perf configurations
@ 2018-06-12 16:37 Lionel Landwerlin
  2018-06-12 16:37 ` [PATCH i-g-t v2 1/2] include: bump i915 header Lionel Landwerlin
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Lionel Landwerlin @ 2018-06-12 16:37 UTC (permalink / raw)
  To: intel-gfx

Hi,

A small update to add query based on configuration uuids.

Cheers,

Lionel Landwerlin (2):
  include: bump i915 header
  tests/i915-query: add new tests for perf configurations queries

 include/drm-uapi/i915_drm.h |  56 +++-
 tests/i915_query.c          | 608 ++++++++++++++++++++++++++++++++++++
 2 files changed, 663 insertions(+), 1 deletion(-)

--
2.17.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* [PATCH i-g-t v2 1/2] include: bump i915 header
  2018-06-12 16:37 [PATCH i-g-t v2 0/2] tests/i915-query: new tests for listing perf configurations Lionel Landwerlin
@ 2018-06-12 16:37 ` Lionel Landwerlin
  2018-06-12 16:37 ` [PATCH i-g-t v2 2/2] tests/i915-query: add new tests for perf configurations queries Lionel Landwerlin
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Lionel Landwerlin @ 2018-06-12 16:37 UTC (permalink / raw)
  To: intel-gfx

---
 include/drm-uapi/i915_drm.h | 56 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 55 insertions(+), 1 deletion(-)

diff --git a/include/drm-uapi/i915_drm.h b/include/drm-uapi/i915_drm.h
index 16e452aa..17f56dcd 100644
--- a/include/drm-uapi/i915_drm.h
+++ b/include/drm-uapi/i915_drm.h
@@ -1620,6 +1620,7 @@ struct drm_i915_perf_oa_config {
 struct drm_i915_query_item {
 	__u64 query_id;
 #define DRM_I915_QUERY_TOPOLOGY_INFO    1
+#define DRM_I915_QUERY_PERF_CONFIG      2
 
 	/*
 	 * When set to zero by userspace, this is filled with the size of the
@@ -1646,9 +1647,18 @@ struct drm_i915_query {
 	__u32 num_items;
 
 	/*
-	 * Unused for now. Must be cleared to zero.
+	 * When query_id == DRM_I915_QUERY_TOPOLOGY_INFO, must be 0.
+	 *
+	 * When query_id == DRM_I915_QUERY_PERF_CONFIG, must be one of the
+	 * following :
+	 *         - DRM_I915_QUERY_PERF_CONFIG_LIST
+	 *         - DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_UUID
+	 *         - DRM_I915_QUERY_PERF_CONFIG_FOR_UUID
 	 */
 	__u32 flags;
+#define DRM_I915_QUERY_PERF_CONFIG_LIST          1
+#define DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_UUID 2
+#define DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_ID   3
 
 	/*
 	 * This points to an array of num_items drm_i915_query_item structures.
@@ -1717,6 +1727,50 @@ struct drm_i915_query_topology_info {
 	__u8 data[];
 };
 
+/*
+ * Data written by the kernel with query DRM_I915_QUERY_PERF_CONFIG.
+ */
+struct drm_i915_query_perf_config {
+	union {
+		/*
+		 * When query_item.flags == DRM_I915_QUERY_PERF_CONFIG_LIST, i915 sets
+		 * this fields to the number of configurations available.
+		 */
+		__u64 n_configs;
+
+		/*
+		 * When query_id == DRM_I915_QUERY_PERF_CONFIG_DATA, i915 will
+		 * use the value in this field as configuration identifier to
+		 * decide what data to write into config_ptr.
+		 */
+		__u64 config;
+
+		/** String formatted like "%08x-%04x-%04x-%04x-%012x" */
+		char uuid[36];
+	};
+
+	/*
+	 * Unused for now. Must be cleared to zero.
+	 */
+	__u32 flags;
+
+	/*
+	 * When query_item.flags == DRM_I915_QUERY_PERF_CONFIG_LIST, i915 will
+	 * write an array of __u64 of configuration identifiers.
+	 *
+	 * When query_item.flags == DRM_I915_QUERY_PERF_CONFIG_DATA, i915 will
+	 * write a struct drm_i915_perf_oa_config. If the following fields of
+	 * drm_i915_perf_oa_config are set not set to 0, i915 will write into
+	 * the associated pointers the values of submitted when the
+	 * configuration was created :
+	 *
+	 *         - n_mux_regs
+	 *         - n_boolean_regs
+	 *         - n_flex_regs
+	 */
+	__u8 data[];
+};
+
 #if defined(__cplusplus)
 }
 #endif
-- 
2.17.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* [PATCH i-g-t v2 2/2] tests/i915-query: add new tests for perf configurations queries
  2018-06-12 16:37 [PATCH i-g-t v2 0/2] tests/i915-query: new tests for listing perf configurations Lionel Landwerlin
  2018-06-12 16:37 ` [PATCH i-g-t v2 1/2] include: bump i915 header Lionel Landwerlin
@ 2018-06-12 16:37 ` Lionel Landwerlin
  2018-06-12 16:53 ` [PATCH i-g-t v2 0/2] tests/i915-query: new tests for listing perf configurations Lionel Landwerlin
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Lionel Landwerlin @ 2018-06-12 16:37 UTC (permalink / raw)
  To: intel-gfx

These new tests allow to list the available configurations and also to
query the data that makes up a configuration.

v2: Verify uuid queries (Lionel)

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
---
 tests/i915_query.c | 608 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 608 insertions(+)

diff --git a/tests/i915_query.c b/tests/i915_query.c
index c7de8cbd..fe2090cf 100644
--- a/tests/i915_query.c
+++ b/tests/i915_query.c
@@ -22,6 +22,7 @@
  */
 
 #include "igt.h"
+#include "igt_sysfs.h"
 
 #include <limits.h>
 
@@ -477,6 +478,598 @@ test_query_topology_known_pci_ids(int fd, int devid)
 	free(topo_info);
 }
 
+static bool query_perf_config_supported(int fd)
+{
+	struct drm_i915_query_item item = {
+		.query_id = DRM_I915_QUERY_PERF_CONFIG,
+		.flags = DRM_I915_QUERY_PERF_CONFIG_LIST,
+	};
+
+	return __i915_query_items(fd, &item, 1) == 0 && item.length > 0;
+}
+
+/*
+ * Verify that perf configuration queries for list of configurations
+ * rejects invalid parameters.
+ */
+static void test_query_perf_config_list_invalid(int fd)
+{
+	struct drm_i915_query_perf_config *query_config_ptr;
+	struct drm_i915_query_item item;
+	size_t len;
+	void *data;
+
+	/* Verify invalid flags for perf config queries */
+	memset(&item, 0, sizeof(item));
+	item.query_id = DRM_I915_QUERY_PERF_CONFIG;
+	item.flags = 42; /* invalid */
+	i915_query_items(fd, &item, 1);
+	igt_assert_eq(item.length, -EINVAL);
+
+	/*
+	 * A too small data length is invalid. We should have at least
+	 * the test config list.
+	 */
+	memset(&item, 0, sizeof(item));
+	item.query_id = DRM_I915_QUERY_PERF_CONFIG;
+	item.flags = DRM_I915_QUERY_PERF_CONFIG_LIST;
+	item.length = sizeof(struct drm_i915_query_perf_config); /* invalid */
+	i915_query_items(fd, &item, 1);
+	igt_assert_eq(item.length, -EINVAL);
+
+	/* Flags on the query config data are invalid. */
+	memset(&item, 0, sizeof(item));
+	item.query_id = DRM_I915_QUERY_PERF_CONFIG;
+	item.flags = DRM_I915_QUERY_PERF_CONFIG_LIST;
+	item.length = 0;
+	i915_query_items(fd, &item, 1);
+	igt_assert(item.length > sizeof(struct drm_i915_query_perf_config));
+
+	query_config_ptr = calloc(1, item.length);
+	query_config_ptr->flags = 1; /* invalid */
+	item.data_ptr = to_user_pointer(query_config_ptr);
+	i915_query_items(fd, &item, 1);
+	igt_assert_eq(item.length, -EINVAL);
+	free(query_config_ptr);
+
+	/*
+	 * A NULL data pointer is invalid when the length is long
+	 * enough for i915 to copy data into the pointed memory.
+	 */
+	memset(&item, 0, sizeof(item));
+	item.query_id = DRM_I915_QUERY_PERF_CONFIG;
+	item.flags = DRM_I915_QUERY_PERF_CONFIG_LIST;
+	item.length = 0;
+	i915_query_items(fd, &item, 1);
+	igt_assert(item.length > sizeof(struct drm_i915_query_perf_config));
+
+	i915_query_items(fd, &item, 1); /* leaves data ptr to null */
+	igt_assert_eq(item.length, -EFAULT);
+
+	/* Trying to write into read only memory will fail. */
+	memset(&item, 0, sizeof(item));
+	item.query_id = DRM_I915_QUERY_PERF_CONFIG;
+	item.flags = DRM_I915_QUERY_PERF_CONFIG_LIST;
+	item.length = 0;
+	i915_query_items(fd, &item, 1);
+	igt_assert(item.length > sizeof(struct drm_i915_query_perf_config));
+
+	len = ALIGN(item.length, 4096);
+	data = mmap(0, len, PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
+	memset(data, 0, len);
+	mprotect(data, len, PROT_READ);
+	item.data_ptr = to_user_pointer(data); /* invalid with read only data */
+	i915_query_items(fd, &item, 1);
+	igt_assert_eq(item.length, -EFAULT);
+
+	munmap(data, len);
+}
+
+static int query_perf_config_id_data(int fd, int length,
+				     struct drm_i915_query_perf_config *query)
+{
+	struct drm_i915_query_item item;
+
+	memset(&item, 0, sizeof(item));
+	item.query_id = DRM_I915_QUERY_PERF_CONFIG;
+	item.flags = DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_ID;
+	item.length = length;
+	item.data_ptr = to_user_pointer(query);
+	i915_query_items(fd, &item, 1);
+
+	return item.length;
+}
+
+static int query_perf_config_uuid_data(int fd, int length,
+				       struct drm_i915_query_perf_config *query)
+{
+	struct drm_i915_query_item item;
+
+	memset(&item, 0, sizeof(item));
+	item.query_id = DRM_I915_QUERY_PERF_CONFIG;
+	item.flags = DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_UUID;
+	item.length = length;
+	item.data_ptr = to_user_pointer(query);
+	i915_query_items(fd, &item, 1);
+
+	return item.length;
+}
+
+/*
+ * Verify that perf configuration queries for configuration data
+ * rejects invalid parameters.
+ */
+static void test_query_perf_config_data_invalid(int fd)
+{
+	struct {
+		struct drm_i915_query_perf_config query;
+		struct drm_i915_perf_oa_config oa;
+	} query;
+	struct drm_i915_query_item item;
+	size_t len;
+	void *data;
+
+	/* Flags are invalid for perf config queries */
+	memset(&item, 0, sizeof(item));
+	item.query_id = DRM_I915_QUERY_PERF_CONFIG;
+	item.flags = DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_ID + 1; /* invalid */
+	i915_query_items(fd, &item, 1);
+	igt_assert_eq(item.length, -EINVAL);
+
+	/*
+	 * A too small data length is invalid. We should have at least
+	 * the test config list.
+	 */
+	memset(&item, 0, sizeof(item));
+	item.query_id = DRM_I915_QUERY_PERF_CONFIG;
+	item.flags = DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_ID;
+	item.length = sizeof(struct drm_i915_query_perf_config); /* invalid */
+	i915_query_items(fd, &item, 1);
+	igt_assert_eq(item.length, -EINVAL);
+
+	memset(&item, 0, sizeof(item));
+	item.query_id = DRM_I915_QUERY_PERF_CONFIG;
+	item.flags = DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_ID;
+	item.length = sizeof(struct drm_i915_query_perf_config) +
+		sizeof(struct drm_i915_perf_oa_config) - 1; /* invalid */
+	i915_query_items(fd, &item, 1);
+	igt_assert_eq(item.length, -EINVAL);
+
+	/* Flags on the query config data are invalid. */
+	memset(&item, 0, sizeof(item));
+	item.query_id = DRM_I915_QUERY_PERF_CONFIG;
+	item.flags = DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_ID;
+	item.length = 0;
+	i915_query_items(fd, &item, 1);
+	igt_assert_eq(item.length, sizeof(query));
+
+	memset(&query, 0, sizeof(query));
+	query.query.flags = 1; /* invalid */
+	item.data_ptr = to_user_pointer(&query.query);
+	i915_query_items(fd, &item, 1);
+	igt_assert_eq(item.length, -EINVAL);
+
+	/* Invalid UUID. */
+	memset(&item, 0, sizeof(item));
+	memset(&query, 0, sizeof(query));
+	item.query_id = DRM_I915_QUERY_PERF_CONFIG;
+	item.flags = DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_UUID;
+	item.data_ptr = to_user_pointer(&query);
+	item.length = sizeof(query);
+	i915_query_items(fd, &item, 1);
+	igt_assert_eq(item.length, -ENOENT);
+
+	/*
+	 * A NULL data pointer is invalid when the length is long
+	 * enough for i915 to copy data into the pointed memory.
+	 */
+	memset(&item, 0, sizeof(item));
+	item.query_id = DRM_I915_QUERY_PERF_CONFIG;
+	item.flags = DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_ID;
+	item.length = 0;
+	i915_query_items(fd, &item, 1);
+	igt_assert_eq(item.length, sizeof(query));
+
+	i915_query_items(fd, &item, 1); /* leaves data ptr to null */
+	igt_assert_eq(item.length, -EFAULT);
+
+	item.data_ptr = ULONG_MAX; /* invalid pointer */
+	i915_query_items(fd, &item, 1);
+	igt_assert_eq(item.length, -EFAULT);
+
+	/* Trying to write into read only memory will fail. */
+	memset(&item, 0, sizeof(item));
+	item.query_id = DRM_I915_QUERY_PERF_CONFIG;
+	item.flags = DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_ID;
+	item.length = 0;
+	i915_query_items(fd, &item, 1);
+	igt_assert_eq(item.length, sizeof(query));
+
+	len = ALIGN(item.length, 4096);
+	data = mmap(0, len, PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
+	memset(data, 0, len);
+	((struct drm_i915_query_perf_config *)data)->config = 1; /* test config */
+	mprotect(data, len, PROT_READ);
+	item.data_ptr = to_user_pointer(data); /* invalid with read only data */
+	i915_query_items(fd, &item, 1);
+	igt_assert_eq(item.length, -EFAULT);
+
+	munmap(data, len);
+
+	/* Invalid memory (NULL) for configuration registers. */
+	memset(&query, 0, sizeof(query));
+	query.query.config = 1; /* test config */
+	igt_assert_eq(sizeof(query),
+		      query_perf_config_id_data(fd, sizeof(query), &query.query));
+
+	igt_debug("Queried test config %.*s\n",
+		  (int)sizeof(query.oa.uuid), query.oa.uuid);
+	igt_debug("  n_mux_regs=%u, n_boolean_regs=%u, n_flex_regs=%u\n",
+		  query.oa.n_mux_regs, query.oa.n_boolean_regs,
+		  query.oa.n_flex_regs);
+	igt_assert_eq(-EFAULT,
+		      query_perf_config_id_data(fd, sizeof(query), &query.query));
+
+	/* Invalid memory (ULONG max) for configuration registers. */
+	memset(&query, 0, sizeof(query));
+	query.query.config = 1; /* test config */
+	igt_assert_eq(sizeof(query), query_perf_config_id_data(fd, 0, &query.query));
+
+	if (query.oa.n_mux_regs > 0) {
+		query.oa.mux_regs_ptr = ULONG_MAX;
+		query.oa.n_boolean_regs = 0;
+		query.oa.n_flex_regs = 0;
+		igt_assert_eq(-EFAULT, query_perf_config_id_data(fd, sizeof(query),
+								 &query.query));
+	}
+
+	memset(&query, 0, sizeof(query));
+	query.query.config = 1; /* test config */
+	igt_assert_eq(sizeof(query),
+		      query_perf_config_id_data(fd, 0, &query.query));
+
+	if (query.oa.n_boolean_regs > 0) {
+		query.oa.boolean_regs_ptr = ULONG_MAX;
+		query.oa.n_mux_regs = 0;
+		query.oa.n_flex_regs = 0;
+		igt_assert_eq(-EFAULT, query_perf_config_id_data(fd, sizeof(query),
+								 &query.query));
+	}
+
+	memset(&query, 0, sizeof(query));
+	query.query.config = 1; /* test config */
+	igt_assert_eq(sizeof(query),
+		      query_perf_config_id_data(fd, 0, &query.query));
+
+	if (query.oa.n_flex_regs > 0) {
+		query.oa.flex_regs_ptr = ULONG_MAX;
+		query.oa.n_mux_regs = 0;
+		query.oa.n_boolean_regs = 0;
+		igt_assert_eq(-EFAULT, query_perf_config_id_data(fd, sizeof(query),
+								 &query.query));
+	}
+
+	/* Too small number of registers to write. */
+	memset(&query, 0, sizeof(query));
+	query.query.config = 1; /* test config */
+	igt_assert_eq(sizeof(query), query_perf_config_id_data(fd, 0, &query.query));
+
+	if (query.oa.n_mux_regs > 0) {
+		query.oa.n_mux_regs--;
+		igt_assert_eq(-EINVAL, query_perf_config_id_data(fd, sizeof(query),
+								 &query.query));
+	}
+
+	memset(&query, 0, sizeof(query));
+	query.query.config = 1; /* test config */
+	igt_assert_eq(sizeof(query),
+		      query_perf_config_id_data(fd, 0, &query.query));
+
+	if (query.oa.n_boolean_regs > 0) {
+		query.oa.n_boolean_regs--;
+		igt_assert_eq(-EINVAL, query_perf_config_id_data(fd, sizeof(query),
+								 &query.query));
+	}
+
+	memset(&query, 0, sizeof(query));
+	query.query.config = 1; /* test config */
+	igt_assert_eq(sizeof(query), query_perf_config_id_data(fd, 0, &query.query));
+
+	if (query.oa.n_flex_regs > 0) {
+		query.oa.n_flex_regs--;
+		igt_assert_eq(-EINVAL, query_perf_config_id_data(fd, sizeof(query),
+								 &query.query));
+	}
+
+	memset(&query, 0, sizeof(query));
+	query.query.config = 1; /* test config */
+	igt_assert_eq(sizeof(query),
+		      query_perf_config_id_data(fd, 0, &query.query));
+
+	if (query.oa.n_boolean_regs > 0) {
+		query.oa.boolean_regs_ptr = ULONG_MAX;
+		query.oa.n_mux_regs = 0;
+		query.oa.n_flex_regs = 0;
+		igt_assert_eq(-EFAULT, query_perf_config_id_data(fd, sizeof(query),
+								 &query.query));
+	}
+
+	/* Read only memory for registers. */
+	memset(&query, 0, sizeof(query));
+	query.query.config = 1; /* test config */
+	igt_assert_eq(sizeof(query),
+		      query_perf_config_id_data(fd, sizeof(query), &query.query));
+
+	len = ALIGN(query.oa.n_mux_regs * sizeof(uint32_t) * 2, 4096);
+	data = mmap(0, len, PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
+	memset(data, 0, len);
+	mprotect(data, len, PROT_READ);
+	query.oa.mux_regs_ptr = to_user_pointer(data);
+	igt_assert_eq(-EFAULT,
+		      query_perf_config_id_data(fd, sizeof(query), &query.query));
+
+	munmap(data, len);
+}
+
+static uint64_t create_perf_config(int fd,
+				   const char *uuid,
+				   uint32_t **boolean_regs,
+				   uint32_t *n_boolean_regs,
+				   uint32_t **flex_regs,
+				   uint32_t *n_flex_regs,
+				   uint32_t **mux_regs,
+				   uint32_t *n_mux_regs)
+{
+	struct drm_i915_perf_oa_config config;
+	int devid = intel_get_drm_devid(fd);
+	int i, ret;
+
+	*n_boolean_regs = rand() % 50;
+	*boolean_regs = calloc(*n_boolean_regs, sizeof(uint32_t) * 2);
+	*n_mux_regs = rand() % 50;
+	*mux_regs = calloc(*n_mux_regs, sizeof(uint32_t) * 2);
+	if (intel_gen(devid) < 8) {
+		/* flex register don't exist on gen7 */
+		*n_flex_regs = 0;
+		*flex_regs = NULL;
+	} else {
+		*n_flex_regs = rand() % 50;
+		*flex_regs = calloc(*n_flex_regs, sizeof(uint32_t) * 2);
+	}
+
+	for (i = 0; i < *n_boolean_regs; i++) {
+		if (rand() % 2) {
+			/* OASTARTTRIG[1-8] */
+			(*boolean_regs)[i * 2] =
+				0x2710 + ((rand() % (0x2730 - 0x2710)) / 4) * 4;
+			(*boolean_regs)[i * 2 + 1] = rand();
+		} else {
+			/* OAREPORTTRIG[1-8] */
+			(*boolean_regs)[i * 2] =
+				0x2740 + ((rand() % (0x275c - 0x2744)) / 4) * 4;
+			(*boolean_regs)[i * 2 + 1] = rand();
+		}
+	}
+
+	for (i = 0; i < *n_mux_regs; i++) {
+		(*mux_regs)[i * 2] = 0x9800;
+		(*mux_regs)[i * 2 + 1] = rand();
+	}
+
+	for (i = 0; i < *n_flex_regs; i++) {
+		const uint32_t flex[] = {
+			0xe458,
+			0xe558,
+			0xe658,
+			0xe758,
+			0xe45c,
+			0xe55c,
+			0xe65c
+		};
+		(*flex_regs)[i * 2] = flex[rand() % ARRAY_SIZE(flex)];
+		(*flex_regs)[i * 2 + 1] = rand();
+	}
+
+	memset(&config, 0, sizeof(config));
+	memcpy(config.uuid, uuid, sizeof(config.uuid));
+
+	config.n_boolean_regs = *n_boolean_regs;
+	config.boolean_regs_ptr = to_user_pointer(*boolean_regs);
+	config.n_flex_regs = *n_flex_regs;
+	config.flex_regs_ptr = to_user_pointer(*flex_regs);
+	config.n_mux_regs = *n_mux_regs;
+	config.mux_regs_ptr = to_user_pointer(*mux_regs);
+
+	ret = igt_ioctl(fd, DRM_IOCTL_I915_PERF_ADD_CONFIG, &config);
+	igt_assert(ret > 1); /* Config 0/1 should be used by the kernel */
+
+	igt_debug("created config id=%i uuid=%s:\n", ret, uuid);
+	igt_debug("\tn_boolean_regs=%u n_flex_regs=%u n_mux_regs=%u\n",
+		  config.n_boolean_regs, config.n_flex_regs,
+		  config.n_mux_regs);
+
+	return ret;
+}
+
+static void remove_perf_config(int fd, uint64_t config_id)
+{
+	igt_assert_eq(0, igt_ioctl(fd, DRM_IOCTL_I915_PERF_REMOVE_CONFIG,
+				   &config_id));
+}
+
+static uint64_t get_config_id(int fd, const char *uuid)
+{
+	char rel_path[100];
+	uint64_t ret;
+	int sysfs;
+
+	sysfs = igt_sysfs_open(fd, NULL);
+	igt_assert_lte(0, sysfs);
+
+	snprintf(rel_path, sizeof(rel_path), "metrics/%s/id", uuid);
+
+	if (igt_sysfs_scanf(sysfs, rel_path, "%lu", &ret) < 0)
+		ret = 0;
+
+	close(sysfs);
+	return ret;
+}
+
+/*
+ * Verifies that created configurations appear in the query of list of
+ * configuration and also verify the content of the queried
+ * configurations matches with what was created.
+ */
+static void test_query_perf_configs(int fd)
+{
+	struct {
+		uint64_t id;
+
+		char uuid[40];
+
+		uint32_t *boolean_regs;
+		uint32_t n_boolean_regs;
+		uint32_t *flex_regs;
+		uint32_t n_flex_regs;
+		uint32_t *mux_regs;
+		uint32_t n_mux_regs;
+	} configs[5];
+	struct {
+		struct drm_i915_query_perf_config query;
+		uint64_t config_ids[];
+	} *list_query;
+	struct drm_i915_query_item item;
+	int i;
+
+	srand(time(NULL));
+
+	for (i = 0; i < ARRAY_SIZE(configs); i++) {
+		uint64_t prev_config_id;
+
+		snprintf(configs[i].uuid, sizeof(configs[i].uuid),
+			 "01234567-%04u-0123-0123-0123456789ab", i);
+
+		prev_config_id = get_config_id(fd, configs[i].uuid);
+		if (prev_config_id)
+			remove_perf_config(fd, prev_config_id);
+
+		configs[i].id =
+			create_perf_config(fd, configs[i].uuid,
+					   &configs[i].boolean_regs,
+					   &configs[i].n_boolean_regs,
+					   &configs[i].flex_regs,
+					   &configs[i].n_flex_regs,
+					   &configs[i].mux_regs,
+					   &configs[i].n_mux_regs);
+	}
+
+	memset(&item, 0, sizeof(item));
+	item.query_id = DRM_I915_QUERY_PERF_CONFIG;
+	item.flags = DRM_I915_QUERY_PERF_CONFIG_LIST;
+	item.length = 0;
+	i915_query_items(fd, &item, 1);
+	igt_assert(item.length > sizeof(struct drm_i915_query_perf_config));
+
+	list_query = malloc(item.length);
+	memset(list_query, 0, item.length);
+	item.data_ptr = to_user_pointer(list_query);
+	i915_query_items(fd, &item, 1);
+	igt_assert(item.length > sizeof(struct drm_i915_query_perf_config));
+
+	igt_debug("listed configs:\n");
+	for (i = 0; i < list_query->query.config; i++)
+		igt_debug("\tid=%lu\n", list_query->config_ids[i]);
+
+	/* Verify that all created configs are listed. */
+	for (i = 0; i < ARRAY_SIZE(configs); i++) {
+		int j;
+		bool found = false;
+
+		for (j = 0; j < list_query->query.config; j++) {
+			if (list_query->config_ids[j] == configs[i].id) {
+				found = true;
+				break;
+			}
+		}
+
+		igt_assert(found);
+	}
+
+	/* Verify the content of the configs. */
+	for (i = 0; i < ARRAY_SIZE(configs); i++) {
+		struct {
+			struct drm_i915_query_perf_config query;
+			struct drm_i915_perf_oa_config oa;
+		} query;
+		uint32_t *boolean_regs = NULL, *flex_regs = NULL, *mux_regs = NULL;
+
+		/* First query with configuration id. */
+		memset(&query, 0, sizeof(query));
+		query.query.config = configs[i].id;
+		igt_assert_eq(sizeof(query),
+			      query_perf_config_id_data(fd, sizeof(query),
+							&query.query));
+
+		igt_debug("queried config data id=%lu uuid=%s:\n",
+			  configs[i].id, configs[i].uuid);
+		igt_debug("\tn_boolean_regs=%u n_flex_regs=%u n_mux_regs=%u\n",
+			  query.oa.n_boolean_regs, query.oa.n_flex_regs,
+			  query.oa.n_mux_regs);
+
+		igt_assert_eq(query.oa.n_boolean_regs, configs[i].n_boolean_regs);
+		igt_assert_eq(query.oa.n_flex_regs, configs[i].n_flex_regs);
+		igt_assert_eq(query.oa.n_mux_regs, configs[i].n_mux_regs);
+
+		/* Query again with configuration uuid. */
+		memset(&query, 0, sizeof(query));
+		memcpy(query.query.uuid, configs[i].uuid,
+		       sizeof(query.query.uuid));
+		igt_assert_eq(sizeof(query),
+			      query_perf_config_uuid_data(fd, sizeof(query),
+							  &query.query));
+
+		igt_assert_eq(query.oa.n_boolean_regs, configs[i].n_boolean_regs);
+		igt_assert_eq(query.oa.n_flex_regs, configs[i].n_flex_regs);
+		igt_assert_eq(query.oa.n_mux_regs, configs[i].n_mux_regs);
+
+		/* Now get the register programming values. */
+		boolean_regs = calloc(query.oa.n_boolean_regs * 2, sizeof(uint32_t));
+		if (query.oa.n_flex_regs > 0)
+			flex_regs = calloc(query.oa.n_flex_regs * 2, sizeof(uint32_t));
+		mux_regs = calloc(query.oa.n_mux_regs * 2, sizeof(uint32_t));
+
+		query.oa.boolean_regs_ptr = to_user_pointer(boolean_regs);
+		query.oa.flex_regs_ptr = to_user_pointer(flex_regs);
+		query.oa.mux_regs_ptr = to_user_pointer(mux_regs);
+
+		igt_assert_eq(sizeof(query),
+			      query_perf_config_uuid_data(fd, sizeof(query),
+							  &query.query));
+
+		igt_assert_eq(0, memcmp(configs[i].boolean_regs,
+					boolean_regs,
+					configs[i].n_boolean_regs * 2 * sizeof(uint32_t)));
+		igt_assert_eq(0, memcmp(configs[i].flex_regs,
+					flex_regs,
+					configs[i].n_flex_regs * 2 * sizeof(uint32_t)));
+		igt_assert_eq(0, memcmp(configs[i].mux_regs,
+					mux_regs,
+					configs[i].n_mux_regs * 2 * sizeof(uint32_t)));
+
+		free(boolean_regs);
+		free(flex_regs);
+		free(mux_regs);
+	}
+
+	for (i = 0; i < ARRAY_SIZE(configs); i++) {
+		remove_perf_config(fd, configs[i].id);
+
+		free(configs[i].boolean_regs);
+		free(configs[i].flex_regs);
+		free(configs[i].mux_regs);
+	}
+}
+
 igt_main
 {
 	int fd = -1;
@@ -524,6 +1117,21 @@ igt_main
 		test_query_topology_known_pci_ids(fd, devid);
 	}
 
+	igt_subtest("query-perf-config-list-invalid") {
+		igt_require(query_perf_config_supported(fd));
+		test_query_perf_config_list_invalid(fd);
+	}
+
+	igt_subtest("query-perf-config-data-invalid") {
+		igt_require(query_perf_config_supported(fd));
+		test_query_perf_config_data_invalid(fd);
+	}
+
+	igt_subtest("query-perf-configs") {
+		igt_require(query_perf_config_supported(fd));
+		test_query_perf_configs(fd);
+	}
+
 	igt_fixture {
 		close(fd);
 	}
-- 
2.17.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH i-g-t v2 0/2] tests/i915-query: new tests for listing perf configurations
  2018-06-12 16:37 [PATCH i-g-t v2 0/2] tests/i915-query: new tests for listing perf configurations Lionel Landwerlin
  2018-06-12 16:37 ` [PATCH i-g-t v2 1/2] include: bump i915 header Lionel Landwerlin
  2018-06-12 16:37 ` [PATCH i-g-t v2 2/2] tests/i915-query: add new tests for perf configurations queries Lionel Landwerlin
@ 2018-06-12 16:53 ` Lionel Landwerlin
  2018-06-12 17:05 ` ✓ Fi.CI.BAT: success for " Patchwork
  2018-06-12 22:01 ` ✗ Fi.CI.IGT: failure " Patchwork
  4 siblings, 0 replies; 6+ messages in thread
From: Lionel Landwerlin @ 2018-06-12 16:53 UTC (permalink / raw)
  To: intel-gfx

On 12/06/18 17:37, Lionel Landwerlin wrote:
> Hi,
>
> A small update to add query based on configuration uuids.
>
> Cheers,
>
> Lionel Landwerlin (2):
>    include: bump i915 header
>    tests/i915-query: add new tests for perf configurations queries
>
>   include/drm-uapi/i915_drm.h |  56 +++-
>   tests/i915_query.c          | 608 ++++++++++++++++++++++++++++++++++++
>   2 files changed, 663 insertions(+), 1 deletion(-)
>
> --
> 2.17.1
>
Oops, wrong mailing list :(

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* ✓ Fi.CI.BAT: success for tests/i915-query: new tests for listing perf configurations
  2018-06-12 16:37 [PATCH i-g-t v2 0/2] tests/i915-query: new tests for listing perf configurations Lionel Landwerlin
                   ` (2 preceding siblings ...)
  2018-06-12 16:53 ` [PATCH i-g-t v2 0/2] tests/i915-query: new tests for listing perf configurations Lionel Landwerlin
@ 2018-06-12 17:05 ` Patchwork
  2018-06-12 22:01 ` ✗ Fi.CI.IGT: failure " Patchwork
  4 siblings, 0 replies; 6+ messages in thread
From: Patchwork @ 2018-06-12 17:05 UTC (permalink / raw)
  To: Lionel Landwerlin; +Cc: intel-gfx

== Series Details ==

Series: tests/i915-query: new tests for listing perf configurations
URL   : https://patchwork.freedesktop.org/series/44644/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4307 -> IGTPW_1451 =

== Summary - SUCCESS ==

  No regressions found.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/44644/revisions/1/mbox/

== Known issues ==

  Here are the changes found in IGTPW_1451 that come from known issues:

  === IGT changes ===

    ==== Issues hit ====

    igt@gem_exec_suspend@basic-s3:
      fi-glk-j4005:       PASS -> DMESG-WARN (fdo#106097)

    igt@gem_exec_suspend@basic-s4-devices:
      fi-hsw-peppy:       PASS -> FAIL (fdo#105900)

    igt@prime_vgem@basic-fence-flip:
      fi-ilk-650:         PASS -> FAIL (fdo#104008)

    
    ==== Possible fixes ====

    igt@debugfs_test@read_all_entries:
      fi-snb-2520m:       INCOMPLETE (fdo#103713) -> PASS

    igt@gem_ctx_create@basic-files:
      fi-glk-j4005:       DMESG-WARN (fdo#106000) -> PASS

    igt@kms_chamelium@dp-edid-read:
      fi-kbl-7500u:       FAIL (fdo#103841) -> PASS

    igt@kms_pipe_crc_basic@hang-read-crc-pipe-a:
      fi-skl-guc:         FAIL (fdo#104724, fdo#103191) -> PASS

    
  fdo#103191 https://bugs.freedesktop.org/show_bug.cgi?id=103191
  fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713
  fdo#103841 https://bugs.freedesktop.org/show_bug.cgi?id=103841
  fdo#104008 https://bugs.freedesktop.org/show_bug.cgi?id=104008
  fdo#104724 https://bugs.freedesktop.org/show_bug.cgi?id=104724
  fdo#105900 https://bugs.freedesktop.org/show_bug.cgi?id=105900
  fdo#106000 https://bugs.freedesktop.org/show_bug.cgi?id=106000
  fdo#106097 https://bugs.freedesktop.org/show_bug.cgi?id=106097


== Participating hosts (42 -> 38) ==

  Missing    (4): fi-ctg-p8600 fi-ilk-m540 fi-byt-squawks fi-skl-6700hq 


== Build changes ==

    * IGT: IGT_4516 -> IGTPW_1451

  CI_DRM_4307: 0cf6f8f74cad691364d738d1607bc45945f3a5f9 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_1451: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1451/
  IGT_4516: 95bfb2902473b9f4e644c3eb831fdf110d87ed4f @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools



== Testlist changes ==

+igt@i915_query@query-perf-configs
+igt@i915_query@query-perf-config-data-invalid
+igt@i915_query@query-perf-config-list-invalid

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1451/issues.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* ✗ Fi.CI.IGT: failure for tests/i915-query: new tests for listing perf configurations
  2018-06-12 16:37 [PATCH i-g-t v2 0/2] tests/i915-query: new tests for listing perf configurations Lionel Landwerlin
                   ` (3 preceding siblings ...)
  2018-06-12 17:05 ` ✓ Fi.CI.BAT: success for " Patchwork
@ 2018-06-12 22:01 ` Patchwork
  4 siblings, 0 replies; 6+ messages in thread
From: Patchwork @ 2018-06-12 22:01 UTC (permalink / raw)
  To: Lionel Landwerlin; +Cc: intel-gfx

== Series Details ==

Series: tests/i915-query: new tests for listing perf configurations
URL   : https://patchwork.freedesktop.org/series/44644/
State : failure

== Summary ==

= CI Bug Log - changes from IGT_4516_full -> IGTPW_1451_full =

== Summary - FAILURE ==

  Serious unknown changes coming with IGTPW_1451_full absolutely need to be
  verified manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in IGTPW_1451_full, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/44644/revisions/1/mbox/

== Possible new issues ==

  Here are the unknown changes that may have been introduced in IGTPW_1451_full:

  === IGT changes ===

    ==== Possible regressions ====

    igt@kms_cursor_legacy@flip-vs-cursor-varying-size:
      shard-hsw:          PASS -> FAIL

    
    ==== Warnings ====

    igt@gem_exec_schedule@deep-bsd2:
      shard-kbl:          PASS -> SKIP

    igt@gem_mocs_settings@mocs-rc6-ctx-dirty-render:
      shard-kbl:          SKIP -> PASS +1

    
== Known issues ==

  Here are the changes found in IGTPW_1451_full that come from known issues:

  === IGT changes ===

    ==== Issues hit ====

    igt@drv_suspend@shrink:
      shard-hsw:          PASS -> INCOMPLETE (fdo#103540)

    igt@gem_busy@basic-busy-default:
      shard-snb:          PASS -> INCOMPLETE (fdo#105411)

    igt@gem_exec_schedule@pi-ringfull-bsd:
      shard-glk:          NOTRUN -> FAIL (fdo#103158)

    igt@kms_atomic_transition@1x-modeset-transitions-nonblocking:
      shard-glk:          NOTRUN -> FAIL (fdo#105703)

    igt@kms_available_modes_crc@available_mode_test_crc:
      shard-snb:          PASS -> FAIL (fdo#106641)

    igt@kms_cursor_legacy@2x-nonblocking-modeset-vs-cursor-atomic:
      shard-glk:          PASS -> FAIL (fdo#105454, fdo#106509)

    igt@kms_flip@flip-vs-expired-vblank:
      shard-hsw:          PASS -> FAIL (fdo#105189)

    igt@kms_flip@plain-flip-fb-recreate-interruptible:
      shard-hsw:          PASS -> FAIL (fdo#100368)

    igt@kms_flip_tiling@flip-to-x-tiled:
      shard-glk:          NOTRUN -> FAIL (fdo#104724)

    igt@kms_flip_tiling@flip-x-tiled:
      shard-glk:          NOTRUN -> FAIL (fdo#103822, fdo#104724) +1

    igt@kms_setmode@basic:
      shard-apl:          PASS -> FAIL (fdo#99912)

    igt@kms_sysfs_edid_timing:
      shard-glk:          NOTRUN -> WARN (fdo#100047)

    
    ==== Possible fixes ====

    igt@drv_selftest@live_hangcheck:
      shard-apl:          DMESG-FAIL (fdo#106560) -> PASS

    igt@kms_cursor_legacy@cursor-vs-flip-toggle:
      shard-hsw:          FAIL (fdo#103355) -> PASS

    igt@kms_flip@plain-flip-fb-recreate-interruptible:
      shard-glk:          FAIL (fdo#100368) -> PASS +1

    igt@kms_frontbuffer_tracking@fbc-1p-offscren-pri-indfb-draw-mmap-wc:
      shard-snb:          INCOMPLETE (fdo#105411) -> PASS

    igt@kms_plane_multiple@atomic-pipe-a-tiling-x:
      shard-snb:          FAIL (fdo#103166, fdo#104724) -> PASS

    igt@perf_pmu@rc6-runtime-pm-long:
      shard-apl:          FAIL (fdo#105010) -> PASS
      shard-kbl:          FAIL (fdo#105010) -> PASS

    
  fdo#100047 https://bugs.freedesktop.org/show_bug.cgi?id=100047
  fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
  fdo#103158 https://bugs.freedesktop.org/show_bug.cgi?id=103158
  fdo#103166 https://bugs.freedesktop.org/show_bug.cgi?id=103166
  fdo#103355 https://bugs.freedesktop.org/show_bug.cgi?id=103355
  fdo#103540 https://bugs.freedesktop.org/show_bug.cgi?id=103540
  fdo#103822 https://bugs.freedesktop.org/show_bug.cgi?id=103822
  fdo#104724 https://bugs.freedesktop.org/show_bug.cgi?id=104724
  fdo#105010 https://bugs.freedesktop.org/show_bug.cgi?id=105010
  fdo#105189 https://bugs.freedesktop.org/show_bug.cgi?id=105189
  fdo#105411 https://bugs.freedesktop.org/show_bug.cgi?id=105411
  fdo#105454 https://bugs.freedesktop.org/show_bug.cgi?id=105454
  fdo#105703 https://bugs.freedesktop.org/show_bug.cgi?id=105703
  fdo#106509 https://bugs.freedesktop.org/show_bug.cgi?id=106509
  fdo#106560 https://bugs.freedesktop.org/show_bug.cgi?id=106560
  fdo#106641 https://bugs.freedesktop.org/show_bug.cgi?id=106641
  fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912


== Participating hosts (5 -> 5) ==

  No changes in participating hosts


== Build changes ==

    * IGT: IGT_4516 -> IGTPW_1451
    * Linux: CI_DRM_4306 -> CI_DRM_4307

  CI_DRM_4306: 46ac5b5698d4aea58eb440f1ec47d734762259f7 @ git://anongit.freedesktop.org/gfx-ci/linux
  CI_DRM_4307: 0cf6f8f74cad691364d738d1607bc45945f3a5f9 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_1451: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1451/
  IGT_4516: 95bfb2902473b9f4e644c3eb831fdf110d87ed4f @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1451/shards.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

end of thread, other threads:[~2018-06-12 22:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-12 16:37 [PATCH i-g-t v2 0/2] tests/i915-query: new tests for listing perf configurations Lionel Landwerlin
2018-06-12 16:37 ` [PATCH i-g-t v2 1/2] include: bump i915 header Lionel Landwerlin
2018-06-12 16:37 ` [PATCH i-g-t v2 2/2] tests/i915-query: add new tests for perf configurations queries Lionel Landwerlin
2018-06-12 16:53 ` [PATCH i-g-t v2 0/2] tests/i915-query: new tests for listing perf configurations Lionel Landwerlin
2018-06-12 17:05 ` ✓ Fi.CI.BAT: success for " Patchwork
2018-06-12 22:01 ` ✗ Fi.CI.IGT: failure " Patchwork

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.