mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 15/15] Documentation: devicetree: codify extension of upstream DTS by phandles
Date: Thu, 18 Jun 2020 11:11:02 +0200	[thread overview]
Message-ID: <20200618091102.30150-16-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20200618091102.30150-1-a.fatoum@pengutronix.de>

Sync with the upstream device tree repository has been a common cause
for breakage in barebox. Often unnoticed:

* New bindings are merged upstream and device trees migrated, but
  barebox didn't yet have support
* Nodes are renamed upstream, but barebox still extends the old name,
  with duplicate nodes resulting

We can solve the second one by requiring dtc to give us errors when
paths we extend no longer exist. Document how to do so.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 Documentation/devicetree/index.rst | 41 ++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/Documentation/devicetree/index.rst b/Documentation/devicetree/index.rst
index 908652642b9a..62fa990032b3 100644
--- a/Documentation/devicetree/index.rst
+++ b/Documentation/devicetree/index.rst
@@ -31,6 +31,47 @@ device tree under ``dts/src/$ARCH`` with ``#include "$ARCH/board.dts"`` and
 then extends it with barebox-specifics like :ref:`barebox,state`,
 environment or boot-time device configuration.
 
+Device Tree probing largely happens via compatible properties with no special
+meaning to the node names themselves. It's thus paramount that any device tree
+nodes extended in the barebox device tree are referenced by a phandle, not by
+path, to avoid run-time breakage like this::
+
+  # Upstream dts/src/$ARCH/board.dts
+  / {
+  	leds {
+            led-red { /* formerly named red when the barebox DTS was written */
+            	/* ... */
+            };
+        };
+  };
+
+  # barebox arch/$ARCH/dts/board.dts
+  #include <$ARCH/board.dts>
+  / {
+  	leds {
+            red {
+                barebox,default-trigger = "heartbeat";
+            };
+        };
+  };
+
+In the prvious example, a device tree sync with upstream resulted in a regression
+as the former override became a new node with a single property without effect.
+
+Using phandles avoids this. When no phandle mapping the full path is defined
+upstream, the ``&{/path}`` syntax should be used instead, e.g.::
+
+  &{/leds/red} {
+      barebox,default-trigger = "heartbeat";
+  };
+
+This would lead to a compile error should the ``/leds/red`` path be renamed or
+removed. This also applies to uses of ``/delete-node/``.
+
+Only exception to this rule are well-known node names that are specified by
+the spec to be parsed by name. These are: ``chosen``, ``aliases`` and ``cpus``,
+but **not** ``memory``.
+
 Device Tree Compiler
 --------------------
 
-- 
2.27.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      parent reply	other threads:[~2020-06-18  9:11 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-18  9:10 [PATCH 00/15] ARM: dts: fix regressions from not using phandles Ahmad Fatoum
2020-06-18  9:10 ` [PATCH 01/15] ARM: i.MX50: fix renamed node reference Ahmad Fatoum
2020-06-18  9:10 ` [PATCH 02/15] ARM: dts: fix now duplicate memory nodes Ahmad Fatoum
2020-06-18  9:10 ` [PATCH 03/15] ARM: dts: align all applicable memory nodes with spec and convention Ahmad Fatoum
2020-06-18 13:59   ` Sascha Hauer
2020-06-18  9:10 ` [PATCH 04/15] ARM: vexpress: dts: fix barebox partitioning breakage Ahmad Fatoum
2020-06-18  9:10 ` [PATCH 05/15] ARM: at91: dts: extend, don't create anew, pinctrl node Ahmad Fatoum
2020-06-18  9:10 ` [PATCH 06/15] ARM: dts: reference nodes to extend by phandles instead Ahmad Fatoum
2020-06-18  9:10 ` [PATCH 07/15] ARM: i.MX7: warp: drop duplicate memory node Ahmad Fatoum
2020-06-18  9:10 ` [PATCH 08/15] ARM: mvebu: remove reference to non-existant node Ahmad Fatoum
2020-06-18  9:10 ` [PATCH 09/15] ARM: i.MX6UL: dts: remove defunct override of pico-hobbit memory node Ahmad Fatoum
2020-06-18  9:15   ` Michael Grzeschik
2020-06-18  9:10 ` [PATCH 10/15] ARM: layerscape: dts: combine fsl-ls1046a-rdb.dts aliases nodes Ahmad Fatoum
2020-06-18  9:10 ` [PATCH 11/15] ARM: i.MX7: dts: replace commented-out code with status = "disabled" Ahmad Fatoum
2020-06-18  9:10 ` [PATCH 12/15] ARM: i.MX: mx53-qsrb: dts: remove now-superfluous override Ahmad Fatoum
2020-06-18  9:11 ` [PATCH 13/15] ARM: zynqmp: dts: drop now superfluous zynqmp.dtsi Ahmad Fatoum
2020-06-18  9:11 ` [PATCH 14/15] ARM: socfpga: dts: remove unused nodes and phandles Ahmad Fatoum
2020-06-18  9:11 ` Ahmad Fatoum [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200618091102.30150-16-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox