All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dixit, Ashutosh" <ashutosh.dixit@intel.com>
To: "Cavitt, Jonathan" <jonathan.cavitt@intel.com>
Cc: "intel-xe@lists.freedesktop.org" <intel-xe@lists.freedesktop.org>,
	"Gupta,\ Saurabhg" <saurabhg.gupta@intel.com>,
	"Zuo, Alex" <alex.zuo@intel.com>,
	"Brost, Matthew" <matthew.brost@intel.com>,
	"Ceraolo Spurio, Daniele" <daniele.ceraolospurio@intel.com>,
	"Vivi, Rodrigo" <rodrigo.vivi@intel.com>,
	"Wajdeczko, Michal" <Michal.Wajdeczko@intel.com>
Subject: Re: [PATCH 6/6] drm/xe/xe_guc_ct: Justify WRITE_ONCE/READ_ONCE usage
Date: Thu, 18 Dec 2025 13:10:57 -0800	[thread overview]
Message-ID: <871pkr338e.wl-ashutosh.dixit@intel.com> (raw)
In-Reply-To: <CH0PR11MB54447005D7FF2D3CBB7BBB36E5A8A@CH0PR11MB5444.namprd11.prod.outlook.com>

On Thu, 18 Dec 2025 13:03:45 -0800, Cavitt, Jonathan wrote:
>
> -----Original Message-----
> From: Dixit, Ashutosh <ashutosh.dixit@intel.com>
> Sent: Thursday, December 18, 2025 1:01 PM
> To: Cavitt, Jonathan <jonathan.cavitt@intel.com>
> Cc: intel-xe@lists.freedesktop.org; Gupta, Saurabhg <saurabhg.gupta@intel.com>; Zuo, Alex <alex.zuo@intel.com>; Brost, Matthew <matthew.brost@intel.com>; Ceraolo Spurio, Daniele <daniele.ceraolospurio@intel.com>; Vivi, Rodrigo <rodrigo.vivi@intel.com>; Wajdeczko, Michal <Michal.Wajdeczko@intel.com>
> Subject: Re: [PATCH 6/6] drm/xe/xe_guc_ct: Justify WRITE_ONCE/READ_ONCE usage
> >
> > On Thu, 18 Dec 2025 07:35:34 -0800, Jonathan Cavitt wrote:
> > >
> > > Usage of READ_ONCE and WRITE_ONCE requires comments justifying it.
> > > Some recently added uses had cross-dependencies with each other, but
> > > needed to be added separately, so introduce the justifications now when
> > > it makes more sense to.
> >
> > What is the reason for doing this in a separate patch? Afais, these
> > comments should be added in the same patches where the code was changed. So
> > people can see it in a single patch...
>
> Because the comment "WRITE_ONCE pairs with READ_ONCEs in xe_guc_ct_initialized
> and xe_guc_ct_enabled" doesn't make sense when those functions don't have
> READ_ONCEs yet.

As Stuart mentioned the WRITE and READ should be in a single patch
anyway. Together with the comments.

>
> >
> > >
> > > Suggested-by: Matthew Brost <matthew.brost@intel.com>
> > > Suggested-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > > Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
> > > ---
> > >  drivers/gpu/drm/xe/xe_guc_ct.c | 5 +++++
> > >  drivers/gpu/drm/xe/xe_guc_ct.h | 2 ++
> > >  2 files changed, 7 insertions(+)
> > >
> > > diff --git a/drivers/gpu/drm/xe/xe_guc_ct.c b/drivers/gpu/drm/xe/xe_guc_ct.c
> > > index 20ac0438ffb6..24857c2c8cb5 100644
> > > --- a/drivers/gpu/drm/xe/xe_guc_ct.c
> > > +++ b/drivers/gpu/drm/xe/xe_guc_ct.c
> > > @@ -529,6 +529,11 @@ 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;
> > > +
> > > +	/*
> > > +	 * 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",
> > > diff --git a/drivers/gpu/drm/xe/xe_guc_ct.h b/drivers/gpu/drm/xe/xe_guc_ct.h
> > > index cb1335f1d66f..8d318b094f33 100644
> > > --- a/drivers/gpu/drm/xe/xe_guc_ct.h
> > > +++ b/drivers/gpu/drm/xe/xe_guc_ct.h
> > > @@ -30,11 +30,13 @@ 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)
> > >  {
> > > +	/* 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)
> > >  {
> > > +	/* READ_ONCE pairs with WRITE_ONCE in guc_ct_change_state */
> > >	return READ_ONCE(ct->state) == XE_GUC_CT_STATE_ENABLED;
> > >  }
> > >
> > > --
> > > 2.43.0
> > >
> >

  reply	other threads:[~2025-12-18 21:11 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-18 15:35 [PATCH 0/6] drm/xe/xe_guc_ct: Prevent compiler read/write optimization breaks Jonathan Cavitt
2025-12-18 15:35 ` [PATCH 1/6] drm/xe/xe_guc_ct: WRITE_ONCE g2h_fence done in g2h_fence_cancel Jonathan Cavitt
2025-12-18 21:08   ` Dixit, Ashutosh
2025-12-18 15:35 ` [PATCH 2/6] drm/xe/xe_guc_ct: WRITE_ONCE g2h_fence done in parse_g2h_response Jonathan Cavitt
2025-12-18 15:35 ` [PATCH 3/6] drm/xe/xe_guc_ct: WRITE_ONCE ct state in guc_ct_change_state Jonathan Cavitt
2025-12-18 15:35 ` [PATCH 4/6] drm/xe/xe_guc_ct: READ_ONCE ct state in xe_guc_ct_initialized Jonathan Cavitt
2025-12-18 15:35 ` [PATCH 5/6] drm/xe/xe_guc_ct: READ_ONCE ct state in xe_guc_ct_enabled Jonathan Cavitt
2025-12-18 15:35 ` [PATCH 6/6] drm/xe/xe_guc_ct: Justify WRITE_ONCE/READ_ONCE usage Jonathan Cavitt
2025-12-18 21:01   ` Dixit, Ashutosh
2025-12-18 21:03     ` Cavitt, Jonathan
2025-12-18 21:10       ` Dixit, Ashutosh [this message]
2025-12-18 21:02   ` Rodrigo Vivi
2025-12-18 16:18 ` ✓ CI.KUnit: success for drm/xe/xe_guc_ct: Prevent compiler read/write optimization breaks (rev3) Patchwork
2025-12-18 16:52 ` ✓ Xe.CI.BAT: " Patchwork
2025-12-18 20:59 ` [PATCH 0/6] drm/xe/xe_guc_ct: Prevent compiler read/write optimization breaks Summers, Stuart
2025-12-19 13:38 ` ✓ Xe.CI.Full: success for drm/xe/xe_guc_ct: Prevent compiler read/write optimization breaks (rev3) 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=871pkr338e.wl-ashutosh.dixit@intel.com \
    --to=ashutosh.dixit@intel.com \
    --cc=Michal.Wajdeczko@intel.com \
    --cc=alex.zuo@intel.com \
    --cc=daniele.ceraolospurio@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jonathan.cavitt@intel.com \
    --cc=matthew.brost@intel.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=saurabhg.gupta@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.