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

Lucas De Marchi lucas.demarchi at intel.com
Wed Jul 31 03:35:03 UTC 2024


Use READ_ONCE() to guarantee we are actually reading the memory written
by the GPU and compiler can't optimize it away.

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