Re: [PATCH v2 3/7] of: resolver: Add export_symbols in of_resolve_phandles() parameters

Luca Ceresoli <[email protected]>
Newsgroups org.kernel.vger.devicetree-compiler,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-kernel
Organization Bootlin
Message-ID <20250502163559.0a5643e5@booty>
Hello Hervé,

On Wed, 30 Apr 2025 14:51:47 +0200
Herve Codina <[email protected]> wrote:

> In order to prepare the introduction of the export symbols node
> handling, add a export_symbols parameter in of_resolve_phandles().
> 
> The export_symbols is the export symbols device tree node the resolver
> will use for the overlay symbols resolution.
> 
> Signed-off-by: Herve Codina <[email protected]>
> Tested-by: Ayush Singh <[email protected]>

[...]

> --- a/drivers/of/resolver.c
> +++ b/drivers/of/resolver.c
> @@ -237,7 +237,8 @@ static int get_phandle_from_symbols_node(const struct device_node *tree_symbols,
>  /**
>   * of_resolve_phandles - Relocate and resolve overlay against live tree
>   *
> - * @overlay:	Pointer to devicetree overlay to relocate and resolve
> + * @overlay:		Pointer to devicetree overlay to relocate and resolve
> + * @export_symbols:	Pointer to devicetree export symbols node.
>   *
>   * Modify (relocate) values of local phandles in @overlay to a range that
>   * does not conflict with the live expanded devicetree.  Update references
> @@ -257,6 +258,10 @@ static int get_phandle_from_symbols_node(const struct device_node *tree_symbols,
>   * corresponding to that symbol in the live tree.  Update the references in
>   * the overlay with the phandle values in the live tree.
>   *
> + * @export_symbols can be use in this references update. The resolver tries
> + * first to find a match in the @export_symbols. If not found, it uses the
> + * "__symbol__" node in the live tree.

The rationale behind this logic is not clear to me. I'd have expected
instead this logic:

  if (export-symbols != NULL):
      match only in export-symbols
  else
      match only in __symbols__

following the idea that it's better to be strict when introducing
something, and possibly relax it later on.

As I see it, with the current logic if you use export-symbols but you
build dtbs with -@, you can still match a global label. export-symbols
should avoid that instead.

Let me know whether I'm missing something here (which is surely
possible).

Other than this, the series looks good to me. I'm not adding my R-by on
the implementation patches though, waiting for the above question to be
clarified.

Luca

-- 
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.