devicetree-compiler.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>
To: Pantelis Antoniou
	<pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
Cc: Jon Loeliger <jdl-CYoMK+44s/E@public.gmane.org>,
	Grant Likely
	<grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	Rob Herring <robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Frank Rowand
	<frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
	Jan Luebbe <jlu-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
	Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
	Matt Porter <mporter-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v5 1/2] dtc: Plugin and fixup support
Date: Fri, 20 Nov 2015 17:57:00 +1100	[thread overview]
Message-ID: <20151120065700.GF18707@voom.fritz.box> (raw)
In-Reply-To: <B8D23946-69DB-4A15-96FE-86C67E358B81-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 7172 bytes --]

On Wed, Oct 21, 2015 at 04:52:25PM +0300, Pantelis Antoniou wrote:
> Hi David,
> 
> > On Oct 21, 2015, at 05:29 , David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org> wrote:
> > 
> > On Wed, Aug 26, 2015 at 09:44:33PM +0300, Pantelis Antoniou wrote:
> >> This patch enable the generation of symbols & local fixup information
> >> for trees compiled with the -@ (--symbols) option.
> >> 
> >> Using this patch labels in the tree and their users emit information
> >> in __symbols__ and __local_fixups__ nodes.
> >> 
> >> The __fixups__ node make possible the dynamic resolution of phandle
> >> references which are present in the plugin tree but lie in the
> >> tree that are applying the overlay against.
> >> 
> >> panto: The original alternative syntax patch required the use of an empty node
> >> which is no longer required.
> >> Numbering of fragments in sequence was also implemented.
> >> 
> >> Signed-off-by: Pantelis Antoniou <pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
> >> Signed-off-by: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> >> Signed-off-by: Jan Luebbe <jlu-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> > 
> > Sorry it's taken me so very long to look at this.  I've been a bit
> > swamped by critical bugs in my day job.
> > 
> 
> No worries.
> 
> > As I've said before (and say several times below), I don't much like
> > the fixups/symbols format, but it's in use so I guess we're stuck with
> > it.
> > 
> > So, the concept and behaviour of this patch seems mostly fine to me.
> > I've made a number of comments below.  Some are just trivial nits, but
> > a few are important implementation problems that could lead to nasty
> > behaviour in edge cases.

[snip]
> >> @@ -652,6 +656,15 @@ static void check_obsolete_chosen_interrupt_controller(struct check *c,
> >> }
> >> TREE_WARNING(obsolete_chosen_interrupt_controller, NULL);
> >> 
> >> +static void check_deprecated_plugin_syntax(struct check *c,
> >> +					   struct node *dt)
> >> +{
> >> +	if (deprecated_plugin_syntax_warning)
> >> +		FAIL(c, "Use '/dts-v1/ /plugin/'; syntax. /dts-v1/; /plugin/; "
> >> +				"is going to be removed in next versions");
> > 
> > Better to put this warning directly where the bad syntax is detected
> > in the parser (using ERROR), transferring it to here with the global
> > is pretty ugly.
> > 
> > The checks infrastructure isn't meant to handle all possible error
> > conditions - just those that are related to the tree's semantic
> > content, rather than pars
> > 
> > Plus.. the old syntax was never committed upstream, so I'm inclined to
> > just drop it now, making this irrelevant.
> > 
> 
> OK, I will drop the deprecated syntax, but I will maintain an out of tree
> patch for people that still keep old style DTSes around.

Ok.  If you think there are a reasonable number of people out there
with the old style dts, then I'll re-consider merging the support for
the older syntax.

[snip]
> >> @@ -156,10 +189,14 @@ devicetree:
> >> 		{
> >> 			struct node *target = get_node_by_ref($1, $2);
> >> 
> >> -			if (target)
> >> +			if (target) {
> >> 				merge_nodes(target, $3);
> >> -			else
> >> -				ERROR(&@2, "Label or path %s not found", $2);
> >> +			} else {
> >> +				if (symbol_fixup_support)
> >> +					add_orphan_node($1, $3, $2);
> >> +				else
> >> +					ERROR(&@2, "Label or path %s not found", $2);
> >> +			}
> >> 			$$ = $1;
> >> 		}
> >> 	| devicetree DT_DEL_NODE DT_REF ';'
> >> @@ -174,6 +211,11 @@ devicetree:
> >> 
> >> 			$$ = $1;
> >> 		}
> >> +	| /* empty */
> >> +		{
> >> +			/* build empty node */
> >> +			$$ = name_node(build_node(NULL, NULL), "");
> >> +		}
> >> 	;
> > 
> > What's the importance of this new rule?  It's connection to plugins
> > isn't obvious to me.
> > 
> 
> It is required when you use the syntactic sugar version of an overlay definition. 
> 
> &target {
> 	foo;
> };

Ah, good point.  With the empty production in place, we should be able
to remove the
	'/' nodedef
