diff mbox series

[v12,11/11] drm/i915: add support for perf configuration queries

Message ID 20190830144726.18291-12-lionel.g.landwerlin@intel.com (mailing list archive)
State New, archived
Headers show
Series drm/i915: Vulkan performance query support | expand

Commit Message

Lionel Landwerlin Aug. 30, 2019, 2:47 p.m. UTC
Listing configurations at the moment is supported only through sysfs.
This might cause issues for applications wanting to list
configurations from a container where sysfs isn't available.

This change adds a way to query the number of configurations and their
content through the i915 query uAPI.

v2: Fix sparse warnings (Lionel)
    Add support to query configuration using uuid (Lionel)

v3: Fix some inconsistency in uapi header (Lionel)
    Fix unlocking when not locked issue (Lionel)
    Add debug messages (Lionel)

v4: Fix missing unlock (Dan)

v5: Drop lock when copying config content to userspace (Chris)

v6: Drop lock when copying config list to userspace (Chris)
    Fix deadlock when calling i915_perf_get_oa_config() under
    perf.metrics_lock (Lionel)
    Add i915_oa_config_get() (Chris)

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_drv.h   |   6 +
 drivers/gpu/drm/i915/i915_perf.c  |   3 +
 drivers/gpu/drm/i915/i915_query.c | 283 ++++++++++++++++++++++++++++++
 include/uapi/drm/i915_drm.h       |  65 ++++++-
 4 files changed, 354 insertions(+), 3 deletions(-)

Comments

Dan Carpenter Sept. 2, 2019, 8:08 p.m. UTC | #1
Hi Lionel,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on drm-intel/for-linux-next]
[cannot apply to v5.3-rc7 next-20190902]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Lionel-Landwerlin/drm-i915-Vulkan-performance-query-support/20190831-033234
base:   git://anongit.freedesktop.org/drm-intel for-linux-next

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

New smatch warnings:
drivers/gpu/drm/i915/i915_query.c:405 query_perf_config_list() warn: maybe return -EFAULT instead of the bytes remaining?

Old smatch warnings:
drivers/gpu/drm/i915/i915_query.c:138 query_engine_info() warn: check that 'query.num_engines' doesn't leak information

# https://github.com/0day-ci/linux/commit/1c566ee2d38f4e7ece15ee33fef205b1088e79bb
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout 1c566ee2d38f4e7ece15ee33fef205b1088e79bb
vim +405 drivers/gpu/drm/i915/i915_query.c

