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 2E923606A32A for ; Wed, 2 Dec 2026 12:18:20 +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=cE/b44BX Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9108410E37F; Wed, 2 Dec 2026 12:18:14 +0000 (UTC) Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by gabe.freedesktop.org (Postfix) with ESMTPS id E60DC112189 for ; Wed, 2 Dec 2026 12:18:07 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 0184C62676; Wed, 2 Dec 2026 12:18:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C1F51F00893; Wed, 2 Dec 2026 12:18:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796213886; bh=1zC+W7wcWExTeTWi/POMUJdO6pQyVWe1XuIVbNqGIB8=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=cE/b44BX5/B1uvldxo+g2uHe0tNARLl1XEIWxa1XSNHIscx+1FD073PtP2SZCe02I XSRWu4F1ATE4/a8RjsALfhQav4wJgS0PCWzMt3v3tz1HmBhg7PwkFXo1+IR0BKUVXB 3rKgbQzOdqM8Na7og/9tvZBYOPsPtnmhH/+ysP68EHWuG7ys2o2ciN2GJ5TteE1V9R cHkj1ckRi8rPgIb+Z1h4EMc80fLbLp18kd48F3a+hmmgfoD8nbz7wuMb5Li476JIC/ rv/YbU4W7LpGattjIhEmhy8GKrsojHW2ZUp8jAA3NIJpv9qSW9amrb0moLQ0oHh6uI ROB1RlC2XAp5Q== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] drm/edid: prefer highest refresh mode within native resolution on eDP To: cengjianeng , dri-devel@lists.freedesktop.org In-Reply-To: <20261202120153.1051508-1-cengjianeng@huaqin.corp-partner.google.com> References: <20261202120153.1051508-1-cengjianeng@huaqin.corp-partner.google.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 12:18:06 +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 3 potential issues to consider: - [High] drm/edid: edid_fixup_preferred_max_vrefresh() promotes unvalidated mode - [Medium] drm/edid: edid_fixup_preferred_max_vrefresh() promotes non-detailed modes - [Medium] drm/edid: edid_fixup_preferred_max_vrefresh() mishandles multiple preferred -- commit e313f14ca873716202a489a3beac07169e41bd70 Author: Jianeng Ceng drm/edid: prefer highest refresh mode within native resolution on eDP This commit adds edid_fixup_preferred_max_vrefresh() to move DRM_MODE_TYPE_PREFERRED to the highest refresh rate mode sharing the preferred mode's resolution on eDP connectors. > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c > index b8f882a17c8f1..e8a6bdc00e326 100644 > --- a/drivers/gpu/drm/drm_edid.c > +++ b/drivers/gpu/drm/drm_edid.c > @@ -3076,6 +3076,53 @@ static void edid_fixup_preferred(struct drm_connec= tor *connector) > preferred_mode->type |=3D DRM_MODE_TYPE_PREFERRED; > } > =20 > +/* > + * Walk the mode list for connector and re-point the preferred status to= the > + * mode with the highest vertical refresh rate among the modes that shar= e the > + * resolution of the current preferred mode. > + */ > +static void edid_fixup_preferred_max_vrefresh(struct drm_connector *conn= ector) > +{ > + struct drm_display_mode *cur_mode, *preferred_mode; > + int hdisplay, vdisplay; > + > + if (list_empty(&connector->probed_modes)) > + return; > + > + preferred_mode =3D list_first_entry(&connector->probed_modes, > + struct drm_display_mode, head); > + 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] Does breaking on the first DRM_MODE_TYPE_PREFERRED mode miss preferred modes at a higher resolution from DisplayID extension blocks? drm_mode_displayid_detailed() adds modes with DRM_MODE_TYPE_PREFERRED after add_detailed_modes(). If the base EDID block has a fallback preferred mode and a DisplayID block has a higher-resolution preferred mode, this loop stops at the base EDID mode and only updates modes at that lower resolution. Also, if no mode in connector->probed_modes has DRM_MODE_TYPE_PREFERRED set, preferred_mode falls back to list_first_entry() and receives DRM_MODE_TYPE_PREFERRED unconditionally at the end of the function. > + > + hdisplay =3D preferred_mode->hdisplay; > + vdisplay =3D preferred_mode->vdisplay; > + > + list_for_each_entry(cur_mode, &connector->probed_modes, head) { > + if (cur_mode->hdisplay !=3D hdisplay || cur_mode->vdisplay !=3D vdispl= ay) > + continue; > + > + cur_mode->type &=3D ~DRM_MODE_TYPE_PREFERRED; > + } > + > + list_for_each_entry(cur_mode, &connector->probed_modes, head) { > + if (cur_mode->hdisplay !=3D hdisplay || cur_mode->vdisplay !=3D vdispl= ay) > + continue; > + > + if (drm_mode_vrefresh(cur_mode) > drm_mode_vrefresh(preferred_mode)) > + preferred_mode =3D cur_mode; > + } > + > + preferred_mode->type |=3D DRM_MODE_TYPE_PREFERRED; [Severity: High] Can moving DRM_MODE_TYPE_PREFERRED to the highest refresh rate mode before mode validation leave connector->modes with no preferred mode or break drivers that latch 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(). If the highest-refresh mode exceeds the GPU dotclock, VBT limit, or available eDP link bandwidth, drm_mode_prune_invalid() removes it after DRM_MODE_TYPE_PREFERRED has already been cleared from the 60Hz mode. In addition, drivers such as i915 and amdgpu snapshot the preferred mode from connector->probed_modes right after drm_edid_connector_add_modes() before mode_valid() runs. In i915, intel_edp_init_connector() -> intel_panel_add_edid_fixed_modes() stores that mode as the primary fixed_mode, and intel_dp_can_link_train_fallback_for_edp() rejects any link training fallback rate or lane count that cannot sustain fixed_mode->clock. > + > + drm_dbg_kms(connector->dev, "[CONNECTOR:%d:%s] preferred mode: " > + DRM_MODE_FMT "\n", connector->base.id, connector->name, > + DRM_MODE_ARG(preferred_mode)); > +} > + > static bool > mode_is_rb(const struct drm_display_mode *mode) > { > @@ -7242,6 +7289,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: Medium] Can calling edid_fixup_preferred_max_vrefresh() here promote an inferred VESA DMT mode over the panel's native detailed timing? At this point in _drm_edid_connector_add_modes(), add_cvt_modes(), add_standard_modes(), add_established_modes(), and add_inferred_modes() have already appended non-detailed modes to connector->probed_modes. On a VRR eDP panel with DRM_EDID_FEATURE_CONTINUOUS_FREQ and a range descriptor extending above the DTD refresh rate (at a DMT resolution such as 1920x1200 or 2560x1600), drm_dmt_modes_for_range() adds higher refresh DMT timings that do not match the panel's blanking or sync flags, which then replace the panel's DTD as DRM_MODE_TYPE_PREFERRED and break exact timing checks such as i915's is_alt_drrs_mode(). Running this unconditionally after edid_fixup_preferred() also overrides EDID_QUIRK_PREFER_LARGE_60 and EDID_QUIRK_PREFER_LARGE_75 on eDP connectors. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202120153.1051= 508-1-cengjianeng@huaqin.corp-partner.google.com?part=3D1