Skip to content

Commit 2750ff9

Browse files
ifdumbrost05
authored andcommitted
drm/xe/hw_engine_group: Add helper to wait for dma fence jobs
This is a required feature for faulting long running jobs not to be submitted while dma fence jobs are running on the hw engine group. v2: Switch to lockdep_assert_held_write in worker, get a proper reference for the last fence (Matt Brost) v3: Directly call dma_fence_put with the fence ref (Matt Brost) Signed-off-by: Francois Dugast <francois.dugast@intel.com> Reviewed-by: Matthew Brost <matthew.brost@intel.com> Signed-off-by: Matthew Brost <matthew.brost@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240809155156.1955925-8-francois.dugast@intel.com
1 parent 0d92cd8 commit 2750ff9

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

drivers/gpu/drm/xe/xe_hw_engine_group.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,36 @@ static int xe_hw_engine_group_suspend_faulting_lr_jobs(struct xe_hw_engine_group
202202
up_write(&group->mode_sem);
203203
return err;
204204
}
205+
206+
/**
207+
* xe_hw_engine_group_wait_for_dma_fence_jobs() - Wait for dma fence jobs to complete
208+
* @group: The hw engine group
209+
*
210+
* This function is not meant to be called directly from a user IOCTL as dma_fence_wait()
211+
* is not interruptible.
212+
*
213+
* Return: 0 on success,
214+
* -ETIME if waiting for one job failed
215+
*/
216+
static int xe_hw_engine_group_wait_for_dma_fence_jobs(struct xe_hw_engine_group *group)
217+
{
218+
long timeout;
219+
struct xe_exec_queue *q;
220+
struct dma_fence *fence;
221+
222+
lockdep_assert_held_write(&group->mode_sem);
223+
224+
list_for_each_entry(q, &group->exec_queue_list, hw_engine_group_link) {
225+
if (xe_vm_in_lr_mode(q->vm))
226+
continue;
227+
228+
fence = xe_exec_queue_last_fence_get_for_resume(q, q->vm);
229+
timeout = dma_fence_wait(fence, false);
230+
dma_fence_put(fence);
231+
232+
if (timeout < 0)
233+
return -ETIME;
234+
}
235+
236+
return 0;
237+
}

0 commit comments

Comments
 (0)