Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp302678pxy; Wed, 21 Apr 2021 03:28:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw49e9tDIAvcapafGJmcuMuC/lRhhNshrcug1s0b4cSbdDsRxSuS9mN2KzcpD0Y+2mbfzFU X-Received: by 2002:aa7:c707:: with SMTP id i7mr37696010edq.261.1619000933497; Wed, 21 Apr 2021 03:28:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619000933; cv=none; d=google.com; s=arc-20160816; b=ltw2hxL6MvVxwHtDCkB72sdgkMhMqtg6CxDwIlq0urY8KyWktXf6ZVQ81Mb0Eq+4Qm kfRxUtF3x8LgzaPILO/AxVYlZP4qR7XbB7spN2uNaRbhZ5TxDNhRxP4k4T5COW24lA5v seUsOEF/VfjW62D3ZVmrfQ0640Km5ae/nXq6qiTOA9qkub+xcjZuXyCUy9aqt6MxKnt3 rs3XXyt10mrC6cQ94oNNb3AzytCaYbyFkbLgFU1huawSOLZg5N0maLlCX2s57rkloWYy zUk6gr71lGKn+fqQQaxu/0JHCOpEf9I1Fv9s+BVuCPfuu9LuKaGKZF/jlh+1vWDv5Pd9 LKZA== 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=d5yWQMfM/Co2rLORB29xCNYtdUpYpDGcIm7lir7nAGY=; b=YZ0vscvTUdZnS8PCNrNq21qvS46ftfQRSSBHSt6t7AdYtgFWk//7Fz7bBPytZIP6Qe NmvRykmMy+WqF6cXtV1kWn28UHdmqIj9DdKkX3APOyl05/PlJ4gvG1LkmgnTl7T4lmIA Z5G7SCLufGlnpkwNJhbl5Lapiy2xwvcTjsXC4Sm4o2cCqFcfs24VbAB8eNp640kHQ09P 132hgYsVxFlpIgzNbCzdjiVLmMFZaVgvy8Y2XkwEIX8O9w9eq+oqRyJ3aDYEA7GbJmT1 I7RTv1c4SjtRNUGcpXyLzTWfAEuH6OZNy8ZP5NPmKqK+xB0mhimsaKmGa4zMyjg6T1HH N2tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm2 header.b="b/p8TqIh"; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=uFwiUhHs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a23si1602800edy.94.2021.04.21.03.28.30; Wed, 21 Apr 2021 03:28:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm2 header.b="b/p8TqIh"; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=uFwiUhHs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S237559AbhDUKBe (ORCPT + 99 others); Wed, 21 Apr 2021 06:01:34 -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: linux-kernel@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--