* [PATCH] checks: Avoid warnings for reg override in __overlay__
@ 2026-06-17 20:44 Brian Norris
2026-06-17 22:54 ` Rob Herring
0 siblings, 1 reply; 4+ messages in thread
From: Brian Norris @ 2026-06-17 20:44 UTC (permalink / raw)
To: devicetree-compiler; +Cc: Brian Norris
A simple overlay case can hit a number of false warnings just because it
provides a 'reg' property [1]:
* avoid_default_addr_size: the generated fragment@0 node is an
artificial node, where #address-cells/#size-cells can't exist.
* 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.)
* unit_address_vs_reg: we don't know the real node name here. (It's not
actually going to be "__overlay__".)
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.
[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 == 2, #size-cells == 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 'avoid_default_addr_size'
<stdout>: Warning (unique_unit_address): Failed prerequisite 'avoid_default_addr_size'
/dts-v1/;
/ {
fragment@0 {
target = <&foo>;
__overlay__ {
reg = <0x00>;
};
};
__fixups__ {
foo = "/fragment@0:target:0";
};
};
Signed-off-by: Brian Norris <briannorris@chromium.org>
---
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
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 = get_unitname(node);
struct property *prop = get_property(node, "reg");
- if (get_subnode(node, "__overlay__")) {
- /* HACK: Overlay fragments are a special case */
- return;
+ /* HACK: Overlay fragments are a special case */
+ if (dti->dtsflags & DTSF_PLUGIN) {
+ if (get_subnode(node, "__overlay__"))
+ return;
+ if (streq(node->name, "__overlay__"))
+ return;
}
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 */
+ /* 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 check *c, struct dt_info *dti,
if (!node->parent)
return; /* Ignore root node */
+ /* Overlay nodes are special */
+ if ((dti->dtsflags & DTSF_PLUGIN) && streq(node->name, "__overlay__"))
+ return;
+
reg = get_property(node, "reg");
ranges = get_property(node, "ranges");
diff --git a/tests/overlay-reg-override.dtso b/tests/overlay-reg-override.dtso
new file mode 100644
index 000000000000..7e5e13883b51
--- /dev/null
+++ b/tests/overlay-reg-override.dtso
@@ -0,0 +1,6 @@
+/dts-v1/;
+/plugin/;
+
+&foo {
+ reg = <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_address_vs_reg avoid_default_addr_size
check_tests "$SRCDIR/bad-phandle-cells.dts" interrupts_extended_property
check_tests "$SRCDIR/bad-gpio.dts" gpios_property
check_tests "$SRCDIR/good-gpio.dts" -n gpios_property
--
2.54.0.1189.g8c84645362-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] checks: Avoid warnings for reg override in __overlay__
2026-06-17 20:44 [PATCH] checks: Avoid warnings for reg override in __overlay__ Brian Norris
@ 2026-06-17 22:54 ` Rob Herring
2026-06-17 23:35 ` Brian Norris
0 siblings, 1 reply; 4+ messages in thread
From: Rob Herring @ 2026-06-17 22:54 UTC (permalink / raw)
To: Brian Norris; +Cc: devicetree-compiler
On Wed, Jun 17, 2026 at 3:44 PM Brian Norris <briannorris@chromium.org> wrote:
>
> A simple overlay case can hit a number of false warnings just because it
> provides a 'reg' property [1]:
>
> * avoid_default_addr_size: the generated fragment@0 node is an
> artificial node, where #address-cells/#size-cells can't exist.
>
> * 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.)
>
> * unit_address_vs_reg: we don't know the real node name here. (It's not
> actually going to be "__overlay__".)
>
> 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.
>
> [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 == 2, #size-cells == 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 'avoid_default_addr_size'
> <stdout>: Warning (unique_unit_address): Failed prerequisite 'avoid_default_addr_size'
> /dts-v1/;
>
> / {
>
> fragment@0 {
> target = <&foo>;
>
> __overlay__ {
> reg = <0x00>;
I would argue (and did the last time this came up IIRC) the overlay
should target the parent node instead and then you can put in
#address-cells and #size-cells in the overlay to make it pass checks
(and make 'reg' parsable without applying the overlay).
Rob
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] checks: Avoid warnings for reg override in __overlay__
2026-06-17 22:54 ` Rob Herring
@ 2026-06-17 23:35 ` Brian Norris
2026-06-18 2:58 ` Rob Herring
0 siblings, 1 reply; 4+ messages in thread
From: Brian Norris @ 2026-06-17 23:35 UTC (permalink / raw)
To: Rob Herring; +Cc: devicetree-compiler
Hi Rob,
On Wed, Jun 17, 2026 at 05:54:42PM -0500, Rob Herring wrote:
> I would argue (and did the last time this came up IIRC) the overlay
I gave a quick look for prior art, but didn't go far enough. I see this
was a similar conversation:
[PATCH v2] checks: Suppress warnings on overlay fragments
https://lore.kernel.org/all/20230308091539.11178-1-qun-wei.lin@mediatek.com/
I don't think it had a satisfying conclusion though.
> should target the parent node instead and then you can put in
> #address-cells and #size-cells in the overlay to make it pass checks
> (and make 'reg' parsable without applying the overlay).
This implies we can't actually target the appropriate node via phandle
any more, and so we lose the ergonomics that phandles provide. Where
previouly an overlay could be resilient to node renaming and other sorts
of incompatibilities between a dtb and a dtbo (the overlay wouldn't
apply if &foo isn't found), now we'd have to open-code the node name and
maybe even its parent node name in the overlay. If either of those were
wrong ... we wouldn't notice at all, unless there's an obvious
functional breakage as a result.
I acknowledge that it's difficult to parse and validate dtbos when they
are low on context. But I don't see why we should emit false warnings
for the possibly-correct, and more ergnomic approach.
Brian
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] checks: Avoid warnings for reg override in __overlay__
2026-06-17 23:35 ` Brian Norris
@ 2026-06-18 2:58 ` Rob Herring
0 siblings, 0 replies; 4+ messages in thread
From: Rob Herring @ 2026-06-18 2:58 UTC (permalink / raw)
To: Brian Norris; +Cc: devicetree-compiler
On Wed, Jun 17, 2026 at 6:35 PM Brian Norris <briannorris@chromium.org> wrote:
>
> Hi Rob,
>
> On Wed, Jun 17, 2026 at 05:54:42PM -0500, Rob Herring wrote:
> > I would argue (and did the last time this came up IIRC) the overlay
>
> I gave a quick look for prior art, but didn't go far enough. I see this
> was a similar conversation:
>
> [PATCH v2] checks: Suppress warnings on overlay fragments
> https://lore.kernel.org/all/20230308091539.11178-1-qun-wei.lin@mediatek.com/
>
> I don't think it had a satisfying conclusion though.
>
> > should target the parent node instead and then you can put in
> > #address-cells and #size-cells in the overlay to make it pass checks
> > (and make 'reg' parsable without applying the overlay).
>
> This implies we can't actually target the appropriate node via phandle
> any more, and so we lose the ergonomics that phandles provide. Where
> previouly an overlay could be resilient to node renaming and other sorts
> of incompatibilities between a dtb and a dtbo (the overlay wouldn't
> apply if &foo isn't found), now we'd have to open-code the node name and
> maybe even its parent node name in the overlay. If either of those were
> wrong ... we wouldn't notice at all, unless there's an obvious
> functional breakage as a result.
Why can't we use the parent node phandle?
> I acknowledge that it's difficult to parse and validate dtbos when they
> are low on context. But I don't see why we should emit false warnings
> for the possibly-correct, and more ergnomic approach.
It just feels to me like we're disabling checks one by one on
overlays. And it's not just dtc checks we have to skip, but schema
checks too. We somewhat mitigate that by requiring (requesting really,
because it gets skipped) overlays to be applied to *something* at
build time, but that's the kernel tree which isn't everything.
I don't care too much other than we validate everything in overlays somehow.
Rob
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-06-18 2:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-17 20:44 [PATCH] checks: Avoid warnings for reg override in __overlay__ Brian Norris
2026-06-17 22:54 ` Rob Herring
2026-06-17 23:35 ` Brian Norris
2026-06-18 2:58 ` Rob Herring
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.