Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH 1/2] Revert "drm/i915/cdclk: Deal with 2 PPC hscale issues when calculating min CDCLK"
  2026-11-26 12:18 ` [PATCH 1/2] Revert "drm/i915/cdclk: Deal with 2 PPC hscale issues when calculating min CDCLK" Uma Shankar
@ 2026-11-26 12:12   ` Ville Syrjälä
  2026-11-26 15:32     ` Shankar, Uma
  0 siblings, 1 reply; 6+ messages in thread
From: Ville Syrjälä @ 2026-11-26 12:12 UTC (permalink / raw)
  To: Uma Shankar; +Cc: intel-gfx, intel-xe

On Thu, Nov 26, 2026 at 05:48:26PM +0530, Uma Shankar wrote:
> This reverts commit f69946f6d891aca1614233573741543b3bab4e6a.
> 
> The empirical "double the entire fractional part of hscale and
> multiply by vscale" formula overestimates the min CDCLK. Bspec now
> documents the actual 2 PPC downscale formula, which will be
> implemented in a follow-up patch.

Why are you reverting this and then adding it back? Just add the
min() to the existing thing?

> 
> Conflicts resolved against the later GMCH pfit rework: the shared
> intel_crtc_compute_pixel_rate() now simply uses the pipe pixel rate
> as the CDCLK pixel rate again. GMCH platforms are 1 PPC, so nothing
> changes for them.
> 
> Signed-off-by: Uma Shankar <uma.shankar@intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_display.c  | 27 +--------
>  drivers/gpu/drm/i915/display/intel_plane.c    | 55 -------------------
>  drivers/gpu/drm/i915/display/intel_plane.h    |  5 --
>  .../drm/i915/display/skl_universal_plane.c    |  6 +-
>  4 files changed, 4 insertions(+), 89 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
> index 19caae633d29..3235bcbbf054 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -2283,30 +2283,6 @@ intel_pipe_pixel_rate(const struct intel_crtc_state *crtc_state)
>  				   pixel_rate);
>  }
>  
> -static unsigned int
> -intel_pipe_pixel_rate_cdclk(const struct intel_crtc_state *crtc_state)
> -{
> -	struct intel_display *display = to_intel_display(crtc_state);
> -	u32 pixel_rate = crtc_state->hw.pipe_mode.crtc_clock;
> -	unsigned int ppc = HAS_2PPC(display) ? 2 : 1;
> -	struct drm_rect src;
> -
> -	/*
> -	 * We only use IF-ID interlacing. If we ever use
> -	 * PF-ID we'll need to adjust the pixel_rate here.
> -	 */
> -
> -	if (!crtc_state->pfit.enabled)
> -		return pixel_rate;
> -
> -	drm_rect_init(&src, 0, 0,
> -		      drm_rect_width(&crtc_state->pipe_src) << 16,
> -		      drm_rect_height(&crtc_state->pipe_src) << 16);
> -
> -	return intel_adjusted_rate_cdclk(&src, &crtc_state->pfit.dst,
> -					 pixel_rate, ppc);
> -}
> -
>  static void intel_mode_from_crtc_timings(struct drm_display_mode *mode,
>  					 const struct drm_display_mode *timings)
>  {
> @@ -2332,8 +2308,7 @@ static void intel_crtc_compute_pixel_rate(struct intel_crtc_state *crtc_state)
>  {
>  	crtc_state->pixel_rate =
>  		intel_pipe_pixel_rate(crtc_state);
> -	crtc_state->pixel_rate_cdclk =
> -		intel_pipe_pixel_rate_cdclk(crtc_state);
> +	crtc_state->pixel_rate_cdclk = crtc_state->pixel_rate;
>  }
>  
>  static void intel_joiner_adjust_timings(const struct intel_crtc_state *crtc_state,
> diff --git a/drivers/gpu/drm/i915/display/intel_plane.c b/drivers/gpu/drm/i915/display/intel_plane.c
> index d23de0f34e4b..82dcb1d87b5e 100644
> --- a/drivers/gpu/drm/i915/display/intel_plane.c
> +++ b/drivers/gpu/drm/i915/display/intel_plane.c
> @@ -265,50 +265,6 @@ unsigned int intel_adjusted_rate(const struct drm_rect *src,
>  				dst_w * dst_h);
>  }
>  
> -static unsigned int hscale_cdclk(const struct drm_rect *src,
> -				 const struct drm_rect *dst,
> -				 unsigned int ppc)
> -{
> -	unsigned int hscale;
> -
> -	hscale = drm_rect_calc_hscale(src, dst, 0, INT_MAX);
> -	hscale = max(hscale, 0x10000);
> -
> -	/*
> -	 * Double the fractional part due to some 2 PPC granularity issue
> -	 *
> -	 * FIXME: BSpec calls for doubling only the <0.5 fractional part,
> -	 * and rounding it down to a unit fraction. In practice that is
> -	 * not sufficient, and we need a more aggressive CDCLK bump in
> -	 * many cases. The updated formula was derived empirically.
> -	 * This may need to be updated once we have better undestading
> -	 * of what's happening in the hardware...
> -	 */
> -	return (hscale & ~0xffff) + ppc * (hscale & 0xffff);
> -}
> -
> -static unsigned int vscale_cdclk(const struct drm_rect *src,
> -				 const struct drm_rect *dst)
> -{
> -	unsigned int vscale;
> -
> -	vscale = drm_rect_calc_vscale(src, dst, 0, INT_MAX);
> -	vscale = max(vscale, 0x10000);
> -
> -	return vscale;
> -}
> -
> -unsigned int intel_adjusted_rate_cdclk(const struct drm_rect *src,
> -				       const struct drm_rect *dst,
> -				       unsigned int rate,
> -				       unsigned int ppc)
> -{
> -	unsigned int hscale = hscale_cdclk(src, dst, ppc);
> -	unsigned int vscale = vscale_cdclk(src, dst);
> -
> -	return DIV64_U64_ROUND_UP((u64)rate * hscale * vscale, 1ull << 32);
> -}
> -
>  unsigned int intel_plane_pixel_rate(const struct intel_crtc_state *crtc_state,
>  				    const struct intel_plane_state *plane_state)
>  {
> @@ -329,17 +285,6 @@ unsigned int intel_plane_pixel_rate(const struct intel_crtc_state *crtc_state,
>  				   crtc_state->pixel_rate);
>  }
>  
> -unsigned int intel_plane_pixel_rate_cdclk(const struct intel_crtc_state *crtc_state,
> -					  const struct intel_plane_state *plane_state)
> -{
> -	struct intel_display *display = to_intel_display(crtc_state);
> -	unsigned int ppc = HAS_2PPC(display) ? 2 : 1;
> -
> -	return intel_adjusted_rate_cdclk(&plane_state->uapi.src,
> -					 &plane_state->uapi.dst,
> -					 crtc_state->pixel_rate_cdclk, ppc);
> -}
> -
>  unsigned int intel_plane_data_rate(const struct intel_crtc_state *crtc_state,
>  				   const struct intel_plane_state *plane_state,
>  				   int color_plane)
> diff --git a/drivers/gpu/drm/i915/display/intel_plane.h b/drivers/gpu/drm/i915/display/intel_plane.h
> index dba2be24aae2..31a6229aea73 100644
> --- a/drivers/gpu/drm/i915/display/intel_plane.h
> +++ b/drivers/gpu/drm/i915/display/intel_plane.h
> @@ -29,13 +29,8 @@ bool intel_plane_can_async_flip(struct intel_plane *plane,
>  unsigned int intel_adjusted_rate(const struct drm_rect *src,
>  				 const struct drm_rect *dst,
>  				 unsigned int rate);
> -unsigned int intel_adjusted_rate_cdclk(const struct drm_rect *src,
> -				       const struct drm_rect *dst,
> -				       unsigned int rate, unsigned int ppc);
>  unsigned int intel_plane_pixel_rate(const struct intel_crtc_state *crtc_state,
>  				    const struct intel_plane_state *plane_state);
> -unsigned int intel_plane_pixel_rate_cdclk(const struct intel_crtc_state *crtc_state,
> -					  const struct intel_plane_state *plane_state);
>  
>  unsigned int intel_plane_data_rate(const struct intel_crtc_state *crtc_state,
>  				   const struct intel_plane_state *plane_state,
> diff --git a/drivers/gpu/drm/i915/display/skl_universal_plane.c b/drivers/gpu/drm/i915/display/skl_universal_plane.c
> index def4798f8502..4cd868d11ad6 100644
> --- a/drivers/gpu/drm/i915/display/skl_universal_plane.c
> +++ b/drivers/gpu/drm/i915/display/skl_universal_plane.c
> @@ -267,7 +267,7 @@ bool icl_is_hdr_plane(struct intel_display *display, enum plane_id plane_id)
>  static int icl_plane_min_cdclk(const struct intel_crtc_state *crtc_state,
>  			       const struct intel_plane_state *plane_state)
>  {
> -	unsigned int pixel_rate = intel_plane_pixel_rate_cdclk(crtc_state, plane_state);
> +	unsigned int pixel_rate = intel_plane_pixel_rate(crtc_state, plane_state);
>  
>  	/* two pixels per clock */
>  	return DIV_ROUND_UP(pixel_rate, 2);
> @@ -291,7 +291,7 @@ glk_plane_ratio(const struct intel_plane_state *plane_state,
>  static int glk_plane_min_cdclk(const struct intel_crtc_state *crtc_state,
>  			       const struct intel_plane_state *plane_state)
>  {
> -	unsigned int pixel_rate = intel_plane_pixel_rate_cdclk(crtc_state, plane_state);
> +	unsigned int pixel_rate = intel_plane_pixel_rate(crtc_state, plane_state);
>  	unsigned int num, den;
>  
>  	glk_plane_ratio(plane_state, &num, &den);
> @@ -318,7 +318,7 @@ skl_plane_ratio(const struct intel_plane_state *plane_state,
>  static int skl_plane_min_cdclk(const struct intel_crtc_state *crtc_state,
>  			       const struct intel_plane_state *plane_state)
>  {
> -	unsigned int pixel_rate = intel_plane_pixel_rate_cdclk(crtc_state, plane_state);
> +	unsigned int pixel_rate = intel_plane_pixel_rate(crtc_state, plane_state);
>  	unsigned int num, den;
>  
>  	skl_plane_ratio(plane_state, &num, &den);
> -- 
> 2.50.1

-- 
Ville Syrjälä
Intel

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

* [PATCH 0/2] Account for 2 PPC horizontal downscale inefficiency in min CDCLK
@ 2026-11-26 12:18 Uma Shankar
  2026-11-26 12:18 ` [PATCH 1/2] Revert "drm/i915/cdclk: Deal with 2 PPC hscale issues when calculating min CDCLK" Uma Shankar
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Uma Shankar @ 2026-11-26 12:18 UTC (permalink / raw)
  To: intel-gfx, intel-xe; +Cc: Uma Shankar

