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>
if (ct->g2h_outstanding)
xe_pm_runtime_put(ct_to_xe(ct));
ct->g2h_outstanding = 0;
- ct->state = state;
+
+ /*
+ * WRITE_ONCE pairs with READ_ONCEs in xe_guc_ct_initialized and
+ * xe_guc_ct_enabled.
+ */
+ WRITE_ONCE(ct->state, state);
xe_gt_dbg(gt, "GuC CT communication channel %s\n",
state == XE_GUC_CT_STATE_STOPPED ? "stopped" :
static inline bool xe_guc_ct_initialized(struct xe_guc_ct *ct)
{
- return ct->state != XE_GUC_CT_STATE_NOT_INITIALIZED;
+ /* READ_ONCE pairs with WRITE_ONCE in guc_ct_change_state. */
+ return READ_ONCE(ct->state) != XE_GUC_CT_STATE_NOT_INITIALIZED;
}
static inline bool xe_guc_ct_enabled(struct xe_guc_ct *ct)
{
- return ct->state == XE_GUC_CT_STATE_ENABLED;
+ /* READ_ONCE pairs with WRITE_ONCE in guc_ct_change_state. */
+ return READ_ONCE(ct->state) == XE_GUC_CT_STATE_ENABLED;
}
static inline void xe_guc_ct_irq_handler(struct xe_guc_ct *ct)