Skip to content

Commit 85d3f9e

Browse files
committed
drm/xe/oa: Allow only certain property changes from config
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. v2: Use separate function table for reconfig case (Jonathan) Change bool function args to enum (Matt B) v3: s/xe_oa_set_property_funcs/xe_oa_set_property_funcs_open/ (Jonathan) Reviewed-by: Jonathan Cavitt <jonathan.cavitt@intel.com> Suggested-by: Jonathan Cavitt <jonathan.cavitt@intel.com> Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20241022200352.1192560-8-ashutosh.dixit@intel.com
1 parent 9920c8b commit 85d3f9e

File tree

1 file changed

+46
-14
lines changed

1 file changed

+46
-14
lines changed

drivers/gpu/drm/xe/xe_oa.c

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ enum xe_oa_submit_deps {
4747
XE_OA_SUBMIT_ADD_DEPS,
4848
};
4949

50+
enum xe_oa_user_extn_from {
51+
XE_OA_USER_EXTN_FROM_OPEN,
52+
XE_OA_USER_EXTN_FROM_CONFIG,
53+
};
54+
5055
struct xe_oa_reg {
5156
struct xe_reg addr;
5257
u32 value;
@@ -1255,9 +1260,15 @@ static int xe_oa_set_prop_syncs_user(struct xe_oa *oa, u64 value,
12551260
return 0;
12561261
}
12571262

1263+
static int xe_oa_set_prop_ret_inval(struct xe_oa *oa, u64 value,
1264+
struct xe_oa_open_param *param)
1265+
{
1266+
return -EINVAL;
1267+
}
1268+
12581269
typedef int (*xe_oa_set_property_fn)(struct xe_oa *oa, u64 value,
12591270
struct xe_oa_open_param *param);
1260-
static const xe_oa_set_property_fn xe_oa_set_property_funcs[] = {
1271+
static const xe_oa_set_property_fn xe_oa_set_property_funcs_open[] = {
12611272
[DRM_XE_OA_PROPERTY_OA_UNIT_ID] = xe_oa_set_prop_oa_unit_id,
12621273
[DRM_XE_OA_PROPERTY_SAMPLE_OA] = xe_oa_set_prop_sample_oa,
12631274
[DRM_XE_OA_PROPERTY_OA_METRIC_SET] = xe_oa_set_prop_metric_set,
@@ -1271,8 +1282,22 @@ static const xe_oa_set_property_fn xe_oa_set_property_funcs[] = {
12711282
[DRM_XE_OA_PROPERTY_SYNCS] = xe_oa_set_prop_syncs_user,
12721283
};
12731284

1274-
static int xe_oa_user_ext_set_property(struct xe_oa *oa, u64 extension,
1275-
struct xe_oa_open_param *param)
1285+
static const xe_oa_set_property_fn xe_oa_set_property_funcs_config[] = {
1286+
[DRM_XE_OA_PROPERTY_OA_UNIT_ID] = xe_oa_set_prop_ret_inval,
1287+
[DRM_XE_OA_PROPERTY_SAMPLE_OA] = xe_oa_set_prop_ret_inval,
1288+
[DRM_XE_OA_PROPERTY_OA_METRIC_SET] = xe_oa_set_prop_metric_set,
1289+
[DRM_XE_OA_PROPERTY_OA_FORMAT] = xe_oa_set_prop_ret_inval,
1290+
[DRM_XE_OA_PROPERTY_OA_PERIOD_EXPONENT] = xe_oa_set_prop_ret_inval,
1291+
[DRM_XE_OA_PROPERTY_OA_DISABLED] = xe_oa_set_prop_ret_inval,
1292+
[DRM_XE_OA_PROPERTY_EXEC_QUEUE_ID] = xe_oa_set_prop_ret_inval,
1293+
[DRM_XE_OA_PROPERTY_OA_ENGINE_INSTANCE] = xe_oa_set_prop_ret_inval,
1294+
[DRM_XE_OA_PROPERTY_NO_PREEMPT] = xe_oa_set_prop_ret_inval,
1295+
[DRM_XE_OA_PROPERTY_NUM_SYNCS] = xe_oa_set_prop_num_syncs,
1296+
[DRM_XE_OA_PROPERTY_SYNCS] = xe_oa_set_prop_syncs_user,
1297+
};
1298+
1299+
static int xe_oa_user_ext_set_property(struct xe_oa *oa, enum xe_oa_user_extn_from from,
1300+
u64 extension, struct xe_oa_open_param *param)
12761301
{
12771302
u64 __user *address = u64_to_user_ptr(extension);
12781303
struct drm_xe_ext_set_property ext;
@@ -1283,23 +1308,30 @@ static int xe_oa_user_ext_set_property(struct xe_oa *oa, u64 extension,
12831308
if (XE_IOCTL_DBG(oa->xe, err))
12841309
return -EFAULT;
12851310

1286-
if (XE_IOCTL_DBG(oa->xe, ext.property >= ARRAY_SIZE(xe_oa_set_property_funcs)) ||
1311+
BUILD_BUG_ON(ARRAY_SIZE(xe_oa_set_property_funcs_open) !=
1312+
ARRAY_SIZE(xe_oa_set_property_funcs_config));
1313+
1314+
if (XE_IOCTL_DBG(oa->xe, ext.property >= ARRAY_SIZE(xe_oa_set_property_funcs_open)) ||
12871315
XE_IOCTL_DBG(oa->xe, ext.pad))
12881316
return -EINVAL;
12891317

1290-
idx = array_index_nospec(ext.property, ARRAY_SIZE(xe_oa_set_property_funcs));
1291-
return xe_oa_set_property_funcs[idx](oa, ext.value, param);
1318+
idx = array_index_nospec(ext.property, ARRAY_SIZE(xe_oa_set_property_funcs_open));
1319+
1320+
if (from == XE_OA_USER_EXTN_FROM_CONFIG)
1321+
return xe_oa_set_property_funcs_config[idx](oa, ext.value, param);
1322+
else
1323+
return xe_oa_set_property_funcs_open[idx](oa, ext.value, param);
12921324
}
12931325

1294-
typedef int (*xe_oa_user_extension_fn)(struct xe_oa *oa, u64 extension,
1295-
struct xe_oa_open_param *param);
1326+
typedef int (*xe_oa_user_extension_fn)(struct xe_oa *oa, enum xe_oa_user_extn_from from,
1327+
u64 extension, struct xe_oa_open_param *param);
12961328
static const xe_oa_user_extension_fn xe_oa_user_extension_funcs[] = {
12971329
[DRM_XE_OA_EXTENSION_SET_PROPERTY] = xe_oa_user_ext_set_property,
12981330
};
12991331

13001332
#define MAX_USER_EXTENSIONS 16
1301-
static int xe_oa_user_extensions(struct xe_oa *oa, u64 extension, int ext_number,
1302-
struct xe_oa_open_param *param)
1333+
static int xe_oa_user_extensions(struct xe_oa *oa, enum xe_oa_user_extn_from from, u64 extension,
1334+
int ext_number, struct xe_oa_open_param *param)
13031335
{
13041336
u64 __user *address = u64_to_user_ptr(extension);
13051337
struct drm_xe_user_extension ext;
@@ -1318,12 +1350,12 @@ static int xe_oa_user_extensions(struct xe_oa *oa, u64 extension, int ext_number
13181350
return -EINVAL;
13191351

13201352
idx = array_index_nospec(ext.name, ARRAY_SIZE(xe_oa_user_extension_funcs));
1321-
err = xe_oa_user_extension_funcs[idx](oa, extension, param);
1353+
err = xe_oa_user_extension_funcs[idx](oa, from, extension, param);
13221354
if (XE_IOCTL_DBG(oa->xe, err))
13231355
return err;
13241356

13251357
if (ext.next_extension)
1326-
return xe_oa_user_extensions(oa, ext.next_extension, ++ext_number, param);
1358+
return xe_oa_user_extensions(oa, from, ext.next_extension, ++ext_number, param);
13271359

13281360
return 0;
13291361
}
@@ -1469,7 +1501,7 @@ static long xe_oa_config_locked(struct xe_oa_stream *stream, u64 arg)
14691501
struct xe_oa_config *config;
14701502
int err;
14711503

1472-
err = xe_oa_user_extensions(stream->oa, arg, 0, &param);
1504+
err = xe_oa_user_extensions(stream->oa, XE_OA_USER_EXTN_FROM_CONFIG, arg, 0, &param);
14731505
if (err)
14741506
return err;
14751507

@@ -2023,7 +2055,7 @@ int xe_oa_stream_open_ioctl(struct drm_device *dev, u64 data, struct drm_file *f
20232055
}
20242056

20252057
param.xef = xef;
2026-
ret = xe_oa_user_extensions(oa, data, 0, &param);
2058+
ret = xe_oa_user_extensions(oa, XE_OA_USER_EXTN_FROM_OPEN, data, 0, &param);
20272059
if (ret)
20282060
return ret;
20292061

0 commit comments

Comments
 (0)