Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Borah, Chaitanya Kumar" <chaitanya.kumar.borah@intel.com>
To: Mitul Golani <mitulkumar.ajitkumar.golani@intel.com>,
	<intel-gfx@lists.freedesktop.org>
Cc: <intel-xe@lists.freedesktop.org>, <uma.shankar@intel.com>,
	<ankit.k.nautiyal@intel.com>
Subject: Re: [PATCH v8 07/10] drm/i915/vrr: Latch CMRR ratio via atomic commit on debugfs write
Date: Fri, 31 Jul 2026 15:13:35 +0530	[thread overview]
Message-ID: <5837b7e2-ff91-44e2-b232-032df8ae1f39@intel.com> (raw)
In-Reply-To: <20260730105919.3913412-8-mitulkumar.ajitkumar.golani@intel.com>



On 7/30/2026 4:29 PM, Mitul Golani wrote:
> Writing the per-CRTC "intel_vrr_target_refresh_rate" debugfs file only
> updates crtc->force_cmrr, a side channel that is not tracked by the
> atomic state. The requested ratio therefore does not reach the hardware
> until some unrelated commit recomputes the pipe config.
> 
> Kick an internal atomic commit for the CRTC from the debugfs write and
> mark the CRTC mode as changed so the pipe config is recomputed.
> 
> Note that this commit may or may not be downgraded to a fastset,
> depending on whether the computed vblank value (with LRR disabled)
> changes, so it is not characterised as a fastset.
> 
> If the commit fails, restore the previous numerator/denominator so that
> force_cmrr does not hold on to bad values, which would otherwise make
> all subsequent commits fail.
> 
> --v2:
> - Commit message and code comment update (Chaitanya)
> - Commit header update
> - Restore to old known debugfs values when commit fails
> (Chaitanya)
> 

LGTM,

Reviewed-by: Chaitanya Kumar Borah <chaitanya.kumar.borah@intel.com>

