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 1D9E2606A69D for ; Wed, 2 Dec 2026 18:40:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=WyPVjdJC Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 99FF110E714; Wed, 2 Dec 2026 18:40:32 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) by gabe.freedesktop.org (Postfix) with ESMTPS id 551B010E714 for ; Wed, 2 Dec 2026 18:40:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796236826; x=1827772826; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=KoQupMxCR2wJWosJYQCsbYtLtmPvRjlDPZ692w88JBM=; b=WyPVjdJCeaas7+gaVlABJwzX0if3JnhAtXF4hLe2hB2jz1Fbpoz9Oz5x GveX7/UxhBwDCydVtgoKwTxbMUM7h2u7luWmdVaTvpyDVOBdQ704EzIkR jm8HRpckZys+Qk7O0Q99eAUpHmd+0+oMW30+Hwzvwup8+LhiUlDQ4KUH1 ux/4hq/gxe/msm1zsK/U7wMa2brLFIPpf65En2xu1P3mII3VxNpzpsj21 YPet+G8ZoxLdewTuEcVy0Iv9pCzD95CQcrgfB55KkaqCp2rSoMBXLvx91 MQEFqx5+R1lY7SQey2U4E2pNikp9ne8K81b3H4/LQ/x+RBXlMLKlnsrLC Q==; X-CSE-ConnectionGUID: 4BKh3CvBSMaTE/s94+yWkA== X-CSE-MsgGUID: LiMJvtwhRVOJ8sIJCUDLqg== X-IronPort-AV: E=McAfee;i="6800,10657,11984"; a="5076188" X-IronPort-AV: E=Sophos;i="6.27,247,1787036400"; d="scan'208";a="5076188" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 10:38:48 -0800 X-CSE-ConnectionGUID: ByKovlPXTPmQRKGmqN9V1A== X-CSE-MsgGUID: 4sf9VHaLShy68CkkUZhdMg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,247,1787036400"; d="scan'208";a="13388480" 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:38:46 -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 01/25] drm/i915: Convert wait_for() wrappers to poll_timeout_us() In-Reply-To: <08a2371d9c750c50f21dcd450cb3f2424556b52c.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: <08a2371d9c750c50f21dcd450cb3f2424556b52c.1796225423.git.sebastian.brzezinka@intel.com> Date: Wed, 02 Dec 2026 20:38:43 +0200 Message-ID: <54158f0e2bd5e7c32ac9c4e24bfb1b58d6dc495a@intel.com> 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 __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 > --- > 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 > #include > > #include > @@ -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