@@ -1923,37 +1923,48 @@ u16 xe_oa_unit_id(struct xe_hw_engine *hwe)
1923
1923
hwe -> oa_unit -> oa_unit_id : U16_MAX ;
1924
1924
}
1925
1925
1926
+ /* A hwe must be assigned to stream/oa_unit for batch submissions */
1926
1927
static int xe_oa_assign_hwe (struct xe_oa * oa , struct xe_oa_open_param * param )
1927
1928
{
1928
- struct xe_gt * gt ;
1929
- int i , ret = 0 ;
1929
+ struct xe_hw_engine * hwe ;
1930
+ enum xe_hw_engine_id id ;
1931
+ int ret = 0 ;
1932
+
1933
+ /* If not provided, OA unit defaults to OA unit 0 as per uapi */
1934
+ if (!param -> oa_unit )
1935
+ param -> oa_unit = & xe_device_get_gt (oa -> xe , 0 )-> oa .oa_unit [0 ];
1930
1936
1937
+ /* When we have an exec_q, get hwe from the exec_q */
1931
1938
if (param -> exec_q ) {
1932
- /* When we have an exec_q, get hwe from the exec_q */
1933
1939
param -> hwe = xe_gt_hw_engine (param -> exec_q -> gt , param -> exec_q -> class ,
1934
1940
param -> engine_instance , true);
1935
- } else {
1936
- struct xe_hw_engine * hwe ;
1937
- enum xe_hw_engine_id id ;
1938
-
1939
- /* Else just get the first hwe attached to the oa unit */
1940
- for_each_gt (gt , oa -> xe , i ) {
1941
- for_each_hw_engine (hwe , gt , id ) {
1942
- if (hwe -> oa_unit == param -> oa_unit ) {
1943
- param -> hwe = hwe ;
1944
- goto out ;
1945
- }
1946
- }
1947
- }
1941
+ if (!param -> hwe || param -> hwe -> oa_unit != param -> oa_unit )
1942
+ goto err ;
1943
+ goto out ;
1948
1944
}
1949
- out :
1950
- if (!param -> hwe || param -> hwe -> oa_unit != param -> oa_unit ) {
1951
- drm_dbg (& oa -> xe -> drm , "Unable to find hwe (%d, %d) for OA unit ID %d\n" ,
1952
- param -> exec_q ? param -> exec_q -> class : -1 ,
1953
- param -> engine_instance , param -> oa_unit -> oa_unit_id );
1954
- ret = - EINVAL ;
1945
+
1946
+ /* Else just get the first hwe attached to the oa unit */
1947
+ for_each_hw_engine (hwe , param -> oa_unit -> gt , id ) {
1948
+ if (hwe -> oa_unit == param -> oa_unit ) {
1949
+ param -> hwe = hwe ;
1950
+ goto out ;
1951
+ }
1955
1952
}
1956
1953
1954
+ /* If we still didn't find a hwe, just get one with a valid oa_unit from the same gt */
1955
+ for_each_hw_engine (hwe , param -> oa_unit -> gt , id ) {
1956
+ if (!hwe -> oa_unit )
1957
+ continue ;
1958
+
1959
+ param -> hwe = hwe ;
1960
+ goto out ;
1961
+ }
1962
+ err :
1963
+ drm_dbg (& oa -> xe -> drm , "Unable to find hwe (%d, %d) for OA unit ID %d\n" ,
1964
+ param -> exec_q ? param -> exec_q -> class : -1 ,
1965
+ param -> engine_instance , param -> oa_unit -> oa_unit_id );
1966
+ ret = - EINVAL ;
1967
+ out :
1957
1968
return ret ;
1958
1969
}
1959
1970
@@ -2578,6 +2589,8 @@ static void __xe_oa_init_oa_units(struct xe_gt *gt)
2578
2589
DRM_XE_OA_UNIT_TYPE_OAM_SAG : DRM_XE_OA_UNIT_TYPE_OAM ;
2579
2590
}
2580
2591
2592
+ u -> gt = gt ;
2593
+
2581
2594
xe_mmio_write32 (& gt -> mmio , u -> regs .oa_ctrl , 0 );
2582
2595
2583
2596
/* Ensure MMIO trigger remains disabled till there is a stream */
0 commit comments