public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Herve Codina <herve.codina@bootlin.com>
To: David Gibson <david@gibson.dropbear.id.au>,
	Andrew Davis <afd@ti.com>, Ayush Singh <ayush@beagleboard.org>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Herve Codina <herve.codina@bootlin.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Saravana Kannan <saravanak@google.com>
Cc: devicetree@vger.kernel.org, devicetree-compiler@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Luca Ceresoli <luca.ceresoli@bootlin.com>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Subject: Re: [PATCH 0/7] of: overlay: Add support for export-symbols node feature
Date: Wed, 30 Apr 2025 14:50:50 +0200	[thread overview]
Message-ID: <20250430145050.69f2e950@bootlin.com> (raw)
In-Reply-To: <20250430124910.195368-1-herve.codina@bootlin.com>

Hi all,

Sorry, this should be a v2 series.

I resend as v2.

Please ighnore this one.

Best regards,
Hervé


On Wed, 30 Apr 2025 14:48:59 +0200
Herve Codina <herve.codina@bootlin.com> wrote:

> Hi,
> 
> At Linux Plumbers Conference 2024, we (me and Luca Ceresolli) talked
> about issues we have with runtime hotplug on non-discoverable busses
> with device tree overlays [1].
> 
> On our system, a base board has a connector and addon boards can be
> connected to this connector. Both boards are described using device
> tree. The base board is described by a base device tree and addon boards
> are describe by overlays device tree. More details can be found at [2].
> 
> This kind of use case can be found also on:
>   - Grove Sunlight Sensor [3]
>   - mikroBUS [4]
> 
> One of the issue we were facing on was referencing resources available
> on the base board device tree from the addon overlay device tree.
> 
> Using a nexus node [5] helps decoupling resources and avoid the
> knowledge of the full base board from the overlay. Indeed, with nexus
> node, the overlay need to know only about the nexus node itself.
> 
> For instance, suppose a connector where a GPIO is connected at PinA. On
> the base board this GPIO is connected to the GPIO 12 of the SoC GPIO
> controller.
> 
> The base board can describe this GPIO using a nexus node:
>     soc_gpio: gpio-controller {
>       #gpio-cells = <2>;
>     };
> 
>     connector1: connector1 {
>         /*
>          * Nexus node for the GPIO available on the connector.
>          * GPIO 0 (Pin A GPIO) is connected to GPIO 12 of the SoC gpio
>          * controller
>          */
>         #gpio-cells = <2>;
>         gpio-map = <0 0 &soc_gpio 12 0>;
>         gpio-map-mask = <0xf 0x0>;
>         gpio-map-pass-thru = <0x0 0xf>;
>     };
> 
> The connector pin A GPIO can be referenced using:
>   <&connector1 0 GPIO_ACTIVE_HIGH>
> 
> This implies that the overlay needs to know about exact label that
> references the connector. This label can be different on a different
> board and so applying the overlay could failed even if it is used to
> describe the exact same addon board. Further more, a given base board
> can have several connectors where the exact same addon board can be
> connected. In that case, the same overlay cannot be used on both
> connector. Indeed, the connector labels have to be different.
> 
> The export-symbols node introduced by this current series solves this
> issue.
> 
> The idea of export-symbols is to have something similar to the global
> __symbols__ node but local to a specific node. Symbols listed in this
> export-symbols are local and visible only when an overlay is applied on
> a node having an export-symbols subnode.
> 
> Using export-symbols, our example becomes:
>     soc_gpio: gpio-controller {
>       #gpio-cells = <2>;
>     };
> 
>     connector1: connector1 {
>         /*
>          * Nexus node for the GPIO available on the connector.
>          * GPIO 0 (Pin A GPIO) is connected to GPIO 12 of the SoC gpio
>          * controller
>          */
>         #gpio-cells = <2>;
>         gpio-map = <0 0 &soc_gpio 12 0>;
>         gpio-map-mask = <0xf 0x0>;
>         gpio-map-pass-thru = <0x0 0xf>;
> 
>         export-symbols {
>           connector = <&connector1>;
>         };
>     };
> 
> With that export-symbols node, an overlay applied on connector1 node can
> have the symbol named 'connector' resolved to connector1. Indeed, the
> export-symbols node available at connector1 node is used when the
> overlay is applied. If the overlay has an unresolved 'connector' symbol,
> it will be resolved to connector1 thanks to export-symbols.
> 
> Our overlay using the nexus node can contains:
>    node {
>       foo-gpio = <&connector 0 GPIO_ACTIVE_HIGH>;
>    };
> It used the GPIO 0 from the connector it is applied on.
> 
> A board with two connectors can be described with:
>     connector1: connector1 {
>         ...
>         export-symbols {
>           connector = <&connector1>;
>         };
>     };
> 
>     connector2: connector2 {
>         ...
>         export-symbols {
>           connector = <&connector2>;
>         };
>     };
> 
> In that case, the same overlay with unresolved 'connector' symbol can be
> applied on both connectors and the correct symbol resolution (connector1
> or connector2) will be done.
> 
> This current series add support for the export-symbols node feature:
>   - Patch 1 describes the export-symbols binding
>   - Patches 2 to 6 prepare and add the support for the export-symbols
>     feature
>   - Patch 7 adds an unittest for the export-symbols feature
> 
> Compare to the previous iteration, the series has been rebased on
> top of v6.15-rc1 and an compilation issue in unittest has been fixed.
> 
> Also it is worth noting the work already done by Ayush Singh related to
> this topic on other repositories:
>   - Add export-symbols in device-tree specification
>       [PATCH v3] Add new `export-symbols` node [6]
> 
>   - Support for export-symbols in the device tree compiler
>       [PATCH 0/3] Allow specifying target node in fdtoverlay [7]
>       [PATCH] checks: Add support for export-symbols [8]
> 
> Best regards,
> Hervé
> 
> [1] https://lpc.events/event/18/contributions/1696/
> [2] https://lore.kernel.org/lkml/20240917-hotplug-drm-bridge-v4-0-bc4dfee61be6@bootlin.com/
> [3] https://lore.kernel.org/lkml/20240702164403.29067-1-afd@ti.com/
> [4] https://lore.kernel.org/lkml/20240627-mikrobus-scratch-spi-v5-0-9e6c148bf5f0@beagleboard.org/
> [5] https://github.com/devicetree-org/devicetree-specification/blob/v0.4/source/chapter2-devicetree-basics.rst#nexus-nodes-and-specifier-mapping
> [6] https://lore.kernel.org/all/20250411-export-symbols-v3-1-f59368d97063@beagleboard.org/
> [7] https://lore.kernel.org/all/20250313-fdtoverlay-target-v1-0-dd5924e12bd3@beagleboard.org/
> [8] https://lore.kernel.org/all/20250110-export-symbols-v1-1-b6213fcd6c82@beagleboard.org/
> 
> Changes v1 -> v2
>   v1: https://lore.kernel.org/all/20241209151830.95723-1-herve.codina@bootlin.com/
> 
>   - All patches
>     Add 'Tested-by: Ayush Singh <ayush@beagleboard.org>'
> 
>   - Patch 1
>     Update the 'patternProperties' regexp
> 
>   - Patch 2 and 4
>     Fix conflicts due to the rebase on top of v6.15-rc1
> 
>   - Patch 5
>     Fix a typo in commit log
> 
>   - Patch 7
>     Fix a compilation issue detected by a kernel test robot
> 
> Herve Codina (7):
>   dt-bindings: Add support for export-symbols node
>   of: resolver: Introduce get_phandle_from_symbols_node()
>   of: resolver: Add export_symbols in of_resolve_phandles() parameters
>   of: resolver: Add support for the export symbols node
>   of: overlay: Add export_symbols_name in of_overlay_fdt_apply()
>     parameters
>   of: overlay: Add support for the export symbols node
>   of: unittest: Add tests for export symbols
> 
>  .../devicetree/bindings/export-symbols.yaml   | 43 +++++++++++
>  drivers/misc/lan966x_pci.c                    |  3 +-
>  drivers/of/of_kunit_helpers.c                 |  2 +-
>  drivers/of/of_private.h                       |  2 +-
>  drivers/of/overlay.c                          | 30 +++++++-
>  drivers/of/resolver.c                         | 75 ++++++++++++++----
>  drivers/of/unittest-data/Makefile             |  5 ++
>  .../unittest-data/overlay_export_symbols.dtso | 15 ++++
>  .../of/unittest-data/testcases_common.dtsi    |  1 +
>  .../unittest-data/tests-export-symbols.dtsi   | 30 ++++++++
>  drivers/of/unittest.c                         | 77 +++++++++++++++++--
>  include/linux/of.h                            |  6 +-
>  12 files changed, 258 insertions(+), 31 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/export-symbols.yaml
>  create mode 100644 drivers/of/unittest-data/overlay_export_symbols.dtso
>  create mode 100644 drivers/of/unittest-data/tests-export-symbols.dtsi
> 



