* [PATCH] dtc: Demote graph_child_address checks to W=2
@ 2025-07-02 8:50 Niklas Söderlund
2025-07-02 13:33 ` Rob Herring
0 siblings, 1 reply; 3+ messages in thread
From: Niklas Söderlund @ 2025-07-02 8:50 UTC (permalink / raw)
To: Rob Herring, Saravana Kannan, Geert Uytterhoeven, devicetree
Cc: linux-renesas-soc, Niklas Söderlund
The dtc graph_child_address check can't distinguish between bindings
where there can only be a single endpoint, and cases where there can be
multiple endpoints.
In cases where the bindings allow for multiple endpoints but only one is
described false warnings about unnecessary #address-cells/#size-cells
can be generated, but only if the endpoint described have an address of
0 (A), for single endpoints with a non-zero address (B) no warnings are
generated.
A)
ports {
#address-cells = <1>;
#size-cells = <0>;
port@0 {
#address-cells = <1>;
#size-cells = <0>;
sourceA: endpoint@0 {
reg = <0>
};
};
};
B)
ports {
#address-cells = <1>;
#size-cells = <0>;
port@0 {
#address-cells = <1>;
#size-cells = <0>;
sourceB: endpoint@1 {
reg = <1>
};
};
};
The false warnings, and especially the confusion on why it only triggers
for single endpoints where the address is 0, leads to confused user and
reports of issues with DTS files. To try and mitigate this behavior by
demote the check to W=2 and document the possibility for false warnings
in the check itself.
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
Hi,
This solution was lightly hinted at [1] by Rob and I have ran with it
for a while locally and I'm happy with the result. Lets see what the
rest of you think.
1. https://lore.kernel.org/all/20250109150327.GA3352888-robh@kernel.org/
---
scripts/Makefile.dtbs | 6 +++---
scripts/dtc/checks.c | 5 +++++
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/scripts/Makefile.dtbs b/scripts/Makefile.dtbs
index 8d56c0815f33..fd8316bcf6c9 100644
--- a/scripts/Makefile.dtbs
+++ b/scripts/Makefile.dtbs
@@ -89,21 +89,21 @@ $(call multi_depend, $(multi-dtb-y), .dtb, -dtbs)
# ---------------------------------------------------------------------------
DTC ?= $(objtree)/scripts/dtc/dtc
-DTC_FLAGS += -Wno-unique_unit_address
+DTC_FLAGS += -Wno-graph_child_address -Wno-unique_unit_address
# Disable noisy checks by default
ifeq ($(findstring 1,$(KBUILD_EXTRA_WARN)),)
DTC_FLAGS += -Wno-unit_address_vs_reg \
-Wno-avoid_unnecessary_addr_size \
-Wno-alias_paths \
- -Wno-graph_child_address \
-Wno-simple_bus_reg
else
DTC_FLAGS += -Wunique_unit_address_if_enabled
endif
ifneq ($(findstring 2,$(KBUILD_EXTRA_WARN)),)
-DTC_FLAGS += -Wnode_name_chars_strict \
+DTC_FLAGS += -Wgraph_child_address \
+ -Wnode_name_chars_strict \
-Wproperty_name_chars_strict \
-Wunique_unit_address
endif
diff --git a/scripts/dtc/checks.c b/scripts/dtc/checks.c
index 6e06aeab5503..103bd4b40f0a 100644
--- a/scripts/dtc/checks.c
+++ b/scripts/dtc/checks.c
@@ -1906,6 +1906,11 @@ static void check_graph_child_address(struct check *c, struct dt_info *dti,
cnt++;
}
+ /*
+ * This check can produce false warnings if the bindings allow for more
+ * then one endpoint in the node but only one is present and it has a
+ * unit address of zero.
+ */
if (cnt == 1 && node->addr_cells != -1)
FAIL(c, dti, node, "graph node has single child node '%s', #address-cells/#size-cells are not necessary",
node->children->name);
--
2.50.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] dtc: Demote graph_child_address checks to W=2
2025-07-02 8:50 [PATCH] dtc: Demote graph_child_address checks to W=2 Niklas Söderlund
@ 2025-07-02 13:33 ` Rob Herring
2025-07-02 13:42 ` Niklas Söderlund
0 siblings, 1 reply; 3+ messages in thread
From: Rob Herring @ 2025-07-02 13:33 UTC (permalink / raw)
To: Niklas Söderlund
Cc: Saravana Kannan, Geert Uytterhoeven, devicetree,
linux-renesas-soc
On Wed, Jul 2, 2025 at 3:50 AM Niklas Söderlund
<niklas.soderlund+renesas@ragnatech.se> wrote:
>
> The dtc graph_child_address check can't distinguish between bindings
> where there can only be a single endpoint, and cases where there can be
> multiple endpoints.
>
> In cases where the bindings allow for multiple endpoints but only one is
> described false warnings about unnecessary #address-cells/#size-cells
> can be generated, but only if the endpoint described have an address of
> 0 (A), for single endpoints with a non-zero address (B) no warnings are
> generated.
>
> A)
> ports {
> #address-cells = <1>;
> #size-cells = <0>;
>
> port@0 {
> #address-cells = <1>;
> #size-cells = <0>;
>
> sourceA: endpoint@0 {
> reg = <0>
> };
> };
> };
>
> B)
> ports {
> #address-cells = <1>;
> #size-cells = <0>;
>
> port@0 {
> #address-cells = <1>;
> #size-cells = <0>;
>
> sourceB: endpoint@1 {
> reg = <1>
> };
> };
> };
>
> The false warnings, and especially the confusion on why it only triggers
> for single endpoints where the address is 0, leads to confused user and
> reports of issues with DTS files. To try and mitigate this behavior by
> demote the check to W=2 and document the possibility for false warnings
> in the check itself.
>
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> ---
> Hi,
>
> This solution was lightly hinted at [1] by Rob and I have ran with it
> for a while locally and I'm happy with the result. Lets see what the
> rest of you think.
>
> 1. https://lore.kernel.org/all/20250109150327.GA3352888-robh@kernel.org/
> ---
> scripts/Makefile.dtbs | 6 +++---
> scripts/dtc/checks.c | 5 +++++
dtc changes have to go upstream first. I can drop this when applying.
Rob
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] dtc: Demote graph_child_address checks to W=2
2025-07-02 13:33 ` Rob Herring
@ 2025-07-02 13:42 ` Niklas Söderlund
0 siblings, 0 replies; 3+ messages in thread
From: Niklas Söderlund @ 2025-07-02 13:42 UTC (permalink / raw)
To: Rob Herring
Cc: Saravana Kannan, Geert Uytterhoeven, devicetree,
linux-renesas-soc
Hi Rob,
Thanks for your feedback.
On 2025-07-02 08:33:10 -0500, Rob Herring wrote:
> On Wed, Jul 2, 2025 at 3:50 AM Niklas Söderlund
> <niklas.soderlund+renesas@ragnatech.se> wrote:
> >
> > The dtc graph_child_address check can't distinguish between bindings
> > where there can only be a single endpoint, and cases where there can be
> > multiple endpoints.
> >
> > In cases where the bindings allow for multiple endpoints but only one is
> > described false warnings about unnecessary #address-cells/#size-cells
> > can be generated, but only if the endpoint described have an address of
> > 0 (A), for single endpoints with a non-zero address (B) no warnings are
> > generated.
> >
> > A)
> > ports {
> > #address-cells = <1>;
> > #size-cells = <0>;
> >
> > port@0 {
> > #address-cells = <1>;
> > #size-cells = <0>;
> >
> > sourceA: endpoint@0 {
> > reg = <0>
> > };
> > };
> > };
> >
> > B)
> > ports {
> > #address-cells = <1>;
> > #size-cells = <0>;
> >
> > port@0 {
> > #address-cells = <1>;
> > #size-cells = <0>;
> >
> > sourceB: endpoint@1 {
> > reg = <1>
> > };
> > };
> > };
> >
> > The false warnings, and especially the confusion on why it only triggers
> > for single endpoints where the address is 0, leads to confused user and
> > reports of issues with DTS files. To try and mitigate this behavior by
> > demote the check to W=2 and document the possibility for false warnings
> > in the check itself.
> >
> > Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> > ---
> > Hi,
> >
> > This solution was lightly hinted at [1] by Rob and I have ran with it
> > for a while locally and I'm happy with the result. Lets see what the
> > rest of you think.
> >
> > 1. https://lore.kernel.org/all/20250109150327.GA3352888-robh@kernel.org/
> > ---
> > scripts/Makefile.dtbs | 6 +++---
> > scripts/dtc/checks.c | 5 +++++
>
> dtc changes have to go upstream first. I can drop this when applying.
Ohh I see now there is a separate tree for dtc. If you agree with the
direction of this work I can submit a patch for this to
devicetree-compiler@vger.kernel.org. Sorry for not realizing this.
If you like please drop this when applying, and please drop the last
half paragraph from the commit message "and document the possibility for
false warnings in the check itself".
>
> Rob
--
Kind Regards,
Niklas Söderlund
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-07-02 13:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-02 8:50 [PATCH] dtc: Demote graph_child_address checks to W=2 Niklas Söderlund
2025-07-02 13:33 ` Rob Herring
2025-07-02 13:42 ` Niklas Söderlund
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).