[PATCH v2 3/3] drm/xe/guc: Flush G2H handler when turning off CTs

Michal Wajdeczko michal.wajdeczko at intel.com
Thu Jan 11 12:29:41 UTC 2024



On 10.01.2024 00:01, Matthew Brost wrote:
> Make sure G2H handler is not running when changing the CT state to drop
> messages or disabled. This will help prevent races in the code ensuring
> that G2H are not being processed after changing the state.

nit: we should also assert that during fini the CT was already disabled,
but that's for another patch

> 
> Signed-off-by: Matthew Brost <matthew.brost at intel.com>
> ---
>  drivers/gpu/drm/xe/xe_guc_ct.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/gpu/drm/xe/xe_guc_ct.c b/drivers/gpu/drm/xe/xe_guc_ct.c
> index 5b122a926ccf..6a2baa9034c8 100644
> --- a/drivers/gpu/drm/xe/xe_guc_ct.c
> +++ b/drivers/gpu/drm/xe/xe_guc_ct.c
> @@ -333,14 +333,21 @@ int xe_guc_ct_enable(struct xe_guc_ct *ct)
>  	return err;
>  }
>  
> +static void flush_g2h_handler(struct xe_guc_ct *ct)

you're cancelling a in-flight work, not flushing it, so maybe:

	static void stop_g2h_handler(struct xe_guc_ct *ct) ?

with that fixed,

Reviewed-by: Michal Wajdeczko <michal.wajdeczko at intel.com>

> +{
> +	cancel_work_sync(&ct->g2h_worker);
> +}
> +
>  void xe_guc_ct_disable(struct xe_guc_ct *ct)
>  {
>  	xe_guc_ct_set_state(ct, XE_GUC_CT_STATE_DISABLED);
> +	flush_g2h_handler(ct);
>  }
>  
>  void xe_guc_ct_stop(struct xe_guc_ct *ct)
>  {
>  	xe_guc_ct_set_state(ct, XE_GUC_CT_STATE_STOPPED);
> +	flush_g2h_handler(ct);
>  	xa_destroy(&ct->fence_lookup);
>  }
>  


More information about the Intel-xe mailing list