From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EEFF7606A322 for ; Thu, 3 Dec 2026 03:59:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=V5w21Ybo Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 68DB410E1AD; Thu, 3 Dec 2026 03:59:19 +0000 (UTC) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9027710E1AD for ; Thu, 3 Dec 2026 03:59:13 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 79325404FB; Thu, 3 Dec 2026 03:59:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 479B51F00898; Thu, 3 Dec 2026 03:59:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796270353; bh=7cacaz1RrFE+FRoFSV1iUxJEl/9x/SqqgqsTW+yb1hs=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=V5w21Ybo3GXjlwAWOix3fUrNV8kmQveFzFObFiCDiBrJHKxE17b4Is5soJigY8zg6 GU94/xY1mLJJt567/BLBfQnq7WYxDDMT+06OtbhcsZ/lBu3taxop+uxXYbcvm/75iz ttCsGeS9KaZFsF/jzSSfl2KEz0El6tdH/TAF7HJTuqA+B5669fjdcroGtnSdIcMkfW NkRfFZJDbTVm9H8YBuWa++b1ogtznsfXIADZj44ui9GoEIVkXmBFly2FDyi+KUNH8i XiFtir0xVIQMPo2+hZPRXJr68HO4RP7KlQcLwClV3k/A8DzKHiRmRckksRWdmoj5AL mxWmU1mi60keA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2] drm/edid: prefer highest refresh mode within native resolution on eDP To: cengjianeng , dri-devel@lists.freedesktop.org In-Reply-To: <20261203034601.675116-1-cengjianeng@huaqin.corp-partner.google.com> References: <20261202120153.1051508-1-cengjianeng@huaqin.corp-partner.google.com> <20261203034601.675116-1-cengjianeng@huaqin.corp-partner.google.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 03:59:12 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "dri-devel" X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 4 potential issues to consider: - [High] drm/edid: edid_fixup_preferred_max_vrefresh() promotes unvalidated mode - [Medium] drm/edid: is_detailed_mode() matches non-detailed DRM_MODE_TYPE_DRIVER modes - [Medium] drm/edid: edid_fixup_preferred_max_vrefresh() mishandles multiple preferred - [Medium] drm/edid: edid_fixup_preferred_max_vrefresh() replaces equal-vrefresh mode -- commit 74767c3cc3c0bdb88a5c146313bff24e0fe4bfc0 Author: Jianeng Ceng drm/edid: prefer highest refresh mode within native resolution on eDP This commit updates eDP connector mode probing to re-point DRM_MODE_TYPE_PREFERRED to the highest refresh rate detailed mode that shares the resolution of the original preferred mode. > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c > index b8f882a17c8f1..13c5a4d099b01 100644 > --- a/drivers/gpu/drm/drm_edid.c > +++ b/drivers/gpu/drm/drm_edid.c > @@ -3076,6 +3076,79 @@ static void edid_fixup_preferred(struct drm_connec= tor *connector) > preferred_mode->type |=3D DRM_MODE_TYPE_PREFERRED; > } > =20 > +/* Only modes parsed from detailed timings describe the panel itself. */ > +static bool is_detailed_mode(const struct drm_display_mode *mode) > +{ > + return mode->type & DRM_MODE_TYPE_DRIVER; > +} [Severity: Medium] Does checking DRM_MODE_TYPE_DRIVER in is_detailed_mode() also match non-detailed modes? edid_fixup_preferred_max_vrefresh() runs at the end of _drm_edid_connector_add_modes() after standard, established, CEA, DisplayID, and inferred modes have been added to connector->probed_modes. Modes in drm_dmt_modes[] (added by add_inferred_modes() -> drm_dmt_modes_for_range() on continuous-frequency panels and by add_standard_modes()), edid_est_modes[], CEA mode tables, and DisplayID modes from drm_mode_displayid_detailed() and drm_mode_displayid_formula() all carry DRM_MODE_TYPE_DRIVER. An inferred DMT or DisplayID formula mode at the native resolution with a higher refresh rate (such as a 75Hz, 85Hz, or 120Hz RB DMT entry) will pass is_detailed_mode() and replace the panel's actual detailed timing as DRM_MODE_TYPE_PREFERRED. > + > +/* > + * Walk the mode list for connector and re-point the preferred status to= the > + * mode with the highest vertical refresh rate among the detailed modes = that > + * share the resolution of the current preferred mode. > + * > + * Only detailed timings are considered: inferred, CVT and standard timi= ng > + * modes are not derived from the panel's own timing descriptors and mus= t not > + * replace it as preferred. > + */ > +static void edid_fixup_preferred_max_vrefresh(struct drm_connector *conn= ector) > +{ > + struct drm_display_mode *cur_mode, *preferred_mode =3D NULL; > + struct drm_display_mode *candidate_mode =3D NULL; > + int hdisplay, vdisplay; > + > + /* Nothing to do if the EDID does not mark any mode preferred. */ > + list_for_each_entry(cur_mode, &connector->probed_modes, head) { > + if (cur_mode->type & DRM_MODE_TYPE_PREFERRED) { > + preferred_mode =3D cur_mode; > + break; > + } > + } [Severity: Medium] What happens when connector->probed_modes has more than one mode marked DRM_MODE_TYPE_PREFERRED? Breaking on the first preferred mode ignores any later preferred mode, such as a higher-resolution preferred timing added by add_displayid_detailed_modes(), leaving multiple preferred modes in the list and failing to promote the highest refresh rate at the DisplayID preferred resolution. In addition, if multiple modes at the first preferred mode's resolution have DRM_MODE_TYPE_PREFERRED set and the first one already has the highest refresh rate, the candidate_mode =3D=3D preferred_mode check below returns early without clearing DRM_MODE_TYPE_PREFERRED from the other modes. > + > + if (!preferred_mode) > + return; > + > + if (!is_detailed_mode(preferred_mode)) > + return; > + > + /* The preferred mode defines the native resolution. */ > + hdisplay =3D preferred_mode->hdisplay; > + vdisplay =3D preferred_mode->vdisplay; > + > + list_for_each_entry(cur_mode, &connector->probed_modes, head) { > + if (!is_detailed_mode(cur_mode)) > + continue; > + > + if (cur_mode->hdisplay !=3D hdisplay || > + cur_mode->vdisplay !=3D vdisplay) > + continue; > + > + if (!candidate_mode || > + drm_mode_vrefresh(cur_mode) > drm_mode_vrefresh(candidate_mode)) > + candidate_mode =3D cur_mode; > + } > + > + if (!candidate_mode || candidate_mode =3D=3D preferred_mode) > + return; [Severity: Medium] Can this replace preferred_mode with an earlier mode that has the same integer drm_mode_vrefresh() value? Because candidate_mode starts at NULL instead of preferred_mode, an earlier non-preferred mode at (hdisplay, vdisplay) with the same drm_mode_vrefresh() value is latched on the first matching iteration and is not replaced when the loop reaches preferred_mode. candidate_mode !=3D preferred_mode then causes DRM_MODE_TYPE_PREFERRED to be moved to that earlier mode even though its refresh rate is not higher. Initializing candidate_mode to preferred_mode would ensure it only changes when a mode has a strictly higher vertical refresh rate. > + > + list_for_each_entry(cur_mode, &connector->probed_modes, head) { > + if (!is_detailed_mode(cur_mode)) > + continue; > + > + if (cur_mode->hdisplay !=3D hdisplay || > + cur_mode->vdisplay !=3D vdisplay) > + continue; > + > + cur_mode->type &=3D ~DRM_MODE_TYPE_PREFERRED; > + } > + > + candidate_mode->type |=3D DRM_MODE_TYPE_PREFERRED; > + > + drm_dbg_kms(connector->dev, "[CONNECTOR:%d:%s] preferred mode: " > + DRM_MODE_FMT "\n", connector->base.id, connector->name, > + DRM_MODE_ARG(candidate_mode)); > +} > + > static bool > mode_is_rb(const struct drm_display_mode *mode) > { > @@ -7242,6 +7315,9 @@ static int _drm_edid_connector_add_modes(struct drm= _connector *connector, > drm_edid_has_internal_quirk(connector, EDID_QUIRK_PREFER_LARGE_75)) > edid_fixup_preferred(connector); > =20 > + if (connector->connector_type =3D=3D DRM_MODE_CONNECTOR_eDP) > + edid_fixup_preferred_max_vrefresh(connector); > + > return num_modes; > } [Severity: High] Can promoting the highest-refresh mode in _drm_edid_connector_add_modes() before mode validation leave the connector without a preferred mode or break drivers that snapshot the preferred mode from probed_modes? _drm_edid_connector_add_modes() runs during .get_modes(), before __drm_helper_update_and_validate() and drm_mode_prune_invalid() in drm_helper_probe_single_connector_modes(). If the promoted highest-refresh mode exceeds source GPU dotclock, bridge, VBT, or eDP link bandwidth limits and is later rejected by mode_valid(), drm_mode_prune_invalid() removes it after DRM_MODE_TYPE_PREFERRED has already been stripped from the original 60Hz preferred mode, leaving connector->modes with no preferred mode. Drivers also consume DRM_MODE_TYPE_PREFERRED directly from connector->probed_modes right after drm_edid_connector_add_modes() and before mode_valid() runs. In i915, intel_edp_init_connector() calls intel_panel_add_edid_fixed_modes() immediately after drm_edid_connector_add_modes(), caching the preferred mode as intel_panel_preferred_fixed_mode(), and intel_dp_can_link_train_fallback_for_edp() rejects any fallback link rate or lane count that cannot sustain fixed_mode->clock. In amdgpu_dm, amdgpu_dm_connector_ddc_get_modes() latches the preferred mode into amdgpu_encoder->native_mode before mode_valid() and uses its pixel clock to synthesize all common scaled modes in amdgpu_dm_create_common_mode(). Also, running edid_fixup_preferred_max_vrefresh() unconditionally after edid_fixup_preferred() overrides the 60Hz or 75Hz target refresh rate selected when EDID_QUIRK_PREFER_LARGE_60 or EDID_QUIRK_PREFER_LARGE_75 is set on an eDP connector. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203034601.6751= 16-1-cengjianeng@huaqin.corp-partner.google.com?part=3D1