Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: "Nautiyal, Ankit K" <ankit.k.nautiyal@intel.com>
Cc: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 5/5] drm/i915/panel: Attempt VRR based refresh rate change for !allow_modeset
Date: Tue, 23 Jun 2026 14:48:32 +0300	[thread overview]
Message-ID: <ajpykEXiNCIqDvFC@intel.com> (raw)
In-Reply-To: <32d5c226-7781-4057-b8b3-27e6637411c0@intel.com>

On Tue, Jun 23, 2026 at 09:58:03AM +0530, Nautiyal, Ankit K wrote:
> 
> On 6/23/2026 3:06 AM, Ville Syrjala wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > Adjust the panel fixed mode selection algorithm to only consider
> > fixed modes that are "VRR compatible" with the old fixed mode
> > when userspace doesn't want to allow full modesets. This will
> > allow a VRR based refresh rate changes (ie. just a change in
> > the vblank length) via the fastset path.
> >
> > When full modesets are allowed, we still use the original algorithm
> > as that may pick a fixed mode with a more optimal dotclock, potentially
> > leading to reduced power consumption.
> >
> > This approach works as long as userspace does the initial
> > allow_modeset=true commit using the highest refresh rate it will
> > want to use. Subsequent commits with allow_modeset=false can then
> > switch between lower refresh rates without blinks.
> >
> > One remaining hurdle we may need to solve is the guardband length.
> > Assuming the highest refresh rate vblank is too short for
> > intel_vrr_compute_optimized_guardband() the intitial guardband will
> > match the highest refresh rate vblank. A subsequent switch to a lower
> > refresh rate will then recompute the guardband and select a value
> > that is higher (since the vblank will be longer). The mismatch in
> > guardband lengths will prevent the fastset. We may either have to
> > preserve the original (sub-optimal) guardband, or we'll have to
> > revisit the idea of changing the guardband without a full modeset.
> >
> > Note that I'm not 100% happy with this solution because
> > intel_panel_fixed_mode() is no longer fully idempotent, but I wasn't
> > able to come up with anything truly better either :/ The simple
> > solution would be just to always pick the fixed mode with the highest
> > dotclock, but that could lead to increased power consumption even
> > when high refresh rates are never used.
> >
> > Perhaps the proper solution would be to just deprecate this
> > idea of taking in random modes for internal panels and then
> > cooking up a compatible fixed modes. Life would be easier if
> > userspace was required to provide the desired fixed mode directly.
> > But in order to do that we'd need to introduce new uapi properties
> > to control the pfit aspect of this, and we'd probably need a new
> > client cap to select between the old and new userspace behaviour.
> > Something to consider in the future...
> >
> > v2: Rebase due to earlier changes to VRR fixed mode selection
> >
> > Reviewed-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com> #v1
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >   drivers/gpu/drm/i915/display/intel_panel.c | 42 ++++++++++++++++++++--
> >   1 file changed, 39 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/display/intel_panel.c b/drivers/gpu/drm/i915/display/intel_panel.c
> > index faa24537ef63..81e638d0c7b3 100644
> > --- a/drivers/gpu/drm/i915/display/intel_panel.c
> > +++ b/drivers/gpu/drm/i915/display/intel_panel.c
> > @@ -72,9 +72,20 @@ static bool is_best_fixed_mode(struct intel_connector *connector,
> >   		abs(drm_mode_vrefresh(best_mode) - vrefresh);
> >   }
> >   
> > +static bool is_vrr_compatible(const struct drm_display_mode *mode1,
> > +			      const struct drm_display_mode *mode2)
> > +{
> > +	return drm_mode_match(mode1, mode2,
> > +			      DRM_MODE_MATCH_CLOCK |
> > +			      DRM_MODE_MATCH_TIMINGS_VRR |
> > +			      DRM_MODE_MATCH_FLAGS |
> > +			      DRM_MODE_MATCH_3D_FLAGS);
> > +}
> > +
> >   static const struct drm_display_mode *
> >   intel_panel_fixed_mode_vrr(struct intel_connector *connector,
> > -			   const struct drm_display_mode *mode)
> > +			   const struct drm_display_mode *mode,
> > +			   const struct drm_display_mode *vrr_ref_mode)
> >   {
> >   	const struct drm_display_mode *fixed_mode, *best_mode = NULL;
> >   	int vrefresh = drm_mode_vrefresh(mode);
> > @@ -82,6 +93,10 @@ intel_panel_fixed_mode_vrr(struct intel_connector *connector,
> >   	if (!intel_vrr_is_in_range(connector, vrefresh))
> >   		return NULL;
> >   
> > +	if (vrr_ref_mode &&
> > +	    !intel_vrr_is_in_range(connector, drm_mode_vrefresh(vrr_ref_mode)))
> > +		return NULL;
> > +
> >   	list_for_each_entry(fixed_mode, &connector->panel.fixed_modes, head) {
> >   		int fixed_mode_vrefresh = drm_mode_vrefresh(fixed_mode);
> >   
> > @@ -96,6 +111,10 @@ intel_panel_fixed_mode_vrr(struct intel_connector *connector,
> >   		if (fixed_mode_vrefresh < vrefresh)
> >   			continue;
> >   
> > +		if (vrr_ref_mode &&
> > +		    !is_vrr_compatible(fixed_mode, vrr_ref_mode))
> > +			continue;
> > +
> >   		if (is_best_fixed_mode(connector, vrefresh,
> >   				       fixed_mode_vrefresh, best_mode))
> >   			best_mode = fixed_mode;
> > @@ -224,10 +243,27 @@ static int intel_panel_compute_config_vrr(struct intel_atomic_state *state,
> >   					  struct intel_connector *connector)
> >   {
> >   	struct drm_display_mode *adjusted_mode = &crtc_state->hw.adjusted_mode;
> > -	const struct drm_display_mode *fixed_mode;
> > +	const struct drm_display_mode *fixed_mode = NULL;
> >   	int vrefresh, fixed_mode_vrefresh;
> >   
> 
> Perhaps an early return for if (!vrr_is_capable()) here will avoid two 
> calls for intel_panel_fixed_mode_vrr().

That's essentially the first thing intel_panel_fixed_mode_vrr() will
end up doing. Granted, we do go through a few extra functions calls
to get there, but I expect that to be negligible given we're about
to run through the whole state compute machinery anyway.

There are probably much more fruitful places to optimize if we were
to actually measure the whole thing.

> 
> I leave it to you.
> 
> In any case the patch LGTM.
> 
> Reviewed-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>

Thanks.

> 
> > -	fixed_mode = intel_panel_fixed_mode_vrr(connector, adjusted_mode);
> > +	/*
> > +	 * Attempt a VRR based refresh rate change if possible
> > +	 * when userspace has forbidden a full modeset.
> > +	 */
> > +	if (!state->base.allow_modeset) {
> > +		struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
> > +		const struct intel_crtc_state *old_crtc_state =
> > +			intel_atomic_get_old_crtc_state(state, crtc);
> > +
> > +		if (old_crtc_state->hw.enable &&
> > +		    old_crtc_state->uapi.encoder_mask == crtc_state->uapi.encoder_mask)
> > +			fixed_mode = intel_panel_fixed_mode_vrr(connector, adjusted_mode,
> > +								&old_crtc_state->hw.adjusted_mode);
> > +	}
> > +
> > +	if (!fixed_mode)
> > +		fixed_mode = intel_panel_fixed_mode_vrr(connector, adjusted_mode, NULL);
> > +
> >   	if (!fixed_mode)
> >   		return -EINVAL;
> >   

-- 
Ville Syrjälä
Intel

  reply	other threads:[~2026-06-23 11:48 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-22 21:35 [PATCH v2 0/5] drm/i915: Work harder to enable VRR based refresh rate changes on eDP Ville Syrjala
2026-06-22 21:35 ` [PATCH v2 1/5] drm/i915/panel: Split VRR vs. fixed refresh rate fixed mode selection into separate stages Ville Syrjala
2026-06-23  4:24   ` Nautiyal, Ankit K
2026-06-23 11:40   ` [PATCH v3 " Ville Syrjala
2026-06-22 21:35 ` [PATCH v2 2/5] drm/modes: Add DRM_MODE_MATCH_TIMINGS_VRR Ville Syrjala
2026-06-22 21:36 ` [PATCH v2 3/5] drm/i915: Pass the full atomic state to .compute_config() Ville Syrjala
2026-06-22 21:36 ` [PATCH v2 4/5] drm/i915/panel: Adjust intel_panel_compute_config() calling convention Ville Syrjala
2026-06-23 11:41   ` [PATCH v3 " Ville Syrjala
2026-06-22 21:36 ` [PATCH v2 5/5] drm/i915/panel: Attempt VRR based refresh rate change for !allow_modeset Ville Syrjala
2026-06-23  4:28   ` Nautiyal, Ankit K
2026-06-23 11:48     ` Ville Syrjälä [this message]
2026-06-22 21:42 ` ✗ CI.checkpatch: warning for drm/i915: Work harder to enable VRR based refresh rate changes on eDP (rev2) Patchwork
2026-06-22 21:43 ` ✓ CI.KUnit: success " Patchwork
2026-06-22 22:39 ` ✓ Xe.CI.BAT: " Patchwork
2026-06-23  3:50 ` ✓ Xe.CI.FULL: " Patchwork
2026-06-23 12:41 ` ✗ CI.checkpatch: warning for drm/i915: Work harder to enable VRR based refresh rate changes on eDP (rev4) Patchwork
2026-06-23 12:42 ` ✓ CI.KUnit: success " Patchwork
2026-06-23 13:51 ` ✓ Xe.CI.BAT: " Patchwork
2026-06-23 16:05 ` [PATCH v2 0/5] drm/i915: Work harder to enable VRR based refresh rate changes on eDP Srinivas, Vidya
2026-06-23 17:35 ` ✗ Xe.CI.FULL: failure for drm/i915: Work harder to enable VRR based refresh rate changes on eDP (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=ajpykEXiNCIqDvFC@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=ankit.k.nautiyal@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    /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