@@ -47,6 +47,11 @@ enum xe_oa_submit_deps {
47
47
XE_OA_SUBMIT_ADD_DEPS ,
48
48
};
49
49
50
+ enum xe_oa_user_extn_from {
51
+ XE_OA_USER_EXTN_FROM_OPEN ,
52
+ XE_OA_USER_EXTN_FROM_CONFIG ,
53
+ };
54
+
50
55
struct xe_oa_reg {
51
56
struct xe_reg addr ;
52
57
u32 value ;
@@ -1255,9 +1260,15 @@ static int xe_oa_set_prop_syncs_user(struct xe_oa *oa, u64 value,
1255
1260
return 0 ;
1256
1261
}
1257
1262
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
+
1258
1269
typedef int (* xe_oa_set_property_fn )(struct xe_oa * oa , u64 value ,
1259
1270
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 [] = {
1261
1272
[DRM_XE_OA_PROPERTY_OA_UNIT_ID ] = xe_oa_set_prop_oa_unit_id ,
1262
1273
[DRM_XE_OA_PROPERTY_SAMPLE_OA ] = xe_oa_set_prop_sample_oa ,
1263
1274
[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[] = {
1271
1282
[DRM_XE_OA_PROPERTY_SYNCS ] = xe_oa_set_prop_syncs_user ,
1272
1283
};
1273
1284
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 )
1276
1301
{
1277
1302
u64 __user * address = u64_to_user_ptr (extension );
1278
1303
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,
1283
1308
if (XE_IOCTL_DBG (oa -> xe , err ))
1284
1309
return - EFAULT ;
1285
1310
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 )) ||
1287
1315
XE_IOCTL_DBG (oa -> xe , ext .pad ))
1288
1316
return - EINVAL ;
1289
1317
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 );
1292
1324
}
1293
1325
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 );
1296
1328
static const xe_oa_user_extension_fn xe_oa_user_extension_funcs [] = {
1297
1329
[DRM_XE_OA_EXTENSION_SET_PROPERTY ] = xe_oa_user_ext_set_property ,
1298
1330
};
1299
1331
1300
1332
#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 )
1303
1335
{
1304
1336
u64 __user * address = u64_to_user_ptr (extension );
1305
1337
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
1318
1350
return - EINVAL ;
1319
1351
1320
1352
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 );
1322
1354
if (XE_IOCTL_DBG (oa -> xe , err ))
1323
1355
return err ;
1324
1356
1325
1357
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 );
1327
1359
1328
1360
return 0 ;
1329
1361
}
@@ -1469,7 +1501,7 @@ static long xe_oa_config_locked(struct xe_oa_stream *stream, u64 arg)
1469
1501
struct xe_oa_config * config ;
1470
1502
int err ;
1471
1503
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 );
1473
1505
if (err )
1474
1506
return err ;
1475
1507
@@ -2023,7 +2055,7 @@ int xe_oa_stream_open_ioctl(struct drm_device *dev, u64 data, struct drm_file *f
2023
2055
}
2024
2056
2025
2057
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 );
2027
2059
if (ret )
2028
2060
return ret ;
2029
2061
0 commit comments