All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Nicolas Frattaroli" <nicolas.frattaroli@collabora.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 09/27] drm: Add VRR target frame rate properties
Date: Thu, 05 Nov 2026 17:07:17 +0000	[thread overview]
Message-ID: <sashiko-outbox-199576@kernel.org> (raw)
In-Reply-To: <20261105-vrr-limiter-uapi-v2-9-55f4215be2c2@collabora.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] drm: missing DRM_MODE_PROP_ATOMIC flag on VRR limiter CRTC properties
- [Medium] drm: missing min <= max VRR rate check in drm_atomic_crtc_check()
--

commit 221e142e46603679a11c0d1b71599449f1d7a39c
Author: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>

drm: Add VRR target frame rate properties

This commit introduces four CRTC properties (VRR_MIN_NUMERATOR,
VRR_MIN_DENOMINATOR, VRR_MAX_NUMERATOR, and VRR_MAX_DENOMINATOR) to allow
userspace to configure a target frame rate range for Variable Refresh Rate
as numerator/denominator fractions.

> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index 9bb761eda59f4..da5c6925c349f 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -489,6 +489,7 @@ EXPORT_SYMBOL(drm_atomic_get_crtc_state);
>  static int drm_atomic_crtc_check(const struct drm_crtc_state *old_crtc_state,
>  				 const struct drm_crtc_state *new_crtc_state)
>  {
> +	const struct drm_crtc_vrr_state *vrr = &new_crtc_state->vrr_state;
>  	struct drm_crtc *crtc = new_crtc_state->crtc;
>  
>  	/* NOTE: we explicitly don't enforce constraints such as primary
> @@ -544,6 +545,19 @@ static int drm_atomic_crtc_check(const struct drm_crtc_state *old_crtc_state,
>  		return -EINVAL;
>  	}
>  
> +	/*
> +	 * Reject VRR limiter ranges that only specify one end of the limit, or
> +	 * specify a numerator > 0 with a denominator that is 0.
> +	 */
> +	if ((!vrr->vrr_min_n || !vrr->vrr_min_d ||
> +	     !vrr->vrr_max_n || !vrr->vrr_max_d) &&
> +	    (vrr->vrr_min_n > 0 || vrr->vrr_max_n > 0)) {
> +		drm_dbg_atomic(crtc->dev,
> +			       "[CRTC:%d:%s] incomplete VRR limiter range\n",
> +			       crtc->base.id, crtc->name);
> +		return -EINVAL;
> +	}

[Severity: Medium]
As reported by Sashiko on RFC [1], should drm_atomic_crtc_check() also reject
inverted VRR target frame rate ranges where the minimum rate fraction exceeds
the maximum rate fraction?

In include/drm/drm_mode_config.h, the kerneldoc for struct drm_mode_config
documents that prop_vrr_max_numerator divided by prop_vrr_max_denominator must
result in a frame rate equal to or above prop_vrr_min_numerator divided by
prop_vrr_min_denominator.

However, drm_atomic_crtc_check() only checks that all four values are non-zero
when either numerator is positive. If userspace submits an atomic commit via
DRM_IOCTL_MODE_ATOMIC with non-zero limiter values where vrr_min_n / vrr_min_d
is greater than vrr_max_n / vrr_max_d (for example while vrr_enabled is false,
or on a non-HDMI connector), the check succeeds and commits the inverted range
into drm_crtc_state.

Would it make sense to check:

    mul_u32_u32(vrr->vrr_min_n, vrr->vrr_max_d) >
    mul_u32_u32(vrr->vrr_max_n, vrr->vrr_min_d)

when the limiter range is non-zero in drm_atomic_crtc_check()?

[ ... ]

> diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> index 48a56f23dadbb..da967d60f832a 100644
> --- a/drivers/gpu/drm/drm_mode_config.c
> +++ b/drivers/gpu/drm/drm_mode_config.c
> @@ -535,6 +535,26 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
>  		return -ENOMEM;
>  	dev->mode_config.prop_vrr_enabled = prop;
>  
> +	prop = drm_property_create_range(dev, 0, "VRR_MIN_NUMERATOR", 0, U32_MAX);
> +	if (!prop)
> +		return -ENOMEM;
> +	dev->mode_config.prop_vrr_min_numerator = prop;
> +
> +	prop = drm_property_create_range(dev, 0, "VRR_MIN_DENOMINATOR", 0, U32_MAX);
> +	if (!prop)
> +		return -ENOMEM;
> +	dev->mode_config.prop_vrr_min_denominator = prop;
> +
> +	prop = drm_property_create_range(dev, 0, "VRR_MAX_NUMERATOR", 0, U32_MAX);
> +	if (!prop)
> +		return -ENOMEM;
> +	dev->mode_config.prop_vrr_max_numerator = prop;
> +
> +	prop = drm_property_create_range(dev, 0, "VRR_MAX_DENOMINATOR", 0, U32_MAX);
> +	if (!prop)
> +		return -ENOMEM;
> +	dev->mode_config.prop_vrr_max_denominator = prop;

[Severity: Medium]
As reported by Sashiko on RFC [2], should these four properties be created
with the DRM_MODE_PROP_ATOMIC flag in drm_mode_create_standard_properties()?

Because flags is passed as 0 to drm_property_create_range(),
drm_mode_object_get_properties() exposes these properties to legacy non-atomic
userspace clients. Non-atomic clients update properties one at a time via
DRM_IOCTL_MODE_OBJ_SETPROPERTY:

    drm_mode_obj_set_property_ioctl()
      -> set_property_atomic()
        -> drm_atomic_commit()
          -> drm_atomic_check_only()
            -> drm_atomic_crtc_check()

Since drm_atomic_crtc_check() rejects any state where only part of the
limiter range is non-zero with -EINVAL, a legacy client cannot transition
from (0, 0, 0, 0) to an active range or clear an active range back to
(0, 0, 0, 0) one property at a time without failing on the intermediate
commits.

[1] https://lore.kernel.org/r/20260921-vrr-limiter-uapi-v1-13-2fcd7d011646@collabora.com
[2] https://lore.kernel.org/r/20260921-vrr-limiter-uapi-v1-13-2fcd7d011646@collabora.com

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261105-vrr-limiter-uapi-v2-0-55f4215be2c2@collabora.com?part=9

  reply	other threads:[~2026-11-05 17:07 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-05 15:51 [PATCH v2 00/27] VRR Target Rate Limiter KMS uAPI and Implementation Nicolas Frattaroli
2026-11-05 15:51 ` Nicolas Frattaroli
2026-11-05 15:51 ` [PATCH v2 01/27] drm: Add VRR state Nicolas Frattaroli
2026-11-05 15:51   ` Nicolas Frattaroli
2026-11-05 16:44   ` sashiko-bot
2026-11-05 15:51 ` [PATCH v2 02/27] drm/connector: add vrr_display_mode connector property Nicolas Frattaroli
2026-11-05 15:51   ` Nicolas Frattaroli
2026-11-05 16:27   ` sashiko-bot
2026-11-05 15:51 ` [PATCH v2 03/27] video/hdmi: Add VTEM EMP packing Nicolas Frattaroli
2026-11-05 15:51   ` Nicolas Frattaroli
2026-11-05 16:29   ` sashiko-bot
2026-11-05 15:51 ` [PATCH v2 04/27] drm/bridge: Add VTEM EMP support Nicolas Frattaroli
2026-11-05 15:51   ` Nicolas Frattaroli
2026-11-05 16:33   ` sashiko-bot
2026-11-05 15:51 ` [PATCH v2 05/27] drm/connector: hdmi: Add VTEM EMP generation Nicolas Frattaroli
2026-11-05 15:51   ` Nicolas Frattaroli
2026-11-05 16:53   ` sashiko-bot
2026-11-05 15:51 ` [PATCH v2 06/27] drm/crtc-helper: Add VRR helper functions Nicolas Frattaroli
2026-11-05 15:51   ` Nicolas Frattaroli
2026-11-05 16:49   ` sashiko-bot
2026-11-05 15:51 ` [PATCH v2 07/27] drm/bridge: synopsys: Add VTEM EMP support Nicolas Frattaroli
2026-11-05 15:51   ` Nicolas Frattaroli
2026-11-05 15:51 ` [PATCH v2 08/27] drm/connector: Add drm_display_info_is_vrr_capable Nicolas Frattaroli
2026-11-05 15:51   ` Nicolas Frattaroli
2026-11-05 16:58   ` sashiko-bot
2026-11-05 15:52 ` [PATCH v2 09/27] drm: Add VRR target frame rate properties Nicolas Frattaroli
2026-11-05 15:52   ` Nicolas Frattaroli
2026-11-05 17:07   ` sashiko-bot [this message]
2026-11-05 15:52 ` [PATCH v2 10/27] drm/connector: Add vrr_display_{min,max} connector properties Nicolas Frattaroli
2026-11-05 15:52   ` Nicolas Frattaroli
2026-11-05 17:08   ` sashiko-bot
2026-11-05 15:52 ` [PATCH v2 11/27] drm: Implement VRR rate limiting Nicolas Frattaroli
2026-11-05 15:52   ` Nicolas Frattaroli
2026-11-05 17:17   ` sashiko-bot
2026-11-05 15:52 ` [PATCH v2 12/27] drm/rockchip: dw_hdmi_qp: Add VRR support Nicolas Frattaroli
2026-11-05 15:52   ` Nicolas Frattaroli
2026-11-05 17:30   ` sashiko-bot
2026-11-05 15:52 ` [PATCH v2 13/27] drm/rockchip: Set mode_changed on vrr_enabled change Nicolas Frattaroli
2026-11-05 15:52   ` Nicolas Frattaroli
2026-11-05 15:52 ` [PATCH v2 14/27] drm/rockchip: vop2: Enable VRR Nicolas Frattaroli
2026-11-05 15:52   ` Nicolas Frattaroli
2026-11-05 17:40   ` sashiko-bot
2026-11-05 15:52 ` [PATCH v2 15/27] drm/edid: Parse QMS flag from HDMI SCDS Nicolas Frattaroli
2026-11-05 15:52   ` Nicolas Frattaroli
2026-11-05 15:52 ` [PATCH v2 16/27] drm/edid: Parse QMS TFR min/max flags " Nicolas Frattaroli
2026-11-05 15:52   ` Nicolas Frattaroli
2026-11-05 15:52 ` [PATCH v2 17/27] drm/connector: Add "Media" VRR display mode for QMS Nicolas Frattaroli
2026-11-05 15:52   ` Nicolas Frattaroli
2026-11-05 15:52 ` [PATCH v2 18/27] video/hdmi: Add support for QMS in VTEM EMP packing Nicolas Frattaroli
2026-11-05 15:52   ` Nicolas Frattaroli
2026-11-05 15:52 ` [PATCH v2 19/27] drm/connector: hdmi: Add QMS to VTEM EMP generation Nicolas Frattaroli
2026-11-05 15:52   ` Nicolas Frattaroli
2026-11-05 17:45   ` sashiko-bot
2026-11-05 15:52 ` [PATCH v2 20/27] drm/connector: hdmi: Add QMS state validation and computation Nicolas Frattaroli
2026-11-05 15:52   ` Nicolas Frattaroli
2026-11-05 17:53   ` sashiko-bot
2026-11-05 15:52 ` [PATCH v2 21/27] drm/rockchip: dw_hdmi_qp: Add QMS support Nicolas Frattaroli
2026-11-05 15:52   ` Nicolas Frattaroli
2026-11-05 18:01   ` sashiko-bot
2026-11-05 15:52 ` [PATCH v2 22/27] drm/tests: hdmi: Add "Game Mode" VRR tests Nicolas Frattaroli
2026-11-05 15:52   ` Nicolas Frattaroli
2026-11-05 15:52 ` [PATCH v2 23/27] drm/tests: hdmi: Add Fixed/Constrained rate " Nicolas Frattaroli
2026-11-05 15:52   ` Nicolas Frattaroli
2026-11-05 17:57   ` sashiko-bot
2026-11-05 15:52 ` [PATCH v2 24/27] drm/tests: hdmi: Add Quick Media Switching tests Nicolas Frattaroli
2026-11-05 15:52   ` Nicolas Frattaroli
2026-11-05 15:52 ` [PATCH v2 25/27] drm/connector: Fix docs for cnmvrr and cinemavrr members Nicolas Frattaroli
2026-11-05 15:52   ` Nicolas Frattaroli
2026-11-05 15:52 ` [PATCH v2 26/27] drm/debugfs: Expose HDMI VRR in vrr_range debugfs Nicolas Frattaroli
2026-11-05 15:52   ` Nicolas Frattaroli
2026-11-05 18:05   ` sashiko-bot
2026-11-05 15:52 ` [PATCH v2 27/27] drm/tests: hdmi: Add tests for vrr_display_{min,max} properties Nicolas Frattaroli
2026-11-05 15:52   ` Nicolas Frattaroli
2026-11-05 18:03   ` sashiko-bot

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-199576@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=nicolas.frattaroli@collabora.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.