All of lore.kernel.org
 help / color / mirror / Atom feed
From: Herve Codina <herve.codina@bootlin.com>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: Simon Glass <sjg@chromium.org>,
	Devicetree Compiler <devicetree-compiler@vger.kernel.org>
Subject: Re: [PATCH v3 16/18] dtc: Add the overlay fragments from merge_fragments()
Date: Thu, 19 Nov 2026 16:35:08 +0100	[thread overview]
Message-ID: <20261119163508.48721934@bootlin.com> (raw)
In-Reply-To: <avqCubv6DB--kLeB@gractus.seuss>

On Mon, 16 Nov 2026 15:12:42 +1100
David Gibson <david@gibson.dropbear.id.au> wrote:

> On Fri, Nov 06, 2026 at 12:51:43PM -0700, Simon Glass wrote:
> > In a plugin, merge_first_ref() and merge_ref() call add_orphan_node() to
> > turn a fragment which refers to the base tree into an overlay fragment
> > (a fragment@N node). The grammar actions have always done this, but it
> > mixes converting the plugin to the overlay format into the functions
> > which merge each fragment.
> > 
> > Have merge_fragment() tell its caller when a fragment is for the base
> > tree, and call add_orphan_node() from merge_fragments() instead, so that
> > none of the merge_*() functions does the conversion. Add a comment for
> > add_orphan_node() too.
> > 
> > This does not change the output.
> > 
> > Suggested-by: Herve Codina <herve.codina@bootlin.com>
> > Link: https://lore.kernel.org/devicetree-compiler/20261105100714.47bf0434@bootlin.com/
> > Assisted-by: Claude:claude-opus-5-5
> > Signed-off-by: Simon Glass <sjg@chromium.org>
> > ---
> > dtc gives the same output and messages as before for every .dts and
> > .dtso file in Linux v7.3-12284-g3799eeb906c9
> > 
> > Changes in v3:
> > - Add new patch to add the overlay fragments from merge_fragments()
> > 
> >  livetree.c | 47 +++++++++++++++++++++++++++++++----------------
> >  1 file changed, 31 insertions(+), 16 deletions(-)
> > 
> > diff --git a/livetree.c b/livetree.c
> > index f2c7703..c5fec49 100644
> > --- a/livetree.c
> > +++ b/livetree.c
> > @@ -225,6 +225,15 @@ struct node *merge_nodes(struct node *old_node, struct node *new_node)
> >  	return old_node;
> >  }
> >  
> > +/*
> > + * Add an overlay fragment (a fragment@N node) to the root of a plugin, for a
> > + * node which refers to the base tree. The node becomes the fragment's
> > + * __overlay__ subnode and ref gives its target, either a path (target-path)
> > + * or a label (target, as a phandle reference). Fragments are numbered in the
> > + * order they are added.
> > + *
> > + * Returns the root node, dt
> > + */
> >  struct node * add_orphan_node(struct node *dt, struct node *new_node, char *ref)
> >  {
> >  	static unsigned int next_orphan_fragment = 0;
> > @@ -611,9 +620,9 @@ static struct node *lookup_ref(struct node *dt, struct fragment *f)
> >  }
> >  
> >  /*
> > - * Make the tree at *dtp from a first fragment which refers to a label or path,
> > - * rather than being the root node. This is only valid in a plugin, where the
> > - * fragment becomes an overlay fragment.
> > + * Make an empty tree at *dtp for a first fragment which refers to a label or
> > + * path, rather than being the root node. This is only valid in a plugin, where
> > + * the fragment becomes an overlay fragment.
> >   *
> >   * Returns true on success, false on an error, which has been reported.
> >   */
> > @@ -628,9 +637,7 @@ static bool merge_first_ref(struct node **dtp, struct fragment *f, bool plugin)
> >  			     "Label or path %s not found", f->ref);
> >  		ok = false;
> >  	}
> > -	/* Make a new, empty tree with a fragment@N node for the reference */
> > -	*dtp = add_orphan_node(name_node(build_node(NULL, NULL, NULL), ""),
> > -			       f->node, f->ref);
> > +	*dtp = name_node(build_node(NULL, NULL, NULL), "");  
> 
> This seems a bit awkward, since this operation no longer resembles any
> kind of merge.  Seems like it would be nicer to unconditionally create
> an empty tree in merge_fragments(), then "merge" everything into it,
> including root fragments.

