@@ -291,12 +291,8 @@ static int amdgpu_cs_pass1(struct amdgpu_cs_parser *p,
291291 return - EINVAL ;
292292
293293 for (i = 0 ; i < p -> gang_size ; ++ i ) {
294- ret = amdgpu_job_alloc (p -> adev , num_ibs [i ], & p -> jobs [i ], vm );
295- if (ret )
296- goto free_all_kdata ;
297-
298- ret = drm_sched_job_init (& p -> jobs [i ]-> base , p -> entities [i ],
299- & fpriv -> vm );
294+ ret = amdgpu_job_alloc (p -> adev , vm , p -> entities [i ], vm ,
295+ num_ibs [i ], & p -> jobs [i ]);
300296 if (ret )
301297 goto free_all_kdata ;
302298 }
@@ -430,7 +426,7 @@ static int amdgpu_cs_p2_dependencies(struct amdgpu_cs_parser *p,
430426 dma_fence_put (old );
431427 }
432428
433- r = amdgpu_sync_fence (& p -> gang_leader -> sync , fence );
429+ r = amdgpu_sync_fence (& p -> sync , fence );
434430 dma_fence_put (fence );
435431 if (r )
436432 return r ;
@@ -452,9 +448,20 @@ static int amdgpu_syncobj_lookup_and_add(struct amdgpu_cs_parser *p,
452448 return r ;
453449 }
454450
455- r = amdgpu_sync_fence (& p -> gang_leader -> sync , fence );
456- dma_fence_put (fence );
451+ r = amdgpu_sync_fence (& p -> sync , fence );
452+ if (r )
453+ goto error ;
457454
455+ /*
456+ * When we have an explicit dependency it might be necessary to insert a
457+ * pipeline sync to make sure that all caches etc are flushed and the
458+ * next job actually sees the results from the previous one.
459+ */
460+ if (fence -> context == p -> gang_leader -> base .entity -> fence_context )
461+ r = amdgpu_sync_fence (& p -> gang_leader -> explicit_sync , fence );
462+
463+ error :
464+ dma_fence_put (fence );
458465 return r ;
459466}
460467
@@ -1101,7 +1108,7 @@ static int amdgpu_cs_vm_handling(struct amdgpu_cs_parser *p)
11011108 if (r )
11021109 return r ;
11031110
1104- r = amdgpu_sync_fence (& job -> sync , fpriv -> prt_va -> last_pt_update );
1111+ r = amdgpu_sync_fence (& p -> sync , fpriv -> prt_va -> last_pt_update );
11051112 if (r )
11061113 return r ;
11071114
@@ -1112,7 +1119,7 @@ static int amdgpu_cs_vm_handling(struct amdgpu_cs_parser *p)
11121119 if (r )
11131120 return r ;
11141121
1115- r = amdgpu_sync_fence (& job -> sync , bo_va -> last_pt_update );
1122+ r = amdgpu_sync_fence (& p -> sync , bo_va -> last_pt_update );
11161123 if (r )
11171124 return r ;
11181125 }
@@ -1131,7 +1138,7 @@ static int amdgpu_cs_vm_handling(struct amdgpu_cs_parser *p)
11311138 if (r )
11321139 return r ;
11331140
1134- r = amdgpu_sync_fence (& job -> sync , bo_va -> last_pt_update );
1141+ r = amdgpu_sync_fence (& p -> sync , bo_va -> last_pt_update );
11351142 if (r )
11361143 return r ;
11371144 }
@@ -1144,7 +1151,7 @@ static int amdgpu_cs_vm_handling(struct amdgpu_cs_parser *p)
11441151 if (r )
11451152 return r ;
11461153
1147- r = amdgpu_sync_fence (& job -> sync , vm -> last_update );
1154+ r = amdgpu_sync_fence (& p -> sync , vm -> last_update );
11481155 if (r )
11491156 return r ;
11501157
@@ -1176,7 +1183,6 @@ static int amdgpu_cs_vm_handling(struct amdgpu_cs_parser *p)
11761183static int amdgpu_cs_sync_rings (struct amdgpu_cs_parser * p )
11771184{
11781185 struct amdgpu_fpriv * fpriv = p -> filp -> driver_priv ;
1179- struct amdgpu_job * leader = p -> gang_leader ;
11801186 struct amdgpu_bo_list_entry * e ;
11811187 unsigned int i ;
11821188 int r ;
@@ -1188,14 +1194,14 @@ static int amdgpu_cs_sync_rings(struct amdgpu_cs_parser *p)
11881194
11891195 sync_mode = amdgpu_bo_explicit_sync (bo ) ?
11901196 AMDGPU_SYNC_EXPLICIT : AMDGPU_SYNC_NE_OWNER ;
1191- r = amdgpu_sync_resv (p -> adev , & leader -> sync , resv , sync_mode ,
1197+ r = amdgpu_sync_resv (p -> adev , & p -> sync , resv , sync_mode ,
11921198 & fpriv -> vm );
11931199 if (r )
11941200 return r ;
11951201 }
11961202
1197- for (i = 0 ; i < p -> gang_size - 1 ; ++ i ) {
1198- r = amdgpu_sync_clone ( & leader -> sync , & p -> jobs [i ]-> sync );
1203+ for (i = 0 ; i < p -> gang_size ; ++ i ) {
1204+ r = amdgpu_sync_push_to_job ( & p -> sync , p -> jobs [i ]);
11991205 if (r )
12001206 return r ;
12011207 }
@@ -1241,7 +1247,7 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
12411247 struct dma_fence * fence ;
12421248
12431249 fence = & p -> jobs [i ]-> base .s_fence -> scheduled ;
1244- r = amdgpu_sync_fence (& leader -> sync , fence );
1250+ r = drm_sched_job_add_dependency (& leader -> base , fence );
12451251 if (r )
12461252 goto error_cleanup ;
12471253 }
0 commit comments