From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Gibson Subject: Re: A question about generated phandle during dtb=>dts conversion Date: Wed, 3 Nov 2021 13:34:07 +1100 Message-ID: References: <005e01d7cfc8$8034c5f0$809e51d0$@etri.re.kr> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="8Z03WLM2fFPGlwW2" Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1635912199; bh=PjFwfZ8mBV3AFfs2KTNuo7VsxWuFTweYlo3iZ2OxVFc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JoZVRmbYDrwYU5hMhK0s4Lk6G33d7XGeWpr1IL+rDKtJXELM/vk5CuJxHgS5Ndgtz w+Re75CM2AeANpa6elrVaQflk6QocF7IlVwG9ENDhCa1MIii5wI2YY4IpR3VuNeWC1 zaudamwO0X+KhpP1zTXuIc5YzSowQg3ApZrtqEI0= Content-Disposition: inline In-Reply-To: <005e01d7cfc8$8034c5f0$809e51d0$@etri.re.kr> List-ID: To: Chan Kim Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org --8Z03WLM2fFPGlwW2 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Nov 02, 2021 at 06:03:27PM +0900, Chan Kim wrote: > Hello, all > I extracted a dtb file from qemu execution (arm virt machine) and convert= ed > the dtb file to dts file using dtc. > But for some node that is referenced by other nodes, the phandle is > generated like =93phandle =3D <0x8000>=94 as shown below. Note that the value is generated by qemu and is in the dtb. It's not generated by dtc during decompilation. > apb-pclk { > =A0=A0=A0=A0=A0=A0=A0 phandle =3D <0x8000>; > =A0=A0=A0=A0=A0=A0=A0 clock-output-names =3D "clk24mhz"; > =A0=A0=A0=A0=A0=A0=A0 clock-frequency =3D <0x16e3600>; > =A0=A0=A0=A0=A0=A0=A0 #clock-cells =3D <0x00>; > =A0=A0=A0=A0=A0=A0=A0 compatible =3D "fixed-clock"; > =A0=A0=A0 }; >=20 > And another node is using this phandle like this. (the clocks is the phan= dle > for the apb-pclk above.) >=20 > pl061@9030000 { > =A0=A0=A0=A0=A0=A0=A0 phandle =3D <0x8003>; > =A0=A0=A0=A0=A0=A0=A0 clock-names =3D "apb_pclk"; > =A0=A0=A0=A0=A0=A0=A0 clocks =3D <0x8000>; > =A0=A0=A0=A0=A0=A0=A0 interrupts =3D <0x00 0x07 0x04>; > =A0=A0=A0=A0=A0=A0=A0 gpio-controller; > =A0=A0=A0=A0=A0=A0=A0 #gpio-cells =3D <0x02>; > =A0=A0=A0=A0=A0=A0=A0 compatible =3D "arm,pl061\0arm,primecell"; > =A0=A0=A0=A0=A0=A0=A0 reg =3D <0x00 0x9030000 0x00 0x1000>; > =A0=A0=A0 }; >=20 > When I convert the dts back to the dtb, dtc doesn=92t understand the phan= dle > and complains that it is not a phandle referenece. >=20 > dts.dts:276.3-21: Warning (clocks_property): /pl061@9030000:clocks: cell 0 > is not a phandle reference >=20 > I=92ve checked event with this warning, the phandle reference is being > preserved through out the procedure. > So, if I want to extract a dtb and convert it to dts, edit some and conve= rt > it back to dtb, how can I prevent this kind of phandle warning?=20 > And why doesn't dtc add labels to the referenced nodes and let other nodes > use that label as phandle? The short answer is because dtc doesn't know it's a phandle. dtb is not a self-describing format - the properties are just bytestrings, and you need to know what you're expecting in there in order to decode them (that's what dt bindings give you). So the only way that dtc could know that those 4 bytes in the 'clocks' property are actually a phandle is by specifically knowing about the "clocks" property. dtc has *some* knowledge of specific properties in the checks, but it's far from complete (and complete knowledge of the bindings is pretty much out of scope for dtc). But.. for the normal case of writing a dts file directly, it's useful to get a warning if you don't use a reference somewhere you probably should (anywhere that's a phandle), so dtc does check that. So, I think basically in just the same way that you might expect generated or decompiled code to be rather messy and generate compiler warnings, so a decompiled dts might have messy things and generate warnings. You can switch off the warnings explicitly if you need (-Wno-clocks_property in this case). --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --8Z03WLM2fFPGlwW2 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEdfRlhq5hpmzETofcbDjKyiDZs5IFAmGB9R0ACgkQbDjKyiDZ s5ICMhAAovkcPWWfD11BUbffHEHZvzEnV9lW+AhX+rW4fL3LRMPgJ5VZmumSYor3 8KwPlCJU5knsQevGS5WuAUkmB1TYj1iPF8Rj9yycex9Ss8cHjwZJGVczM7KZwD0t 89QgWEWz8dJh63vzQR6xbaASlb0YBiqup74yh9w7qusK59j2md/2z1/mhVm2WaN4 KQJDkJcowlWkxL3j8U3//y0ZEXRifA7Mu5eqd7011QkBUZQxDBTWWhQAXZtIYMhk AEu12FE9DUZ4OK+JtXI2s232Mx1pfzzMyX2Rw71fs4NnUasGMAz9oHa4NaqYRaJa HJubv9yq86nRDgeUpDB3yz9gdLNSRnkLsSGrM+71xHU9nVshG0z/6fyXGsF86G80 RW0zU2pDbLTBRWHqsZWYwBl7CJd7xIQP1AsH2jb6VHtWoJYYhd15vE3AT5rEBrix ZWDEmCFmiPd7OBrOkW0jyz1JPEz2XtkScvLc4Lf7tZvmr1xaFhBoDW/YNYY/HKZ4 BDd4KzA7S8BRj80IGbDGIBEScLXK0ZQF8VQzv4qm51tC7ZRxIX4uM0lEM58Egz7p 2/8fpI0ICqJfBoPhaMLgaGaiYGUXi3kbV6DJ+tN9zni8eSbaLPj/RV/shvfFBTF8 Ar6ma6eFR5HgCFDrYuauzV2vDXHcSAGiFgU/i7famU6oeFjrfps= =5CCL -----END PGP SIGNATURE----- --8Z03WLM2fFPGlwW2--