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

Herve Codina <[email protected]>
Newsgroups org.kernel.vger.devicetree-compiler,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-kernel
Organization Bootlin
Message-ID <[email protected]>
Hi Luca,

On Fri, 2 May 2025 16:35:59 +0200
Luca Ceresoli <[email protected]> wrote:

> 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).

No, you don't miss anything, it was just a choice and I have chosen to be
not exclusive between export-symbols and __symbols__.

export-symbols is taken in priority and if the symbol is not found in
export-symbols, we try with __symbols__.

Maybe I should be stricter. I don't have any strong opinion about that.

Ayush, on fdtoverlay what is the choice done ?

If an export-symbols is present and a symbol needs to be resolved but this
symbol is not found in export-symbols, do you try to fing it in __symbols__
or do you simply abort the resolution with an error ?

Best regards,
Hervé
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.