The horizontal scaler filter works at 2 PPC, but still needs a full
clock for a fractional shift of just one pixel. It doesn't shift by
two pixels and re-align the taps, so the extra clock doesn't average
out. Without accounting for this, CDCLK may end up too low for certain
horizontal downscale factors, which leads to underruns.

Implement the Bspec formula for the downscale amount, used for both
plane and pipe scalers when computing the min CDCLK

Uma Shankar (2):
  Revert "drm/i915/cdclk: Deal with 2 PPC hscale issues when calculating
    min CDCLK"
  drm/i915/cdclk: Account for 2 PPC horizontal downscale inefficiency in
    min CDCLK

 drivers/gpu/drm/i915/display/intel_plane.c | 54 +++++++++-------------
 1 file changed, 22 insertions(+), 32 deletions(-)

-- 
2.50.1


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

* [PATCH 1/2] Revert "drm/i915/cdclk: Deal with 2 PPC hscale issues when calculating min CDCLK"
  2026-11-26 12:18 [PATCH 0/2] Account for 2 PPC horizontal downscale inefficiency in min CDCLK Uma Shankar
@ 2026-11-26 12:18 ` Uma Shankar
  2026-11-26 12:12   ` Ville Syrjälä
  2026-11-26 12:18 ` [PATCH 2/2] drm/i915/cdclk: Account for 2 PPC horizontal downscale inefficiency in min CDCLK Uma Shankar
  2026-11-26 14:46 ` ✓ i915.CI.BAT: success for " Patchwork
  2 siblings, 1 reply; 6+ messages in thread
From: Uma Shankar @ 2026-11-26 12:18 UTC (permalink / raw)
  To: intel-gfx, intel-xe; +Cc: Uma Shankar

This reverts commit f69946f6d891aca1614233573741543b3bab4e6a.

The empirical "double the entire fractional part of hscale and
multiply by vscale" formula overestimates the min CDCLK. Bspec now
documents the actual 2 PPC downscale formula, which will be
implemented in a follow-up patch.

Conflicts resolved against the later GMCH pfit rework: the shared
intel_crtc_compute_pixel_rate() now simply uses the pipe pixel rate
as the CDCLK pixel rate again. GMCH platforms are 1 PPC, so nothing
changes for them.

Signed-off-by: Uma Shankar <uma.shankar@intel.com>
---
 drivers/gpu/drm/i915/display/intel_display.c  | 27 +--------
 drivers/gpu/drm/i915/display/intel_plane.c    | 55 -------------------
 drivers/gpu/drm/i915/display/intel_plane.h    |  5 --
 .../drm/i915/display/skl_universal_plane.c    |  6 +-
 4 files changed, 4 insertions(+), 89 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index 19caae633d29..3235bcbbf054 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -2283,30 +2283,6 @@ intel_pipe_pixel_rate(const struct intel_crtc_state *crtc_state)
 				   pixel_rate);
 }
 
