intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@intel.com>
To: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org
Cc: jani.nikula@intel.com, ville.syrjala@linux.intel.com
Subject: [PATCH 07/20] drm/i915/wm: use generic poll_timeout_us() instead of wait_for()
Date: Thu, 28 Aug 2025 15:20:49 +0300	[thread overview]
Message-ID: <52c80860ea7b98e84f2386ed6cdd761f03190b1e.1756383233.git.jani.nikula@intel.com> (raw)
In-Reply-To: <cover.1756383233.git.jani.nikula@intel.com>

Prefer generic poll helpers over i915 custom helpers.

The functional change is losing the exponentially growing sleep of
wait_for(), which used to be 10, 20, 40, ..., 640, and 1280 us.

Use an arbitrary constant 500 us sleep instead. The timeout remains at 3
ms.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/i915/display/i9xx_wm.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/i9xx_wm.c b/drivers/gpu/drm/i915/display/i9xx_wm.c
index 591acce2a4b1..060aff765994 100644
--- a/drivers/gpu/drm/i915/display/i9xx_wm.c
+++ b/drivers/gpu/drm/i915/display/i9xx_wm.c
@@ -3,6 +3,8 @@
  * Copyright © 2023 Intel Corporation
  */
 
+#include <linux/iopoll.h>
+
 #include "soc/intel_dram.h"
 
 #include "i915_drv.h"