> Signed-off-by: Mitul Golani <mitulkumar.ajitkumar.golani@intel.com>
> ---
>   drivers/gpu/drm/i915/display/intel_vrr.c | 77 ++++++++++++++++++++++++
>   1 file changed, 77 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_vrr.c b/drivers/gpu/drm/i915/display/intel_vrr.c
> index f406f34b816e..3463533b1ea1 100644
> --- a/drivers/gpu/drm/i915/display/intel_vrr.c
> +++ b/drivers/gpu/drm/i915/display/intel_vrr.c
> @@ -8,10 +8,12 @@
>   #include <linux/seq_file.h>
>   #include <linux/string.h>
>   
> +#include <drm/drm_atomic.h>
>   #include <drm/drm_print.h>
>   #include <drm/intel/step.h>
>   
>   #include "intel_alpm.h"
> +#include "intel_atomic.h"
>   #include "intel_cmtg.h"
>   #include "intel_crtc.h"
>   #include "intel_de.h"
> @@ -1304,12 +1306,67 @@ static int intel_vrr_debugfs_target_rr_open(struct inode *inode, struct file *fi
>   	return single_open(file, intel_vrr_debugfs_target_rr_show, inode->i_private);
>   }
>   
> +/*
> + * Force an internal commit on @crtc so that a CMRR ratio programmed
> + * via debugfs gets recomputed and latched into hardware.
> + *
> + * CMRR only alters the (average) vtotal. Depending on whether the
> + * computed vblank value (with LRR disabled) changes, this commit may or
> + * may not be downgraded to a fastset.
> + */
> +static int intel_vrr_cmrr_commit_force(struct intel_crtc *crtc)
> +{
> +	struct intel_display *display = to_intel_display(crtc);
> +	struct drm_modeset_acquire_ctx ctx;
> +	struct drm_atomic_commit *state;
> +	struct intel_crtc_state *crtc_state;
> +	int ret = 0;
> +
> +	state = drm_atomic_commit_alloc(display->drm);
> +	if (!state)
> +		return -ENOMEM;
> +
> +	drm_modeset_acquire_init(&ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE);
> +
> +	state->acquire_ctx = &ctx;
> +	to_intel_atomic_state(state)->internal = true;
> +
> +retry:
> +	crtc_state = intel_atomic_get_crtc_state(state, crtc);
> +	if (IS_ERR(crtc_state)) {
> +		ret = PTR_ERR(crtc_state);
> +		goto out;
> +	}
> +
> +	if (!crtc_state->hw.active)
> +		goto out;
> +
> +	/* Mark mode as changed to trigger a pipe recompute + update() */
> +	crtc_state->uapi.mode_changed = true;
> +
> +	ret = drm_atomic_commit(state);
> +out:
> +	if (ret == -EDEADLK) {
> +		drm_atomic_commit_clear(state);
> +		ret = drm_modeset_backoff(&ctx);
> +		if (!ret)
> +			goto retry;
> +	}
> +
> +	drm_modeset_drop_locks(&ctx);
> +	drm_modeset_acquire_fini(&ctx);
> +	drm_atomic_commit_put(state);
> +
> +	return ret;
> +}
> +
>   static ssize_t intel_vrr_debugfs_target_rr_write(struct file *file, const char __user *ubuf,
>   						 size_t len, loff_t *offp)
>   {
>   	struct seq_file *m = file->private_data;
>   	struct intel_crtc *crtc = m->private;
>   	u32 numerator, denominator;
> +	u32 old_numerator, old_denominator;
>   	char kbuf[32];
>   	int ret;
>   
> @@ -1329,9 +1386,29 @@ static ssize_t intel_vrr_debugfs_target_rr_write(struct file *file, const char _
>   	    crtc->force_cmrr.denominator == denominator)
>   		return len;
>   
> +	old_numerator = crtc->force_cmrr.numerator;
> +	old_denominator = crtc->force_cmrr.denominator;
> +
>   	crtc->force_cmrr.numerator = numerator;
>   	crtc->force_cmrr.denominator = denominator;
>   
> +	/*
> +	 * The debugfs value is a side channel that is not tracked by the atomic
> +	 * state, so kick an internal commit to recompute and latch the
> +	 * new CMRR parameters.
> +	 */
> +	ret = intel_vrr_cmrr_commit_force(crtc);
> +	if (ret) {
> +		/*
> +		 * Restore the last known good ratio so that force_cmrr does not
> +		 * hold on to bad values, which would make all subsequent commits
> +		 * fail.
> +		 */
> +		crtc->force_cmrr.numerator = old_numerator;
> +		crtc->force_cmrr.denominator = old_denominator;
> +		return ret;
> +	}
> +
>   	return len;
>   }
>   


  reply	other threads:[~2026-07-31  9:43 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-30 10:59 [PATCH v8 00/10] Enable CMRR in fixed-RR VRR path Mitul Golani
2026-07-30 10:59 ` [PATCH v8 01/10] drm/i915/psr: Do not enable PSR2 when CMRR is enabled Mitul Golani
2026-07-30 10:59 ` [PATCH v8 02/10] drm/i915/vrr: Restrict CMRR enable condition to VRR-TG-default platforms Mitul Golani
2026-07-30 10:59 ` [PATCH v8 03/10] drm/i915/vrr: Add per-CRTC vrr/cmrr debugfs control Mitul Golani
2026-07-30 10:59 ` [PATCH v8 04/10] drm/i915/vrr: Update AS_SDP target_rr_divider based on CMRR config request Mitul Golani
2026-07-30 10:59 ` [PATCH v8 05/10] drm/i915/display: Move CMRR crtc_state members under VRR Mitul Golani
2026-07-30 10:59 ` [PATCH v8 06/10] drm/i915/vrr: Compute CMRR fractional timings generically Mitul Golani
2026-07-30 10:59 ` [PATCH v8 07/10] drm/i915/vrr: Latch CMRR ratio via atomic commit on debugfs write Mitul Golani
2026-07-31  9:43   ` Borah, Chaitanya Kumar [this message]
2026-07-30 10:59 ` [PATCH v8 08/10] drm/i915/vrr: Program CMRR enable/disable from transcoder timings Mitul Golani
2026-07-30 10:59 ` [PATCH v8 09/10] drm/i915/vrr: Dump CMRR state in the crtc state dump Mitul Golani
2026-07-30 10:59 ` [PATCH v8 10/10] drm/i915/vrr: Enable cmrr Mitul Golani
2026-07-31  9:45   ` Borah, Chaitanya Kumar
2026-07-30 11:58 ` ✓ CI.KUnit: success for Enable CMRR in fixed-RR VRR path (rev8) Patchwork
2026-07-30 12:45 ` ✓ Xe.CI.BAT: " Patchwork
2026-07-30 15:22 ` ✓ Xe.CI.FULL: " 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=5837b7e2-ff91-44e2-b232-032df8ae1f39@intel.com \
    --to=chaitanya.kumar.borah@intel.com \
    --cc=ankit.k.nautiyal@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=mitulkumar.ajitkumar.golani@intel.com \
    --cc=uma.shankar@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