[PATCH i-g-t 2/3] lib/xe_spin: Fix xe_spin_wait_started()

Cavitt, Jonathan jonathan.cavitt at intel.com
Wed Jul 31 21:37:51 UTC 2024


-----Original Message-----
From: igt-dev <igt-dev-bounces at lists.freedesktop.org> On Behalf Of Lucas De Marchi
Sent: Tuesday, July 30, 2024 8:35 PM
To: igt-dev at lists.freedesktop.org
Cc: Nerlige Ramappa, Umesh <umesh.nerlige.ramappa at intel.com>; Brost, Matthew <matthew.brost at intel.com>; De Marchi, Lucas <lucas.demarchi at intel.com>
Subject: [PATCH i-g-t 2/3] lib/xe_spin: Fix xe_spin_wait_started()
> 
> Use READ_ONCE() to guarantee we are actually reading the memory written
> by the GPU and compiler can't optimize it away.

Has this issue come up before, or is this just a preventative measure?

At any rate, this change doesn't cause any harm, so I won't block it.

Reviewed-by: Jonathan Cavitt <jonathan.cavitt at intel.com>
-Jonathan Cavitt

> 
> 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 3adacc3a8..43a7a43c2 100644
> --- a/lib/xe/xe_spin.c
> +++ b/lib/xe/xe_spin.c
> @@ -166,7 +166,7 @@ void xe_spin_init(struct xe_spin *spin, struct xe_spin_opts *opts)
>   */
>  bool xe_spin_started(struct xe_spin *spin)
>  {
> -	return spin->start != 0;
> +	return READ_ONCE(spin->start) != 0;
>  }
>  
>  /**
> -- 
> 2.43.0
> 
> 


More information about the igt-dev mailing list