Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] drm/i915: Add fallback for CDCLK selection when min_cdclk is too high
@ 2025-10-17 11:48 Naladala Ramanaidu
  2025-10-17 13:03 ` ✓ i915.CI.BAT: success for " Patchwork
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Naladala Ramanaidu @ 2025-10-17 11:48 UTC (permalink / raw)
  To: intel-xe, intel-gfx; +Cc: ankit.k.nautiyal, Naladala Ramanaidu

In cases where the requested minimum CDCLK exceeds all available
values for the current reference clock, the CDCLK selection logic
previously returned 0. This could result coverity division or
modulo by zero issue.

This change introduces a fallback mechanism that selects the last
valid CDCLK value associated with the current reference clock. A
warning is logged to indicate that the minimum requirement could
not be satisfied, and a safe fallback value is used instead.

Fixes: Coverity CID 2628056

Signed-off-by: Naladala Ramanaidu <ramanaidu.naladala@intel.com>
---
 drivers/gpu/drm/i915/display/intel_cdclk.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_cdclk.c b/drivers/gpu/drm/i915/display/intel_cdclk.c
index e92e7fd9fd13..a90b602a40c4 100644
--- a/drivers/gpu/drm/i915/display/intel_cdclk.c
+++ b/drivers/gpu/drm/i915/display/intel_cdclk.c
@@ -1551,17 +1551,21 @@ static int cdclk_divider(int cdclk, int vco, u16 waveform)
 static int bxt_calc_cdclk(struct intel_display *display, int min_cdclk)
 {
 	const struct intel_cdclk_vals *table = display->cdclk.table;
-	int i;
+	int i, last_valid_cdclk = 0;
 
-	for (i = 0; table[i].refclk; i++)
+	for (i = 0; table[i].refclk; i++) {
 		if (table[i].refclk == display->cdclk.hw.ref &&
 		    table[i].cdclk >= min_cdclk)
 			return table[i].cdclk;
 
+		if (table[i].refclk == display->cdclk.hw.ref)
+			last_valid_cdclk = table[i].cdclk;
+	}
+
 	drm_WARN(display->drm, 1,
-		 "Cannot satisfy minimum cdclk %d with refclk %u\n",
-		 min_cdclk, display->cdclk.hw.ref);
-	return 0;
+		 "Cannot satisfy minimum cdclk %d with refclk %u, falling back to %d\n",
+		 min_cdclk, display->cdclk.hw.ref, last_valid_cdclk);
+	return last_valid_cdclk;
 }
 
 static int bxt_calc_cdclk_pll_vco(struct intel_display *display, int cdclk)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-10-29  8:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-17 11:48 [PATCH v1] drm/i915: Add fallback for CDCLK selection when min_cdclk is too high Naladala Ramanaidu
2025-10-17 13:03 ` ✓ i915.CI.BAT: success for " Patchwork
2025-10-17 13:22 ` [PATCH v1] " Ville Syrjälä
2025-10-17 15:05 ` [PATCH v2] " Naladala Ramanaidu
2025-10-28 12:07   ` Kahola, Mika
2025-10-29  8:05     ` Naladala, Ramanaidu
2025-10-17 16:44 ` ✓ i915.CI.BAT: success for drm/i915: Add fallback for CDCLK selection when min_cdclk is too high (rev2) Patchwork
2025-10-18  1:21 ` ✗ i915.CI.Full: failure " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox