From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Uma Shankar <uma.shankar@intel.com>
Cc: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org,
Vidya Srinivas <vidya.srinivas@intel.com>
Subject: Re: [PATCH] drm/i915/cdclk: Fix 2 PPC hscale adjustment for min CDCLK
Date: Thu, 26 Nov 2026 21:41:49 +0200 [thread overview]
Message-ID: <awiLffAoM4GsVxUw@intel.com> (raw)
In-Reply-To: <20261126191032.1961148-1-uma.shankar@intel.com>
On Fri, Nov 27, 2026 at 12:40:32AM +0530, Uma Shankar wrote:
> 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.
>
> Bspec now documents the downscale amount used for the min CDCLK
> calculation as:
>
> hscale_ppc = int(hscale) + min(1, ppc * frac(hscale))
> downscale = max(hscale_ppc, hscale * vscale)
>
> Compared to the empirical formula we have now, the fractional penalty
> is capped at one extra clock, and since the scaler filters vertically
> first the penalty does not multiply with the vertical downscale factor.
> Update the code to match.
>
> Platforms without 2 PPC (ppc == 1) are unaffected as the formula then
> reduces to hscale * vscale.
>
> Bspec: 68858
> Fixes: f69946f6d891 ("drm/i915/cdclk: Deal with 2 PPC hscale issues when calculating min CDCLK")
> Tested-by: Vidya Srinivas <vidya.srinivas@intel.com>
> Signed-off-by: Uma Shankar <uma.shankar@intel.com>
Looks good.
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
> drivers/gpu/drm/i915/display/intel_plane.c | 42 ++++++++++++++--------
> 1 file changed, 27 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_plane.c b/drivers/gpu/drm/i915/display/intel_plane.c
> index d23de0f34e4b..4a430d6a0ba9 100644
> --- a/drivers/gpu/drm/i915/display/intel_plane.c
> +++ b/drivers/gpu/drm/i915/display/intel_plane.c
> @@ -266,25 +266,28 @@ unsigned int intel_adjusted_rate(const struct drm_rect *src,
> }
>
> static unsigned int hscale_cdclk(const struct drm_rect *src,
> - const struct drm_rect *dst,
> - unsigned int ppc)
> + const struct drm_rect *dst)
> {
> 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);
> + return hscale;
> +}
> +
> +/*
> + * 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.
> + */
> +static unsigned int hscale_ppc_cdclk(unsigned int hscale,
> + unsigned int ppc)
> +{
> + return (hscale & ~0xffff) + min(ppc * (hscale & 0xffff), 0x10000);
> }
>
> static unsigned int vscale_cdclk(const struct drm_rect *src,
> @@ -303,10 +306,19 @@ unsigned int intel_adjusted_rate_cdclk(const struct drm_rect *src,
> unsigned int rate,
> unsigned int ppc)
> {
> - unsigned int hscale = hscale_cdclk(src, dst, ppc);
> + unsigned int hscale = hscale_cdclk(src, dst);
> unsigned int vscale = vscale_cdclk(src, dst);
> + u64 scale;
> +
> + /*
> + * The scaler filters vertically first, so the horizontal
> + * PPC inefficiency doesn't multiply with the vertical
> + * downscale factor. .32 fixed point.
> + */
> + scale = max((u64)hscale_ppc_cdclk(hscale, ppc) << 16,
> + mul_u32_u32(hscale, vscale));
>
> - return DIV64_U64_ROUND_UP((u64)rate * hscale * vscale, 1ull << 32);
> + return DIV64_U64_ROUND_UP(rate * scale, 1ull << 32);
> }
>
> unsigned int intel_plane_pixel_rate(const struct intel_crtc_state *crtc_state,
> --
> 2.50.1
--
Ville Syrjälä
Intel
prev parent reply other threads:[~2026-11-26 19:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 19:10 [PATCH] drm/i915/cdclk: Fix 2 PPC hscale adjustment for min CDCLK Uma Shankar
2026-11-26 19:41 ` Ville Syrjälä [this message]
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=awiLffAoM4GsVxUw@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=uma.shankar@intel.com \
--cc=vidya.srinivas@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