From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?Q?C=c3=a9dric_Le_Goater?= Date: Tue, 7 Jan 2020 09:20:38 +0100 Subject: [PATCH 06/19] aspeed: ast2500: Read clock ofdata in the correct method In-Reply-To: <20191229211913.6.I9f208c8708d1b33625601d8034ef08e6305c09d5@changeid> References: <20191230041928.74874-1-sjg@chromium.org> <20191229211913.6.I9f208c8708d1b33625601d8034ef08e6305c09d5@changeid> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: u-boot@lists.denx.de On 12/30/19 5:19 AM, Simon Glass wrote: > At present the clock driver reads its ofdata in the probe() method. This > is not correct although it is often harmless. >=20 > However in this case it causes a problem, something like this: >=20 > - ast_get_scu() is called (from somewhere) to get the SCI address > - this probes the clock > - first sets up ofdata (which does nothing at present) > - DM marks clock device as active > - DM calls pinctrl > - pinctrl probes and calls ast_get_scu() in ast2500_pinctrl_probe() > - ast_get_scu() probes the clock, but sees it already marked as > probed > - ast_get_scu() accesses the clock's private data, with scu as NULL > - DM calls clock probe function ast2500_clk_probe() which reads scu >=20 > By putting the read of scu into the correct method, scu is read as part of > ofdata setup, and everything is OK. >=20 > Note: This problem did not matter until now since DM always probed all > parents before reading a child's ofdata. The fact that pinctrl is a child > of clock seems to trigger this strange bug. Did you find it with QEMU ? >=20 > Signed-off-by: Simon Glass Reviewed-by: C=C3=A9dric Le Goater C. > --- >=20 > drivers/clk/aspeed/clk_ast2500.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) >=20 > diff --git a/drivers/clk/aspeed/clk_ast2500.c b/drivers/clk/aspeed/clk_as= t2500.c > index 9249cf9cdf..b3a3f3d4dd 100644 > --- a/drivers/clk/aspeed/clk_ast2500.c > +++ b/drivers/clk/aspeed/clk_ast2500.c > @@ -490,7 +490,7 @@ struct clk_ops ast2500_clk_ops =3D { > .enable =3D ast2500_clk_enable, > }; > =20 > -static int ast2500_clk_probe(struct udevice *dev) > +static int ast2500_clk_ofdata_to_platdata(struct udevice *dev) > { > struct ast2500_clk_priv *priv =3D dev_get_priv(dev); > =20 > @@ -525,5 +525,5 @@ U_BOOT_DRIVER(aspeed_ast2500_scu) =3D { > .priv_auto_alloc_size =3D sizeof(struct ast2500_clk_priv), > .ops =3D &ast2500_clk_ops, > .bind =3D ast2500_clk_bind, > - .probe =3D ast2500_clk_probe, > + .ofdata_to_platdata =3D ast2500_clk_ofdata_to_platdata, > }; >=20