Skip to contentSkip to conversation

dt-bindings: Only show unique unit address warning for enabled nodes

PATCH Applied Sam Protsenko 2 participants 4 messages Dec 3, 2021 – Dec 7, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dt-bindings: Only show unique unit address warning for enabled nodes

There are valid cases when two nodes can have the same address. For example, in Exynos SoCs there is USI IP-core, which might be configured to provide UART, SPI or I2C block, all of which having the same base register address. But only one can be enabled at a time. That looks like this:

    usi@138200c0 {
        serial@13820000 {
            status = "okay";
        };

        i2c@13820000 {
            status = "disabled";
        };
    };

When running "make dt_binding_check", it reports next warning:

    Warning (unique_unit_address):
    /example-0/usi@138200c0/serial@13820000:
    duplicate unit-address (also used in node
    /example-0/usi@138200c0/i2c@13820000)

Disable "unique_unit_address" in DTC_FLAGS to suppress warnings like that, but enable "unique_unit_address_if_enabled" warning, so that dtc still reports a warning when two enabled nodes are having the same address.

---
 Documentation/devicetree/bindings/Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/Makefile +3 -1
index c9abfbe3f0aa..41c555181b6f 100644
@@ -65,7 +65,9 @@ DT_DOCS = $(patsubst $(srctree)/%,%,$(shell $(find_all_cmd)))
 override DTC_FLAGS := \
 	-Wno-avoid_unnecessary_addr_size \
 	-Wno-graph_child_address \
-	-Wno-interrupt_provider
+	-Wno-interrupt_provider \
+	-Wno-unique_unit_address \
+	-Wunique_unit_address_if_enabled
 
 # Disable undocumented compatible checks until warning free
 override DT_CHECKER_FLAGS ?=
Signature · 1 line
2.30.2
maintainer
#1 lore raw
Quoted 23 lines · Sam Protsenko

There are valid cases when two nodes can have the same address. For example, in Exynos SoCs there is USI IP-core, which might be configured to provide UART, SPI or I2C block, all of which having the same base register address. But only one can be enabled at a time. That looks like this:

    usi@138200c0 {
        serial@13820000 {
            status = "okay";
        };

        i2c@13820000 {
            status = "disabled";
        };
    };

When running "make dt_binding_check", it reports next warning:

    Warning (unique_unit_address):
    /example-0/usi@138200c0/serial@13820000:
    duplicate unit-address (also used in node
    /example-0/usi@138200c0/i2c@13820000)
Quoted 4 lines

Disable "unique_unit_address" in DTC_FLAGS to suppress warnings like that, but enable "unique_unit_address_if_enabled" warning, so that dtc still reports a warning when two enabled nodes are having the same address.

Presumably you have a dts file needing the same thing, so I'll be expecting a patch for that too. That's in scripts/Makefile.lib BTW.

Quoted 27 lines
---
 Documentation/devicetree/bindings/Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/Makefile +3 -1
index c9abfbe3f0aa..41c555181b6f 100644
@@ -65,7 +65,9 @@ DT_DOCS = $(patsubst $(srctree)/%,%,$(shell $(find_all_cmd)))
 override DTC_FLAGS := \
 	-Wno-avoid_unnecessary_addr_size \
 	-Wno-graph_child_address \
-	-Wno-interrupt_provider
+	-Wno-interrupt_provider \
+	-Wno-unique_unit_address \
+	-Wunique_unit_address_if_enabled
 
 # Disable undocumented compatible checks until warning free
 override DT_CHECKER_FLAGS ?=
Signature · 1 line
2.30.2
#2 lore raw
Quoted 25 lines · Rob Herring
Quoted 23 lines · Sam Protsenko

There are valid cases when two nodes can have the same address. For example, in Exynos SoCs there is USI IP-core, which might be configured to provide UART, SPI or I2C block, all of which having the same base register address. But only one can be enabled at a time. That looks like this:

    usi@138200c0 {
        serial@13820000 {
            status = "okay";
        };

        i2c@13820000 {
            status = "disabled";
        };
    };

When running "make dt_binding_check", it reports next warning:

    Warning (unique_unit_address):
    /example-0/usi@138200c0/serial@13820000:
    duplicate unit-address (also used in node
    /example-0/usi@138200c0/i2c@13820000)
Quoted 8 lines
Quoted 4 lines

Disable "unique_unit_address" in DTC_FLAGS to suppress warnings like that, but enable "unique_unit_address_if_enabled" warning, so that dtc still reports a warning when two enabled nodes are having the same address.

Presumably you have a dts file needing the same thing, so I'll be expecting a patch for that too. That's in scripts/Makefile.lib BTW.

'-Wno-unique_unit_address' is already in scripts/Makefile.lib, and when I add '-Wunique_unit_address_if_enabled' there, "make dtbs_check" reports a lot of warnings (for ARCH=arm64 at least). Among obvious bugs found, there are some cases like this:

        qfprom@784000 {
            compatible = "qcom,qfprom";
            reg = <0 0x00784000 0 0x8ff>;
            #address-cells = <1>;
            #size-cells = <1>;

            qusb2p_hstx_trim: hstx-trim-primary@1eb {
                reg = <0x1eb 0x1>;
                bits = <1 4>;
            };

            qusb2s_hstx_trim: hstx-trim-secondary@1eb {
                reg = <0x1eb 0x2>;
                bits = <6 4>;
            };
        };

where "dtbs_check" doesn't like duplicated "reg = <0x1eb 0x2>;" line.

I'll send the patch soon. Just want you to be on the same page about side effects from that, because I'm not completely sure it's ok.

Quoted 27 lines
Quoted 27 lines
---
 Documentation/devicetree/bindings/Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/Makefile +3 -2
index c9abfbe3f0aa..41c555181b6f 100644
@@ -65,7 +65,9 @@ DT_DOCS = $(patsubst $(srctree)/%,%,$(shell $(find_all_cmd)))
 override DTC_FLAGS := \
      -Wno-avoid_unnecessary_addr_size \
      -Wno-graph_child_address \
-     -Wno-interrupt_provider
+     -Wno-interrupt_provider \
+     -Wno-unique_unit_address \
+     -Wunique_unit_address_if_enabled
 
 # Disable undocumented compatible checks until warning free
 override DT_CHECKER_FLAGS ?=
--

2.30.2

maintainer Applied
#3 lore raw
In reply to Sam Protsenko
Quoted 28 lines · Sam Protsenko

There are valid cases when two nodes can have the same address. For example, in Exynos SoCs there is USI IP-core, which might be configured to provide UART, SPI or I2C block, all of which having the same base register address. But only one can be enabled at a time. That looks like this:

    usi@138200c0 {
        serial@13820000 {
            status = "okay";
        };

        i2c@13820000 {
            status = "disabled";
        };
    };

When running "make dt_binding_check", it reports next warning:

    Warning (unique_unit_address):
    /example-0/usi@138200c0/serial@13820000:
    duplicate unit-address (also used in node
    /example-0/usi@138200c0/i2c@13820000)

Disable "unique_unit_address" in DTC_FLAGS to suppress warnings like that, but enable "unique_unit_address_if_enabled" warning, so that dtc still reports a warning when two enabled nodes are having the same address.

Quoted 7 lines
---
 Documentation/devicetree/bindings/Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Applied, thanks!