production.  In fact, I'm a little surprised we're not getting bison
warnings, since this definitely makes the grammar ambiguous.

[snip]
> >> diff --git a/dtc.h b/dtc.h
> >> index 56212c8..d025111 100644
> >> --- a/dtc.h
> >> +++ b/dtc.h
> >> @@ -20,7 +20,7 @@
> >>  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
> >>  *                                                                   USA
> >>  */
> >> -
> >> +#define _GNU_SOURCE
> > 
> > Ugh.. I'm at least trying to keep dtc compilable on FreeBSD, so I'd
> > prefer to avoid using GNU extensions.  What's the feature you needed
> > this for?
> > 
> 
> Hmm, it’s for using asprintf.
> 
> Funnily asprintf is already used in the srcpos.c file, which is used for the
> converter. I can easily switch to sprintf with some hit to readability.

Yeah, I cleaned a bunch of stuff to get things compiling on FreeBSD,
but then I think it bitrotted again.  Mind you I suspect FreeBSD has
asprintf, just maybe in a different header.

I kind of want to include an asprintf implementation which we use if
the system library doesn't have it, except that involves adding some
kind of configure step that I've so far been able to avoid.

Hmm.. for now, I think use asprintf, putting any _GNU_SOURCE that's
necessary into individual C files, rather than dtc.h.  We can think
about cleaning that up some other time.

[snip]
> >> +void add_orphan_node(struct node *dt, struct node *new_node, char *ref)
> >> +{
> >> +	static unsigned int next_orphan_fragment = 0;
> >> +	struct node *ovl = xmalloc(sizeof(*ovl));
> >> +	struct property *p;
> >> +	struct data d = empty_data;
> >> +	char *name;
> >> +	int ret;
> >> +
> >> +	memset(ovl, 0, sizeof(*ovl));
> >> +
> >> +	d = data_add_marker(d, REF_PHANDLE, ref);
> >> +	d = data_append_integer(d, 0xffffffff, 32);
> >> +	p = build_property("target", d);
> >> +	add_property(ovl, p);
> > 
> > Hmm, using a phandle (which has to be later mangled) rather than a
> > string ref directly in the target property seems an unnecessarily
> > difficult way of doing things, but I guess the format's in use so we
> > can't fix that now.
> 
> It makes sense in practice though and it makes this to work:
> 
> &target {
> 	foo;
> };

Yeah, but that could have been implemented by putting the label string
straight into the "target" property on the overlay blob, rather than
putting a necessarily meaningless phandle which later gets resolved.

Oh well, too late now.

[snip]
> >> +	has_label = 0;
> >> +	for_each_label(node->labels, l) {
> >> +		has_label = 1;
> >> +		break;
> >> +	}
> >> +
> >> +	if (has_label) {
> >> +
> > 
> > Nit: extraneous blank line.
> > 
> 
> OK. (geeze)

Yeah, that was a nitpick.  Wouldn't mention it if there weren't
already other reasons for a respin.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  parent reply	other threads:[~2015-11-20  6:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-26 18:44 [PATCH v5 0/2] dtc: Dynamic DT support Pantelis Antoniou
     [not found] ` <1440614674-7055-1-git-send-email-pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2015-08-26 18:44   ` [PATCH v5 1/2] dtc: Plugin and fixup support Pantelis Antoniou
     [not found]     ` <1440614674-7055-2-git-send-email-pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2015-10-21  2:29       ` David Gibson
     [not found]         ` <20151021022903.GB15881-RXTfZT5YzpxwFLYp8hBm2A@public.gmane.org>
2015-10-21 13:52           ` Pantelis Antoniou
     [not found]             ` <B8D23946-69DB-4A15-96FE-86C67E358B81-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2015-11-20  6:57               ` David Gibson [this message]
2015-08-26 18:44   ` [PATCH v5 2/2] dtc: Document the dynamic plugin internals Pantelis Antoniou
     [not found]     ` <1440614674-7055-3-git-send-email-pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2015-10-21  2:44       ` David Gibson
2015-09-08  4:00   ` [PATCH v5 0/2] dtc: Dynamic DT support David Gibson
     [not found]     ` <20150908040024.GC24774-1s0os16eZneny3qCrzbmXA@public.gmane.org>
2015-09-08  6:43       ` Pantelis Antoniou

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=20151120065700.GF18707@voom.fritz.box \
    --to=david-xt8fgy+axnrb3ne2bgzf6laj5h9x9tb+@public.gmane.org \
    --cc=devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=jdl-CYoMK+44s/E@public.gmane.org \
    --cc=jlu-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
    --cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
    --cc=mporter-OWPKS81ov/FWk0Htik3J/w@public.gmane.org \
    --cc=pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org \
    --cc=robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.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;
as well as URLs for NNTP newsgroup(s).