From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jernej =?utf-8?B?xaBrcmFiZWM=?= Subject: Re: [PATCH v3 10/24] drm/sun4i: tcon: Generalize engine search algorithm Date: Thu, 28 Jun 2018 06:48:50 +0200 Message-ID: <1812731.FQOhD8MfmX@jernej-laptop> References: <20180625120304.7543-1-jernej.skrabec@siol.net> <20180625120304.7543-11-jernej.skrabec@siol.net> Reply-To: jernej.skrabec-gGgVlfcn5nU@public.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Return-path: Sender: linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org In-Reply-To: List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , To: Chen-Yu Tsai Cc: Maxime Ripard , Rob Herring , David Airlie , Gustavo Padovan , Maarten Lankhorst , Sean Paul , Mark Rutland , dri-devel , devicetree , linux-arm-kernel , linux-kernel , linux-clk , linux-sunxi List-Id: devicetree@vger.kernel.org Dne =C4=8Detrtek, 28. junij 2018 ob 04:06:52 CEST je Chen-Yu Tsai napisal(a= ): > On Mon, Jun 25, 2018 at 8:02 PM, Jernej Skrabec = =20 wrote: > > Current "old" method to find engine worked pretty well for DE2. However= , > > it doesn't work when TCON TOP is between mixer (engine) and TCON. TCON > > TOP has multiple input ports, but current engine search algorithm > > expects only one. > >=20 > > This can be fixed by first looking for output port id and selecting > > matching input by subtracting 1 for the next round. This work even if > > there is only one input and output. > >=20 > > Signed-off-by: Jernej Skrabec > > --- > >=20 > > drivers/gpu/drm/sun4i/sun4i_tcon.c | 22 ++++++++++++++++++---- > > 1 file changed, 18 insertions(+), 4 deletions(-) > >=20 > > diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c > > b/drivers/gpu/drm/sun4i/sun4i_tcon.c index 08747fc3ee71..264bcc43da11 > > 100644 > > --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c > > +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c > > @@ -791,12 +791,14 @@ static int sun4i_tcon_init_regmap(struct device > > *dev, > >=20 > > */ > > =20 > > static struct sunxi_engine * > > sun4i_tcon_find_engine_traverse(struct sun4i_drv *drv, > >=20 > > - struct device_node *node) > > + struct device_node *node, > > + u32 port_id) > >=20 > > { > > =20 > > struct device_node *port, *ep, *remote; > > struct sunxi_engine *engine =3D ERR_PTR(-EINVAL); > >=20 > > + u32 reg =3D 0; > >=20 > > - port =3D of_graph_get_port_by_id(node, 0); > > + port =3D of_graph_get_port_by_id(node, port_id); > >=20 > > if (!port) > > =20 > > return ERR_PTR(-EINVAL); > >=20 > > @@ -826,8 +828,20 @@ sun4i_tcon_find_engine_traverse(struct sun4i_drv > > *drv, > >=20 > > if (remote =3D=3D engine->node) > > =20 > > goto out_put_remote; > >=20 > > + /* > > + * According to device tree binding input ports have even id > > + * number and output ports have odd id. Since component with > > + * more than one input and one output (TCON TOP) exits, correct > > + * remote input id has to be calculated by subtracting 1 from > > + * remote output id. If this for some reason can't be done, 0 > > + * is used as input port id. > > + */ >=20 > You need to call >=20 > of_node_put(port); >=20 > to drop the reference to the original port. Thanks for noticing it. I guess I should send fix patch, since patches from= =20 drm-misc-next can't be dropped. Best regards, Jernej > Otherwise, >=20 > Reviewed-by: Chen-Yu Tsai >=20 > > + port =3D of_graph_get_remote_port(ep); > > + if (!of_property_read_u32(port, "reg", ®) && reg > 0) > > + reg -=3D 1; > > + > >=20 > > /* keep looking through upstream ports */ > >=20 > > - engine =3D sun4i_tcon_find_engine_traverse(drv, remote); > > + engine =3D sun4i_tcon_find_engine_traverse(drv, remote, reg); > >=20 > > out_put_remote: > > of_node_put(remote); > >=20 > > @@ -950,7 +964,7 @@ static struct sunxi_engine > > *sun4i_tcon_find_engine(struct sun4i_drv *drv,>=20 > > /* Fallback to old method by traversing input endpoints */ > > of_node_put(port); > >=20 > > - return sun4i_tcon_find_engine_traverse(drv, node); > > + return sun4i_tcon_find_engine_traverse(drv, node, 0); > >=20 > > } > > =20 > > static int sun4i_tcon_bind(struct device *dev, struct device *master, > >=20 > > -- > > 2.18.0 --=20 You received this message because you are subscribed to the Google Groups "= linux-sunxi" group. To unsubscribe from this group and stop receiving emails from it, send an e= mail to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/d/optout.