Unverified Commit ac1317df authored by Jonathan Cavitt's avatar Jonathan Cavitt Committed by Rodrigo Vivi
Browse files

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: default avatarMatthew Brost <matthew.brost@intel.com>
Signed-off-by: default avatarJonathan 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: default avatarMatthew Brost <matthew.brost@intel.com>
Link: https://patch.msgid.link/20251222201957.63245-6-jonathan.cavitt@intel.com


Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
parent b5179dbd
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -529,7 +529,12 @@ static void guc_ct_change_state(struct xe_guc_ct *ct,
	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" :
+4 −2
Original line number Diff line number Diff line
@@ -30,12 +30,14 @@ void xe_guc_ct_print(struct xe_guc_ct *ct, struct drm_printer *p, bool want_ctb)

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)