From: Jani Nikula <jani.nikula@intel.com>
To: Sebastian Brzezinka <sebastian.brzezinka@intel.com>,
intel-gfx@lists.freedesktop.org
Cc: Sebastian Brzezinka <sebastian.brzezinka@intel.com>,
andi.shyti@linux.intel.com, krzysztof.karas@intel.com,
krzysztof.niemiec@intel.com, janusz.krzysztofik@linux.intel.com
Subject: Re: [RFC PATCH 01/25] drm/i915: Convert wait_for() wrappers to poll_timeout_us()
Date: Wed, 02 Dec 2026 20:38:43 +0200 [thread overview]
Message-ID: <54158f0e2bd5e7c32ac9c4e24bfb1b58d6dc495a@intel.com> (raw)
In-Reply-To: <08a2371d9c750c50f21dcd450cb3f2424556b52c.1796225423.git.sebastian.brzezinka@intel.com>
On Wed, 02 Dec 2026, Sebastian Brzezinka <sebastian.brzezinka@intel.com> wrote:
> Convert __intel_wait_for_register_fw() and __intel_wait_for_register()
> to poll_timeout_us() and poll_timeout_us_atomic().
>
> The atomic fast path used to busy-loop and measure time with
> local_clock(). poll_timeout_us_atomic() has no clock and only charges
> its udelay() against the timeout, so use a 1us delay. The register
> read time is not counted, so a wait that times out can last longer than
> fast_timeout_us, and a wait that succeeds can be noticed up to 1us later.
>
> The sleeping paths backed off from 10us to 1000us, but poll_timeout_us()
> only takes a fixed interval. Poll every 1% of the timeout, capped at
> 1000us. A register that settles shortly after the fast phase is now
> noticed up to that interval later, instead of after about 10us.
>
> intel_de_wait_for_register() keeps its backoff: it runs with atomic
> timeouts from a few us to several ms, and a fixed interval short enough
> for the small waits would busy loop on the long ones.
intel_de_wait* no longer uses uncore waits, and the patch at hand has no
bearing on them.
>
> Signed-off-by: Sebastian Brzezinka <sebastian.brzezinka@intel.com>
> ---
> drivers/gpu/drm/i915/intel_uncore.c | 19 ++++++++++++-------
> 1 file changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c
> index 170e83a8c9fc..77dd1bc435ba 100644
> --- a/drivers/gpu/drm/i915/intel_uncore.c
> +++ b/drivers/gpu/drm/i915/intel_uncore.c
> @@ -21,6 +21,7 @@
> * IN THE SOFTWARE.
> */
>
> +#include <linux/iopoll.h>
> #include <linux/pm_runtime.h>
>
> #include <drm/drm_managed.h>
> @@ -2761,7 +2762,8 @@ int __intel_wait_for_register_fw(struct intel_uncore *uncore,
> u32 *out_value)
> {
> u32 reg_value = 0;
> -#define done (((reg_value = intel_uncore_read_fw(uncore, reg)) & mask) == value)
> +#define read_reg (reg_value = intel_uncore_read_fw(uncore, reg))
> +#define done ((reg_value & mask) == value)
> int ret;
>
> /* Catch any overuse of this function */
> @@ -2771,15 +2773,18 @@ int __intel_wait_for_register_fw(struct intel_uncore *uncore,
>
> ret = -ETIMEDOUT;
> if (fast_timeout_us && fast_timeout_us <= 20000)
> - ret = _wait_for_atomic(done, fast_timeout_us, 0);
> + ret = poll_timeout_us_atomic(read_reg, done, 1, fast_timeout_us, false);
> if (ret && slow_timeout_ms)
> - ret = wait_for(done, slow_timeout_ms);
> + ret = poll_timeout_us(read_reg, done,
> + min_t(unsigned int, slow_timeout_ms * 10, 1000),
> + slow_timeout_ms * 1000, false);
>
> if (out_value)
> *out_value = reg_value;
>
> return ret;
> #undef done
> +#undef read_reg
> }
>
> /**
> @@ -2827,10 +2832,10 @@ int __intel_wait_for_register(struct intel_uncore *uncore,
> spin_unlock_irq(&uncore->lock);
>
> if (ret && slow_timeout_ms)
> - ret = __wait_for(reg_value = intel_uncore_read_notrace(uncore,
> - reg),
> - (reg_value & mask) == value,
> - slow_timeout_ms * 1000, 10, 1000);
> + ret = poll_timeout_us(reg_value = intel_uncore_read_notrace(uncore, reg),
> + (reg_value & mask) == value,
> + min_t(unsigned int, slow_timeout_ms * 10, 1000),
> + slow_timeout_ms * 1000, false);
>
> /* just trace the final value */
> trace_i915_reg_rw(false, reg, reg_value, sizeof(reg_value), true);
--
Jani Nikula, Intel
next prev parent reply other threads:[~2026-12-02 18:40 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 15:40 [RFC PATCH 00/25] drm/i915: Replace wait_for() helpers with poll_timeout_us() Sebastian Brzezinka
2026-12-02 15:40 ` [RFC PATCH 01/25] drm/i915: Convert wait_for() wrappers to poll_timeout_us() Sebastian Brzezinka
2026-12-02 18:38 ` Jani Nikula [this message]
2026-12-02 15:40 ` [RFC PATCH 02/25] drm/i915: Convert remaining intel_uncore.c wait_for() users " Sebastian Brzezinka
2026-12-02 18:34 ` Jani Nikula
2026-12-02 15:40 ` [RFC PATCH 03/25] drm/i915/guc: Convert intel_guc_send_mmio() " Sebastian Brzezinka
2026-12-02 15:40 ` [RFC PATCH 04/25] drm/i915/guc: Convert CTB response wait_for()/wait_for_us() " Sebastian Brzezinka
2026-12-02 15:40 ` [RFC PATCH 05/25] drm/i915/gsc: Convert proxy waits " Sebastian Brzezinka
2026-12-02 15:40 ` [RFC PATCH 06/25] drm/i915/guc: Convert request alloc " Sebastian Brzezinka
2026-12-02 15:40 ` [RFC PATCH 07/25] drm/i915/guc: Convert guc_wait_ucode() " Sebastian Brzezinka
2026-12-02 15:40 ` [RFC PATCH 08/25] drm/i915/guc: Convert slpc_reset() " Sebastian Brzezinka
2026-12-02 15:40 ` [RFC PATCH 09/25] drm/i915/gsc: Convert HECI packet submit waits " Sebastian Brzezinka
2026-12-02 15:40 ` [RFC PATCH 10/25] drm/i915/huc: Update stale wait_for() comment reference Sebastian Brzezinka
2026-12-02 15:40 ` [RFC PATCH 11/25] drm/i915/rps: Convert wait_for()/wait_for_atomic() to poll_timeout_us() Sebastian Brzezinka
2026-12-02 15:40 ` [RFC PATCH 12/25] drm/i915/gt: " Sebastian Brzezinka
2026-12-02 15:40 ` [RFC PATCH 13/25] drm/i915/gt: Convert wait_for_atomic() to poll_timeout_us_atomic() Sebastian Brzezinka
2026-12-02 15:40 ` [RFC PATCH 14/25] drm/i915/gt: Convert wait_for_atomic_us()/wait_for() to poll_timeout_us*() Sebastian Brzezinka
2026-12-02 15:40 ` [RFC PATCH 15/25] drm/i915/gt: Convert _wait_for_atomic()/wait_for*() " Sebastian Brzezinka
2026-12-02 15:40 ` [RFC PATCH 16/25] drm/i915/gt: Convert pte_tlbinv() selftest wait to poll_timeout_us() Sebastian Brzezinka
2026-12-02 15:40 ` [RFC PATCH 17/25] drm/i915/gvt: Convert wait_for_atomic() to poll_timeout_us_atomic() Sebastian Brzezinka
2026-12-02 15:41 ` [RFC PATCH 18/25] drm/i915: Convert wait_for() to poll_timeout_us() in i915_debugfs.c Sebastian Brzezinka
2026-12-02 15:41 ` [RFC PATCH 19/25] drm/i915: Convert _wait_for()/wait_for_atomic() to poll_timeout_us*() Sebastian Brzezinka
2026-12-02 15:41 ` [RFC PATCH 20/25] drm/i915/pxp: Convert wait_for() to poll_timeout_us() Sebastian Brzezinka
2026-12-02 15:41 ` [RFC PATCH 21/25] drm/i915: Convert wait_for() to poll_timeout_us() in vlv_suspend.c Sebastian Brzezinka
2026-12-02 15:41 ` [RFC PATCH 22/25] drm/i915: Convert wait_for() to poll_timeout_us() in i915_request.c selftests Sebastian Brzezinka
2026-12-02 15:41 ` [RFC PATCH 23/25] drm/i915: Convert wait_for() to poll_timeout_us() in i915_selftest.c Sebastian Brzezinka
2026-12-02 15:41 ` [RFC PATCH 24/25] drm/i915/selftests: Convert wait_for_us()/wait_for() to poll_timeout_us() Sebastian Brzezinka
2026-12-02 15:41 ` [RFC PATCH 25/25] drm/i915: Remove now-unused i915_wait_util.h Sebastian Brzezinka
2026-12-02 18:55 ` ✗ Fi.CI.BUILD: failure for drm/i915: Replace wait_for() helpers with poll_timeout_us() 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=54158f0e2bd5e7c32ac9c4e24bfb1b58d6dc495a@intel.com \
--to=jani.nikula@intel.com \
--cc=andi.shyti@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=janusz.krzysztofik@linux.intel.com \
--cc=krzysztof.karas@intel.com \
--cc=krzysztof.niemiec@intel.com \
--cc=sebastian.brzezinka@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.