Skip to content

Commit 1bab7ec

Browse files
ashutoshxrodrigovivi
authored andcommitted
drm/xe/oa: Allow stream enable/disable functions to return error
Stream enable/disable functions previously had void return because failure during function execution was not possible. This will change when we introduce functionality to disable preemption on the stream exec queue. Therefore, in preparation for this functionality, prepare this code to be able to handle error returns. Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com> Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240626181817.1516229-2-ashutosh.dixit@intel.com Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
1 parent 8d789ff commit 1bab7ec

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

drivers/gpu/drm/xe/xe_oa.c

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,24 +1013,26 @@ static void xe_oa_stream_disable(struct xe_oa_stream *stream)
10131013
hrtimer_cancel(&stream->poll_check_timer);
10141014
}
10151015

1016-
static void xe_oa_enable_locked(struct xe_oa_stream *stream)
1016+
static int xe_oa_enable_locked(struct xe_oa_stream *stream)
10171017
{
10181018
if (stream->enabled)
1019-
return;
1020-
1021-
stream->enabled = true;
1019+
return 0;
10221020

10231021
xe_oa_stream_enable(stream);
1022+
1023+
stream->enabled = true;
1024+
return 0;
10241025
}
10251026

1026-
static void xe_oa_disable_locked(struct xe_oa_stream *stream)
1027+
static int xe_oa_disable_locked(struct xe_oa_stream *stream)
10271028
{
10281029
if (!stream->enabled)
1029-
return;
1030-
1031-
stream->enabled = false;
1030+
return 0;
10321031

10331032
xe_oa_stream_disable(stream);
1033+
1034+
stream->enabled = false;
1035+
return 0;
10341036
}
10351037

10361038
static long xe_oa_config_locked(struct xe_oa_stream *stream, u64 arg)
@@ -1105,11 +1107,9 @@ static long xe_oa_ioctl_locked(struct xe_oa_stream *stream,
11051107
{
11061108
switch (cmd) {
11071109
case DRM_XE_PERF_IOCTL_ENABLE:
1108-
xe_oa_enable_locked(stream);
1109-
return 0;
1110+
return xe_oa_enable_locked(stream);
11101111
case DRM_XE_PERF_IOCTL_DISABLE:
1111-
xe_oa_disable_locked(stream);
1112-
return 0;
1112+
return xe_oa_disable_locked(stream);
11131113
case DRM_XE_PERF_IOCTL_CONFIG:
11141114
return xe_oa_config_locked(stream, arg);
11151115
case DRM_XE_PERF_IOCTL_STATUS:
@@ -1432,19 +1432,25 @@ static int xe_oa_stream_open_ioctl_locked(struct xe_oa *oa,
14321432
if (ret)
14331433
goto err_free;
14341434

1435+
if (!param->disabled) {
1436+
ret = xe_oa_enable_locked(stream);
1437+
if (ret)
1438+
goto err_destroy;
1439+
}
1440+
14351441
stream_fd = anon_inode_getfd("[xe_oa]", &xe_oa_fops, stream, 0);
14361442
if (stream_fd < 0) {
14371443
ret = stream_fd;
1438-
goto err_destroy;
1444+
goto err_disable;
14391445
}
14401446

1441-
if (!param->disabled)
1442-
xe_oa_enable_locked(stream);
1443-
14441447
/* Hold a reference on the drm device till stream_fd is released */
14451448
drm_dev_get(&stream->oa->xe->drm);
14461449

14471450
return stream_fd;
1451+
err_disable:
1452+
if (!param->disabled)
1453+
xe_oa_disable_locked(stream);
14481454
err_destroy:
14491455
xe_oa_stream_destroy(stream);
14501456
err_free:

0 commit comments

Comments
 (0)