1c566ee2d38f4e Lionel Landwerlin 2019-08-30  336  
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  337  static int query_perf_config_list(struct drm_i915_private *i915,
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  338  				  struct drm_i915_query_item *query_item)
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  339  {
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  340  	struct drm_i915_query_perf_config __user *user_query_config_ptr =
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  341  		u64_to_user_ptr(query_item->data_ptr);
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  342  	struct i915_oa_config *oa_config;
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  343  	u32 flags, total_size;
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  344  	u64 i, n_configs, *oa_config_ids;
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  345  	int ret, id;
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  346  
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  347  	if (!i915->perf.initialized)
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  348  		return -ENODEV;
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  349  
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  350  	/* Count the default test configuration */
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  351  	n_configs = i915->perf.n_metrics + 1;
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  352  	total_size = sizeof(struct drm_i915_query_perf_config) +
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  353  		sizeof(u64) * n_configs;
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  354  
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  355  	if (query_item->length == 0)
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  356  		return total_size;
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  357  
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  358  	if (query_item->length < total_size) {
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  359  		DRM_DEBUG("Invalid query config list item size=%u expected=%u\n",
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  360  			  query_item->length, total_size);
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  361  		return -EINVAL;
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  362  	}
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  363  
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  364  	if (!access_ok(user_query_config_ptr, total_size))
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  365  		return -EFAULT;
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  366  
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  367  	if (__get_user(flags, &user_query_config_ptr->flags))
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  368  		return -EFAULT;
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  369  
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  370  	if (flags != 0)
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  371  		return -EINVAL;
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  372  
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  373  	if (__put_user(n_configs, &user_query_config_ptr->config))
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  374  		return -EFAULT;
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  375  
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  376  	ret = mutex_lock_interruptible(&i915->perf.metrics_lock);
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  377  	if (ret)
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  378  		return ret;
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  379  
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  380  	/* Count the configs. */
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  381  	n_configs = 1;
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  382  	idr_for_each_entry(&i915->perf.metrics_idr, oa_config, id)
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  383  		n_configs++;
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  384  
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  385  	oa_config_ids =
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  386  		kmalloc_array(n_configs, sizeof(*oa_config_ids), GFP_KERNEL);
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  387  	if (!oa_config_ids) {
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  388  		mutex_unlock(&i915->perf.metrics_lock);
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  389  		return -ENOMEM;
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  390  	}
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  391  
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  392  	i = 0;
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  393  	oa_config_ids[i++] = 1ull;
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  394  	idr_for_each_entry(&i915->perf.metrics_idr, oa_config, id)
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  395  		oa_config_ids[i++] = id;
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  396  
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  397  	mutex_unlock(&i915->perf.metrics_lock);
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  398  
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  399  	ret = copy_to_user(u64_to_user_ptr(query_item->data_ptr +
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  400  					   sizeof(struct drm_i915_query_perf_config)),
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  401  			   oa_config_ids,
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  402  			   n_configs * sizeof(*oa_config_ids));
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  403  	kfree(oa_config_ids);
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  404  	if (ret)
1c566ee2d38f4e Lionel Landwerlin 2019-08-30 @405  		return ret;
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  406  
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  407  	return total_size;
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  408  }
1c566ee2d38f4e Lionel Landwerlin 2019-08-30  409  

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index d18e12ada4e1..04d538dcc3c1 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1704,6 +1704,12 @@  struct drm_i915_private {
 		 */
 		struct idr metrics_idr;
 
+		/*
+		 * Number of dynamic configurations, you need to hold
+		 * dev_priv->perf.metrics_lock to access it.
+		 */
+		u32 n_metrics;
+
 		/*
 		 * Lock associated with anything below within this structure
 		 * except exclusive_stream.
diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c
index 39681fb43034..54dba3487dfe 100644
--- a/drivers/gpu/drm/i915/i915_perf.c
+++ b/drivers/gpu/drm/i915/i915_perf.c
@@ -3910,6 +3910,8 @@  int i915_perf_add_config_ioctl(struct drm_device *dev, void *data,
 		goto sysfs_err;
 	}
 
+	dev_priv->perf.n_metrics++;
+
 	mutex_unlock(&dev_priv->perf.metrics_lock);
 
 	DRM_DEBUG("Added config %s id=%i\n", oa_config->uuid, oa_config->id);
@@ -3970,6 +3972,7 @@  int i915_perf_remove_config_ioctl(struct drm_device *dev, void *data,
 			   &oa_config->sysfs_metric);
 
 	idr_remove(&dev_priv->perf.metrics_idr, *arg);
+	dev_priv->perf.n_metrics--;
 
 	mutex_unlock(&dev_priv->perf.metrics_lock);
 
diff --git a/drivers/gpu/drm/i915/i915_query.c b/drivers/gpu/drm/i915/i915_query.c
index abac5042da2b..89b2821be4a0 100644
--- a/drivers/gpu/drm/i915/i915_query.c
+++ b/drivers/gpu/drm/i915/i915_query.c
@@ -7,6 +7,7 @@ 
 #include <linux/nospec.h>
 
 #include "i915_drv.h"
+#include "i915_perf.h"
 #include "i915_query.h"
 #include <uapi/drm/i915_drm.h>
 
@@ -140,10 +141,292 @@  query_engine_info(struct drm_i915_private *i915,
 	return len;
 }
 
+static int can_copy_perf_config_registers_or_number(u32 user_n_regs,
+						    u64 user_regs_ptr,
+						    u32 kernel_n_regs)
+{
+	/*
+	 * We'll just put the number of registers, and won't copy the
+	 * register.
+	 */
+	if (user_n_regs == 0)
+		return 0;
+
+	if (user_n_regs < kernel_n_regs)
+		return -EINVAL;
+
+	if (!access_ok(u64_to_user_ptr(user_regs_ptr),
+		       2 * sizeof(u32) * kernel_n_regs))
+		return -EFAULT;
+
+	return 0;
+}
+
+static int copy_perf_config_registers_or_number(const struct i915_oa_reg *kernel_regs,
+						u32 kernel_n_regs,
+						u64 user_regs_ptr,
+						u32 *user_n_regs)
+{
+	u32 r;
+
+	if (*user_n_regs == 0) {
+		*user_n_regs = kernel_n_regs;
+		return 0;
+	}
+
+	*user_n_regs = kernel_n_regs;
+
+	for (r = 0; r < kernel_n_regs; r++) {
+		u32 __user *user_reg_ptr =
+			u64_to_user_ptr(user_regs_ptr + sizeof(u32) * r * 2);
+		u32 __user *user_val_ptr =
+			u64_to_user_ptr(user_regs_ptr + sizeof(u32) * r * 2 +
+					sizeof(u32));
+		int ret;
+
+		ret = __put_user(i915_mmio_reg_offset(kernel_regs[r].addr),
+				 user_reg_ptr);
+		if (ret)
+			return -EFAULT;
+
+		ret = __put_user(kernel_regs[r].value, user_val_ptr);
+		if (ret)
+			return -EFAULT;
+	}
+
+	return 0;
+}
+
+static int query_perf_config_data(struct drm_i915_private *i915,
+				  struct drm_i915_query_item *query_item,
+				  bool use_uuid)
+{
+	struct drm_i915_query_perf_config __user *user_query_config_ptr =
+		u64_to_user_ptr(query_item->data_ptr);
+	struct drm_i915_perf_oa_config __user *user_config_ptr =
+		u64_to_user_ptr(query_item->data_ptr +
+				sizeof(struct drm_i915_query_perf_config));
+	struct drm_i915_perf_oa_config user_config;
+	struct i915_oa_config *oa_config = NULL;
+	char uuid[UUID_STRING_LEN + 1];
+	u64 config_id;
+	u32 flags, total_size;
+	int ret;
+
+	if (!i915->perf.initialized)
+		return -ENODEV;
+
+	total_size = sizeof(struct drm_i915_query_perf_config) +
+		sizeof(struct drm_i915_perf_oa_config);
+
+	if (query_item->length == 0)
+		return total_size;
+
+	if (query_item->length < total_size) {
+		DRM_DEBUG("Invalid query config data item size=%u expected=%u\n",
+			  query_item->length, total_size);
+		return -EINVAL;
+	}
+
+	if (!access_ok(user_query_config_ptr, total_size))
+		return -EFAULT;
+
+	if (__get_user(flags, &user_query_config_ptr->flags))
+		return -EFAULT;
+
+	if (flags != 0)
+		return -EINVAL;
+
+	if (use_uuid) {
+		BUILD_BUG_ON(sizeof(user_query_config_ptr->uuid) >= sizeof(uuid));
+
+		memset(&uuid, 0, sizeof(uuid));
+		if (__copy_from_user(uuid, user_query_config_ptr->uuid,
+				     sizeof(user_query_config_ptr->uuid)))
+			return -EFAULT;
+	} else {
+		if (__get_user(config_id, &user_query_config_ptr->config)) {
+			return -EFAULT;
+		}
+	}
+
+	if (use_uuid) {
+		struct i915_oa_config *tmp;
+		int id;
+
+		ret = mutex_lock_interruptible(&i915->perf.metrics_lock);
+		if (ret)
+			return ret;
+
+		idr_for_each_entry(&i915->perf.metrics_idr, tmp, id) {
+			if (!strcmp(tmp->uuid, uuid)) {
+				oa_config = i915_oa_config_get(tmp);
+				break;
+			}
+		}
+
+		mutex_unlock(&i915->perf.metrics_lock);
+	} else {
+		ret = i915_perf_get_oa_config(i915, config_id, &oa_config);
+	}
+
+	if (ret || !oa_config)
+		return -ENOENT;
+
+	if (__copy_from_user(&user_config, user_config_ptr,
+			     sizeof(user_config))) {
+		ret = -EFAULT;
+		goto out;
+	}
+
+	ret = can_copy_perf_config_registers_or_number(user_config.n_boolean_regs,
+						       user_config.boolean_regs_ptr,
+						       oa_config->b_counter_regs_len);
+	if (ret)
+		goto out;
+
+	ret = can_copy_perf_config_registers_or_number(user_config.n_flex_regs,
+						       user_config.flex_regs_ptr,
+						       oa_config->flex_regs_len);
+	if (ret)
+		goto out;
+
+	ret = can_copy_perf_config_registers_or_number(user_config.n_mux_regs,
+						       user_config.mux_regs_ptr,
+						       oa_config->mux_regs_len);
+	if (ret)
+		goto out;
+
+	ret = copy_perf_config_registers_or_number(oa_config->b_counter_regs,
+						   oa_config->b_counter_regs_len,
+						   user_config.boolean_regs_ptr,
+						   &user_config.n_boolean_regs);
+	if (ret)
+		goto out;
+
+	ret = copy_perf_config_registers_or_number(oa_config->flex_regs,
+						   oa_config->flex_regs_len,
+						   user_config.flex_regs_ptr,
+						   &user_config.n_flex_regs);
+	if (ret)
+		goto out;
+
+	ret = copy_perf_config_registers_or_number(oa_config->mux_regs,
+						   oa_config->mux_regs_len,
+						   user_config.mux_regs_ptr,
+						   &user_config.n_mux_regs);
+	if (ret)
+		goto out;
+
+	memcpy(user_config.uuid, oa_config->uuid, sizeof(user_config.uuid));
+
+	if (__copy_to_user(user_config_ptr, &user_config,
+			   sizeof(user_config))) {
+		ret = -EFAULT;
+		goto out;
+	}
+
+	ret = total_size;
+
+out:
+	i915_oa_config_put(oa_config);
+
+	return ret;
+}
+
+static int query_perf_config_list(struct drm_i915_private *i915,
+				  struct drm_i915_query_item *query_item)
+{
+	struct drm_i915_query_perf_config __user *user_query_config_ptr =
+		u64_to_user_ptr(query_item->data_ptr);
+	struct i915_oa_config *oa_config;
+	u32 flags, total_size;
+	u64 i, n_configs, *oa_config_ids;
+	int ret, id;
+
+	if (!i915->perf.initialized)
+		return -ENODEV;
+
+	/* Count the default test configuration */
+	n_configs = i915->perf.n_metrics + 1;
+	total_size = sizeof(struct drm_i915_query_perf_config) +
+		sizeof(u64) * n_configs;
+
+	if (query_item->length == 0)
+		return total_size;
+
+	if (query_item->length < total_size) {
+		DRM_DEBUG("Invalid query config list item size=%u expected=%u\n",
+			  query_item->length, total_size);
+		return -EINVAL;
+	}
+
+	if (!access_ok(user_query_config_ptr, total_size))
+		return -EFAULT;
+
+	if (__get_user(flags, &user_query_config_ptr->flags))
+		return -EFAULT;
+
+	if (flags != 0)
+		return -EINVAL;
+
+	if (__put_user(n_configs, &user_query_config_ptr->config))
+		return -EFAULT;
+
+	ret = mutex_lock_interruptible(&i915->perf.metrics_lock);
+	if (ret)
+		return ret;
+
+	/* Count the configs. */
+	n_configs = 1;
+	idr_for_each_entry(&i915->perf.metrics_idr, oa_config, id)
+		n_configs++;
+
+	oa_config_ids =
+		kmalloc_array(n_configs, sizeof(*oa_config_ids), GFP_KERNEL);
+	if (!oa_config_ids) {
+		mutex_unlock(&i915->perf.metrics_lock);
+		return -ENOMEM;
+	}
+
+	i = 0;
+	oa_config_ids[i++] = 1ull;
+	idr_for_each_entry(&i915->perf.metrics_idr, oa_config, id)
+		oa_config_ids[i++] = id;
+
+	mutex_unlock(&i915->perf.metrics_lock);
+
+	ret = copy_to_user(u64_to_user_ptr(query_item->data_ptr +
+					   sizeof(struct drm_i915_query_perf_config)),
+			   oa_config_ids,
+			   n_configs * sizeof(*oa_config_ids));
+	kfree(oa_config_ids);
+	if (ret)
+		return ret;
+
+	return total_size;
+}
+
+static int query_perf_config(struct drm_i915_private *i915,
+			     struct drm_i915_query_item *query_item)
+{
+	switch (query_item->flags) {
+	case DRM_I915_QUERY_PERF_CONFIG_LIST:
+		return query_perf_config_list(i915, query_item);
+	case DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_UUID:
+		return query_perf_config_data(i915, query_item, true);
+	case DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_ID:
+		return query_perf_config_data(i915, query_item, false);
+	default:
+		return -EINVAL;
+	}
+}
+
 static int (* const i915_query_funcs[])(struct drm_i915_private *dev_priv,
 					struct drm_i915_query_item *query_item) = {
 	query_topology_info,
 	query_engine_info,
+	query_perf_config,
 };
 
 int i915_query_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h
