Skip to content

Commit 9920c8b

Browse files
committed
drm/xe/oa: Add syncs support to OA config ioctl
In addition to stream open, add xe_sync support to the OA config ioctl, where it is even more useful. This allows e.g. Mesa to replay a workload repeatedly on the GPU, each time with a different OA configuration, while precisely controlling (at batch buffer granularity) the workload segment for which a particular OA configuration is active, without introducing stalls in the userspace pipeline. v2: Emit OA config even when config id is same as previous, to ensure consistent sync behavior (Jose) Reviewed-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-7-ashutosh.dixit@intel.com
1 parent cc4e699 commit 9920c8b

File tree

2 files changed

+26
-18
lines changed

2 files changed

+26
-18
lines changed

drivers/gpu/drm/xe/xe_oa.c

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,7 @@ static void xe_oa_stream_destroy(struct xe_oa_stream *stream)
893893
xe_gt_WARN_ON(gt, xe_guc_pc_unset_gucrc_mode(&gt->uc.guc.pc));
894894

895895
xe_oa_free_configs(stream);
896+
xe_file_put(stream->xef);
896897
}
897898

898899
static int xe_oa_alloc_oa_buffer(struct xe_oa_stream *stream)
@@ -1463,36 +1464,38 @@ static int xe_oa_disable_locked(struct xe_oa_stream *stream)
14631464

14641465
static long xe_oa_config_locked(struct xe_oa_stream *stream, u64 arg)
14651466
{
1466-
struct drm_xe_ext_set_property ext;
1467+
struct xe_oa_open_param param = {};
14671468
long ret = stream->oa_config->id;
14681469
struct xe_oa_config *config;
14691470
int err;
14701471

1471-
err = __copy_from_user(&ext, u64_to_user_ptr(arg), sizeof(ext));
1472-
if (XE_IOCTL_DBG(stream->oa->xe, err))
1473-
return -EFAULT;
1474-
1475-
if (XE_IOCTL_DBG(stream->oa->xe, ext.pad) ||
1476-
XE_IOCTL_DBG(stream->oa->xe, ext.base.name != DRM_XE_OA_EXTENSION_SET_PROPERTY) ||
1477-
XE_IOCTL_DBG(stream->oa->xe, ext.base.next_extension) ||
1478-
XE_IOCTL_DBG(stream->oa->xe, ext.property != DRM_XE_OA_PROPERTY_OA_METRIC_SET))
1479-
return -EINVAL;
1472+
err = xe_oa_user_extensions(stream->oa, arg, 0, &param);
1473+
if (err)
1474+
return err;
14801475

1481-
config = xe_oa_get_oa_config(stream->oa, ext.value);
1476+
config = xe_oa_get_oa_config(stream->oa, param.metric_set);
14821477
if (!config)
14831478
return -ENODEV;
14841479

1485-
if (config != stream->oa_config) {
1486-
err = xe_oa_emit_oa_config(stream, config);
1487-
if (!err)
1488-
config = xchg(&stream->oa_config, config);
1489-
else
1490-
ret = err;
1480+
param.xef = stream->xef;
1481+
err = xe_oa_parse_syncs(stream->oa, &param);
1482+
if (err)
1483+
goto err_config_put;
1484+
1485+
stream->num_syncs = param.num_syncs;
1486+
stream->syncs = param.syncs;
1487+
1488+
err = xe_oa_emit_oa_config(stream, config);
1489+
if (!err) {
1490+
config = xchg(&stream->oa_config, config);
1491+
drm_dbg(&stream->oa->xe->drm, "changed to oa config uuid=%s\n",
1492+
stream->oa_config->uuid);
14911493
}
14921494

1495+
err_config_put:
14931496
xe_oa_config_put(config);
14941497

1495-
return ret;
1498+
return err ?: ret;
14961499
}
14971500

14981501
static long xe_oa_status_locked(struct xe_oa_stream *stream, unsigned long arg)
@@ -1734,6 +1737,7 @@ static int xe_oa_stream_init(struct xe_oa_stream *stream,
17341737
stream->period_exponent = param->period_exponent;
17351738
stream->no_preempt = param->no_preempt;
17361739

1740+
stream->xef = xe_file_get(param->xef);
17371741
stream->num_syncs = param->num_syncs;
17381742
stream->syncs = param->syncs;
17391743

@@ -1837,6 +1841,7 @@ static int xe_oa_stream_init(struct xe_oa_stream *stream,
18371841
err_free_configs:
18381842
xe_oa_free_configs(stream);
18391843
exit:
1844+
xe_file_put(stream->xef);
18401845
return ret;
18411846
}
18421847

drivers/gpu/drm/xe/xe_oa_types.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@ struct xe_oa_stream {
239239
/** @no_preempt: Whether preemption and timeslicing is disabled for stream exec_q */
240240
u32 no_preempt;
241241

242+
/** @xef: xe_file with which the stream was opened */
243+
struct xe_file *xef;
244+
242245
/** @last_fence: fence to use in stream destroy when needed */
243246
struct dma_fence *last_fence;
244247

0 commit comments

Comments
 (0)