[PATCH i-g-t 3/3] lib/xe_spin: Fix ending the loop

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Wed Jul 31 06:09:46 UTC 2024


On Tue, Jul 30, 2024 at 08:35:04PM -0700, Lucas De Marchi wrote:
> Less likely to be a problem with optimizations than the started
> condition, but let's stay on the safe side. Comparing to igt_spin_end(),
> that one uses a sync_write() to force a MI_BATCH_BUFFER_END in the
> beginning of the loop that has a even stronger guarantee.
> 
> Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
> ---
>  lib/xe/xe_spin.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/xe/xe_spin.c b/lib/xe/xe_spin.c
> index 43a7a43c2..f8b225125 100644
> --- a/lib/xe/xe_spin.c
> +++ b/lib/xe/xe_spin.c
> @@ -183,7 +183,7 @@ void xe_spin_wait_started(struct xe_spin *spin)
>  
>  void xe_spin_end(struct xe_spin *spin)
>  {
> -	spin->end = 0;
> +	WRITE_ONCE(spin->end, 0);
>  }
>  
>  /**
> -- 
> 2.43.0
> 

Same as in 2/3. Checked in godbolt, -fpic/O3 always produces
memory access.

--
Zbigniew


More information about the igt-dev mailing list