Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Jonathan Cavitt and committed by
Rodrigo Vivi
ac1317df b5179dbd

+10 -3
+6 -1
drivers/gpu/drm/xe/xe_guc_ct.c
··· 529 529 if (ct->g2h_outstanding) 530 530 xe_pm_runtime_put(ct_to_xe(ct)); 531 531 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); 533 538 534 539 xe_gt_dbg(gt, "GuC CT communication channel %s\n", 535 540 state == XE_GUC_CT_STATE_STOPPED ? "stopped" :
+4 -2
drivers/gpu/drm/xe/xe_guc_ct.h
··· 30 30 31 31 static inline bool xe_guc_ct_initialized(struct xe_guc_ct *ct) 32 32 { 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; 34 35 } 35 36 36 37 static inline bool xe_guc_ct_enabled(struct xe_guc_ct *ct) 37 38 { 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; 39 41 } 40 42 41 43 static inline void xe_guc_ct_irq_handler(struct xe_guc_ct *ct)