Re: [PATCH] checks: Avoid warnings for reg override in __overlay__
David Gibson <[email protected]> Thu, 18 Jun 2026 18:25:03 +1000
| Newsgroups | org.kernel.vger.devicetree-compiler |
|---|---|
| Message-ID | <ajOrX76nVn7mN5am@zatzit> |
--QkkMauYhCtgSPzHm
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Wed, Jun 17, 2026 at 01:44:01PM -0700, Brian Norris wrote:
> A simple overlay case can hit a number of false warnings just because it
> provides a 'reg' property [1]:
>=20
> * avoid_default_addr_size: the generated fragment@0 node is an
> artificial node, where #address-cells/#size-cells can't exist.
>=20
> * reg_format: we're assuming the wrong/default #address-cells here, so
> the analysis is wrong. (We don't know how many cells should be in
> this 'reg', in isolation.)
>=20
> * unit_address_vs_reg: we don't know the real node name here. (It's not
> actually going to be "__overlay__".)
>=20
> All these cannot be checked by the overlay compiler in isolation.
> Suppress them when we identify we're running in plugin mode, and we're
> likely looking at a generated __overlay__ hierarchy that can't be
> analyzed in this way.
Yeah, the check system was designed before runtime overlays and
doesn't work well with them. Specifically there's not distinction
between checks that can be applied locally (just looking at one node),
checks that can be applied to a subtree (without looking outside the
subtree) and checks which require a full tree including a root node.
Just suppressing checks ad-hoc like this is not a great solution.
I had a loose plan for tackling this, amongst some other problems, by
making the assembly of a complete tree an explicitly separate step in
dtc from parsing each fragment (here referring to compile time dts
fragments).
The idea was that each of the (compile time) overlays would be
separately parsed into a temporary tree, rather than assembling them
together into a single tree as we go. Then we'd have a pass applying
those checks that make sense for subtrees separately to each
subtree/overlay.
Then there would be a separate assembly stage. For full trees that
would essentially apply each overlay. For overlay output it would add
the fragment@XX/__overlay__ encoding. Afterwards there would be
another checks pass for the assembled tree - that would have a
different set of checks from the individual fragment tests, and
different ones for complete trees versus overlay output.
Unfortunately, I will not realistically ever get to this.
>=20
> [1]
> $ dtc -I dts -O dts tests/overlay-reg-override.dtso
> tests/overlay-reg-override.dtso:5.2-14: Warning (reg_format): /fragment@0=
/__overlay__:reg: property has invalid length (4 bytes) (#address-cells =3D=
=3D 2, #size-cells =3D=3D 1)
> tests/overlay-reg-override.dtso:4.6-6.3: Warning (unit_address_vs_reg): /=
fragment@0/__overlay__: node has a reg or ranges property, but no unit name
> <stdout>: Warning (pci_device_reg): Failed prerequisite 'reg_format'
> <stdout>: Warning (pci_device_bus_num): Failed prerequisite 'reg_format'
> <stdout>: Warning (simple_bus_reg): Failed prerequisite 'reg_format'
> <stdout>: Warning (i2c_bus_reg): Failed prerequisite 'reg_format'
> <stdout>: Warning (spi_bus_reg): Failed prerequisite 'reg_format'
> tests/overlay-reg-override.dtso:4.6-6.3: Warning (avoid_default_addr_size=
): /fragment@0/__overlay__: Relying on default #address-cells value
> tests/overlay-reg-override.dtso:4.6-6.3: Warning (avoid_default_addr_size=
): /fragment@0/__overlay__: Relying on default #size-cells value
> <stdout>: Warning (avoid_unnecessary_addr_size): Failed prerequisite 'avo=
id_default_addr_size'
> <stdout>: Warning (unique_unit_address): Failed prerequisite 'avoid_defau=
lt_addr_size'
> /dts-v1/;
>=20
> / {
>=20
> fragment@0 {
> target =3D <&foo>;
>=20
> __overlay__ {
> reg =3D <0x00>;
> };
> };
>=20
> __fixups__ {
> foo =3D "/fragment@0:target:0";
> };
> };
>=20
> Signed-off-by: Brian Norris <[email protected]>
> ---
> checks.c | 17 ++++++++++++++---
> tests/overlay-reg-override.dtso | 6 ++++++
> tests/run_tests.sh | 1 +
> 3 files changed, 21 insertions(+), 3 deletions(-)
> create mode 100644 tests/overlay-reg-override.dtso
>=20
> diff --git a/checks.c b/checks.c
> index a6037ed08000..dd6824dce6ea 100644
> --- a/checks.c
> +++ b/checks.c
> @@ -368,9 +368,12 @@ static void check_unit_address_vs_reg(struct check *=
c, struct dt_info *dti,
> const char *unitname =3D get_unitname(node);
> struct property *prop =3D get_property(node, "reg");
> =20
> - if (get_subnode(node, "__overlay__")) {
> - /* HACK: Overlay fragments are a special case */
> - return;
> + /* HACK: Overlay fragments are a special case */
Yeah... it's definitely a hack.
> + if (dti->dtsflags & DTSF_PLUGIN) {
> + if (get_subnode(node, "__overlay__"))
> + return;
> + if (streq(node->name, "__overlay__"))
> + return;
> }
> =20
> if (!prop) {
> @@ -774,6 +777,10 @@ static void check_reg_format(struct check *c, struct=
dt_info *dti,
> if (!prop)
> return; /* No "reg", that's fine */
> =20
> + /* Overlay nodes are special */
> + if ((dti->dtsflags & DTSF_PLUGIN) && streq(node->name, "__overlay__"))
> + return;
> +
> if (!node->parent) {
> FAIL(c, dti, node, "Root node has a \"reg\" property");
> return;
> @@ -1210,6 +1217,10 @@ static void check_avoid_default_addr_size(struct c=
heck *c, struct dt_info *dti,
> if (!node->parent)
> return; /* Ignore root node */
> =20
> + /* Overlay nodes are special */
> + if ((dti->dtsflags & DTSF_PLUGIN) && streq(node->name, "__overlay__"))
> + return;
> +
> reg =3D get_property(node, "reg");
> ranges =3D get_property(node, "ranges");
> =20
> diff --git a/tests/overlay-reg-override.dtso b/tests/overlay-reg-override=
=2Edtso
> new file mode 100644
> index 000000000000..7e5e13883b51
> --- /dev/null
> +++ b/tests/overlay-reg-override.dtso
> @@ -0,0 +1,6 @@
> +/dts-v1/;
> +/plugin/;
> +
> +&foo {
> + reg =3D <0x0>;
> +};
> diff --git a/tests/run_tests.sh b/tests/run_tests.sh
> index 842b543059bb..8f3265afa5cc 100755
> --- a/tests/run_tests.sh
> +++ b/tests/run_tests.sh
> @@ -752,6 +752,7 @@ dtc_tests () {
> check_tests "$SRCDIR/unit-addr-leading-0x.dts" unit_address_format
> check_tests "$SRCDIR/unit-addr-leading-0s.dts" unit_address_format
> check_tests "$SRCDIR/unit-addr-unique.dts" unique_unit_address
> + check_tests "$SRCDIR/overlay-reg-override.dtso" -n reg_format unit_a=
ddress_vs_reg avoid_default_addr_size
> check_tests "$SRCDIR/bad-phandle-cells.dts" interrupts_extended_prop=
erty
> check_tests "$SRCDIR/bad-gpio.dts" gpios_property
> check_tests "$SRCDIR/good-gpio.dts" -n gpios_property
> --=20
> 2.54.0.1189.g8c84645362-goog
>=20
>=20
--=20
David Gibson (he or they) | 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
--QkkMauYhCtgSPzHm
Content-Type: application/pgp-signature; name=signature.asc
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmozq1oACgkQzQJF27ox
2GdjsA/+OFtTiV9v2s9X2mzTfnucwRD70jRiZQBnK0FVKOLmvryV4KPQHzi7JEr4
3P88ZZ/THmTiDCCO9k7DRJU3a0CL3US3wVkOL/s4kCWQzOADn9z4KoOy7oPsKe91
9oAHHrq4Gpoqr44LTKfd4vO1swReQ82B7+BEwG7b3rqlCnOZdLQcUj4bvnTGGV/B
YGVe5dPr/ZfrJKcdBs9kqJAs+yZE+MGJqdYpQyDR0XivzyGXKxi5ZlCDP4mD+aIh
qaF1t3+Brjo8flkkmAAnCTHr00ZIcrADGzZCQc9cZ5fhsNOwJDsR7wB3bikW+RBN
zoCC1MHuvDzOMECipV8v8+zo3kMMnb7Bqgw8QX6oH5xdCkSmN/pqJPB//x7oQuh4
tY2Zf6O/lPMB2fv+De3lBJZKemAeszTup2eSAzIrGEX16jcBv+svNyzpSfzKOXNX
oLqD2GvvqjdV3+O6JYsK+4xnijeZ6wQdEOxJ/CC+/RKwXQbXGWN2YrZMRurLDP5u
+mrV/vy2VMlXht2untKDxBnWQ/NC/FYL4l17pMnd03mo9lTRHlLusyue6S0ZIaAX
fYsuw9lke9X4AkoDfCxRT1wFZKIvZ6HS+IsGvW1IjPwT3TLncBRGDU/TlVDf0fsL
hoOHfe1oLvsF8yiUE2hGvq+fclobikuFMOJV/g0LxYdK4XuKNAs=
=Iej8
-----END PGP SIGNATURE-----
--QkkMauYhCtgSPzHm--