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>
@@ -1390,7 +1391,9 @@ static int xe_oa_user_extensions(struct xe_oa *oa, enum xe_oa_user_extn_from fro
13901391 return 0 ;
13911392}
13921393
1393- static int xe_oa_parse_syncs (struct xe_oa * oa , struct xe_oa_open_param * param )
1394+ static int xe_oa_parse_syncs (struct xe_oa * oa ,
1395+ struct xe_oa_stream * stream ,
1396+ struct xe_oa_open_param * param )
13941397{
13951398 int ret , num_syncs , num_ufence = 0 ;
13961399
@@ -1410,7 +1413,9 @@ static int xe_oa_parse_syncs(struct xe_oa *oa, struct xe_oa_open_param *param)
14101413
14111414 for (num_syncs = 0 ; num_syncs < param -> num_syncs ; num_syncs ++ ) {
14121415 ret = xe_sync_entry_parse (oa -> xe , param -> xef , & param -> syncs [num_syncs ],
1413- & param -> syncs_user [num_syncs ], 0 );
1416+ & param -> syncs_user [num_syncs ],
1417+ stream -> ufence_syncobj ,
1418+ ++ stream -> ufence_timeline_value , 0 );
14141419 if (ret )
14151420 goto err_syncs ;
14161421
@@ -1540,7 +1545,7 @@ static long xe_oa_config_locked(struct xe_oa_stream *stream, u64 arg)
15401545 return - ENODEV ;
15411546
15421547 param .xef = stream -> xef ;
1543- err = xe_oa_parse_syncs (stream -> oa , & param );
1548+ err = xe_oa_parse_syncs (stream -> oa , stream , & param );
15441549 if (err )
15451550 goto err_config_put ;
15461551
@@ -1636,6 +1641,7 @@ static void xe_oa_destroy_locked(struct xe_oa_stream *stream)
16361641 if (stream -> exec_q )
16371642 xe_exec_queue_put (stream -> exec_q );
16381643
1644+ drm_syncobj_put (stream -> ufence_syncobj );
16391645 kfree (stream );
16401646}
16411647
@@ -1827,6 +1833,7 @@ static int xe_oa_stream_open_ioctl_locked(struct xe_oa *oa,
18271833 struct xe_oa_open_param * param )
18281834{
18291835 struct xe_oa_stream * stream ;
1836+ struct drm_syncobj * ufence_syncobj ;
18301837 int stream_fd ;
18311838 int ret ;
18321839
@@ -1837,17 +1844,31 @@ static int xe_oa_stream_open_ioctl_locked(struct xe_oa *oa,
18371844 goto exit ;
18381845 }
18391846
1847+ ret = drm_syncobj_create (& ufence_syncobj , DRM_SYNCOBJ_CREATE_SIGNALED ,
1848+ NULL );
1849+ if (ret )
1850+ goto exit ;
1851+
18401852 stream = kzalloc (sizeof (* stream ), GFP_KERNEL );
18411853 if (!stream ) {
18421854 ret = - ENOMEM ;
1843- goto exit ;
1855+ goto err_syncobj ;
18441856 }
1845-
1857+ stream -> ufence_syncobj = ufence_syncobj ;
18461858 stream -> oa = oa ;
1847- ret = xe_oa_stream_init (stream , param );
1859+
1860+ ret = xe_oa_parse_syncs (oa , stream , param );
18481861 if (ret )
18491862 goto err_free ;
18501863
1864+ ret = xe_oa_stream_init (stream , param );
1865+ if (ret ) {
1866+ while (param -> num_syncs -- )
1867+ xe_sync_entry_cleanup (& param -> syncs [param -> num_syncs ]);
1868+ kfree (param -> syncs );
1869+ goto err_free ;
1870+ }
1871+
18511872 if (!param -> disabled ) {
18521873 ret = xe_oa_enable_locked (stream );
18531874 if (ret )
@@ -1871,6 +1892,8 @@ static int xe_oa_stream_open_ioctl_locked(struct xe_oa *oa,
18711892 xe_oa_stream_destroy (stream );
18721893err_free :
18731894 kfree (stream );
1895+ err_syncobj :
1896+ drm_syncobj_put (ufence_syncobj );
18741897exit :
18751898 return ret ;
18761899}
@@ -2084,22 +2107,14 @@ int xe_oa_stream_open_ioctl(struct drm_device *dev, u64 data, struct drm_file *f
20842107 goto err_exec_q ;
20852108 }
20862109
2087- ret = xe_oa_parse_syncs (oa , & param );
2088- if (ret )
2089- goto err_exec_q ;
2090-
20912110 mutex_lock (& param .hwe -> gt -> oa .gt_lock );
20922111 ret = xe_oa_stream_open_ioctl_locked (oa , & param );
20932112 mutex_unlock (& param .hwe -> gt -> oa .gt_lock );
20942113 if (ret < 0 )
2095- goto err_sync_cleanup ;
2114+ goto err_exec_q ;
20962115
20972116 return ret ;
20982117
2099- err_sync_cleanup :
2100- while (param .num_syncs -- )
2101- xe_sync_entry_cleanup (& param .syncs [param .num_syncs ]);
2102- kfree (param .syncs );
21032118err_exec_q :
21042119 if (param .exec_q )
21052120 xe_exec_queue_put (param .exec_q );
0 commit comments