Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp1970001rdf; Mon, 6 Nov 2023 00:02:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IGYwVFzbvy/aKXg7dcXbA9u9q1WEPbTQ/t/pNEnQA5xKbnRRD5WXt+hcrlsL/d1EJUwmOGZ X-Received: by 2002:a05:6808:1986:b0:3ad:ae62:8253 with SMTP id bj6-20020a056808198600b003adae628253mr32788268oib.15.1699257760763; Mon, 06 Nov 2023 00:02:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699257760; cv=none; d=google.com; s=arc-20160816; b=LiXQBWynOCgIODlYIC5T0OwgGqt+HDIdMV/oOphlnUGTLYibNagOb5Rs71RGSk29L3 aSMmfu9+JVQ5/9HtHbG+R0uDWJsI/1srG1hlvuKJOROCvE49g0nkwTuZkXH9j2jpvS80 ZOnIw9g4mfEau+IdDBUm4xQOVrtqaHNBSCEZdR3rFjHmSjd+a7KxdQpYFsAM4L1eRxuM FcuCHG0VL11rggCxu7YPa/y/fPQX/tM/JKK/iykeBOn3uT3tDHm8gcDaHDawZjTFTp5g fPvf4agK2unKcGHnKQQ3R88qDJNuv/vUQ7zsxFGpK6fLOdx097deUluWmIfm433eu50N S/1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=hpyabEBRBvWl319YjomYQqLvUZK96FG70pdMhOtIvYw=; fh=4UBgZwi6LxViPMzQcJ9B9k6SxB3xkakNbZpPAvbQOec=; b=h4MkVN1k8bBQrokPtF1pz+h88pIdD0wrN4eo3A98PrXApgt8T+Me66caN5zvL0VslO m871I2I+yKaEVicTALXfPYFei7qBJCus9IZR22uk7OYvX/uXc6anJVQt08L80gbf3fC9 R2rjQ8Cks1dC3Xnv8wbXXMfnEetEbBoUj2G2cn4nHp/hK4shLagSRyUaNCvmeI0kI8gp ptRb2ujlYyFpb12WBaaWrjr2cQ1HkOVNqDntHdlZFh44eV2puQ5HxCTaVu4Awf96WM7Y lcZzpWcTMnQ0JcJpx7It1EBWRbix1AqbdQ28g1uh/DIjpV2WyHdCIL9ccpqVHt/QYPva T+7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KWbORS22; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id z16-20020a056a001d9000b00690d55d630dsi7320488pfw.274.2023.11.06.00.02.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 00:02:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KWbORS22; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id A20A2802FB96; Mon, 6 Nov 2023 00:02:39 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229881AbjKFICi (ORCPT + 99 others); Mon, 6 Nov 2023 03:02:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229486AbjKFICh (ORCPT ); Mon, 6 Nov 2023 03:02:37 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D1A8BF for ; Mon, 6 Nov 2023 00:02:35 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A191C433C8; Mon, 6 Nov 2023 08:02:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699257754; bh=B2J3tYwWs8unjrG1R06v2y9BPdzrC6cCQw+FiMQOotM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KWbORS22YQ2++WmwX3m64ZLcVMEK8GXlY6QliYHgd1996iWKxVtwUSwkx/aVZLGzy sSeekCi/0B0fNx11SKHW/KeDHi78McSSyRQwJpcu9wOxNqwRP1RfQVt7i6bylDABlN 9M6sNML4dVfuOb9wcOYYigdEilrHemvXe6FMOxLJF6Qt9BYLtK4yJvyeQd+/jvX2b1 BVjPmvHTbVTMuSLoLcTKvtV4qUuQpPxeXpFeCUlmtXF9lWF5qg5bgwy41YPzE41es+ 4+79XEx4Nom6g3PqtmObE4WMCu9A5vmYvcMKQKVzlYYT/OgCMwaMS8UdUEHku7tMdd iC51iu1eSY4vQ== Date: Mon, 6 Nov 2023 09:02:31 +0100 From: Maxime Ripard To: Hsin-Yi Wang Cc: Douglas Anderson , Neil Armstrong , Jessica Zhang , Sam Ravnborg , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/3] drm/panel-edp: Choose correct preferred mode Message-ID: References: <20231101212604.1636517-1-hsinyi@chromium.org> <20231101212604.1636517-4-hsinyi@chromium.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="waxprhmhdgzl4ous" Content-Disposition: inline In-Reply-To: <20231101212604.1636517-4-hsinyi@chromium.org> X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 06 Nov 2023 00:02:39 -0800 (PST) --waxprhmhdgzl4ous Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Wed, Nov 01, 2023 at 02:20:11PM -0700, Hsin-Yi Wang wrote: > If a non generic edp-panel is under aux-bus, the mode read from edid would > still be selected as preferred and results in multiple preferred modes, > which is ambiguous. >=20 > If a hard-coded mode is present, unset the preferred bit of the modes read > from edid. >=20 > Signed-off-by: Hsin-Yi Wang > --- > drivers/gpu/drm/drm_modes.c | 16 ++++++++++++++++ > drivers/gpu/drm/panel/panel-edp.c | 7 +++++-- > include/drm/drm_modes.h | 1 + > 3 files changed, 22 insertions(+), 2 deletions(-) This should be in two separate patches, with kunit tests for the helper you create. > diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c > index ac9a406250c5..35927467f4b0 100644 > --- a/drivers/gpu/drm/drm_modes.c > +++ b/drivers/gpu/drm/drm_modes.c > @@ -1933,6 +1933,22 @@ void drm_connector_list_update(struct drm_connecto= r *connector) > } > EXPORT_SYMBOL(drm_connector_list_update); > =20 > +/** > + * drm_mode_unset_preferred - clear the preferred status on existing mod= es. > + * @connector: the connector to update > + * > + * Walk the mode list for connector, clearing the preferred status on ex= isting > + * modes. > + */ > +void drm_mode_unset_preferred_modes(struct drm_connector *connector) > +{ > + struct drm_display_mode *cur_mode; > + > + list_for_each_entry(cur_mode, &connector->probed_modes, head) > + cur_mode->type &=3D ~DRM_MODE_TYPE_PREFERRED; > +} > +EXPORT_SYMBOL_GPL(drm_mode_unset_preferred_modes); > + More importantly, why do you need a helper for this at all? If it's only useful in a single driver for now, then just add it to that driver. > static int drm_mode_parse_cmdline_bpp(const char *str, char **end_ptr, > struct drm_cmdline_mode *mode) > { > diff --git a/drivers/gpu/drm/panel/panel-edp.c b/drivers/gpu/drm/panel/pa= nel-edp.c > index 0883ff312eba..b3ac473b2554 100644 > --- a/drivers/gpu/drm/panel/panel-edp.c > +++ b/drivers/gpu/drm/panel/panel-edp.c > @@ -622,10 +622,13 @@ static int panel_edp_get_modes(struct drm_panel *pa= nel, > * and no modes (the generic edp-panel case) because it will clobber > * the display_info that was already set by drm_add_edid_modes(). > */ > - if (p->desc->num_timings || p->desc->num_modes) > + if (p->desc->num_timings || p->desc->num_modes) { > + /* hard-coded modes present, unset preferred modes from edid. */ > + drm_mode_unset_preferred_modes(connector); > num +=3D panel_edp_get_non_edid_modes(p, connector); > - else if (!num) > + } else if (!num) { > dev_warn(p->base.dev, "No display modes\n"); > + } It's also not clear to me why you need to mess with the modes at all. If the mode is unreliable and needs to be overloaded, then just ignore the EDIDs entirely and report the mode you have hardcoded in the driver. You then don't need to play with the flags at all. Maxime --waxprhmhdgzl4ous Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCZUidjwAKCRDj7w1vZxhR xSJkAPsHDamy1dLJRTi+5dbBulJ2mpxrcxu6WVXfbKUnFeOWfgD+MqRXsdB0pXpb EF6KGkVBrTAneLMEUAHEcp13e2J3ygo= =iFih -----END PGP SIGNATURE----- --waxprhmhdgzl4ous--