@@ -97,6 +97,7 @@ struct xe_oa_open_param {
97
97
int num_syncs ;
98
98
struct xe_sync_entry * syncs ;
99
99
size_t oa_buffer_size ;
100
+ int wait_num_reports ;
100
101
};
101
102
102
103
struct xe_oa_config_bo {
@@ -241,11 +242,10 @@ static void oa_timestamp_clear(struct xe_oa_stream *stream, u32 *report)
241
242
static bool xe_oa_buffer_check_unlocked (struct xe_oa_stream * stream )
242
243
{
243
244
u32 gtt_offset = xe_bo_ggtt_addr (stream -> oa_buffer .bo );
245
+ u32 tail , hw_tail , partial_report_size , available ;
244
246
int report_size = stream -> oa_buffer .format -> size ;
245
- u32 tail , hw_tail ;
246
247
unsigned long flags ;
247
248
bool pollin ;
248
- u32 partial_report_size ;
249
249
250
250
spin_lock_irqsave (& stream -> oa_buffer .ptr_lock , flags );
251
251
@@ -289,8 +289,8 @@ static bool xe_oa_buffer_check_unlocked(struct xe_oa_stream *stream)
289
289
290
290
stream -> oa_buffer .tail = tail ;
291
291
292
- pollin = xe_oa_circ_diff (stream , stream -> oa_buffer .tail ,
293
- stream -> oa_buffer . head ) >= report_size ;
292
+ available = xe_oa_circ_diff (stream , stream -> oa_buffer .tail , stream -> oa_buffer . head );
293
+ pollin = available >= stream -> wait_num_reports * report_size ;
294
294
295
295
spin_unlock_irqrestore (& stream -> oa_buffer .ptr_lock , flags );
296
296
@@ -1285,6 +1285,17 @@ static int xe_oa_set_prop_oa_buffer_size(struct xe_oa *oa, u64 value,
1285
1285
return 0 ;
1286
1286
}
1287
1287
1288
+ static int xe_oa_set_prop_wait_num_reports (struct xe_oa * oa , u64 value ,
1289
+ struct xe_oa_open_param * param )
1290
+ {
1291
+ if (!value ) {
1292
+ drm_dbg (& oa -> xe -> drm , "wait_num_reports %llu\n" , value );
1293
+ return - EINVAL ;
1294
+ }
1295
+ param -> wait_num_reports = value ;
1296
+ return 0 ;
1297
+ }
1298
+
1288
1299
static int xe_oa_set_prop_ret_inval (struct xe_oa * oa , u64 value ,
1289
1300
struct xe_oa_open_param * param )
1290
1301
{
@@ -1306,6 +1317,7 @@ static const xe_oa_set_property_fn xe_oa_set_property_funcs_open[] = {
1306
1317
[DRM_XE_OA_PROPERTY_NUM_SYNCS ] = xe_oa_set_prop_num_syncs ,
1307
1318
[DRM_XE_OA_PROPERTY_SYNCS ] = xe_oa_set_prop_syncs_user ,
1308
1319
[DRM_XE_OA_PROPERTY_OA_BUFFER_SIZE ] = xe_oa_set_prop_oa_buffer_size ,
1320
+ [DRM_XE_OA_PROPERTY_WAIT_NUM_REPORTS ] = xe_oa_set_prop_wait_num_reports ,
1309
1321
};
1310
1322
1311
1323
static const xe_oa_set_property_fn xe_oa_set_property_funcs_config [] = {
@@ -1321,6 +1333,7 @@ static const xe_oa_set_property_fn xe_oa_set_property_funcs_config[] = {
1321
1333
[DRM_XE_OA_PROPERTY_NUM_SYNCS ] = xe_oa_set_prop_num_syncs ,
1322
1334
[DRM_XE_OA_PROPERTY_SYNCS ] = xe_oa_set_prop_syncs_user ,
1323
1335
[DRM_XE_OA_PROPERTY_OA_BUFFER_SIZE ] = xe_oa_set_prop_ret_inval ,
1336
+ [DRM_XE_OA_PROPERTY_WAIT_NUM_REPORTS ] = xe_oa_set_prop_ret_inval ,
1324
1337
};
1325
1338
1326
1339
static int xe_oa_user_ext_set_property (struct xe_oa * oa , enum xe_oa_user_extn_from from ,
@@ -1797,6 +1810,7 @@ static int xe_oa_stream_init(struct xe_oa_stream *stream,
1797
1810
stream -> periodic = param -> period_exponent > 0 ;
1798
1811
stream -> period_exponent = param -> period_exponent ;
1799
1812
stream -> no_preempt = param -> no_preempt ;
1813
+ stream -> wait_num_reports = param -> wait_num_reports ;
1800
1814
1801
1815
stream -> xef = xe_file_get (param -> xef );
1802
1816
stream -> num_syncs = param -> num_syncs ;
@@ -2156,6 +2170,14 @@ int xe_oa_stream_open_ioctl(struct drm_device *dev, u64 data, struct drm_file *f
2156
2170
if (!param .oa_buffer_size )
2157
2171
param .oa_buffer_size = DEFAULT_XE_OA_BUFFER_SIZE ;
2158
2172
2173
+ if (!param .wait_num_reports )
2174
+ param .wait_num_reports = 1 ;
2175
+ if (param .wait_num_reports > param .oa_buffer_size / f -> size ) {
2176
+ drm_dbg (& oa -> xe -> drm , "wait_num_reports %d\n" , param .wait_num_reports );
2177
+ ret = - EINVAL ;
2178
+ goto err_exec_q ;
2179
+ }
2180
+
2159
2181
ret = xe_oa_parse_syncs (oa , & param );
2160
2182
if (ret )
2161
2183
goto err_exec_q ;
0 commit comments