-- 
Hervé Codina, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

  parent reply	other threads:[~2025-04-30 12:51 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-30 12:48 [PATCH 0/7] of: overlay: Add support for export-symbols node feature Herve Codina
2025-04-30 12:49 ` [PATCH 1/7] dt-bindings: Add support for export-symbols node Herve Codina
2025-04-30 12:49 ` [PATCH 2/7] of: resolver: Introduce get_phandle_from_symbols_node() Herve Codina
2025-04-30 12:49 ` [PATCH 3/7] of: resolver: Add export_symbols in of_resolve_phandles() parameters Herve Codina
2025-04-30 12:49 ` [PATCH 4/7] of: resolver: Add support for the export symbols node Herve Codina
2025-04-30 12:49 ` [PATCH 5/7] of: overlay: Add export_symbols_name in of_overlay_fdt_apply() parameters Herve Codina
2025-04-30 12:49 ` [PATCH 6/7] of: overlay: Add support for the export symbols node Herve Codina
2025-04-30 12:49 ` [PATCH 7/7] of: unittest: Add tests for export symbols Herve Codina
2025-04-30 12:50 ` Herve Codina [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-12-09 15:18 [PATCH 0/7] of: overlay: Add support for export-symbols node feature Herve Codina
2024-12-09 16:47 ` Andrew Davis
2024-12-09 17:03   ` Herve Codina
2024-12-09 17:47     ` Andrew Davis
2024-12-09 19:39       ` Rob Herring
2024-12-10  9:30       ` Ayush Singh
2024-12-09 20:11 ` Rob Herring
2024-12-10  8:16   ` Herve Codina
2024-12-10 13:46     ` Rob Herring
2024-12-10 14:58       ` Herve Codina
2024-12-18 12:22         ` Herve Codina
2024-12-10  9:22 ` Ayush Singh
2024-12-10  9:41   ` Herve Codina
2024-12-10  9:56     ` Ayush Singh
2024-12-10 10:55       ` Herve Codina
2025-01-08  7:36         ` Ayush Singh
2025-01-08  8:07           ` Herve Codina
2025-01-08  8:28             ` Ayush Singh
2025-01-08  9:47               ` Herve Codina
2025-01-10  4:26                 ` David Gibson
2025-01-10  7:36                   ` Herve Codina
2025-01-10  7:55                   ` Ayush Singh
2025-01-11  3:17                     ` David Gibson
2025-04-29 19:12 ` Ayush Singh

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=20250430145050.69f2e950@bootlin.com \
    --to=herve.codina@bootlin.com \
    --cc=afd@ti.com \
    --cc=arnd@arndb.de \
    --cc=ayush@beagleboard.org \
    --cc=conor+dt@kernel.org \
    --cc=david@gibson.dropbear.id.au \
    --cc=devicetree-compiler@vger.kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=geert@linux-m68k.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luca.ceresoli@bootlin.com \
    --cc=robh@kernel.org \
    --cc=saravanak@google.com \
    --cc=thomas.petazzoni@bootlin.com \
    /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