]> www.infradead.org Git - linux.git/commitdiff
drm/xe/oa: Add syncs support to OA config ioctl
authorAshutosh Dixit <ashutosh.dixit@intel.com>
Tue, 22 Oct 2024 20:03:51 +0000 (13:03 -0700)
committerAshutosh Dixit <ashutosh.dixit@intel.com>
Wed, 23 Oct 2024 19:42:19 +0000 (12:42 -0700)
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
drivers/gpu/drm/xe/xe_oa.c
drivers/gpu/drm/xe/xe_oa_types.h

index 8684ffca929fd03a45d9d84902000b5054b72102..9806caf1e530dfa727a9ac24816bad422111ed36 100644 (file)
@@ -893,6 +893,7 @@ static void xe_oa_stream_destroy(struct xe_oa_stream *stream)
                xe_gt_WARN_ON(gt, xe_guc_pc_unset_gucrc_mode(&gt->uc.guc.pc));
 
        xe_oa_free_configs(stream);
+       xe_file_put(stream->xef);
 }
 
 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)
 
 static long xe_oa_config_locked(struct xe_oa_stream *stream, u64 arg)
 {
-       struct drm_xe_ext_set_property ext;
+       struct xe_oa_open_param param = {};
        long ret = stream->oa_config->id;
        struct xe_oa_config *config;
        int err;
 
-       err = __copy_from_user(&ext, u64_to_user_ptr(arg), sizeof(ext));
-       if (XE_IOCTL_DBG(stream->oa->xe, err))
-               return -EFAULT;
-
-       if (XE_IOCTL_DBG(stream->oa->xe, ext.pad) ||
-           XE_IOCTL_DBG(stream->oa->xe, ext.base.name != DRM_XE_OA_EXTENSION_SET_PROPERTY) ||
-           XE_IOCTL_DBG(stream->oa->xe, ext.base.next_extension) ||
-           XE_IOCTL_DBG(stream->oa->xe, ext.property != DRM_XE_OA_PROPERTY_OA_METRIC_SET))
-               return -EINVAL;
+       err = xe_oa_user_extensions(stream->oa, arg, 0, &param);
+       if (err)
+               return err;
 
-       config = xe_oa_get_oa_config(stream->oa, ext.value);
+       config = xe_oa_get_oa_config(stream->oa, param.metric_set);
        if (!config)
                return -ENODEV;
 
-       if (config != stream->oa_config) {
-               err = xe_oa_emit_oa_config(stream, config);
-               if (!err)
-                       config = xchg(&stream->oa_config, config);
-               else
-                       ret = err;
+       param.xef = stream->xef;
+       err = xe_oa_parse_syncs(stream->oa, &param);
+       if (err)
+               goto err_config_put;
+
+       stream->num_syncs = param.num_syncs;
+       stream->syncs = param.syncs;
+
+       err = xe_oa_emit_oa_config(stream, config);
+       if (!err) {
+               config = xchg(&stream->oa_config, config);
+               drm_dbg(&stream->oa->xe->drm, "changed to oa config uuid=%s\n",
+                       stream->oa_config->uuid);
        }
 
+err_config_put:
        xe_oa_config_put(config);
 
-       return ret;
+       return err ?: ret;
 }
 
 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,
        stream->period_exponent = param->period_exponent;
        stream->no_preempt = param->no_preempt;
 
+       stream->xef = xe_file_get(param->xef);
        stream->num_syncs = param->num_syncs;
        stream->syncs = param->syncs;
 
@@ -1837,6 +1841,7 @@ err_fw_put:
 err_free_configs:
        xe_oa_free_configs(stream);
 exit:
+       xe_file_put(stream->xef);
        return ret;
 }
 
index c8e0df13faf83a95abb97773aa9bf9d7121cd5c8..fea9d981e414fadbba7d660da65a449c3d33fe61 100644 (file)
@@ -239,6 +239,9 @@ struct xe_oa_stream {
        /** @no_preempt: Whether preemption and timeslicing is disabled for stream exec_q */
        u32 no_preempt;
 
+       /** @xef: xe_file with which the stream was opened */
+       struct xe_file *xef;
+
        /** @last_fence: fence to use in stream destroy when needed */
        struct dma_fence *last_fence;