[PATCH v7 04/13] drm/xe/hw_engine_group: Add helper to suspend faulting LR jobs

Matthew Brost matthew.brost at intel.com
Thu Aug 8 03:10:27 UTC 2024


On Wed, Aug 07, 2024 at 06:23:33PM +0200, Francois Dugast wrote:
> This is a required feature for dma fence jobs to preempt faulting long
> running jobs in order to ensure mutual exclusion on a given hw engine
> group.
> 
> v2: Pipeline calls to suspend(q) and suspend_wait(q) to improve
>     efficiency, switch to lockdep_assert_held_write (Matt Brost)
> 
> Signed-off-by: Francois Dugast <francois.dugast at intel.com>
> ---
>  drivers/gpu/drm/xe/xe_hw_engine_group.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/drivers/gpu/drm/xe/xe_hw_engine_group.c b/drivers/gpu/drm/xe/xe_hw_engine_group.c
> index 52e1dc78518e..3f74ff577a4c 100644
> --- a/drivers/gpu/drm/xe/xe_hw_engine_group.c
> +++ b/drivers/gpu/drm/xe/xe_hw_engine_group.c
> @@ -155,3 +155,28 @@ void xe_hw_engine_group_del_exec_queue(struct xe_hw_engine_group *group, struct
>  
>  	up_write(&group->mode_sem);
>  }
> +
> +/**
> + * xe_hw_engine_group_suspend_faulting_lr_jobs() - Suspend the faulting LR jobs of this group
> + * @group: The hw engine group
> + */
> +static void xe_hw_engine_group_suspend_faulting_lr_jobs(struct xe_hw_engine_group *group)
> +{
> +	struct xe_exec_queue *q;
> +
> +	lockdep_assert_held_write(&group->mode_sem);
> +
> +	list_for_each_entry(q, &group->exec_queue_list, hw_engine_group_link) {
> +		if (!xe_vm_in_fault_mode(q->vm))
> +			continue;
> +
> +		q->ops->suspend(q);
> +	}
> +
> +	list_for_each_entry(q, &group->exec_queue_list, hw_engine_group_link) {
> +		if (!xe_vm_in_fault_mode(q->vm))
> +			continue;
> +
> +		q->ops->suspend_wait(q);

This can fail now via being interrupted (e.g. user presses ctrl-c), so
this failure needs to be propagated all the way up the call stack to
exec IOCTL and returned to the user. With that, upon retry
'q->ops->suspend' can be called multiple times too. Ensure that function
can safely be called multiple times too.

Matt 

> +	}
> +}
> -- 
> 2.43.0
> 


More information about the Intel-xe mailing list