In the future with addons, we could have a only orphan nodes.
Creating and empty in merge_fragments() will lead potentially an this empty
available even if no empty root nodes were present in DT.

This empty tree is needed for overlays. I don't think that having and empty
tree artifact created by merge_fragments is the right solution.

Best regards,
Hervé

  reply	other threads:[~2026-11-19 15:35 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-06 19:51 [PATCH v3 00/18] dtc: Merge the fragments of a dts file after parsing Simon Glass
2026-11-06 19:51 ` [PATCH v3 01/18] tests: Check how the fragments of a dts file are merged Simon Glass
2026-11-13  3:20   ` David Gibson
2026-11-06 19:51 ` [PATCH v3 02/18] srcpos: Allow srcpos_string() to accept NULL Simon Glass
2026-11-11  4:56   ` David Gibson
2026-11-06 19:51 ` [PATCH v3 03/18] dtc: Add a struct for the top-level fragments of a dts file Simon Glass
2026-11-13  3:46   ` David Gibson
2026-11-06 19:51 ` [PATCH v3 04/18] dtc: Move the /delete-node/ handling out of the grammar Simon Glass
2026-11-13  3:49   ` David Gibson
2026-11-06 19:51 ` [PATCH v3 05/18] dtc: Move the /omit-if-no-ref/ " Simon Glass
2026-11-13  3:50   ` David Gibson
2026-11-06 19:51 ` [PATCH v3 06/18] dtc: Move is_ref_relative() to livetree.c Simon Glass
2026-11-13  3:55   ` David Gibson
2026-11-06 19:51 ` [PATCH v3 07/18] dtc: Move label-reference handling out of the grammar Simon Glass
2026-11-13  3:58   ` David Gibson
2026-11-06 19:51 ` [PATCH v3 08/18] dtc: Merge &{label} in a plugin as with &label Simon Glass
2026-11-13  4:01   ` David Gibson
2026-11-06 19:51 ` [PATCH v3 09/18] dtc: Move path-reference handling out of the grammar Simon Glass
2026-11-13  4:09   ` David Gibson
2026-11-16 23:49     ` Simon Glass
2026-11-16 23:55       ` David Gibson
2026-11-06 19:51 ` [PATCH v3 10/18] dtc: Move labelled-reference " Simon Glass
2026-11-13  4:13   ` David Gibson
2026-11-16 23:49     ` Simon Glass
2026-11-16 23:57       ` David Gibson
2026-11-06 19:51 ` [PATCH v3 11/18] dtc: Move first-reference " Simon Glass
2026-11-13  4:19   ` David Gibson
2026-11-06 19:51 ` [PATCH v3 12/18] dtc: Add merge_fragment() to merge any fragment Simon Glass
2026-11-13  4:24   ` David Gibson
2026-11-06 19:51 ` [PATCH v3 13/18] dtc: Add helpers for the errors when merging a fragment Simon Glass
2026-11-16  3:49   ` David Gibson
2026-11-06 19:51 ` [PATCH v3 14/18] dtc: Merge the fragments of a dts file after parsing Simon Glass
2026-11-16  4:04   ` David Gibson
2026-11-06 19:51 ` [PATCH v3 15/18] dtc: Merge the fragments of a dts file in main() Simon Glass
2026-11-16  4:08   ` David Gibson
2026-11-06 19:51 ` [PATCH v3 16/18] dtc: Add the overlay fragments from merge_fragments() Simon Glass
2026-11-16  4:12   ` David Gibson
2026-11-19 15:35     ` Herve Codina [this message]
2026-11-06 19:51 ` [PATCH v3 17/18] tests: Check references to a generated overlay fragment Simon Glass
2026-11-16  4:15   ` David Gibson
2026-11-06 19:51 ` [PATCH v3 18/18] dtc: Add the overlay fragments after merging a plugin Simon Glass
2026-11-16  4:34   ` David Gibson

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=20261119163508.48721934@bootlin.com \
    --to=herve.codina@bootlin.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=devicetree-compiler@vger.kernel.org \
    --cc=sjg@chromium.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.