Skip to content

Commit b5179db

Browse files
Jonathan-Cavittrodrigovivi
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>
1 parent c3a613a commit b5179db

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
@@ -206,7 +206,9 @@ static void g2h_fence_cancel(struct g2h_fence *g2h_fence)
206206
{
207207
g2h_fence->cancel = true;
208208
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);
210212
}
211213

212214
static bool g2h_fence_needs_alloc(struct g2h_fence *g2h_fence)
@@ -1294,10 +1296,13 @@ static int guc_ct_send_recv(struct xe_guc_ct *ct, const u32 *action, u32 len,
12941296
return ret;
12951297
}
12961298

1297-
ret = wait_event_timeout(ct->g2h_fence_wq, g2h_fence.done, HZ);
1299+
/* READ_ONCEs pairs with WRITE_ONCEs in parse_g2h_response
1300+
* and g2h_fence_cancel.
1301+
*/
1302+
ret = wait_event_timeout(ct->g2h_fence_wq, READ_ONCE(g2h_fence.done), HZ);
12981303
if (!ret) {
12991304
LNL_FLUSH_WORK(&ct->g2h_worker);
1300-
if (g2h_fence.done) {
1305+
if (READ_ONCE(g2h_fence.done)) {
13011306
xe_gt_warn(gt, "G2H fence %u, action %04x, done\n",
13021307
g2h_fence.seqno, action[0]);
13031308
ret = 1;
@@ -1498,7 +1503,8 @@ static int parse_g2h_response(struct xe_guc_ct *ct, u32 *msg, u32 len)
14981503

14991504
g2h_release_space(ct, GUC_CTB_HXG_MSG_MAX_LEN);
15001505

1501-
g2h_fence->done = true;
1506+
/* WRITE_ONCE pairs with READ_ONCEs in guc_ct_send_recv. */
1507+
WRITE_ONCE(g2h_fence->done, true);
15021508
smp_mb();
15031509

15041510
wake_up_all(&ct->g2h_fence_wq);

0 commit comments

Comments
 (0)