From: "Dixit, Ashutosh" <ashutosh.dixit@intel.com>
To: Jonathan Cavitt <jonathan.cavitt@intel.com>
Cc: intel-xe@lists.freedesktop.org, saurabhg.gupta@intel.com,
alex.zuo@intel.com, matthew.brost@intel.com,
daniele.ceraolospurio@intel.com, rodrigo.vivi@intel.com,
michal.wajdeczko@intel.com
Subject: Re: [PATCH 1/6] drm/xe/xe_guc_ct: WRITE_ONCE g2h_fence done in g2h_fence_cancel
Date: Thu, 18 Dec 2025 13:08:23 -0800 [thread overview]
Message-ID: <87345733co.wl-ashutosh.dixit@intel.com> (raw)
In-Reply-To: <20251218153527.6436-9-jonathan.cavitt@intel.com>
On Thu, 18 Dec 2025 07:35:29 -0800, Jonathan Cavitt wrote:
>
> Use WRITE_ONCE when operating on g2h_fence->done in g2h_fence_cancel to
> prevent the compiler from ignoring this operation.
>
> Fixes: 94de94d24ea8 ("drm/xe/guc: Cancel ongoing H2G requests when stopping CT")
> Suggested-by: Matthew Brost <matthew.brost@intel.com>
> Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
> Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
> ---
> drivers/gpu/drm/xe/xe_guc_ct.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_guc_ct.c b/drivers/gpu/drm/xe/xe_guc_ct.c
> index c3df9b3f1b4d..d177df166d2a 100644
> --- a/drivers/gpu/drm/xe/xe_guc_ct.c
> +++ b/drivers/gpu/drm/xe/xe_guc_ct.c
> @@ -206,7 +206,9 @@ static void g2h_fence_cancel(struct g2h_fence *g2h_fence)
> {
> g2h_fence->cancel = true;
> g2h_fence->fail = true;
> - g2h_fence->done = true;
> +
> + /* WRITE_ONCE pairs with wait_event_timeout in guc_ct_send_recv */
> + WRITE_ONCE(g2h_fence->done, true);
> }
So the compiler just optimizes ->done? It doesn't optimize ->cancel and
->fail, e.g.?
Generally ok to do this, but sometimes they are also unnecessary. Have we
seen evidence of the compiler optimizing this out? Also in other places
where we are doing this in other patches?
>
> static bool g2h_fence_needs_alloc(struct g2h_fence *g2h_fence)
> --
> 2.43.0
>
next prev parent reply other threads:[~2025-12-18 21:08 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 [this message]
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
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=87345733co.wl-ashutosh.dixit@intel.com \
--to=ashutosh.dixit@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=michal.wajdeczko@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox