Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [Medium] drm/rockchip: dw_hdmi_qp: live VRR property mutation in encoder 
atomic_check()
--

commit cf4752529f9d39b6df9beff8735c1aec029921cc
Author: Nicolas Frattaroli <[email protected]>

drm/rockchip: dw_hdmi_qp: Add VRR support

This commit attaches VRR connector properties on RK3588 in
dw_hdmi_qp_rockchip_bind() and updates vrr_capable and the VRR display limit
properties in dw_hdmi_qp_rockchip_encoder_atomic_check().

> diff --git a/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c 
> b/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c
> index f2a1ea8dfefa5..dcde50bca36bf 100644
> --- a/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c
> +++ b/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c

[ ... ]

> @@ -195,6 +198,7 @@ dw_hdmi_qp_rockchip_encoder_atomic_check(struct 
> drm_encoder *encoder,
>                                        struct drm_crtc_state *crtc_state,
>                                        struct drm_connector_state *conn_state)
>  {
> +     struct drm_connector *connector = conn_state->connector;
>       struct rockchip_crtc_state *s = to_rockchip_crtc_state(crtc_state);
>       struct rockchip_hdmi_qp *hdmi = to_rockchip_hdmi_qp(encoder);
>       union phy_configure_opts phy_cfg = {};
> @@ -205,6 +209,12 @@ dw_hdmi_qp_rockchip_encoder_atomic_check(struct 
> drm_encoder *encoder,
>       if (ingest_fmt < 0)
>               return -EINVAL;
>  
> +     if (connector->vrr_capable_property) {
> +             drm_connector_set_vrr_capable_property(connector,
> +                     
> drm_display_info_is_vrr_capable(&connector->display_info));
> +             drm_connector_hdmi_update_vrr_limits(connector, 
> &crtc_state->mode);
> +     }

[Severity: Medium]
As reported by Sashiko on RFC [1], is it safe to update the live connector
VRR properties inside dw_hdmi_qp_rockchip_encoder_atomic_check()?

Both drm_connector_set_vrr_capable_property() and
drm_connector_hdmi_update_vrr_limits() call drm_object_property_set_value()
on connector->base, which directly mutates connector->base.properties->values[]
because vrr_capable, vrr_display_min, and vrr_display_max are immutable
properties rather than transactional drm_connector_state fields.

When userspace performs a DRM_MODE_ATOMIC_TEST_ONLY commit to probe candidate
modes, or when an atomic check fails later in the pipeline, this path:

  drm_mode_atomic_ioctl()
    drm_atomic_check_only()
      drm_atomic_helper_check()
        drm_atomic_helper_check_modeset()
          mode_fixup()
            dw_hdmi_qp_rockchip_encoder_atomic_check()

immediately overwrites the live user-visible vrr_display_min and
vrr_display_max values with limits derived from the uncommitted
crtc_state->mode.

In addition, mode_fixup() in drivers/gpu/drm/drm_atomic_helper.c skips the
encoder atomic_check when a connector has no CRTC or encoder assigned:

  if (!new_conn_state->crtc || !new_conn_state->best_encoder)
          continue;

When a VRR-capable display is connected at boot or hotplugged while the
connector is disabled, DRM_IOCTL_MODE_GETCONNECTOR probes the connector and
updates EDID without running dw_hdmi_qp_rockchip_encoder_atomic_check(),
leaving vrr_capable at 0 until a modeset occurs. Conversely, when a VRR
display is unplugged and its CRTC is disabled (new_conn_state->crtc == NULL),
mode_fixup() skips the encoder check and leaves vrr_capable stuck at 1 and
vrr_display_min / vrr_display_max holding the disconnected sink's values.

Finally, connector->display_info and connector->status (read by
drm_display_info_is_vrr_capable() and drm_connector_hdmi_update_vrr_limits())
are protected by dev->mode_config.mutex, whereas atomic_check only holds
connection_mutex and crtc->mutex, which can race with concurrent hotplug
updates in drm_bridge_connector_handle_hpd().

Should vrr_capable be updated in the connector hotplug / EDID probe path
while holding mode_config.mutex, and should the mode-dependent VRR limits be
updated during atomic commit rather than atomic_check?

[1] 
https://lore.kernel.org/r/[email protected]

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=12

Reply via email to