Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Matthew Brost <matthew.brost@intel.com>
Cc: Jonathan Cavitt <jonathan.cavitt@intel.com>,
	<intel-xe@lists.freedesktop.org>, <saurabhg.gupta@intel.com>,
	<alex.zuo@intel.com>, <daniele.ceraolospurio@intel.com>,
	<michal.wajdeczko@intel.com>, <stuart.summers@intel.com>,
	<ashutosh.dixit@intel.com>
Subject: Re: [PATCH v3 2/2] drm/xe/guc: READ/WRITE_ONCE ct->state
Date: Tue, 23 Dec 2025 16:45:03 -0500	[thread overview]
Message-ID: <aUsNOudeywmMtGdP@intel.com> (raw)
In-Reply-To: <aUsLbPyLcHFzAlTQ@lstrano-desk.jf.intel.com>

On Tue, Dec 23, 2025 at 01:36:44PM -0800, Matthew Brost wrote:
> On Mon, Dec 22, 2025 at 08:20:00PM +0000, Jonathan Cavitt wrote:
> > 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>
> 
> Reviewed-by: Matthew Brost <matthew.brost@intel.com>

Patches pushed to drm-xe-next. Thanks for the patches, reviews
and patience...

> 
> > 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>
> > ---
> >  drivers/gpu/drm/xe/xe_guc_ct.c | 7 ++++++-
> >  drivers/gpu/drm/xe/xe_guc_ct.h | 6 ++++--
> >  2 files changed, 10 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/xe/xe_guc_ct.c b/drivers/gpu/drm/xe/xe_guc_ct.c
> > index f2148a8bf208..dfbf76037b04 100644
> > --- a/drivers/gpu/drm/xe/xe_guc_ct.c
> > +++ b/drivers/gpu/drm/xe/xe_guc_ct.c
> > @@ -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" :
> > diff --git a/drivers/gpu/drm/xe/xe_guc_ct.h b/drivers/gpu/drm/xe/xe_guc_ct.h
> > index 5599939f8fe1..767365a33dee 100644
> > --- a/drivers/gpu/drm/xe/xe_guc_ct.h
> > +++ b/drivers/gpu/drm/xe/xe_guc_ct.h
> > @@ -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)
> > -- 
> > 2.43.0
> > 

  reply	other threads:[~2025-12-23 21:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-22 20:19 [PATCH v3 0/2] drm/xe/guc: Prevent compiler read/write optimization breaks Jonathan Cavitt
2025-12-22 20:19 ` [PATCH v3 1/2] drm/xe/guc: READ/WRITE_ONCE g2h_fence->done Jonathan Cavitt
2025-12-23 21:36   ` Matthew Brost
2025-12-22 20:20 ` [PATCH v3 2/2] drm/xe/guc: READ/WRITE_ONCE ct->state Jonathan Cavitt
2025-12-23 21:36   ` Matthew Brost
2025-12-23 21:45     ` Rodrigo Vivi [this message]
2025-12-23  2:05 ` ✓ CI.KUnit: success for drm/xe/guc: Prevent compiler read/write optimization breaks (rev2) Patchwork
2025-12-23  2:43 ` ✓ Xe.CI.BAT: " Patchwork
2025-12-23 13:20 ` ✓ Xe.CI.Full: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aUsNOudeywmMtGdP@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=alex.zuo@intel.com \
    --cc=ashutosh.dixit@intel.com \
    --cc=daniele.ceraolospurio@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jonathan.cavitt@intel.com \
    --cc=matthew.brost@intel.com \
    --cc=michal.wajdeczko@intel.com \
    --cc=saurabhg.gupta@intel.com \
    --cc=stuart.summers@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox