Skip to content

Commit bed2a6b

Browse files
Jonathan-CavittThomas Hellström
authored andcommitted
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: dd08ebf ("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> (cherry picked from commit b5179db) Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
1 parent 754c232 commit bed2a6b

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

drivers/gpu/drm/xe/xe_guc_ct.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ static void g2h_fence_cancel(struct g2h_fence *g2h_fence)
104104
{
105105
g2h_fence->cancel = true;
106106
g2h_fence->fail = true;
107-
g2h_fence->done = true;
107+
108+
/* WRITE_ONCE pairs with READ_ONCEs in guc_ct_send_recv. */
109+
WRITE_ONCE(g2h_fence->done, true);
108110
}
109111

110112
static bool g2h_fence_needs_alloc(struct g2h_fence *g2h_fence)
@@ -1203,10 +1205,13 @@ static int guc_ct_send_recv(struct xe_guc_ct *ct, const u32 *action, u32 len,
12031205
return ret;
12041206
}
12051207

1206-
ret = wait_event_timeout(ct->g2h_fence_wq, g2h_fence.done, HZ);
1208+
/* READ_ONCEs pairs with WRITE_ONCEs in parse_g2h_response
1209+
* and g2h_fence_cancel.
1210+
*/
1211+
ret = wait_event_timeout(ct->g2h_fence_wq, READ_ONCE(g2h_fence.done), HZ);
12071212
if (!ret) {
12081213
LNL_FLUSH_WORK(&ct->g2h_worker);
1209-
if (g2h_fence.done) {
1214+
if (READ_ONCE(g2h_fence.done)) {
12101215
xe_gt_warn(gt, "G2H fence %u, action %04x, done\n",
12111216
g2h_fence.seqno, action[0]);
12121217
ret = 1;
@@ -1454,7 +1459,8 @@ static int parse_g2h_response(struct xe_guc_ct *ct, u32 *msg, u32 len)
14541459

14551460
g2h_release_space(ct, GUC_CTB_HXG_MSG_MAX_LEN);
14561461

1457-
g2h_fence->done = true;
1462+
/* WRITE_ONCE pairs with READ_ONCEs in guc_ct_send_recv. */
1463+
WRITE_ONCE(g2h_fence->done, true);
14581464
smp_mb();
14591465

14601466
wake_up_all(&ct->g2h_fence_wq);

0 commit comments

Comments
 (0)