Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/xe/guc: READ/WRITE_ONCE g2h_fence->done

Use READ_ONCE and WRITE_ONCE when operating on g2h_fence->done
to prevent the compiler from ignoring important modifications
to its value.

Fixes: dd08ebf6c352 ("drm/xe: Introduce a new DRM driver for Intel GPUs")
Suggested-by: Matthew Brost <matthew.brost@intel.com>
Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Link: https://patch.msgid.link/20251222201957.63245-5-jonathan.cavitt@intel.com
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

authored by

Jonathan Cavitt and committed by
Rodrigo Vivi
b5179dbd c3a613a0

+10 -4
+10 -4
drivers/gpu/drm/xe/xe_guc_ct.c
··· 206 206 { 207 207 g2h_fence->cancel = true; 208 208 g2h_fence->fail = true; 209 - g2h_fence->done = true; 209 + 210 + /* WRITE_ONCE pairs with READ_ONCEs in guc_ct_send_recv. */ 211 + WRITE_ONCE(g2h_fence->done, true); 210 212 } 211 213 212 214 static bool g2h_fence_needs_alloc(struct g2h_fence *g2h_fence) ··· 1296 1294 return ret; 1297 1295 } 1298 1296 1299 - ret = wait_event_timeout(ct->g2h_fence_wq, g2h_fence.done, HZ); 1297 + /* READ_ONCEs pairs with WRITE_ONCEs in parse_g2h_response 1298 + * and g2h_fence_cancel. 1299 + */ 1300 + ret = wait_event_timeout(ct->g2h_fence_wq, READ_ONCE(g2h_fence.done), HZ); 1300 1301 if (!ret) { 1301 1302 LNL_FLUSH_WORK(&ct->g2h_worker); 1302 - if (g2h_fence.done) { 1303 + if (READ_ONCE(g2h_fence.done)) { 1303 1304 xe_gt_warn(gt, "G2H fence %u, action %04x, done\n", 1304 1305 g2h_fence.seqno, action[0]); 1305 1306 ret = 1; ··· 1503 1498 1504 1499 g2h_release_space(ct, GUC_CTB_HXG_MSG_MAX_LEN); 1505 1500 1506 - g2h_fence->done = true; 1501 + /* WRITE_ONCE pairs with READ_ONCEs in guc_ct_send_recv. */ 1502 + WRITE_ONCE(g2h_fence->done, true); 1507 1503 smp_mb(); 1508 1504 1509 1505 wake_up_all(&ct->g2h_fence_wq);