index 5850d68327ec..2e7215989df2 100644
--- a/include/uapi/drm/i915_drm.h
+++ b/include/uapi/drm/i915_drm.h
@@ -1037,8 +1037,7 @@  enum drm_i915_gem_execbuffer_ext {
 	DRM_I915_GEM_EXECBUFFER_EXT_TIMELINE_FENCES = 1,
 
 	/**
-	 * This identifier is associated with
-	 * drm_i915_gem_execbuffer_perf_ext.
+	 * See drm_i915_gem_execbuffer_perf_ext.
 	 */
 	DRM_I915_GEM_EXECBUFFER_EXT_PERF,
 
@@ -2113,6 +2112,7 @@  struct drm_i915_query_item {
 	__u64 query_id;
 #define DRM_I915_QUERY_TOPOLOGY_INFO    1
 #define DRM_I915_QUERY_ENGINE_INFO	2
+#define DRM_I915_QUERY_PERF_CONFIG      3
 /* Must be kept compact -- no holes and well documented */
 
 	/*
@@ -2124,9 +2124,18 @@  struct drm_i915_query_item {
 	__s32 length;
 
 	/*
-	 * 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
 
 	/*
 	 * Data will be written at the location pointed by data_ptr when the
@@ -2252,6 +2261,56 @@  struct drm_i915_query_engine_info {
 	struct drm_i915_engine_info engines[];
 };
 
+/*
+ * 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_FOR_ID,
+		 * i915 will use the value in this field as configuration
+		 * identifier to decide what data to write into config_ptr.
+		 */
+		__u64 config;
+
+		/*
+		 * When query_id == DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_UUID,
+		 * i915 will use the value in this field as configuration
+		 * identifier to decide what data to write into config_ptr.
+		 *
+		 * 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