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 02/25] drm/i915: Convert remaining intel_uncore.c wait_for() users to poll_timeout_us()
Date: Wed, 02 Dec 2026 20:34:34 +0200 [thread overview]
Message-ID: <d0e0773ab4fbbf385e36794450a5b8985fe58ad8@intel.com> (raw)
In-Reply-To: <376420dcb8dd6ace94f448c9ed8bd14bf8305dd6.1796225423.git.sebastian.brzezinka@intel.com>
On Wed, 02 Dec 2026, Sebastian Brzezinka <sebastian.brzezinka@intel.com> wrote:
> Convert the remaining wait_for()/wait_for_atomic*() users in
> intel_uncore.c and its selftest to poll_timeout_us*().
>
> The atomic waits 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. Register read time is not
> counted, so a wait that times out can last longer than before.
>
> The sleeping waits backed off up to usleep_range(1000, 2000), but
> poll_timeout_us() takes a fixed interval, so poll every 1000us.
>
> Signed-off-by: Sebastian Brzezinka <sebastian.brzezinka@intel.com>
> ---
> drivers/gpu/drm/i915/intel_uncore.c | 18 ++++++++++--------
> drivers/gpu/drm/i915/selftests/intel_uncore.c | 4 +++-
> 2 files changed, 13 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c
> index 77dd1bc435ba..23837b7277a8 100644
> --- a/drivers/gpu/drm/i915/intel_uncore.c
> +++ b/drivers/gpu/drm/i915/intel_uncore.c
> @@ -36,7 +36,6 @@
> #include "i915_iosf_mbi.h"
> #include "i915_reg.h"
> #include "i915_vgpu.h"
> -#include "i915_wait_util.h"
> #include "i915_mmio_range.h"
> #include "intel_uncore_trace.h"
>
> @@ -168,8 +167,8 @@ __wait_for_ack(const struct intel_uncore_forcewake_domain *d,
> const u32 ack,
> const u32 value)
> {
> - return wait_for_atomic((fw_ack(d) & ack) == value,
> - FORCEWAKE_ACK_TIMEOUT_MS);
> + return poll_timeout_us_atomic(, (fw_ack(d) & ack) == value,
> + 1, FORCEWAKE_ACK_TIMEOUT_MS * 1000, false);
I think poll_timeout_us(, ...) i.e. omitting the op is an anti-pattern
that should be avoided. Ditto throughout the series.
I would go for expressing the op and cond in a way that flow
naturally. Sometimes it means adding a local temp variable for it, but I
trust the compiler to optimize it away anyway.
A good example is intel_dsb_wait() with:
bool is_busy;
int ret;
ret = poll_timeout_us(is_busy = is_dsb_busy(display, pipe, dsb->id),
!is_busy,
100, 1000, false);
You could also write it:
ret = poll_timeout_us(, !is_dsb_busy(display, pipe, dsb->id),
100, 1000, false);
but the former is *much* better for clarity.
> }
>
> static inline int
> @@ -387,7 +386,8 @@ static void __gen6_gt_wait_for_thread_c0(struct intel_uncore *uncore)
> * thread to wake up.
> */
> drm_WARN_ONCE(&uncore->i915->drm,
> - wait_for_atomic_us(gt_thread_status(uncore) == 0, 5000),
> + poll_timeout_us_atomic(, gt_thread_status(uncore) == 0,
> + 1, 5000, false),
> "GT thread status wait timed out\n");
> }
>
> @@ -439,6 +439,7 @@ static inline u32 fifo_free_entries(struct intel_uncore *uncore)
> static void __gen6_gt_wait_for_fifo(struct intel_uncore *uncore)
> {
> u32 n;
> + int ret;
>
> /* On VLV, FIFO will be shared by both SW and HW.
> * So, we need to read the FREE_ENTRIES everytime */
> @@ -448,9 +449,10 @@ static void __gen6_gt_wait_for_fifo(struct intel_uncore *uncore)
> n = uncore->fifo_count;
>
> if (n <= GT_FIFO_NUM_RESERVED_ENTRIES) {
> - if (wait_for_atomic((n = fifo_free_entries(uncore)) >
> - GT_FIFO_NUM_RESERVED_ENTRIES,
> - GT_FIFO_TIMEOUT_MS)) {
> + ret = poll_timeout_us_atomic(n = fifo_free_entries(uncore),
> + n > GT_FIFO_NUM_RESERVED_ENTRIES,
> + 1, GT_FIFO_TIMEOUT_MS * 1000, false);
> + if (ret) {
> drm_dbg(&uncore->i915->drm,
> "GT_FIFO timeout, entries: %u\n", n);
> return;
> @@ -2521,7 +2523,7 @@ static int sanity_check_mmio_access(struct intel_uncore *uncore)
> * recovers, then give up.
> */
> #define COND (__raw_uncore_read32(uncore, FORCEWAKE_MT) != ~0)
> - if (wait_for(COND, 2000) == -ETIMEDOUT) {
> + if (poll_timeout_us(, COND, 1000, 2000 * 1000, false) == -ETIMEDOUT) {
> drm_err(&i915->drm, "Device is non-operational; MMIO access returns 0xFFFFFFFF!\n");
> return -EIO;
> }
> diff --git a/drivers/gpu/drm/i915/selftests/intel_uncore.c b/drivers/gpu/drm/i915/selftests/intel_uncore.c
> index 514d2200751b..c80e923b2745 100644
> --- a/drivers/gpu/drm/i915/selftests/intel_uncore.c
> +++ b/drivers/gpu/drm/i915/selftests/intel_uncore.c
> @@ -22,6 +22,8 @@
> *
> */
>
> +#include <linux/iopoll.h>
> +
> #include "../i915_selftest.h"
>
> #include "gt/intel_gt.h"
> @@ -259,7 +261,7 @@ static int live_forcewake_ops(void *arg)
> }
>
> /* We then expect the read to return 0 outside of the fw */
> - if (wait_for(readl(reg) == 0, 100)) {
> + if (poll_timeout_us(, readl(reg) == 0, 1000, 100 * 1000, false)) {
See readl_poll_timeout().
> pr_err("%s:%s=%0x, fw_domains 0x%x still up after 100ms!\n",
> engine->name, r->name, readl(reg), fw_domains);
> err = -ETIMEDOUT;
--
Jani Nikula, Intel
next prev parent reply other threads:[~2026-12-02 18:34 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
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 [this message]
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=d0e0773ab4fbbf385e36794450a5b8985fe58ad8@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.