Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ville Syrjala" <ville.syrjala@linux.intel.com>,
	intel-gfx@lists.freedesktop.org
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [PATCH 15/15] drm/i915/pfit: Allow downscaling on i966+
Date: Mon, 19 Oct 2026 14:47:56 +0000	[thread overview]
Message-ID: <sashiko-outbox-177503@kernel.org> (raw)
In-Reply-To: <20261019135309.23578-16-ville.syrjala@linux.intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] drm/i915/pfit: off-by-one max_scale in i9xx_pfit_check_scaling()
--

commit c5496f644982a254aa09057b7c02f1bea3cb5b18
Author: Ville Syrjälä <ville.syrjala@linux.intel.com>

drm/i915/pfit: Allow downscaling on i966+

This commit updates i9xx_pfit_check_scaling() to raise max_scale to 0x20000 on
DISPLAY_VER(display) >= 4 platforms to permit panel fitter downscaling.

> diff --git a/drivers/gpu/drm/i915/display/intel_pfit.c b/drivers/gpu/drm/i915/display/intel_pfit.c
> index 6eb457047bf4c..2b6706c7af534 100644
> --- a/drivers/gpu/drm/i915/display/intel_pfit.c
> +++ b/drivers/gpu/drm/i915/display/intel_pfit.c
> @@ -563,7 +563,10 @@ static int i9xx_pfit_check_scaling(const struct intel_crtc_state *crtc_state)
>  	int hscale, vscale, max_scale;
>  	struct drm_rect src;
>  
> -	max_scale = 0x10000;
> +	if (DISPLAY_VER(display) >= 4)
> +		max_scale = 0x20000;
> +	else
> +		max_scale = 0x10000;
>  
>  	drm_rect_init(&src, 0, 0, pipe_src_w << 16, pipe_src_h << 16);
>  

[Severity: Medium]
Should max_scale be 0x20000 - 1 (or 0x1fff0) rather than 0x20000 here?

In i9xx_pfit_check_scaling(), max_scale is passed to drm_rect_calc_hscale()
and drm_rect_calc_vscale(), which treat max_hscale and max_vscale as inclusive
upper bounds and only reject with -ERANGE when scale > max_scale. Setting
max_scale = 0x20000 allows an exact 2.0x downscale factor (for example, when
scaling a 1600x1200 pipe_src to an 800x600 dst).

However, in drivers/gpu/drm/i915/display/intel_pfit_regs.h, the i965+ scaling
ratio fields in PFIT_PGM_RATIOS are 13-bit 1.12 fixed-point values:

#define   PFIT_VERT_SCALE_MASK_965	REG_GENMASK(28, 16) /* 965+ */
#define   PFIT_VERT_SCALE_965(x)	REG_FIELD_PREP(PFIT_VERT_SCALE_MASK_965, (x))
#define   PFIT_HORIZ_SCALE_MASK_965	REG_GENMASK(12, 0) /* 965+ */
#define   PFIT_HORIZ_SCALE_965(x)	REG_FIELD_PREP(PFIT_HORIZ_SCALE_MASK_965, (x))

These 13-bit fields have a maximum representable value of 0x1fff (< 2.0). For
an exact 2.0x downscale, panel_fitter_scaling() computes 0x2000 (BIT(13)),
which overflows the 13-bit register field and causes a hardware state readout
mismatch in i965_pfit_get_config() -> i9xx_compute_pfit_dst() on
crtc_state->pfit.dst and pixel_rate:

