1010
1111#include <drm/drm_drv.h>
1212#include <drm/drm_managed.h>
13+ #include <drm/drm_syncobj.h>
1314#include <uapi/drm/xe_drm.h>
1415
1516#include <generated/xe_wa_oob.h>
@@ -1389,7 +1390,9 @@ static int xe_oa_user_extensions(struct xe_oa *oa, enum xe_oa_user_extn_from fro
13891390 return 0 ;
13901391}
13911392
1392- static int xe_oa_parse_syncs (struct xe_oa * oa , struct xe_oa_open_param * param )
1393+ static int xe_oa_parse_syncs (struct xe_oa * oa ,
1394+ struct xe_oa_stream * stream ,
1395+ struct xe_oa_open_param * param )
13931396{
13941397 int ret , num_syncs , num_ufence = 0 ;
13951398
@@ -1409,7 +1412,9 @@ static int xe_oa_parse_syncs(struct xe_oa *oa, struct xe_oa_open_param *param)
14091412
14101413 for (num_syncs = 0 ; num_syncs < param -> num_syncs ; num_syncs ++ ) {
14111414 ret = xe_sync_entry_parse (oa -> xe , param -> xef , & param -> syncs [num_syncs ],
1412- & param -> syncs_user [num_syncs ], 0 );
1415+ & param -> syncs_user [num_syncs ],
1416+ stream -> ufence_syncobj ,
1417+ ++ stream -> ufence_timeline_value , 0 );
14131418 if (ret )
14141419 goto err_syncs ;
14151420
@@ -1539,7 +1544,7 @@ static long xe_oa_config_locked(struct xe_oa_stream *stream, u64 arg)
15391544 return - ENODEV ;
15401545
15411546 param .xef = stream -> xef ;
1542- err = xe_oa_parse_syncs (stream -> oa , & param );
1547+ err = xe_oa_parse_syncs (stream -> oa , stream , & param );
15431548 if (err )
15441549 goto err_config_put ;
15451550
@@ -1635,6 +1640,7 @@ static void xe_oa_destroy_locked(struct xe_oa_stream *stream)
16351640 if (stream -> exec_q )
16361641 xe_exec_queue_put (stream -> exec_q );
16371642
1643+ drm_syncobj_put (stream -> ufence_syncobj );
16381644 kfree (stream );
16391645}
16401646
@@ -1826,6 +1832,7 @@ static int xe_oa_stream_open_ioctl_locked(struct xe_oa *oa,
18261832 struct xe_oa_open_param * param )
18271833{
18281834 struct xe_oa_stream * stream ;
1835+ struct drm_syncobj * ufence_syncobj ;
18291836 int stream_fd ;
18301837 int ret ;
18311838
@@ -1836,17 +1843,31 @@ static int xe_oa_stream_open_ioctl_locked(struct xe_oa *oa,
18361843 goto exit ;
18371844 }
18381845
1846+ ret = drm_syncobj_create (& ufence_syncobj , DRM_SYNCOBJ_CREATE_SIGNALED ,
1847+ NULL );
1848+ if (ret )
1849+ goto exit ;
1850+
18391851 stream = kzalloc (sizeof (* stream ), GFP_KERNEL );
18401852 if (!stream ) {
18411853 ret = - ENOMEM ;
1842- goto exit ;
1854+ goto err_syncobj ;
18431855 }
1844-
1856+ stream -> ufence_syncobj = ufence_syncobj ;
18451857 stream -> oa = oa ;
1846- ret = xe_oa_stream_init (stream , param );
1858+
1859+ ret = xe_oa_parse_syncs (oa , stream , param );
18471860 if (ret )
18481861 goto err_free ;
18491862
1863+ ret = xe_oa_stream_init (stream , param );
1864+ if (ret ) {
1865+ while (param -> num_syncs -- )
1866+ xe_sync_entry_cleanup (& param -> syncs [param -> num_syncs ]);
1867+ kfree (param -> syncs );
1868+ goto err_free ;
1869+ }
1870+
18501871 if (!param -> disabled ) {
18511872 ret = xe_oa_enable_locked (stream );
18521873 if (ret )
@@ -1870,6 +1891,8 @@ static int xe_oa_stream_open_ioctl_locked(struct xe_oa *oa,
18701891 xe_oa_stream_destroy (stream );
18711892err_free :
18721893 kfree (stream );
1894+ err_syncobj :
1895+ drm_syncobj_put (ufence_syncobj );
18731896exit :
18741897 return ret ;
18751898}
@@ -2083,22 +2106,14 @@ int xe_oa_stream_open_ioctl(struct drm_device *dev, u64 data, struct drm_file *f
20832106 goto err_exec_q ;
20842107 }
20852108
2086- ret = xe_oa_parse_syncs (oa , & param );
2087- if (ret )
2088- goto err_exec_q ;
2089-
20902109 mutex_lock (& param .hwe -> gt -> oa .gt_lock );
20912110 ret = xe_oa_stream_open_ioctl_locked (oa , & param );
20922111 mutex_unlock (& param .hwe -> gt -> oa .gt_lock );
20932112 if (ret < 0 )
2094- goto err_sync_cleanup ;
2113+ goto err_exec_q ;
20952114
20962115 return ret ;
20972116
2098- err_sync_cleanup :
2099- while (param .num_syncs -- )
2100- xe_sync_entry_cleanup (& param .syncs [param .num_syncs ]);
2101- kfree (param .syncs );
21022117err_exec_q :
21032118 if (param .exec_q )
21042119 xe_exec_queue_put (param .exec_q );
0 commit comments