@@ -112,6 +114,7 @@ static const struct cxsr_latency *pnv_get_cxsr_latency(struct intel_display *dis
 static void chv_set_memory_dvfs(struct intel_display *display, bool enable)
 {
 	u32 val;
+	int ret;
 
 	vlv_punit_get(display->drm);
 
@@ -124,8 +127,10 @@ static void chv_set_memory_dvfs(struct intel_display *display, bool enable)
 	val |= FORCE_DDR_FREQ_REQ_ACK;
 	vlv_punit_write(display->drm, PUNIT_REG_DDR_SETUP2, val);
 
-	if (wait_for((vlv_punit_read(display->drm, PUNIT_REG_DDR_SETUP2) &
-		      FORCE_DDR_FREQ_REQ_ACK) == 0, 3))
+	ret = poll_timeout_us(val = vlv_punit_read(display->drm, PUNIT_REG_DDR_SETUP2),
+			      (val & FORCE_DDR_FREQ_REQ_ACK) == 0,
+			      500, 3000, false);
+	if (ret)
 		drm_err(display->drm,
 			"timed out waiting for Punit DDR DVFS request\n");
 
@@ -3905,6 +3910,7 @@ static void vlv_wm_get_hw_state(struct intel_display *display)
 	struct vlv_wm_values *wm = &display->wm.vlv;
 	struct intel_crtc *crtc;
 	u32 val;
+	int ret;
 
 	vlv_read_wm_values(display, wm);
 
@@ -3931,8 +3937,10 @@ static void vlv_wm_get_hw_state(struct intel_display *display)
 		val |= FORCE_DDR_FREQ_REQ_ACK;
 		vlv_punit_write(display->drm, PUNIT_REG_DDR_SETUP2, val);
 
-		if (wait_for((vlv_punit_read(display->drm, PUNIT_REG_DDR_SETUP2) &
-			      FORCE_DDR_FREQ_REQ_ACK) == 0, 3)) {
+		ret = poll_timeout_us(val = vlv_punit_read(display->drm, PUNIT_REG_DDR_SETUP2),
+				      (val & FORCE_DDR_FREQ_REQ_ACK) == 0,
+				      500, 3000, false);
+		if (ret) {
 			drm_dbg_kms(display->drm,
 				    "Punit not acking DDR DVFS request, "
 				    "assuming DDR DVFS is disabled\n");
-- 
2.47.2


  parent reply	other threads:[~2025-08-28 12:21 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-28 12:20 [PATCH 00/20] drm/i915/display: convert to generic poll_timeout_us() Jani Nikula
2025-08-28 12:20 ` [PATCH 01/20] drm/i915/hdmi: use generic poll_timeout_us() instead of __wait_for() Jani Nikula
2025-09-03 13:29   ` Hogander, Jouni
2025-08-28 12:20 ` [PATCH 02/20] drm/i915/hdcp: " Jani Nikula
2025-09-03 13:42   ` Hogander, Jouni
2025-08-28 12:20 ` [PATCH 03/20] drm/i915/hdcp: use generic poll_timeout_us() instead of wait_for() Jani Nikula
2025-09-04  4:14   ` Hogander, Jouni
2025-08-28 12:20 ` [PATCH 04/20] drm/i915/dsi: use generic poll_timeout_us() instead of wait_for_us() Jani Nikula
2025-09-04  4:27   ` Hogander, Jouni
2025-08-28 12:20 ` [PATCH 05/20] drm/i915/dsi-pll: use generic poll_timeout_us() instead of wait_for() Jani Nikula
2025-09-04  4:34   ` Hogander, Jouni
2025-08-28 12:20 ` [PATCH 06/20] drm/i915/gmbus: use generic poll_timeout*() instead of wait_for*() Jani Nikula
2025-09-04  4:53   ` Hogander, Jouni
2025-08-28 12:20 ` Jani Nikula [this message]
2025-09-04  5:01   ` [PATCH 07/20] drm/i915/wm: use generic poll_timeout_us() instead of wait_for() Hogander, Jouni
2025-08-28 12:20 ` [PATCH 08/20] drm/i915/cdclk: " Jani Nikula
2025-09-04  5:45   ` Hogander, Jouni
2025-08-28 12:20 ` [PATCH 09/20] drm/i915/power: " Jani Nikula
2025-09-04  5:47   ` Hogander, Jouni
2025-08-28 12:20 ` [PATCH 10/20] drm/i915/power-well: use generic poll_timeout_us() instead of wait_for() for DKL PHY Jani Nikula
2025-09-04  5:48   ` Hogander, Jouni
2025-08-28 12:20 ` [PATCH 11/20] drm/i915/power-well: use generic poll_timeout_us() instead of wait_for() for VLV/CHV Jani Nikula
2025-09-04  5:54   ` Hogander, Jouni
2025-08-28 12:20 ` [PATCH 12/20] drm/i915/dp: use generic poll_timeout_us() instead of wait_for() Jani Nikula
2025-09-04  6:08   ` Hogander, Jouni
2025-08-28 12:20 ` [PATCH 13/20] drm/i915/dp: use generic poll_timeout_us() instead of wait_for() in link training Jani Nikula
2025-09-04  6:15   ` Hogander, Jouni
2025-08-28 12:20 ` [PATCH 14/20] drm/i915/vblank: use generic poll_timeout_us() instead of wait_for() Jani Nikula
2025-09-04  8:05   ` Hogander, Jouni
2025-08-28 12:20 ` [PATCH 15/20] drm/i915/tc: " Jani Nikula
2025-09-04  8:41   ` Hogander, Jouni
2025-08-28 12:20 ` [PATCH 16/20] drm/i915/dsb: " Jani Nikula
2025-09-04  8:42   ` Hogander, Jouni
2025-08-28 12:20 ` [PATCH 17/20] drm/i915/lspcon: " Jani Nikula
2025-09-04  8:47   ` Hogander, Jouni
2025-08-28 12:21 ` [PATCH 18/20] drm/i915/opregion: " Jani Nikula
2025-09-04  9:06   ` Hogander, Jouni
2025-08-28 12:21 ` [PATCH 19/20] drm/i915/ddi: prefer poll_timeout_us() over readx_poll_timeout() Jani Nikula
2025-08-28 12:21 ` [PATCH 20/20] drm/i915/pps: prefer poll_timeout_us() over read_poll_timeout() Jani Nikula
2025-08-28 17:44 ` ✓ i915.CI.BAT: success for drm/i915/display: convert to generic poll_timeout_us() Patchwork
2025-08-29  0:27 ` ✗ i915.CI.Full: failure " 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=52c80860ea7b98e84f2386ed6cdd761f03190b1e.1756383233.git.jani.nikula@intel.com \
    --to=jani.nikula@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.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;
as well as URLs for NNTP newsgroup(s).