Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ashutosh Dixit <ashutosh.dixit@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>,
	Jose Souza <jose.souza@intel.com>,
	Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Subject: [PATCH 8/8] drm/xe/oa: Allow only certain property changes from config ioctl
Date: Thu,  8 Aug 2024 10:41:39 -0700	[thread overview]
Message-ID: <20240808174139.4027534-9-ashutosh.dixit@intel.com> (raw)
In-Reply-To: <20240808174139.4027534-1-ashutosh.dixit@intel.com>

Whereas all properties can be specified during OA stream open, when the OA
stream is reconfigured only the config_id and syncs can be specified.

Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
---
 drivers/gpu/drm/xe/xe_oa.c | 69 ++++++++++++++++++++++++++------------
 1 file changed, 47 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_oa.c b/drivers/gpu/drm/xe/xe_oa.c
index c9f77f0342b60..27654a0d4358f 100644
--- a/drivers/gpu/drm/xe/xe_oa.c
+++ b/drivers/gpu/drm/xe/xe_oa.c
@@ -1133,9 +1133,12 @@ static int decode_oa_format(struct xe_oa *oa, u64 fmt, enum xe_oa_format_name *n
 	return -EINVAL;
 }
 
-static int xe_oa_set_prop_oa_unit_id(struct xe_oa *oa, u64 value,
+static int xe_oa_set_prop_oa_unit_id(struct xe_oa *oa, u64 value, bool all,
 				     struct xe_oa_open_param *param)
 {
+	if (!all)
+		return -EINVAL;
+
 	if (value >= oa->oa_unit_ids) {
 		drm_dbg(&oa->xe->drm, "OA unit ID out of range %lld\n", value);
 		return -EINVAL;
@@ -1144,25 +1147,32 @@ static int xe_oa_set_prop_oa_unit_id(struct xe_oa *oa, u64 value,
 	return 0;
 }
 
-static int xe_oa_set_prop_sample_oa(struct xe_oa *oa, u64 value,
+static int xe_oa_set_prop_sample_oa(struct xe_oa *oa, u64 value, bool all,
 				    struct xe_oa_open_param *param)
 {
+	if (!all)
+		return -EINVAL;
+
 	param->sample = value;
 	return 0;
 }
 
-static int xe_oa_set_prop_metric_set(struct xe_oa *oa, u64 value,
+static int xe_oa_set_prop_metric_set(struct xe_oa *oa, u64 value, bool all,
 				     struct xe_oa_open_param *param)
 {
 	param->metric_set = value;
 	return 0;
 }
 
-static int xe_oa_set_prop_oa_format(struct xe_oa *oa, u64 value,
+static int xe_oa_set_prop_oa_format(struct xe_oa *oa, u64 value, bool all,
 				    struct xe_oa_open_param *param)
 {
-	int ret = decode_oa_format(oa, value, &param->oa_format);
+	int ret;
 
+	if (!all)
+		return -EINVAL;
+
+	ret = decode_oa_format(oa, value, &param->oa_format);
 	if (ret) {
 		drm_dbg(&oa->xe->drm, "Unsupported OA report format %#llx\n", value);
 		return ret;
@@ -1170,11 +1180,14 @@ static int xe_oa_set_prop_oa_format(struct xe_oa *oa, u64 value,
 	return 0;
 }
 
-static int xe_oa_set_prop_oa_exponent(struct xe_oa *oa, u64 value,
+static int xe_oa_set_prop_oa_exponent(struct xe_oa *oa, u64 value, bool all,
 				      struct xe_oa_open_param *param)
 {
 #define OA_EXPONENT_MAX 31
 
+	if (!all)
+		return -EINVAL;
+
 	if (value > OA_EXPONENT_MAX) {
 		drm_dbg(&oa->xe->drm, "OA timer exponent too high (> %u)\n", OA_EXPONENT_MAX);
 		return -EINVAL;
@@ -1183,49 +1196,61 @@ static int xe_oa_set_prop_oa_exponent(struct xe_oa *oa, u64 value,
 	return 0;
 }
 
-static int xe_oa_set_prop_disabled(struct xe_oa *oa, u64 value,
+static int xe_oa_set_prop_disabled(struct xe_oa *oa, u64 value, bool all,
 				   struct xe_oa_open_param *param)
 {
+	if (!all)
+		return -EINVAL;
+
 	param->disabled = value;
 	return 0;
 }
 
-static int xe_oa_set_prop_exec_queue_id(struct xe_oa *oa, u64 value,
+static int xe_oa_set_prop_exec_queue_id(struct xe_oa *oa, u64 value, bool all,
 					struct xe_oa_open_param *param)
 {
+	if (!all)
+		return -EINVAL;
+
 	param->exec_queue_id = value;
 	return 0;
 }
 
-static int xe_oa_set_prop_engine_instance(struct xe_oa *oa, u64 value,
+static int xe_oa_set_prop_engine_instance(struct xe_oa *oa, u64 value, bool all,
 					  struct xe_oa_open_param *param)
 {
+	if (!all)
+		return -EINVAL;
+
 	param->engine_instance = value;
 	return 0;
 }
 
-static int xe_oa_set_no_preempt(struct xe_oa *oa, u64 value,
+static int xe_oa_set_no_preempt(struct xe_oa *oa, u64 value, bool all,
 				struct xe_oa_open_param *param)
 {
+	if (!all)
+		return -EINVAL;
+
 	param->no_preempt = value;
 	return 0;
 }
 
-static int xe_oa_set_num_syncs(struct xe_oa *oa, u64 value,
+static int xe_oa_set_num_syncs(struct xe_oa *oa, u64 value, bool all,
 			       struct xe_oa_open_param *param)
 {
 	param->num_syncs = value;
 	return 0;
 }
 
-static int xe_oa_set_syncs_user(struct xe_oa *oa, u64 value,
+static int xe_oa_set_syncs_user(struct xe_oa *oa, u64 value, bool all,
 				struct xe_oa_open_param *param)
 {
 	param->syncs_user = u64_to_user_ptr(value);
 	return 0;
 }
 
-typedef int (*xe_oa_set_property_fn)(struct xe_oa *oa, u64 value,
+typedef int (*xe_oa_set_property_fn)(struct xe_oa *oa, u64 value, bool all,
 				     struct xe_oa_open_param *param);
 static const xe_oa_set_property_fn xe_oa_set_property_funcs[] = {
 	[DRM_XE_OA_PROPERTY_OA_UNIT_ID] = xe_oa_set_prop_oa_unit_id,
@@ -1241,7 +1266,7 @@ static const xe_oa_set_property_fn xe_oa_set_property_funcs[] = {
 	[DRM_XE_OA_PROPERTY_SYNCS] = xe_oa_set_syncs_user,
 };
 
-static int xe_oa_user_ext_set_property(struct xe_oa *oa, u64 extension,
+static int xe_oa_user_ext_set_property(struct xe_oa *oa, u64 extension, bool all,
 				       struct xe_oa_open_param *param)
 {
 	u64 __user *address = u64_to_user_ptr(extension);
@@ -1258,18 +1283,18 @@ static int xe_oa_user_ext_set_property(struct xe_oa *oa, u64 extension,
 		return -EINVAL;
 
 	idx = array_index_nospec(ext.property, ARRAY_SIZE(xe_oa_set_property_funcs));
-	return xe_oa_set_property_funcs[idx](oa, ext.value, param);
+	return xe_oa_set_property_funcs[idx](oa, ext.value, all, param);
 }
 
-typedef int (*xe_oa_user_extension_fn)(struct xe_oa *oa, u64 extension,
+typedef int (*xe_oa_user_extension_fn)(struct xe_oa *oa, u64 extension, bool all,
 				       struct xe_oa_open_param *param);
 static const xe_oa_user_extension_fn xe_oa_user_extension_funcs[] = {
 	[DRM_XE_OA_EXTENSION_SET_PROPERTY] = xe_oa_user_ext_set_property,
 };
 
 #define MAX_USER_EXTENSIONS	16
-static int xe_oa_user_extensions(struct xe_oa *oa, u64 extension, int ext_number,
-				 struct xe_oa_open_param *param)
+static int xe_oa_user_extensions(struct xe_oa *oa, u64 extension, bool all,
+				 int ext_number, struct xe_oa_open_param *param)
 {
 	u64 __user *address = u64_to_user_ptr(extension);
 	struct drm_xe_user_extension ext;
@@ -1288,12 +1313,12 @@ static int xe_oa_user_extensions(struct xe_oa *oa, u64 extension, int ext_number
 		return -EINVAL;
 
 	idx = array_index_nospec(ext.name, ARRAY_SIZE(xe_oa_user_extension_funcs));
-	err = xe_oa_user_extension_funcs[idx](oa, extension, param);
+	err = xe_oa_user_extension_funcs[idx](oa, extension, all, param);
 	if (XE_IOCTL_DBG(oa->xe, err))
 		return err;
 
 	if (ext.next_extension)
-		return xe_oa_user_extensions(oa, ext.next_extension, ++ext_number, param);
+		return xe_oa_user_extensions(oa, ext.next_extension, all, ++ext_number, param);
 
 	return 0;
 }
@@ -1439,7 +1464,7 @@ static long xe_oa_config_locked(struct xe_oa_stream *stream, u64 arg)
 	struct xe_oa_config *config;
 	int err;
 
-	err = xe_oa_user_extensions(stream->oa, arg, 0, &param);
+	err = xe_oa_user_extensions(stream->oa, arg, false, 0, &param);
 	if (err)
 		return err;
 
@@ -1989,7 +2014,7 @@ int xe_oa_stream_open_ioctl(struct drm_device *dev, u64 data, struct drm_file *f
 	}
 
 	param.xef = xef;
-	ret = xe_oa_user_extensions(oa, data, 0, &param);
+	ret = xe_oa_user_extensions(oa, data, true, 0, &param);
 	if (ret)
 		return ret;
 
-- 
2.41.0


  parent reply	other threads:[~2024-08-08 17:41 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-08 17:41 [PATCH 0/8] drm/xe/oa: xe_syncs for OA Ashutosh Dixit
2024-08-08 17:41 ` [PATCH 1/8] drm/xe/oa: Separate batch submission from waiting for completion Ashutosh Dixit
2024-08-08 20:18   ` Cavitt, Jonathan
2024-08-20  1:01     ` Dixit, Ashutosh
2024-08-08 23:04   ` Matthew Brost
2024-08-20  1:00     ` Dixit, Ashutosh
2024-08-08 17:41 ` [PATCH 2/8] drm/xe/oa: Introduce 'struct xe_oa_fence' Ashutosh Dixit
2024-08-08 20:58   ` Cavitt, Jonathan
2024-08-20  1:03     ` Dixit, Ashutosh
2024-08-08 23:29   ` Matthew Brost
2024-08-08 17:41 ` [PATCH 3/8] drm/xe/oa/uapi: Define and parse OA sync properties Ashutosh Dixit
2024-08-08 21:05   ` Cavitt, Jonathan
2024-08-08 23:13   ` Matthew Brost
2024-08-20  1:04     ` Dixit, Ashutosh
2024-08-08 17:41 ` [PATCH 4/8] drm/xe/oa: Add input fence dependencies Ashutosh Dixit
2024-08-08 21:09   ` Cavitt, Jonathan
2024-08-20  1:05     ` Dixit, Ashutosh
2024-08-08 23:25   ` Matthew Brost
2024-08-20  1:06     ` Dixit, Ashutosh
2024-08-08 17:41 ` [PATCH 5/8] drm/xe/oa: Signal output fences Ashutosh Dixit
2024-08-08 21:16   ` Cavitt, Jonathan
2024-08-20  1:30     ` Dixit, Ashutosh
2024-08-08 23:19   ` Matthew Brost
2024-08-09  4:15     ` Dixit, Ashutosh
2024-08-09  4:50       ` Matthew Brost
2024-08-13 21:35         ` Dixit, Ashutosh
2024-08-20  1:30         ` Dixit, Ashutosh
2024-08-08 17:41 ` [PATCH 6/8] drm/xe/oa: Move functions up so they can be reused for config ioctl Ashutosh Dixit
2024-08-08 21:18   ` Cavitt, Jonathan
2024-08-08 17:41 ` [PATCH 7/8] drm/xe/oa: Add syncs support to OA " Ashutosh Dixit
2024-08-08 21:39   ` Cavitt, Jonathan
2024-08-20  1:40     ` Dixit, Ashutosh
2024-08-08 17:41 ` Ashutosh Dixit [this message]
2024-08-08 22:15   ` [PATCH 8/8] drm/xe/oa: Allow only certain property changes from " Cavitt, Jonathan
2024-08-20  1:45     ` Dixit, Ashutosh
2024-08-08 19:04 ` ✓ CI.Patch_applied: success for drm/xe/oa: xe_syncs for OA Patchwork
2024-08-08 19:04 ` ✓ CI.checkpatch: " Patchwork
2024-08-08 19:05 ` ✓ CI.KUnit: " Patchwork
2024-08-08 19:17 ` ✓ CI.Build: " Patchwork
2024-08-08 19:19 ` ✓ CI.Hooks: " Patchwork
2024-08-08 19:21 ` ✓ CI.checksparse: " Patchwork
2024-08-08 19:51 ` ✓ CI.BAT: " Patchwork
2024-08-08 22:26 ` ✗ CI.FULL: failure " Patchwork

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=20240808174139.4027534-9-ashutosh.dixit@intel.com \
    --to=ashutosh.dixit@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jose.souza@intel.com \
    --cc=lionel.g.landwerlin@intel.com \
    --cc=umesh.nerlige.ramappa@intel.com \
    /path/to/YOUR_REPLY

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

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