From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 70745606A682 for ; Wed, 2 Dec 2026 18:34:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=F0Fib8u2 Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0315F10E653; Wed, 2 Dec 2026 18:34:47 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id ED02B10E653 for ; Wed, 2 Dec 2026 18:34:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796236481; x=1827772481; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=4MpwWLqh1o0cfKJZBqOKt5GfBn4xl45naMefiDr1Na8=; b=F0Fib8u2djP5YvqDiZAIsJZhsJSMynEurfgXQwa7CsKsekjZvW0r1D00 R/mYCW+QezUVL6dIcY7hhByo3lICvgkDJ+Mv2jKVf8FEBzZvXVUO0cQ7N AQFG0Eo+0AdWl9wRonAhdb+33bfHh0bzCimzkcvvIqD6arXW1iHNf3HKV czuIeoVEorDGDoOF+SaAGDmdDF/wjdDQLR6yrNcUe3ZL8E4eQpqcUQegB 4jsZ+O2Hxzm3L4K+ZgvhEGfdviMnm0CZluWWZ2v3g5svBs8VEhO4t0bWq rlspLj1mtQxDyVWEbYJfGQX14Rh5dYrRUegiIbgReSjPQPs8uipEsSeuo g==; X-CSE-ConnectionGUID: knFf1QedT9KjSCd7s8KVGQ== X-CSE-MsgGUID: 39UGMcP/Rx+D/w3mG7u+2Q== X-IronPort-AV: E=McAfee;i="6800,10657,11984"; a="5188431" X-IronPort-AV: E=Sophos;i="6.27,247,1787036400"; d="scan'208";a="5188431" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 10:34:40 -0800 X-CSE-ConnectionGUID: K16atGRDSFqfScY2Fkasow== X-CSE-MsgGUID: nQ8kRoiiQTO6Xv25+ha53A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,247,1787036400"; d="scan'208";a="13803595" Received: from conormcd-mobl2.ger.corp.intel.com (HELO localhost) ([10.245.244.18]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 10:34:38 -0800 From: Jani Nikula To: Sebastian Brzezinka , intel-gfx@lists.freedesktop.org Cc: Sebastian Brzezinka , 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() In-Reply-To: <376420dcb8dd6ace94f448c9ed8bd14bf8305dd6.1796225423.git.sebastian.brzezinka@intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs Bertel Jungin Aukio 5, 02600 Espoo, Finland References: <376420dcb8dd6ace94f448c9ed8bd14bf8305dd6.1796225423.git.sebastian.brzezinka@intel.com> Date: Wed, 02 Dec 2026 20:34:34 +0200 Message-ID: X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Intel-gfx" X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Wed, 02 Dec 2026, Sebastian Brzezinka 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 > --- > 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 > + > #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