-static unsigned int
-intel_pipe_pixel_rate_cdclk(const struct intel_crtc_state *crtc_state)
-{
-	struct intel_display *display = to_intel_display(crtc_state);
-	u32 pixel_rate = crtc_state->hw.pipe_mode.crtc_clock;
-	unsigned int ppc = HAS_2PPC(display) ? 2 : 1;
-	struct drm_rect src;
-
-	/*
-	 * We only use IF-ID interlacing. If we ever use
-	 * PF-ID we'll need to adjust the pixel_rate here.
-	 */
-
-	if (!crtc_state->pfit.enabled)
-		return pixel_rate;
-
-	drm_rect_init(&src, 0, 0,
-		      drm_rect_width(&crtc_state->pipe_src) << 16,
-		      drm_rect_height(&crtc_state->pipe_src) << 16);
-
-	return intel_adjusted_rate_cdclk(&src, &crtc_state->pfit.dst,
-					 pixel_rate, ppc);
-}
-
 static void intel_mode_from_crtc_timings(struct drm_display_mode *mode,
 					 const struct drm_display_mode *timings)
 {
@@ -2332,8 +2308,7 @@ static void intel_crtc_compute_pixel_rate(struct intel_crtc_state *crtc_state)
 {
 	crtc_state->pixel_rate =
 		intel_pipe_pixel_rate(crtc_state);
-	crtc_state->pixel_rate_cdclk =
-		intel_pipe_pixel_rate_cdclk(crtc_state);
+	crtc_state->pixel_rate_cdclk = crtc_state->pixel_rate;
 }
 
 static void intel_joiner_adjust_timings(const struct intel_crtc_state *crtc_state,
diff --git a/drivers/gpu/drm/i915/display/intel_plane.c b/drivers/gpu/drm/i915/display/intel_plane.c
index d23de0f34e4b..82dcb1d87b5e 100644
--- a/drivers/gpu/drm/i915/display/intel_plane.c
+++ b/drivers/gpu/drm/i915/display/intel_plane.c
@@ -265,50 +265,6 @@ unsigned int intel_adjusted_rate(const struct drm_rect *src,
 				dst_w * dst_h);
 }
 
-static unsigned int hscale_cdclk(const struct drm_rect *src,
-				 const struct drm_rect *dst,
-				 unsigned int ppc)
-{
-	unsigned int hscale;
-
-	hscale = drm_rect_calc_hscale(src, dst, 0, INT_MAX);
-	hscale = max(hscale, 0x10000);
-
-	/*
-	 * Double the fractional part due to some 2 PPC granularity issue
-	 *
-	 * FIXME: BSpec calls for doubling only the <0.5 fractional part,
-	 * and rounding it down to a unit fraction. In practice that is
-	 * not sufficient, and we need a more aggressive CDCLK bump in
-	 * many cases. The updated formula was derived empirically.
-	 * This may need to be updated once we have better undestading
-	 * of what's happening in the hardware...
-	 */
-	return (hscale & ~0xffff) + ppc * (hscale & 0xffff);
-}
-
-static unsigned int vscale_cdclk(const struct drm_rect *src,
-				 const struct drm_rect *dst)
-{
-	unsigned int vscale;
-
-	vscale = drm_rect_calc_vscale(src, dst, 0, INT_MAX);
-	vscale = max(vscale, 0x10000);
-
-	return vscale;
-}
-
-unsigned int intel_adjusted_rate_cdclk(const struct drm_rect *src,
-				       const struct drm_rect *dst,
-				       unsigned int rate,
-				       unsigned int ppc)
-{
-	unsigned int hscale = hscale_cdclk(src, dst, ppc);
-	unsigned int vscale = vscale_cdclk(src, dst);
-
-	return DIV64_U64_ROUND_UP((u64)rate * hscale * vscale, 1ull << 32);
-}
-
 unsigned int intel_plane_pixel_rate(const struct intel_crtc_state *crtc_state,
 				    const struct intel_plane_state *plane_state)
 {
@@ -329,17 +285,6 @@ unsigned int intel_plane_pixel_rate(const struct intel_crtc_state *crtc_state,
 				   crtc_state->pixel_rate);
 }
 
-unsigned int intel_plane_pixel_rate_cdclk(const struct intel_crtc_state *crtc_state,
-					  const struct intel_plane_state *plane_state)
-{
-	struct intel_display *display = to_intel_display(crtc_state);
-	unsigned int ppc = HAS_2PPC(display) ? 2 : 1;
-
-	return intel_adjusted_rate_cdclk(&plane_state->uapi.src,
-					 &plane_state->uapi.dst,
-					 crtc_state->pixel_rate_cdclk, ppc);
-}
-
 unsigned int intel_plane_data_rate(const struct intel_crtc_state *crtc_state,
 				   const struct intel_plane_state *plane_state,
 				   int color_plane)
diff --git a/drivers/gpu/drm/i915/display/intel_plane.h b/drivers/gpu/drm/i915/display/intel_plane.h
index dba2be24aae2..31a6229aea73 100644
--- a/drivers/gpu/drm/i915/display/intel_plane.h
+++ b/drivers/gpu/drm/i915/display/intel_plane.h
@@ -29,13 +29,8 @@ bool intel_plane_can_async_flip(struct intel_plane *plane,
 unsigned int intel_adjusted_rate(const struct drm_rect *src,
 				 const struct drm_rect *dst,
 				 unsigned int rate);
-unsigned int intel_adjusted_rate_cdclk(const struct drm_rect *src,
-				       const struct drm_rect *dst,
-				       unsigned int rate, unsigned int ppc);
 unsigned int intel_plane_pixel_rate(const struct intel_crtc_state *crtc_state,
 				    const struct intel_plane_state *plane_state);
-unsigned int intel_plane_pixel_rate_cdclk(const struct intel_crtc_state *crtc_state,
-					  const struct intel_plane_state *plane_state);
 
 unsigned int intel_plane_data_rate(const struct intel_crtc_state *crtc_state,
 				   const struct intel_plane_state *plane_state,
diff --git a/drivers/gpu/drm/i915/display/skl_universal_plane.c b/drivers/gpu/drm/i915/display/skl_universal_plane.c
index def4798f8502..4cd868d11ad6 100644
--- a/drivers/gpu/drm/i915/display/skl_universal_plane.c
+++ b/drivers/gpu/drm/i915/display/skl_universal_plane.c
@@ -267,7 +267,7 @@ bool icl_is_hdr_plane(struct intel_display *display, enum plane_id plane_id)
 static int icl_plane_min_cdclk(const struct intel_crtc_state *crtc_state,
 			       const struct intel_plane_state *plane_state)
 {
-	unsigned int pixel_rate = intel_plane_pixel_rate_cdclk(crtc_state, plane_state);
+	unsigned int pixel_rate = intel_plane_pixel_rate(crtc_state, plane_state);
 
 	/* two pixels per clock */
 	return DIV_ROUND_UP(pixel_rate, 2);
@@ -291,7 +291,7 @@ glk_plane_ratio(const struct intel_plane_state *plane_state,
 static int glk_plane_min_cdclk(const struct intel_crtc_state *crtc_state,
 			       const struct intel_plane_state *plane_state)
 {
-	unsigned int pixel_rate = intel_plane_pixel_rate_cdclk(crtc_state, plane_state);
+	unsigned int pixel_rate = intel_plane_pixel_rate(crtc_state, plane_state);
 	unsigned int num, den;
 
 	glk_plane_ratio(plane_state, &num, &den);
@@ -318,7 +318,7 @@ skl_plane_ratio(const struct intel_plane_state *plane_state,
 static int skl_plane_min_cdclk(const struct intel_crtc_state *crtc_state,
 			       const struct intel_plane_state *plane_state)
 {
-	unsigned int pixel_rate = intel_plane_pixel_rate_cdclk(crtc_state, plane_state);
+	unsigned int pixel_rate = intel_plane_pixel_rate(crtc_state, plane_state);
 	unsigned int num, den;
 
 	skl_plane_ratio(plane_state, &num, &den);
-- 
2.50.1


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

* [PATCH 2/2] drm/i915/cdclk: Account for 2 PPC horizontal downscale inefficiency in min CDCLK
  2026-11-26 12:18 [PATCH 0/2] Account for 2 PPC horizontal downscale inefficiency in min CDCLK Uma Shankar
  2026-11-26 12:18 ` [PATCH 1/2] Revert "drm/i915/cdclk: Deal with 2 PPC hscale issues when calculating min CDCLK" Uma Shankar
@ 2026-11-26 12:18 ` Uma Shankar
  2026-11-26 14:46 ` ✓ i915.CI.BAT: success for " Patchwork
  2 siblings, 0 replies; 6+ messages in thread
From: Uma Shankar @ 2026-11-26 12:18 UTC (permalink / raw)
  To: intel-gfx, intel-xe; +Cc: Uma Shankar

The horizontal scaler filter works at 2 PPC, but still needs a full
clock for a fractional shift of just one pixel. It doesn't shift by
two pixels and re-align the taps, so the extra clock doesn't average
out. Without accounting for this, CDCLK may end up too low for certain
horizontal downscale factors, which leads to underruns.

Implement the Bspec formula for the downscale amount, used for both
plane and pipe scalers when computing the min CDCLK:

  hscale_ppc = int(hscale) + min(1, ppc * frac(hscale))
  downscale  = max(hscale_ppc, hscale * vscale)

The fractional penalty is capped at one extra clock, and since the
scaler filters vertically first, it does not multiply with the
vertical downscale factor.

Platforms without 2 PPC (ppc == 1) are unaffected as the formula then
reduces to hscale * vscale.

Bspec: 68858
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Uma Shankar <uma.shankar@intel.com>
Signed-off-by: Vidya Srinivas <vidya.srinivas@intel.com>
---
 drivers/gpu/drm/i915/display/intel_display.c  | 27 ++++++++++-
 drivers/gpu/drm/i915/display/intel_plane.c    | 45 +++++++++++++++++++
 drivers/gpu/drm/i915/display/intel_plane.h    |  5 +++
 .../drm/i915/display/skl_universal_plane.c    |  6 +--
 4 files changed, 79 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index 3235bcbbf054..19caae633d29 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -2283,6 +2283,30 @@ intel_pipe_pixel_rate(const struct intel_crtc_state *crtc_state)
 				   pixel_rate);
 }
 
+static unsigned int
+intel_pipe_pixel_rate_cdclk(const struct intel_crtc_state *crtc_state)
+{
+	struct intel_display *display = to_intel_display(crtc_state);
+	u32 pixel_rate = crtc_state->hw.pipe_mode.crtc_clock;
+	unsigned int ppc = HAS_2PPC(display) ? 2 : 1;
+	struct drm_rect src;
+
+	/*
+	 * We only use IF-ID interlacing. If we ever use
+	 * PF-ID we'll need to adjust the pixel_rate here.
+	 */
+
+	if (!crtc_state->pfit.enabled)
+		return pixel_rate;
+
+	drm_rect_init(&src, 0, 0,
+		      drm_rect_width(&crtc_state->pipe_src) << 16,
+		      drm_rect_height(&crtc_state->pipe_src) << 16);
+
+	return intel_adjusted_rate_cdclk(&src, &crtc_state->pfit.dst,
+					 pixel_rate, ppc);
+}
+
 static void intel_mode_from_crtc_timings(struct drm_display_mode *mode,
 					 const struct drm_display_mode *timings)
 {
@@ -2308,7 +2332,8 @@ static void intel_crtc_compute_pixel_rate(struct intel_crtc_state *crtc_state)
 {
 	crtc_state->pixel_rate =
 		intel_pipe_pixel_rate(crtc_state);
-	crtc_state->pixel_rate_cdclk = crtc_state->pixel_rate;
+	crtc_state->pixel_rate_cdclk =
+		intel_pipe_pixel_rate_cdclk(crtc_state);
 }
 
 static void intel_joiner_adjust_timings(const struct intel_crtc_state *crtc_state,
diff --git a/drivers/gpu/drm/i915/display/intel_plane.c b/drivers/gpu/drm/i915/display/intel_plane.c
index 82dcb1d87b5e..16d653e3739e 100644
--- a/drivers/gpu/drm/i915/display/intel_plane.c
+++ b/drivers/gpu/drm/i915/display/intel_plane.c
@@ -265,6 +265,40 @@ unsigned int intel_adjusted_rate(const struct drm_rect *src,
 				dst_w * dst_h);
 }
 
+/*
+ * Bspec: 68858
+ *
+ * The horizontal filter works at 2 PPC but still needs a full clock
+ * for a fractional shift of just 1 pixel, so the fractional part of
+ * the horizontal downscale factor costs PPC times more (but at most
+ * one full extra clock). The scaler filters vertically first, so this
+ * inefficiency does not multiply with the vertical downscale factor:
+ *
+ * hscale_ppc = int(hscale) + min(1, ppc * frac(hscale))
+ * scale = max(hscale_ppc, hscale * vscale)
+ */
+unsigned int intel_adjusted_rate_cdclk(const struct drm_rect *src,
+				       const struct drm_rect *dst,
+				       unsigned int rate,
+				       unsigned int ppc)
+{
+	unsigned int hscale, vscale, hscale_ppc;
+	u64 scale;
+
+	hscale = drm_rect_calc_hscale(src, dst, 0, INT_MAX);
+	hscale = max(hscale, 0x10000);
+
+	vscale = drm_rect_calc_vscale(src, dst, 0, INT_MAX);
+	vscale = max(vscale, 0x10000);
+
+	hscale_ppc = (hscale & ~0xffff) + min(ppc * (hscale & 0xffff), 0x10000);
+
+	/* .32 fixed point */
+	scale = max((u64)hscale_ppc << 16, mul_u32_u32(hscale, vscale));
+
+	return DIV64_U64_ROUND_UP(rate * scale, 1ull << 32);
+}
+
 unsigned int intel_plane_pixel_rate(const struct intel_crtc_state *crtc_state,
 				    const struct intel_plane_state *plane_state)
 {
@@ -285,6 +319,17 @@ unsigned int intel_plane_pixel_rate(const struct intel_crtc_state *crtc_state,
 				   crtc_state->pixel_rate);
 }
 
+unsigned int intel_plane_pixel_rate_cdclk(const struct intel_crtc_state *crtc_state,
+					  const struct intel_plane_state *plane_state)
+{
+	struct intel_display *display = to_intel_display(crtc_state);
+	unsigned int ppc = HAS_2PPC(display) ? 2 : 1;
+
+	return intel_adjusted_rate_cdclk(&plane_state->uapi.src,
+					 &plane_state->uapi.dst,
+					 crtc_state->pixel_rate_cdclk, ppc);
+}
+
 unsigned int intel_plane_data_rate(const struct intel_crtc_state *crtc_state,
 				   const struct intel_plane_state *plane_state,
 				   int color_plane)
diff --git a/drivers/gpu/drm/i915/display/intel_plane.h b/drivers/gpu/drm/i915/display/intel_plane.h
index 31a6229aea73..dba2be24aae2 100644
--- a/drivers/gpu/drm/i915/display/intel_plane.h
+++ b/drivers/gpu/drm/i915/display/intel_plane.h
@@ -29,8 +29,13 @@ bool intel_plane_can_async_flip(struct intel_plane *plane,
 unsigned int intel_adjusted_rate(const struct drm_rect *src,
 				 const struct drm_rect *dst,
 				 unsigned int rate);
+unsigned int intel_adjusted_rate_cdclk(const struct drm_rect *src,
+				       const struct drm_rect *dst,
+				       unsigned int rate, unsigned int ppc);
 unsigned int intel_plane_pixel_rate(const struct intel_crtc_state *crtc_state,
 				    const struct intel_plane_state *plane_state);
+unsigned int intel_plane_pixel_rate_cdclk(const struct intel_crtc_state *crtc_state,
+					  const struct intel_plane_state *plane_state);
 
 unsigned int intel_plane_data_rate(const struct intel_crtc_state *crtc_state,
 				   const struct intel_plane_state *plane_state,
diff --git a/drivers/gpu/drm/i915/display/skl_universal_plane.c b/drivers/gpu/drm/i915/display/skl_universal_plane.c
index 4cd868d11ad6..def4798f8502 100644
--- a/drivers/gpu/drm/i915/display/skl_universal_plane.c
+++ b/drivers/gpu/drm/i915/display/skl_universal_plane.c
@@ -267,7 +267,7 @@ bool icl_is_hdr_plane(struct intel_display *display, enum plane_id plane_id)
 static int icl_plane_min_cdclk(const struct intel_crtc_state *crtc_state,
 			       const struct intel_plane_state *plane_state)
 {
-	unsigned int pixel_rate = intel_plane_pixel_rate(crtc_state, plane_state);
+	unsigned int pixel_rate = intel_plane_pixel_rate_cdclk(crtc_state, plane_state);
 
 	/* two pixels per clock */
 	return DIV_ROUND_UP(pixel_rate, 2);
@@ -291,7 +291,7 @@ glk_plane_ratio(const struct intel_plane_state *plane_state,
 static int glk_plane_min_cdclk(const struct intel_crtc_state *crtc_state,
 			       const struct intel_plane_state *plane_state)
 {
-	unsigned int pixel_rate = intel_plane_pixel_rate(crtc_state, plane_state);
+	unsigned int pixel_rate = intel_plane_pixel_rate_cdclk(crtc_state, plane_state);
 	unsigned int num, den;
 
 	glk_plane_ratio(plane_state, &num, &den);
@@ -318,7 +318,7 @@ skl_plane_ratio(const struct intel_plane_state *plane_state,
 static int skl_plane_min_cdclk(const struct intel_crtc_state *crtc_state,
 			       const struct intel_plane_state *plane_state)
 {
-	unsigned int pixel_rate = intel_plane_pixel_rate(crtc_state, plane_state);
+	unsigned int pixel_rate = intel_plane_pixel_rate_cdclk(crtc_state, plane_state);
 	unsigned int num, den;
 
 	skl_plane_ratio(plane_state, &num, &den);
-- 
2.50.1


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

* ✓ i915.CI.BAT: success for Account for 2 PPC horizontal downscale inefficiency in min CDCLK
  2026-11-26 12:18 [PATCH 0/2] Account for 2 PPC horizontal downscale inefficiency in min CDCLK Uma Shankar
  2026-11-26 12:18 ` [PATCH 1/2] Revert "drm/i915/cdclk: Deal with 2 PPC hscale issues when calculating min CDCLK" Uma Shankar
  2026-11-26 12:18 ` [PATCH 2/2] drm/i915/cdclk: Account for 2 PPC horizontal downscale inefficiency in min CDCLK Uma Shankar
@ 2026-11-26 14:46 ` Patchwork
  2 siblings, 0 replies; 6+ messages in thread
From: Patchwork @ 2026-11-26 14:46 UTC (permalink / raw)
  To: Uma Shankar; +Cc: intel-gfx

[-- Attachment #1: Type: text/plain, Size: 2004 bytes --]

== Series Details ==

Series: Account for 2 PPC horizontal downscale inefficiency in min CDCLK
URL   : https://patchwork.freedesktop.org/series/179748/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_19616 -> Patchwork_179748v1
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_179748v1/index.html

Participating hosts (40 -> 39)
------------------------------

  Missing    (1): bat-dg2-13 

Known issues
------------

  Here are the changes found in Patchwork_179748v1 that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@i915_selftest@live:
    - fi-bsw-n3050:       [PASS][1] -> [ABORT][2] ([i915#17765]) +1 other test abort
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_19616/fi-bsw-n3050/igt@i915_selftest@live.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_179748v1/fi-bsw-n3050/igt@i915_selftest@live.html

  * igt@vgem_basic@unload:
    - bat-rpls-4:         [PASS][3] -> [DMESG-WARN][4] ([i915#13400])
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_19616/bat-rpls-4/igt@vgem_basic@unload.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_179748v1/bat-rpls-4/igt@vgem_basic@unload.html

  
  [i915#13400]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/13400
  [i915#17765]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/17765


Build changes
-------------

  * Linux: CI_DRM_19616 -> Patchwork_179748v1

  CI-20190529: 20190529
  CI_DRM_19616: c7a2a8c7a31d55cffae58b6551a554b65009c67a @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_9204: 52e9317c945f97f29fbec75be29280fc7b00cf32 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
  Patchwork_179748v1: c7a2a8c7a31d55cffae58b6551a554b65009c67a @ git://anongit.freedesktop.org/gfx-ci/linux

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_179748v1/index.html

[-- Attachment #2: Type: text/html, Size: 2626 bytes --]

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

* RE: [PATCH 1/2] Revert "drm/i915/cdclk: Deal with 2 PPC hscale issues when calculating min CDCLK"
  2026-11-26 12:12   ` Ville Syrjälä
@ 2026-11-26 15:32     ` Shankar, Uma
  0 siblings, 0 replies; 6+ messages in thread
From: Shankar, Uma @ 2026-11-26 15:32 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org



> -----Original Message-----
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Sent: Thursday, November 26, 2026 5:43 PM
> To: Shankar, Uma <uma.shankar@intel.com>
> Cc: intel-gfx@lists.freedesktop.org; intel-xe@lists.freedesktop.org
> Subject: Re: [PATCH 1/2] Revert "drm/i915/cdclk: Deal with 2 PPC hscale issues
> when calculating min CDCLK"
> 
> On Thu, Nov 26, 2026 at 05:48:26PM +0530, Uma Shankar wrote:
> > This reverts commit f69946f6d891aca1614233573741543b3bab4e6a.
> >
> > The empirical "double the entire fractional part of hscale and
> > multiply by vscale" formula overestimates the min CDCLK. Bspec now
> > documents the actual 2 PPC downscale formula, which will be
> > implemented in a follow-up patch.
> 
> Why are you reverting this and then adding it back? Just add the
> min() to the existing thing?

Yes sure Ville, will update the existing one with Fixes instead of revert.

Regards,
Uma Shankar

> >
> > Conflicts resolved against the later GMCH pfit rework: the shared
> > intel_crtc_compute_pixel_rate() now simply uses the pipe pixel rate as
> > the CDCLK pixel rate again. GMCH platforms are 1 PPC, so nothing
> > changes for them.
> >
> > Signed-off-by: Uma Shankar <uma.shankar@intel.com>
> > ---
> >  drivers/gpu/drm/i915/display/intel_display.c  | 27 +--------
> >  drivers/gpu/drm/i915/display/intel_plane.c    | 55 -------------------
> >  drivers/gpu/drm/i915/display/intel_plane.h    |  5 --
> >  .../drm/i915/display/skl_universal_plane.c    |  6 +-
> >  4 files changed, 4 insertions(+), 89 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/display/intel_display.c
> > b/drivers/gpu/drm/i915/display/intel_display.c
> > index 19caae633d29..3235bcbbf054 100644
> > --- a/drivers/gpu/drm/i915/display/intel_display.c
> > +++ b/drivers/gpu/drm/i915/display/intel_display.c
> > @@ -2283,30 +2283,6 @@ intel_pipe_pixel_rate(const struct intel_crtc_state
> *crtc_state)
> >  				   pixel_rate);
> >  }
> >
> > -static unsigned int
> > -intel_pipe_pixel_rate_cdclk(const struct intel_crtc_state
> > *crtc_state) -{
> > -	struct intel_display *display = to_intel_display(crtc_state);
> > -	u32 pixel_rate = crtc_state->hw.pipe_mode.crtc_clock;
> > -	unsigned int ppc = HAS_2PPC(display) ? 2 : 1;
> > -	struct drm_rect src;
> > -
> > -	/*
> > -	 * We only use IF-ID interlacing. If we ever use
> > -	 * PF-ID we'll need to adjust the pixel_rate here.
> > -	 */
> > -
> > -	if (!crtc_state->pfit.enabled)
> > -		return pixel_rate;
> > -
> > -	drm_rect_init(&src, 0, 0,
> > -		      drm_rect_width(&crtc_state->pipe_src) << 16,
> > -		      drm_rect_height(&crtc_state->pipe_src) << 16);
> > -
> > -	return intel_adjusted_rate_cdclk(&src, &crtc_state->pfit.dst,
> > -					 pixel_rate, ppc);
> > -}
> > -
> >  static void intel_mode_from_crtc_timings(struct drm_display_mode *mode,
> >  					 const struct drm_display_mode *timings)
> { @@ -2332,8 +2308,7
> > @@ static void intel_crtc_compute_pixel_rate(struct intel_crtc_state
> > *crtc_state)  {
> >  	crtc_state->pixel_rate =
> >  		intel_pipe_pixel_rate(crtc_state);
> > -	crtc_state->pixel_rate_cdclk =
> > -		intel_pipe_pixel_rate_cdclk(crtc_state);
> > +	crtc_state->pixel_rate_cdclk = crtc_state->pixel_rate;
> >  }
> >
> >  static void intel_joiner_adjust_timings(const struct intel_crtc_state
> > *crtc_state, diff --git a/drivers/gpu/drm/i915/display/intel_plane.c
> > b/drivers/gpu/drm/i915/display/intel_plane.c
> > index d23de0f34e4b..82dcb1d87b5e 100644
> > --- a/drivers/gpu/drm/i915/display/intel_plane.c
> > +++ b/drivers/gpu/drm/i915/display/intel_plane.c
> > @@ -265,50 +265,6 @@ unsigned int intel_adjusted_rate(const struct drm_rect
> *src,
> >  				dst_w * dst_h);
> >  }
> >
> > -static unsigned int hscale_cdclk(const struct drm_rect *src,
> > -				 const struct drm_rect *dst,
> > -				 unsigned int ppc)
> > -{
> > -	unsigned int hscale;
> > -
> > -	hscale = drm_rect_calc_hscale(src, dst, 0, INT_MAX);
> > -	hscale = max(hscale, 0x10000);
> > -
> > -	/*
> > -	 * Double the fractional part due to some 2 PPC granularity issue
> > -	 *
> > -	 * FIXME: BSpec calls for doubling only the <0.5 fractional part,
> > -	 * and rounding it down to a unit fraction. In practice that is
> > -	 * not sufficient, and we need a more aggressive CDCLK bump in
> > -	 * many cases. The updated formula was derived empirically.
> > -	 * This may need to be updated once we have better undestading
> > -	 * of what's happening in the hardware...
> > -	 */
> > -	return (hscale & ~0xffff) + ppc * (hscale & 0xffff);
> > -}
> > -
> > -static unsigned int vscale_cdclk(const struct drm_rect *src,
> > -				 const struct drm_rect *dst)
> > -{
> > -	unsigned int vscale;
> > -
> > -	vscale = drm_rect_calc_vscale(src, dst, 0, INT_MAX);
> > -	vscale = max(vscale, 0x10000);
> > -
> > -	return vscale;
> > -}
> > -
> > -unsigned int intel_adjusted_rate_cdclk(const struct drm_rect *src,
> > -				       const struct drm_rect *dst,
> > -				       unsigned int rate,
> > -				       unsigned int ppc)
> > -{
> > -	unsigned int hscale = hscale_cdclk(src, dst, ppc);
> > -	unsigned int vscale = vscale_cdclk(src, dst);
> > -
> > -	return DIV64_U64_ROUND_UP((u64)rate * hscale * vscale, 1ull << 32);
> > -}
> > -
> >  unsigned int intel_plane_pixel_rate(const struct intel_crtc_state *crtc_state,
> >  				    const struct intel_plane_state *plane_state)  {
> @@ -329,17
> > +285,6 @@ unsigned int intel_plane_pixel_rate(const struct intel_crtc_state
> *crtc_state,
> >  				   crtc_state->pixel_rate);
> >  }
> >
> > -unsigned int intel_plane_pixel_rate_cdclk(const struct intel_crtc_state
> *crtc_state,
> > -					  const struct intel_plane_state
> *plane_state)
> > -{
> > -	struct intel_display *display = to_intel_display(crtc_state);
> > -	unsigned int ppc = HAS_2PPC(display) ? 2 : 1;
> > -
> > -	return intel_adjusted_rate_cdclk(&plane_state->uapi.src,
> > -					 &plane_state->uapi.dst,
> > -					 crtc_state->pixel_rate_cdclk, ppc);
> > -}
> > -
> >  unsigned int intel_plane_data_rate(const struct intel_crtc_state *crtc_state,
> >  				   const struct intel_plane_state *plane_state,
> >  				   int color_plane)
> > diff --git a/drivers/gpu/drm/i915/display/intel_plane.h
> > b/drivers/gpu/drm/i915/display/intel_plane.h
> > index dba2be24aae2..31a6229aea73 100644
> > --- a/drivers/gpu/drm/i915/display/intel_plane.h
> > +++ b/drivers/gpu/drm/i915/display/intel_plane.h
> > @@ -29,13 +29,8 @@ bool intel_plane_can_async_flip(struct intel_plane
> > *plane,  unsigned int intel_adjusted_rate(const struct drm_rect *src,
> >  				 const struct drm_rect *dst,
> >  				 unsigned int rate);
> > -unsigned int intel_adjusted_rate_cdclk(const struct drm_rect *src,
> > -				       const struct drm_rect *dst,
> > -				       unsigned int rate, unsigned int ppc);
> >  unsigned int intel_plane_pixel_rate(const struct intel_crtc_state *crtc_state,
> >  				    const struct intel_plane_state *plane_state); -
> unsigned int
> > intel_plane_pixel_rate_cdclk(const struct intel_crtc_state *crtc_state,
> > -					  const struct intel_plane_state
> *plane_state);
> >
> >  unsigned int intel_plane_data_rate(const struct intel_crtc_state *crtc_state,
> >  				   const struct intel_plane_state *plane_state, diff -
> -git
> > a/drivers/gpu/drm/i915/display/skl_universal_plane.c
> > b/drivers/gpu/drm/i915/display/skl_universal_plane.c
> > index def4798f8502..4cd868d11ad6 100644
> > --- a/drivers/gpu/drm/i915/display/skl_universal_plane.c
> > +++ b/drivers/gpu/drm/i915/display/skl_universal_plane.c
> > @@ -267,7 +267,7 @@ bool icl_is_hdr_plane(struct intel_display
> > *display, enum plane_id plane_id)  static int icl_plane_min_cdclk(const struct
> intel_crtc_state *crtc_state,
> >  			       const struct intel_plane_state *plane_state)  {
> > -	unsigned int pixel_rate = intel_plane_pixel_rate_cdclk(crtc_state,
> plane_state);
> > +	unsigned int pixel_rate = intel_plane_pixel_rate(crtc_state,
> > +plane_state);
> >
> >  	/* two pixels per clock */
> >  	return DIV_ROUND_UP(pixel_rate, 2);
> > @@ -291,7 +291,7 @@ glk_plane_ratio(const struct intel_plane_state
> > *plane_state,  static int glk_plane_min_cdclk(const struct intel_crtc_state
> *crtc_state,
> >  			       const struct intel_plane_state *plane_state)  {
> > -	unsigned int pixel_rate = intel_plane_pixel_rate_cdclk(crtc_state,
> plane_state);
> > +	unsigned int pixel_rate = intel_plane_pixel_rate(crtc_state,
> > +plane_state);
> >  	unsigned int num, den;
> >
> >  	glk_plane_ratio(plane_state, &num, &den); @@ -318,7 +318,7 @@
> > skl_plane_ratio(const struct intel_plane_state *plane_state,  static
> > int skl_plane_min_cdclk(const struct intel_crtc_state *crtc_state,
> >  			       const struct intel_plane_state *plane_state)  {
> > -	unsigned int pixel_rate = intel_plane_pixel_rate_cdclk(crtc_state,
> plane_state);
> > +	unsigned int pixel_rate = intel_plane_pixel_rate(crtc_state,
> > +plane_state);
> >  	unsigned int num, den;
> >
> >  	skl_plane_ratio(plane_state, &num, &den);
> > --
> > 2.50.1
> 
> --
> Ville Syrjälä
> Intel

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

end of thread, other threads:[~2026-11-26 15:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26 12:18 [PATCH 0/2] Account for 2 PPC horizontal downscale inefficiency in min CDCLK Uma Shankar
2026-11-26 12:18 ` [PATCH 1/2] Revert "drm/i915/cdclk: Deal with 2 PPC hscale issues when calculating min CDCLK" Uma Shankar
2026-11-26 12:12   ` Ville Syrjälä
2026-11-26 15:32     ` Shankar, Uma
2026-11-26 12:18 ` [PATCH 2/2] drm/i915/cdclk: Account for 2 PPC horizontal downscale inefficiency in min CDCLK Uma Shankar
2026-11-26 14:46 ` ✓ i915.CI.BAT: success for " Patchwork

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