drivers/gpu/drm/i915/display/intel_pfit.c:i965_pfit_get_config() {
	...
	case PFIT_SCALING_AUTO:
	case PFIT_SCALING_PROGRAMMED:
		hscale = REG_FIELD_GET(PFIT_HORIZ_SCALE_MASK_965, ratios);
		vscale = REG_FIELD_GET(PFIT_VERT_SCALE_MASK_965, ratios);
		break;
	}

	i9xx_compute_pfit_dst(crtc_state, hscale, vscale);
	...
}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261019135309.23578-1-ville.syrjala@linux.intel.com?part=15

  reply	other threads:[~2026-10-19 14:48 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-19 13:52 [PATCH 00/15] drm/i915/pfit: Make GMCH panel fitter nicer Ville Syrjala
2026-10-19 13:52 ` [PATCH 01/15] drm/i915/pfit: s/pch_pfit/pfit/ Ville Syrjala
2026-10-19 15:48   ` Jani Nikula
2026-10-19 13:52 ` [PATCH 02/15] drm/i915/pfit: s/intel_pch_pfit/ilk_pfit/ Ville Syrjala
2026-10-19 15:49   ` Jani Nikula
2026-10-19 13:52 ` [PATCH 03/15] drm/i915/pfit: Stop using HAS_PCH_SPLIT() in confusing places Ville Syrjala
2026-10-19 15:49   ` Jani Nikula
2026-10-19 13:52 ` [PATCH 04/15] drm/i915/pfit: Introduce intel_pfit_get_config() Ville Syrjala
2026-10-19 15:53   ` Jani Nikula
2026-10-19 13:52 ` [PATCH 05/15] drm/i915/pfit: Rename some pfit functions Ville Syrjala
2026-10-19 15:54   ` Jani Nikula
2026-10-19 13:53 ` [PATCH 06/15] drm/i915/pfit: Extract i965_pfit_get_config() Ville Syrjala
2026-10-19 16:02   ` Jani Nikula
2026-10-19 16:05     ` Jani Nikula
2026-10-19 17:04       ` Ville Syrjälä
2026-10-20 18:38   ` [PATCH v2 " Ville Syrjala
2026-10-19 13:53 ` [PATCH 07/15] drm/i915/pfit: Drop platform check for gmch_pfit.pgm_ratios Ville Syrjala
2026-10-19 16:05   ` Jani Nikula
2026-10-19 13:53 ` [PATCH 08/15] drm/i915/pfit: Unconfuse panel_fitter_scaling() Ville Syrjala
2026-10-19 16:15   ` Jani Nikula
2026-10-19 13:53 ` [PATCH 09/15] drm/i915/pfit: Populate crtc_state->pfit.dst on GMCH platforms Ville Syrjala
2026-10-19 14:23   ` sashiko-bot
2026-10-20 18:40   ` [PATCH v2 " Ville Syrjala
2026-10-19 13:53 ` [PATCH 10/15] drm/i915/pfit: Check scaling factor on GMCH Ville Syrjala
2026-10-19 13:53 ` [PATCH 11/15] drm/i915/pfit: Check panel fitter source size " Ville Syrjala
2026-10-19 13:53 ` [PATCH 12/15] drm/i915/pfit: Extract i9xx_pfit_vscale_ratio() and i9xx_pfit_is_one_line_mode() Ville Syrjala
2026-10-19 13:53 ` [PATCH 13/15] drm/i915/pfit: No pfit one line mode on i965+ Ville Syrjala
2026-10-19 13:53 ` [PATCH 14/15] drm/i915/pfit: Account for pfit downscaling in pixel rate on GMCH platforms Ville Syrjala
2026-10-19 13:53 ` [PATCH 15/15] drm/i915/pfit: Allow downscaling on i966+ Ville Syrjala
2026-10-19 14:47   ` sashiko-bot [this message]
2026-10-20 18:31     ` Ville Syrjälä
2026-10-20 18:41   ` [PATCH v2 " Ville Syrjala
2026-10-19 17:23 ` ✓ i915.CI.BAT: success for drm/i915/pfit: Make GMCH panel fitter nicer Patchwork
2026-10-19 22:45 ` ✓ i915.CI.Full: " Patchwork
2026-10-20 19:43 ` ✓ i915.CI.BAT: success for drm/i915/pfit: Make GMCH panel fitter nicer (rev4) 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=sashiko-outbox-177503@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --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