Skip to content

Commit ac1317d

Browse files
Jonathan-Cavittrodrigovivi
authored andcommitted
drm/xe/guc: READ/WRITE_ONCE ct->state
Use READ_ONCE and WRITE_ONCE when operating on ct->state to prevent the compiler form ignoring important modifications to its value. Suggested-by: Matthew Brost <matthew.brost@intel.com> Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com> Cc: Michal Wajdeczko <michal.wajdeczko@intel.com> Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com> Reviewed-by: Matthew Brost <matthew.brost@intel.com> Link: https://patch.msgid.link/20251222201957.63245-6-jonathan.cavitt@intel.com Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
1 parent b5179db commit ac1317d

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

drivers/gpu/drm/xe/xe_guc_ct.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,12 @@ static void guc_ct_change_state(struct xe_guc_ct *ct,
529529
if (ct->g2h_outstanding)
530530
xe_pm_runtime_put(ct_to_xe(ct));
531531
ct->g2h_outstanding = 0;
532-
ct->state = state;
532+
533+
/*
534+
* WRITE_ONCE pairs with READ_ONCEs in xe_guc_ct_initialized and
535+
* xe_guc_ct_enabled.
536+
*/
537+
WRITE_ONCE(ct->state, state);
533538

534539
xe_gt_dbg(gt, "GuC CT communication channel %s\n",
535540
state == XE_GUC_CT_STATE_STOPPED ? "stopped" :

drivers/gpu/drm/xe/xe_guc_ct.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ void xe_guc_ct_print(struct xe_guc_ct *ct, struct drm_printer *p, bool want_ctb)
3030

3131
static inline bool xe_guc_ct_initialized(struct xe_guc_ct *ct)
3232
{
33-
return ct->state != XE_GUC_CT_STATE_NOT_INITIALIZED;
33+
/* READ_ONCE pairs with WRITE_ONCE in guc_ct_change_state. */
34+
return READ_ONCE(ct->state) != XE_GUC_CT_STATE_NOT_INITIALIZED;
3435
}
3536

3637
static inline bool xe_guc_ct_enabled(struct xe_guc_ct *ct)
3738
{
38-
return ct->state == XE_GUC_CT_STATE_ENABLED;
39+
/* READ_ONCE pairs with WRITE_ONCE in guc_ct_change_state. */
40+
return READ_ONCE(ct->state) == XE_GUC_CT_STATE_ENABLED;
3941
}
4042

4143
static inline void xe_guc_ct_irq_handler(struct xe_guc_ct *ct)

0 commit comments

Comments
 (0)