Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2559960pxp; Fri, 18 Mar 2022 13:14:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbuaseJ75pJsHyJdLjBvZYBdfZNrOl+2rrhLCi8YCcwOexNnV0v1glfpNfvlvQrJW4qvR7 X-Received: by 2002:a05:6402:3581:b0:418:ec68:f48e with SMTP id y1-20020a056402358100b00418ec68f48emr11195148edc.63.1647634472679; Fri, 18 Mar 2022 13:14:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647634472; cv=none; d=google.com; s=arc-20160816; b=qh/kaFhzy+Z6XjL/j7ANCm8ZCb5X1tZZjw/B1FOfUPPjLdSpgtz6XmQfR7TmCGBKx+ 3bNZo61P8rvLbKttI3LtNveAyBQf/y6GRJqvx0u7Plw6t39NA8BmwNRDKOWiKD7HPUrd 9pASqaTNvDEQbFdfr3kU7lQIg5y5RLL3gsoUdNpLAlOrUazHp48MTDBfHzjhARv8biKQ nJm+BKQWSqfvble6EHmaLWcFrgP2/SG29N3l9Xba0SydrpZHOtSmtdmpCVunas44yz01 T4q+0hsWVyY0x8gvUHN4fgp18ZDDJlSH6lr7EJn1Lfju9Gy3jCrySBFkUyrLghILlFjN jBFA== 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=XyvG+0AhV6GNZxavZndSgFd1DvfzNuoKrvusjJeU8vE=; b=zCFg/ewxpbkfWhLx/BhJOEU+0PLD5YzvYWLigbHgjtcIlKHo89uerYP1+WQkErw2Ix /og+GJHlhBfHK2k7tP70+GFusuZP7ibhjyvTp4mm5Cnaj93LDI8OKEKwcQOJOYr4U54e 5hpCLjDXKYA4EPWpNpOSdHrQ8AD8Tg27rPBYsbRKVX/Ub9eQuZP+AuNZkf83uQ185pjt uAZf9xogi9/Z0PoBog0W3zYojNh0mQ8BW50/34iyW7OQUjnZVlt+tlfpe+GF23avRXyN IbUQBOIico7zd0rHwZXWvAg8+q7dHYws59EptefVpVMFXj8ksQoYqSIhyU3HlMtwmygE 2m/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=UsYH9OeB; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m3-20020a50d7c3000000b00418c2b5bd4dsi3910970edj.47.2022.03.18.13.14.06; Fri, 18 Mar 2022 13:14:32 -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=@bootlin.com header.s=gm1 header.b=UsYH9OeB; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237965AbiCRP0p (ORCPT + 99 others); Fri, 18 Mar 2022 11:26:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237957AbiCRP0n (ORCPT ); Fri, 18 Mar 2022 11:26:43 -0400 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78CABBA301 for ; Fri, 18 Mar 2022 08:25:24 -0700 (PDT) Received: (Authenticated sender: paul.kocialkowski@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id E54B61BF21A; Fri, 18 Mar 2022 15:25:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1647617122; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=XyvG+0AhV6GNZxavZndSgFd1DvfzNuoKrvusjJeU8vE=; b=UsYH9OeBcFQ6hgH9ohMrhQ+cU1pfKK0vFkTLHxSk0YHw3H0fj6cr9oqytc3wyHsEDuouTb /v6UGrSum7PT9kKgup9zugCZhxlGFtLYzhsQ2zbe7mp1qLs7Ok5lXc6aSFFOoiZI1q5GAE 2TBwmTtfvuV6EiQt/clDR/KewxpbeC/DywMmcoGwSr1j2EfJ7g51oDB18WHaswH5dMmaBC 2+omuK1g+4lai9lcIcM0ChSmIcNEQ+sIuvjclC2OrSiRk8GqucokirKUK4svZ/slntAeYZ 7xPg1TEWhM9cDCimSgM1ASHWhJNIlFbnp1FlaaAmgwGNb+9UKsHAc0Vajjb2Mw== Date: Fri, 18 Mar 2022 16:25:21 +0100 From: Paul Kocialkowski To: Maxime Ripard 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: References: <20220309143200.111292-1-paul.kocialkowski@bootlin.com> <20220310145423.but7r7ul4j7h3wxw@houat> <20220318151414.vxormel2vfgzss6t@houat> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="QRbFUewSOUn4mwmT" Content-Disposition: inline In-Reply-To: <20220318151414.vxormel2vfgzss6t@houat> 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,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 --QRbFUewSOUn4mwmT Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Maxime, On Fri 18 Mar 22, 16:14, Maxime Ripard wrote: > 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 br= idge") > > >=20 > > > Thanks, it's in pretty good shape now, but I have a few bike sheds to= paint :) > > >=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 devi= ce_node *node, > > > > } > > > > EXPORT_SYMBOL_GPL(drm_of_encoder_active_endpoint); > > > > =20 > > > > +static int drm_of_find_remote_panel_or_bridge(struct device_node *= remote, > > > > + 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 grea= t. > > > 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 fu= nctions > > also usually carry the drm prefix but I might be wrong. >=20 > Not necessarily, see handle_conflicting_encoders, commit_tail, commit_wor= k, > convert_clip_rect_to_rect, edid_load, etc. >=20 > Most functions do, but it's not a rule or a convention. Okay then, I'm fine with find_panel_or_bridge. > > > > +{ > > > > + 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 brid= ge > > 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 h= ere. >=20 > 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. Oh absolutely, I agree that would be best. > > > > + 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 = device > > > > * @np: device tree node containing encoder output ports > > > > @@ -249,57 +278,33 @@ int drm_of_find_panel_or_bridge(const struct = device_node *np, > > > > if (panel) > > > > *panel =3D NULL; > > > > =20 > > > > - /** > > > > - * Devices can also be child nodes when we also control that devi= ce > > > > - * through the upstream device (ie, MIPI-DCS for a MIPI-DSI devic= e). > > > > - * > > > > - * Lookup for a child node of the given parent that isn't either = port > > > > - * 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 p= ort > > > > - * node isn't found and the absence of the port is a legit case h= ere, > > > > - * 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. >=20 > Nothing, really. I don't expect any change there, it just happens sometim= es :) All right then :) I'll send another iteration soon. Cheers, Paul --=20 Paul Kocialkowski, Bootlin Embedded Linux and kernel engineering https://bootlin.com --QRbFUewSOUn4mwmT Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEJZpWjZeIetVBefti3cLmz3+fv9EFAmI0pGEACgkQ3cLmz3+f v9F38wgAiW0fsg1uHAG9RbQHGQPMR6EPkKAA+fF3K8Dw5S8e327Pbb37JOO0OaRq awMEK2tU+azdYXWM0AY8w2/6FrquKCQOeIIPUyCMNUvDdZYJR1VIcPFeOd75CoWX uQ6eq7Kp/BiWN0iQzOnXGZwEQWBaYirtzBIS/kbHmVHXoBV6RNSQ3paPffPiuqd0 gbZ6SfUivqhd5F8DNqw9c/EmnRnVcVm5GEdm2hNh8btG9mOgAjWTOl4zT39Bk+JQ BhyuxGDH72Eqr+NolyiIVs/GkZRb4cfysQOFEqhu3gzdW+H4q88PbgaFrBQ72wEp iyuWUTkZWcyt3A2QZuCDSfmOk6ctlw== =CNx8 -----END PGP SIGNATURE----- --QRbFUewSOUn4mwmT--