Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2428584pxp; Fri, 18 Mar 2022 10:15:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTdnepr8K9WQzdahPJaQMZJYQJ7AmhPS/JLONls00kTV4KllxUACmGvn6ewZoOHCoAcJMp X-Received: by 2002:a17:902:dad2:b0:151:a546:db2 with SMTP id q18-20020a170902dad200b00151a5460db2mr479312plx.0.1647623731663; Fri, 18 Mar 2022 10:15:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647623731; cv=none; d=google.com; s=arc-20160816; b=Rko4ibtVC6dWdP+r6THN9mmiOuHsp1ePvfibW30WsI6PP4fYSpcU3Q7elgb1UnsMAN 6oKfS9wc2VxnnJU0szOnRhm3+Y+GL4hVSpuWL5AQEL4tw9xHeh+X7yH0jpSS0knkv+Ys UpR3NdY/NjJLywSw5DGH1+dzt9LumPRJhiJqQWZ6QvOlMzMWjYsFTMBQoNxq4VF+M88P SDZQFll2UXa12vzuw0k5gq8t9A8t+R2qXrDL8gL4LODaYFAp7XvIi1Mn+evaB5HAKmqT B+lhDS0vZGvFx0iqDCgNjLV2UqKmZq/78k721HvLUqdITYkkYC42Nm6zTkO3o8YxUHPn YDLA== 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 :dkim-signature; bh=1HdyI7LG9qznT8yjtXFxPBo2TxxXkPEftGXqce+D3Xk=; b=mhYl6Hb34AbWM/K7MtPRt5vB4immCxsQzXST5/k88RcfWhGGYu6Js2urrzAA1fFMEx KKpUvALak84mOP5C+X9Owg8w5ABZXR8BHUD5mUGdUcb8GRkcxkfW47mQIx2Fm18w0NbP kMROCBSsebaorpOcG1PttfvK5d4/vbJfilBCnF/hcsxzRA04mO78BLNqojAclPCA0qZp hUihgoRvafTBKxiAl1jz39xo+tek3gtBRBtq0FUMfcBBvxsC1SVH0E1xBgT6dBeZJvpr 0ixJ1FQi+drz8rew8I4d3bdf0Z0PW74hKzO/r/ndZgUybnutMOPA9Rr8GbZIAUeAd+YG wGDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm3 header.b=Epwuw+DZ; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=jropfC5r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p1-20020a1709026b8100b00153b2d1655bsi2789365plk.355.2022.03.18.10.15.17; Fri, 18 Mar 2022 10:15:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm3 header.b=Epwuw+DZ; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=jropfC5r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237850AbiCRPPl (ORCPT + 99 others); Fri, 18 Mar 2022 11:15:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237843AbiCRPPj (ORCPT ); Fri, 18 Mar 2022 11:15:39 -0400 Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 490AC3D1F1 for ; Fri, 18 Mar 2022 08:14:19 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 004573200FA9; Fri, 18 Mar 2022 11:14:17 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Fri, 18 Mar 2022 11:14:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm3; bh=1HdyI7LG9qznT8yjtXFxPBo2TxxXkPEftGXqce +D3Xk=; b=Epwuw+DZ/yrrGGqmomOfiRUvgAhA+Tfj8QUktFC88+Hfnf+H8vDZNh bwAPGL428aML/B1ZG56zz5NFN6WsgQLm6fmMW+DdJGVGCOoyKXdxiuOue7MbVcBb VHnLvxcuxd4t7Sn810a+qIeNWnowNANaPUWkTFo2NmG6a4BA5a64VP2JBUlHJqDa qLEWEOJmn9PyawZyiDvqJ0WWdL7Od3WDY0vGcuo9/jowO3had1U+Qdj5VukcfnqS OGMqVqVddn6f0GH5CzppeDLGMu0tSfOUITisG+j3VtKGk6a1TFhPqtcf5CDnOsJK gGLy3h/36aXNHQZSJfLNxj2ZPDIUPA0w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=1HdyI7LG9qznT8yjt XFxPBo2TxxXkPEftGXqce+D3Xk=; b=jropfC5rDyX9t02DwuXI1sElkhp4/6Vqb uIbShiiI/TbuVTFcN4pAB3YWl0ubaJ3McCz+7XwIR61XCKYqxskkL0wq2WSd6tDf Aj5fb1VlhqZlf/gkxrrUFz5oA/fF4wBaxRX18yf2Sgc/px7apOORd3NFgEoSNaTG wxy4w5x3JHgQcopmgPPnXPE6MrueKlbmMKJx9KWU+/FiP/38FdWjqyt1OG3aXhjY Z4qJRxIRKg6plQc0HT3ODlQAigQUfmZr4qCUIcglld2om1gH7J59ZeLG1z8+1KlJ zxZgvRuOjfU7me+fH68dk/iPwpvxcck7zuvywGsKH1009xABUa/Yw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrudefiedgjeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucdnkfhovfculdeitddmnecujfgurhepfffhvffukf hfgggtuggjsehgtderredttddvnecuhfhrohhmpeforgigihhmvgcutfhiphgrrhguuceo mhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrthhtvghrnhepleekgeehhf dutdeljefgleejffehfffgieejhffgueefhfdtveetgeehieehgedunecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmhgrgihimhgvsegtvghrnh hordhtvggthh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 18 Mar 2022 11:14:16 -0400 (EDT) Date: Fri, 18 Mar 2022 16:14:14 +0100 From: Maxime Ripard To: Paul Kocialkowski Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Linus Walleij , Jagan Teki Subject: Re: [PATCH] drm: of: Properly try all possible cases for bridge/panel detection Message-ID: <20220318151414.vxormel2vfgzss6t@houat> References: <20220309143200.111292-1-paul.kocialkowski@bootlin.com> <20220310145423.but7r7ul4j7h3wxw@houat> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="wh3wounixr5n56qp" Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,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 --wh3wounixr5n56qp Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Mar 16, 2022 at 04:40:49PM +0100, Paul Kocialkowski wrote: > Hi Maxime, >=20 > Thanks for the review! >=20 > On Thu 10 Mar 22, 15:54, Maxime Ripard wrote: > > Hi Paul, > >=20 > > On Wed, Mar 09, 2022 at 03:32:00PM +0100, Paul Kocialkowski wrote: > > > While bridge/panel detection was initially relying on the usual > > > port/ports-based of graph detection, it was recently changed to > > > perform the lookup on any child node that is not port/ports > > > instead when such a node is available, with no fallback on the > > > usual way. > > >=20 > > > This results in breaking detection when a child node is present > > > but does not contain any panel or bridge node, even when the > > > usual port/ports-based of graph is there. > > >=20 > > > In order to support both situations properly, this commit reworks > > > the logic to try both options and not just one of the two: it will > > > only return -EPROBE_DEFER when both have failed. > > >=20 > > > Signed-off-by: Paul Kocialkowski > > > Fixes: 80253168dbfd ("drm: of: Lookup if child node has panel or brid= ge") > >=20 > > Thanks, it's in pretty good shape now, but I have a few bike sheds to p= aint :) > >=20 > > > --- > > > drivers/gpu/drm/drm_of.c | 93 +++++++++++++++++++++-----------------= -- > > > 1 file changed, 49 insertions(+), 44 deletions(-) > > >=20 > > > diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c > > > index 9d90cd75c457..67f1b7dfc892 100644 > > > --- a/drivers/gpu/drm/drm_of.c > > > +++ b/drivers/gpu/drm/drm_of.c > > > @@ -219,6 +219,35 @@ int drm_of_encoder_active_endpoint(struct device= _node *node, > > > } > > > EXPORT_SYMBOL_GPL(drm_of_encoder_active_endpoint); > > > =20 > > > +static int drm_of_find_remote_panel_or_bridge(struct device_node *re= mote, > > > + struct drm_panel **panel, > > > + struct drm_bridge **bridge) > >=20 > > This function performs its look up directly on the struct device_node > > passed as argument, so I don't think the "remote" in the name is great. > > Since it's static, we can just call it find_panel_or_bridge, what do you > > think? >=20 > From a quick look at other DRM code I got the impression that static func= tions > also usually carry the drm prefix but I might be wrong. Not necessarily, see handle_conflicting_encoders, commit_tail, commit_work, convert_clip_rect_to_rect, edid_load, etc. Most functions do, but it's not a rule or a convention. > > > +{ > > > + int ret =3D -EPROBE_DEFER; > > > + > > > + if (panel) { > > > + *panel =3D of_drm_find_panel(remote); > > > + if (!IS_ERR(*panel)) > > > + ret =3D 0; > >=20 > > return 0? >=20 > The idea was to still go through the "*bridge =3D NULL;" path if a bridge > pointer is provided, to preserve the original behavior of the function. > There may or may not not be any hard expectation on that, in any case > I feel like it would be good to avoid out-of-scope functional changes her= e. Then we could just clear it just like we clear the panel pointer in drm_of_find_panel_or_bridge. It would be more consistent. > > > + else > > > + *panel =3D NULL; > > > + > > > + } > > > + > > > + /* No panel found yet, check for a bridge next. */ > > > + if (bridge) { > > > + if (ret) { > >=20 > > And the return above allows to remove that test > >=20 > > > + *bridge =3D of_drm_find_bridge(remote); > > > + if (*bridge) > > > + ret =3D 0; > >=20 > > return 0? > >=20 > > > + } else { > > > + *bridge =3D NULL; > > > + } > > > + > > > + } > > > + > > > + return ret; > >=20 > > And here we can just return -EPROBE_DEFER > >=20 > > > +} > > > + > >=20 > > > /** > > > * drm_of_find_panel_or_bridge - return connected panel or bridge de= vice > > > * @np: device tree node containing encoder output ports > > > @@ -249,57 +278,33 @@ int drm_of_find_panel_or_bridge(const struct de= vice_node *np, > > > if (panel) > > > *panel =3D NULL; > > > =20 > > > - /** > > > - * Devices can also be child nodes when we also control that device > > > - * through the upstream device (ie, MIPI-DCS for a MIPI-DSI device). > > > - * > > > - * Lookup for a child node of the given parent that isn't either po= rt > > > - * or ports. > > > - */ > > > - for_each_available_child_of_node(np, remote) { > > > - if (of_node_name_eq(remote, "port") || > > > - of_node_name_eq(remote, "ports")) > > > - continue; > > > - > > > - goto of_find_panel_or_bridge; > > > + /* Check for a graph on the device node first. */ > > > + if (of_graph_is_present(np)) { > > > + remote =3D of_graph_get_remote_node(np, port, endpoint); > > > + if (remote) { > > > + ret =3D drm_of_find_remote_panel_or_bridge(remote, panel, > > > + bridge); > > > + of_node_put(remote); > > > + } > > > } > > > =20 > > > - /* > > > - * of_graph_get_remote_node() produces a noisy error message if port > > > - * node isn't found and the absence of the port is a legit case her= e, > > > - * so at first we silently check whether graph presents in the > > > - * device-tree node. > > > - */ > > > - if (!of_graph_is_present(np)) > > > - return -ENODEV; > > > - > > > - remote =3D of_graph_get_remote_node(np, port, endpoint); > > > - > > > -of_find_panel_or_bridge: > > > - if (!remote) > > > - return -ENODEV; > > > + /* Otherwise check for any child node other than port/ports. */ > > > + if (ret) { > > > + for_each_available_child_of_node(np, remote) { > > > + if (of_node_name_eq(remote, "port") || > > > + of_node_name_eq(remote, "ports")) > > > + continue; > > > =20 > > > - if (panel) { > > > - *panel =3D of_drm_find_panel(remote); > > > - if (!IS_ERR(*panel)) > > > - ret =3D 0; > > > - else > > > - *panel =3D NULL; > > > - } > > > + ret =3D drm_of_find_remote_panel_or_bridge(remote, panel, > > > + bridge); > > > + of_node_put(remote); > > > =20 > > > - /* No panel found yet, check for a bridge next. */ > > > - if (bridge) { > > > - if (ret) { > > > - *bridge =3D of_drm_find_bridge(remote); > > > - if (*bridge) > > > - ret =3D 0; > > > - } else { > > > - *bridge =3D NULL; > > > + /* Stop at the first found occurrence. */ > > > + if (!ret) > > > + break; > > > } > > > - > > > } > > > =20 > > > - of_node_put(remote); > > > return ret; > > > } > >=20 > > So the diff is fairly hard to read, but it ends up as: >=20 > Yeah I agree, not sure what I can do about that. Nothing, really. I don't expect any change there, it just happens sometimes= :) Maxime --wh3wounixr5n56qp Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCYjShxgAKCRDj7w1vZxhR xf5JAQDmxxQlwOLr+WoU55rb+kKgTqjN81stleRWwvtNPvHL/QD/b96Wr8MjlVF0 8r//DEe2OL2d9vGdB5FxsoQbIiUCjg8= =SsVH -----END PGP SIGNATURE----- --wh3wounixr5n56qp--