From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5FF1C433ED for ; Wed, 21 Apr 2021 10:01:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9E5FC61446 for ; Wed, 21 Apr 2021 10:01:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237531AbhDUKBd (ORCPT ); Wed, 21 Apr 2021 06:01:33 -0400 Received: from new3-smtp.messagingengine.com ([66.111.4.229]:59967 "EHLO new3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234678AbhDUKBc (ORCPT ); Wed, 21 Apr 2021 06:01:32 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailnew.nyi.internal (Postfix) with ESMTP id 1153C5804F2; Wed, 21 Apr 2021 06:00:58 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Wed, 21 Apr 2021 06:00:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm2; bh=d5yWQMfM/Co2rLORB29xCNYtdUp YpDGcIm7lir7nAGY=; b=b/p8TqIhLg7pPNSTCKSnslytl8onsOGnWIA8xYMuMe+ qyRE9+0YZlilCL7ye6NWgpTfEFIYJBxcYdohgGs9alOxf/zbe6hi82JrS9bO6WUJ yxoF5PtCtLgvboOZ7qUt1A83Sh44vhK9zJn2yeTBkVnzEvUf89MBpNNLxSVgO9tX 5ZbtZSeSKC4BicPMINIAlGs56wmZPb1AheIzgchSaYoc7vfc9xog9VxhVO/VVTEh PY9xDmouJM6zTjssRBgJHk10citEkQeJImaS7/EwPvXtKPSJEK8bCAb2pH4x0PHm yd9KRcW1/rlOcCFohaVcOcCluiaQDWjcQgex6yufTrQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=d5yWQM fM/Co2rLORB29xCNYtdUpYpDGcIm7lir7nAGY=; b=uFwiUhHsWbDMf1DwUm1b5C iGjD+Jff5gc28W1BgCPiuqNBxxd55jajR82MDE/UAx3QlFnN9OFpoqSwEXNqJBqN GFC4bVNbIRADqroj2pisTgW6X1EzCDQk/IfksmDvfPXfWHDYTg6QR0QJ+xmi3KCq xfK+d/5BJHgo/10JnliV053JKQKz6jYw9J6ynmgM/jAVE2tV24TOV9FLCschx1rp k/HGvHwOnE825MmXlsu9GhV5C8v52+fm0sxvT9/urTAg3MnH3oldpwrX+CFTvE+h 2H0J5NjAUDcubc1rqIFaCo3Gk8X183yTSQP1j+eD4JyszHbCpJpRKjyNk/WGZh3A == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvddtkedgvdefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehgtderredttdejnecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrth htvghrnhepjedtudekleffteevffduvdekfffffedvtdeuveffgfeffedtleetueelgeef leetnecuffhomhgrihhnpegsohhothhlihhnrdgtohhmnecukfhppeeltddrkeelrdeike drjeeinecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhep mhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Received: from localhost (lfbn-tou-1-1502-76.w90-89.abo.wanadoo.fr [90.89.68.76]) by mail.messagingengine.com (Postfix) with ESMTPA id 3E9ED1080063; Wed, 21 Apr 2021 06:00:56 -0400 (EDT) Date: Wed, 21 Apr 2021 12:00:52 +0200 From: Maxime Ripard To: Kevin Tang Cc: Maarten Lankhorst , Sean Paul , David Airlie , Daniel Vetter , Rob Herring , Mark Rutland , Orson Zhai , Chunyan Zhang , "Linux-Kernel@Vger. Kernel. Org" , ML dri-devel , devicetree@vger.kernel.org Subject: Re: [PATCH v4 4/6] drm/sprd: add Unisoc's drm display controller driver Message-ID: <20210421100052.gujzkrafp26e6tcz@gilmour> References: <20210222132822.7830-1-kevin3.tang@gmail.com> <20210222132822.7830-5-kevin3.tang@gmail.com> <20210324111019.og6d3w47swjim2mq@gilmour> <20210415090312.md6exuuv2y4mblxn@gilmour> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="kpgrv3m2gbmdl54j" Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org --kpgrv3m2gbmdl54j Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Apr 19, 2021 at 07:01:00AM +0800, Kevin Tang wrote: > Maxime Ripard =E4=BA=8E2021=E5=B9=B44=E6=9C=8815=E6= =97=A5=E5=91=A8=E5=9B=9B =E4=B8=8B=E5=8D=885:03=E5=86=99=E9=81=93=EF=BC=9A > > On Thu, Apr 15, 2021 at 08:18:52AM +0800, Kevin Tang wrote: > > > Maxime Ripard =E4=BA=8E2021=E5=B9=B43=E6=9C=8824= =E6=97=A5=E5=91=A8=E4=B8=89 =E4=B8=8B=E5=8D=887:10=E5=86=99=E9=81=93=EF=BC= =9A > > > > > +static struct sprd_dpu *sprd_crtc_init(struct drm_device *drm, > > > > > + struct drm_plane *primary) > > > > > +{ > > > > > + struct device_node *port; > > > > > + struct sprd_dpu *dpu; > > > > > + > > > > > + /* > > > > > + * set crtc port so that drm_of_find_possible_crtcs call wo= rks > > > > > + */ > > > > > + port =3D of_parse_phandle(drm->dev->of_node, "ports", 0); > > > > > + if (!port) { > > > > > + drm_err(drm, "find 'ports' phandle of %s failed\n", > > > > > + drm->dev->of_node->full_name); > > > > > + return ERR_PTR(-EINVAL); > > > > > + } > > > > > + of_node_put(port); > > > > > > > > The YAML binding should already make sure that your binding is sane= , and > > > > if you still get a DT that doesn't follow it, you have a whole lot = of > > > > other issues than whether ports is there :) > > > > > > > > > + dpu =3D drmm_crtc_alloc_with_planes(drm, struct sprd_dpu, b= ase, > > > > > + primary, NULL, > > > > > + &sprd_crtc_funcs, NULL); > > > > > + if (IS_ERR(dpu)) { > > > > > + drm_err(drm, "failed to init crtc.\n"); > > > > > + return dpu; > > > > > + } > > > > > + > > > > > + dpu->base.port =3D port; > > > > > > > > But you're still referencing it here, while you called of_node_put = on it > > > > already? You should only call it once you're done with it. > > > > > > of_node_put should be called after done with it, this maybe indeed b= e a bug. > > > i will fix it. > > > > > > > > > > > > I'm not really sure why you would need drm_of_find_possible_crtcs to > > > > work then if you don't follow the OF-Graph bindings. > > > > > > it scan all endports of encoder, if a matching crtc is found by > > > OF-Graph bindings > > > and then genarate the crtc mask, here is description: > > > 41 /** > > > 42 * drm_of_find_possible_crtcs - find the possible CRTCs for an en= coder port > > > 43 * @dev: DRM device > > > 44 * @port: encoder port to scan for endpoints > > > 45 * > > > 46 * Scan all endpoints attached to a port, locate their attached C= RTCs, > > > 47 * and generate the DRM mask of CRTCs which may be attached to th= is > > > 48 * encoder. > > > 49 * > > > if we don't follow the OF-Graph bindings, crtc can't attched to encod= er. > > > > Yeah, what I'm actually confused about is why you would need the > > of_parse_phandle call. You usually call drm_of_find_possible_crtcs with > > the encoder device node, so from your MIPI-DSI driver in your case, and > > with it's device->of_node pointer and it should work perfectly fine? > I still confused about use drm_of_find_possible_crtcs to bind crtc and > encoder, the port of drm_crtc, default is null? >=20 > 709 /** > 710 * struct drm_crtc - central CRTC control structure > 711 * @dev: parent DRM device > 712 * @port: OF node used by drm_of_find_possible_crtcs() > -------------------------------------------------------------------------= ---------------------------- > 25 static uint32_t drm_crtc_port_mask(struct drm_device *dev, > 26 struct device_node *port) > 27 { > 28 unsigned int index =3D 0; > 29 struct drm_crtc *tmp; > 30 > 31 drm_for_each_crtc(tmp, dev) { > 32 if (tmp->port =3D=3D port) > 33 return 1 << index; > 34 > 35 index++; > 36 } > 37 > 38 return 0; > 39 } >=20 > I did not see any place to initialize the port of drm_crtc in the drm > framework, if not setup it. > it looks like the port of drm_crtc is undefined. >=20 > https://elixir.bootlin.com/linux/latest/source/drivers/gpu/drm/rockchip/r= ockchip_drm_vop.c#L1851 > https://elixir.bootlin.com/linux/latest/source/drivers/gpu/drm/tilcdc/til= cdc_crtc.c#L1051 Yeah, you need to initialize it for drm_of_find_possible_crtcs to work, but my point was that you shouldn't do it through of_parse_phandle, just put the output of_graph_get_port_by_id like you found in those drivers. Maxime --kpgrv3m2gbmdl54j Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCYH/31AAKCRDj7w1vZxhR xfYbAQCyx/frCmI48iF2v9KLvwRkV6q7XhdIGq6JZ8So9sDZdwEAg7fNpob0hObc +1Speo1tpFxjtmM3FtNHpH8nYvYk4ww= =LDrh -----END PGP SIGNATURE----- --kpgrv3m2gbmdl54j--