From: Jani Nikula <jani.nikula@linux.intel.com>
To: Ville Syrjala <ville.syrjala@linux.intel.com>,
intel-gfx@lists.freedesktop.org
Cc: stable@vger.kernel.org
Subject: Re: [PATCH] drm/i915: Order OP vs. timeout correctly in __wait_for()
Date: Tue, 17 Mar 2026 15:07:29 +0200 [thread overview]
Message-ID: <c158ed8a644a9c3bf10a14cc083dcd33f84c236b@intel.com> (raw)
In-Reply-To: <20260313110740.24620-1-ville.syrjala@linux.intel.com>
On Fri, 13 Mar 2026, Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Put the barrier() before the OP so that anything we read out in
> OP and check in COND will actually be read out after the timeout
> has been evaluated.
>
> Currently the only place where we use OP is __intel_wait_for_register(),
> but the use there is precisely susceptible to this reordering, assuming
> the ktime_*() stuff itself doesn't act as a sufficient barrier:
>
> __intel_wait_for_register(...)
> {
> ...
> ret = __wait_for(reg_value = intel_uncore_read_notrace(...),
> (reg_value & mask) == value, ...);
> ...
> }
>
> Cc: stable@vger.kernel.org
> Fixes: 1c3c1dc66a96 ("drm/i915: Add compiler barrier to wait_for")
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
> ---
> drivers/gpu/drm/i915/i915_wait_util.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_wait_util.h b/drivers/gpu/drm/i915/i915_wait_util.h
> index 7376898e3bf8..e1ed7921ec70 100644
> --- a/drivers/gpu/drm/i915/i915_wait_util.h
> +++ b/drivers/gpu/drm/i915/i915_wait_util.h
> @@ -25,9 +25,9 @@
> might_sleep(); \
> for (;;) { \
> const bool expired__ = ktime_after(ktime_get_raw(), end__); \
> - OP; \
> /* Guarantee COND check prior to timeout */ \
> barrier(); \
> + OP; \
> if (COND) { \
> ret__ = 0; \
> break; \
--
Jani Nikula, Intel
prev parent reply other threads:[~2026-03-17 13:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-13 11:07 [PATCH] drm/i915: Order OP vs. timeout correctly in __wait_for() Ville Syrjala
2026-03-17 13:07 ` Jani Nikula [this message]
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=c158ed8a644a9c3bf10a14cc083dcd33f84c236b@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=stable@vger.kernel.org \
--cc=ville.syrjala@linux.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