All of lore.kernel.org
 help / color / mirror / Atom feed
* dtc 1.6.0 overlay full-path reference in array produces broken property names
@ 2021-09-27 14:04 Vincent Pelletier
       [not found] ` <20210927140456.4e45f05b-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Vincent Pelletier @ 2021-09-27 14:04 UTC (permalink / raw)
  To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA

(please keep me cc'ed in replies)

Hello,

I suspect this may be a dtc bug, but I am not too familiar with
devicetree specs to tell.

Here is a simplified example reproducing this issue:

(SNIP)
/dts-v1/;
/plugin/;

/ {
  compatible = "foo";
};

&{/soc/gpio@7e200000} {
    status = "okay";
};

&{/soc/spi@7e204000} {
    cs-gpios = <&{/soc/gpio@7e200000} 8 0x01>;
};
(SNIP)

This code builds fine:
  $ dtc -I dts -O dtb -o test.dtbo test.dts
  $
But then when disassembling the output, I get:
  $ dtc -I dtb -O dts test.dtbo
  <stdout>: ERROR (property_name_chars): /__fixups__:/soc/gpio@7e200000: Bad character '/' in property name
  ERROR: Input tree has errors, aborting (use -f to force output)
And forcing output:
  $ dtc -I dtb -O dts -f test.dtbo
  <stdout>: ERROR (property_name_chars): /__fixups__:/soc/gpio@7e200000: Bad character '/' in property name
  Warning: Input tree has errors, output forced
  /dts-v1/;

  / {
          compatible = "foo";

          fragment@0 {
                  target-path = "/soc/gpio@7e200000";

                  __overlay__ {
                          status = "okay";
                  };
          };

          fragment@1 {
                  target-path = "/soc/spi@7e204000";

                  __overlay__ {
                          cs-gpios = <0xffffffff 0x08 0x01>;
                  };
          };

          __fixups__ {
                  /soc/gpio@7e200000 = "/fragment@1/__overlay__:cs-gpios:0";
          };
  };

Indeed, the node in __fixups__ has an invalid name.

I suspect this is uncommon because:
- it probably only occurs in overlays and not in self-contained trees,
  as a self-contained tree would likely produce an internal phandle and
  never store the full path anywhere.
- ...which does not attach to labels but full paths
  Labels being (probably ?) valid node names, they would avoid the issue.
- ...in arrays
  In a node overlay, the full path ends up as a quoted string, not as a
  name, so it is safe.

Is this a dtc bug ?


I came up with the following workaround which gets me what I need, but
it is not very nice (extract):

  &{/soc} {
    gpio: gpio@7e200000 {
      #gpio-cells = <0x02>;
    };
    spi: spi@7e204000 {
      #address-cells = <1>;
      #size-cells = <0>;
    };
  };
  ...
  &spi {
      cs-gpios = <&gpio 8 0x01>;
  };

IOW:
- overlay the parent of the nodes I am interested in, just to declare
  labels
- ...while at it, repeat a few of the #... properties, which seem magic
  (this is where my devicetree knowledge ends, really)
- and go on implementing the actual overlays I want, using the
  just-defined labels.

Regards,
-- 
Vincent Pelletier
GPG fingerprint 983A E8B7 3B91 1598 7A92 3845 CAC9 3691 4257 B0C1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: dtc 1.6.0 overlay full-path reference in array produces broken property names
       [not found] ` <20210927140456.4e45f05b-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2021-09-28 11:28   ` Vincent Pelletier
       [not found]     ` <20210928112859.79b55d5a-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2021-11-01  6:19   ` David Gibson
  1 sibling, 1 reply; 5+ messages in thread
From: Vincent Pelletier @ 2021-09-28 11:28 UTC (permalink / raw)
  To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA

On Mon, 27 Sep 2021 14:04:56 +0000, Vincent Pelletier <plr.vincent-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> (please keep me cc'ed in replies)
[...]
> This code builds fine:
>   $ dtc -I dts -O dtb -o test.dtbo test.dts
>   $
> But then when disassembling the output, I get:
>   $ dtc -I dtb -O dts test.dtbo
>   <stdout>: ERROR (property_name_chars): /__fixups__:/soc/gpio@7e200000: Bad character '/' in property name
>   ERROR: Input tree has errors, aborting (use -f to force output)

I just noticed 1.6.1 was released (but not packaged yet by my
distribution, it seems), so I reproduced from git master as of

  commit e33ce1d6a8c7e54e3ad12cff33690b6da0aee1dc (HEAD -> master, origin/master, origin/main, origin/HEAD)
  Author: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>
  Date:   Fri Sep 24 23:39:56 2021 +1000

      flattree: Use '\n', not ';' to separate asm pseudo-ops

and I confirm the error is still present.

Regards,
-- 
Vincent Pelletier
GPG fingerprint 983A E8B7 3B91 1598 7A92 3845 CAC9 3691 4257 B0C1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: dtc 1.6.0 overlay full-path reference in array produces broken property names
       [not found]     ` <20210928112859.79b55d5a-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2021-09-29  1:40       ` David Gibson
  0 siblings, 0 replies; 5+ messages in thread
From: David Gibson @ 2021-09-29  1:40 UTC (permalink / raw)
  To: Vincent Pelletier; +Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA

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

On Tue, Sep 28, 2021 at 11:28:59AM +0000, Vincent Pelletier wrote:
> On Mon, 27 Sep 2021 14:04:56 +0000, Vincent Pelletier <plr.vincent@gmail.com> wrote:
> > (please keep me cc'ed in replies)
> [...]
> > This code builds fine:
> >   $ dtc -I dts -O dtb -o test.dtbo test.dts
> >   $
> > But then when disassembling the output, I get:
> >   $ dtc -I dtb -O dts test.dtbo
> >   <stdout>: ERROR (property_name_chars): /__fixups__:/soc/gpio@7e200000: Bad character '/' in property name
> >   ERROR: Input tree has errors, aborting (use -f to force output)
> 
> I just noticed 1.6.1 was released (but not packaged yet by my
> distribution, it seems), so I reproduced from git master as of
> 
>   commit e33ce1d6a8c7e54e3ad12cff33690b6da0aee1dc (HEAD -> master, origin/master, origin/main, origin/HEAD)
>   Author: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>
>   Date:   Fri Sep 24 23:39:56 2021 +1000
> 
>       flattree: Use '\n', not ';' to separate asm pseudo-ops
> 
> and I confirm the error is still present.

Thanks for checking, and yes, this definitely looks like a dtc bug.

-- 
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: 833 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: dtc 1.6.0 overlay full-path reference in array produces broken property names
       [not found] ` <20210927140456.4e45f05b-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2021-09-28 11:28   ` Vincent Pelletier
@ 2021-11-01  6:19   ` David Gibson
  2022-07-31 12:12     ` David Gibson
  1 sibling, 1 reply; 5+ messages in thread
From: David Gibson @ 2021-11-01  6:19 UTC (permalink / raw)
  To: Vincent Pelletier; +Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA

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

On Mon, Sep 27, 2021 at 02:04:56PM +0000, Vincent Pelletier wrote:
> (please keep me cc'ed in replies)
> 
> Hello,
> 
> I suspect this may be a dtc bug, but I am not too familiar with
> devicetree specs to tell.
> 
> Here is a simplified example reproducing this issue:
> 
> (SNIP)
> /dts-v1/;
> /plugin/;
> 
> / {
>   compatible = "foo";
> };
> 
> &{/soc/gpio@7e200000} {
>     status = "okay";
> };
> 
> &{/soc/spi@7e204000} {
>     cs-gpios = <&{/soc/gpio@7e200000} 8 0x01>;
> };
> (SNIP)
> 
> This code builds fine:
>   $ dtc -I dts -O dtb -o test.dtbo test.dts
>   $
> But then when disassembling the output, I get:
>   $ dtc -I dtb -O dts test.dtbo
>   <stdout>: ERROR (property_name_chars): /__fixups__:/soc/gpio@7e200000: Bad character '/' in property name
>   ERROR: Input tree has errors, aborting (use -f to force output)
> And forcing output:
>   $ dtc -I dtb -O dts -f test.dtbo
>   <stdout>: ERROR (property_name_chars): /__fixups__:/soc/gpio@7e200000: Bad character '/' in property name
>   Warning: Input tree has errors, output forced
>   /dts-v1/;
> 
>   / {
>           compatible = "foo";
> 
>           fragment@0 {
>                   target-path = "/soc/gpio@7e200000";
> 
>                   __overlay__ {
>                           status = "okay";
>                   };
>           };
> 
>           fragment@1 {
>                   target-path = "/soc/spi@7e204000";
> 
>                   __overlay__ {
>                           cs-gpios = <0xffffffff 0x08 0x01>;
>                   };
>           };
> 
>           __fixups__ {
>                   /soc/gpio@7e200000 = "/fragment@1/__overlay__:cs-gpios:0";
>           };
>   };
> 
> Indeed, the node in __fixups__ has an invalid name.
> 
> I suspect this is uncommon because:
> - it probably only occurs in overlays and not in self-contained trees,
>   as a self-contained tree would likely produce an internal phandle and
>   never store the full path anywhere.
> - ...which does not attach to labels but full paths
>   Labels being (probably ?) valid node names, they would avoid the issue.
> - ...in arrays
>   In a node overlay, the full path ends up as a quoted string, not as a
>   name, so it is safe.
> 
> Is this a dtc bug ?

I've looked at this again and... not really.

Unfortunately, such a reference can't work given the specification of
the overlay format.  The property name in fixups is the target of the
reference, which works fine for labels, but will necessarily result in
an invalid property name for path references.

dtc should, of course, have a less ugly failure mode.

-- 
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: 833 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: dtc 1.6.0 overlay full-path reference in array produces broken property names
  2021-11-01  6:19   ` David Gibson
@ 2022-07-31 12:12     ` David Gibson
  0 siblings, 0 replies; 5+ messages in thread
From: David Gibson @ 2022-07-31 12:12 UTC (permalink / raw)
  To: Vincent Pelletier; +Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA

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

On Mon, Nov 01, 2021 at 05:19:20PM +1100, David Gibson wrote:
> On Mon, Sep 27, 2021 at 02:04:56PM +0000, Vincent Pelletier wrote:
> > (please keep me cc'ed in replies)
> > 
> > Hello,
> > 
> > I suspect this may be a dtc bug, but I am not too familiar with
> > devicetree specs to tell.
> > 
> > Here is a simplified example reproducing this issue:
> > 
> > (SNIP)
> > /dts-v1/;
> > /plugin/;
> > 
> > / {
> >   compatible = "foo";
> > };
> > 
> > &{/soc/gpio@7e200000} {
> >     status = "okay";
> > };
> > 
> > &{/soc/spi@7e204000} {
> >     cs-gpios = <&{/soc/gpio@7e200000} 8 0x01>;
> > };
> > (SNIP)
> > 
> > This code builds fine:
> >   $ dtc -I dts -O dtb -o test.dtbo test.dts
> >   $
> > But then when disassembling the output, I get:
> >   $ dtc -I dtb -O dts test.dtbo
> >   <stdout>: ERROR (property_name_chars): /__fixups__:/soc/gpio@7e200000: Bad character '/' in property name
> >   ERROR: Input tree has errors, aborting (use -f to force output)
> > And forcing output:
> >   $ dtc -I dtb -O dts -f test.dtbo
> >   <stdout>: ERROR (property_name_chars): /__fixups__:/soc/gpio@7e200000: Bad character '/' in property name
> >   Warning: Input tree has errors, output forced
> >   /dts-v1/;
> > 
> >   / {
> >           compatible = "foo";
> > 
> >           fragment@0 {
> >                   target-path = "/soc/gpio@7e200000";
> > 
> >                   __overlay__ {
> >                           status = "okay";
> >                   };
> >           };
> > 
> >           fragment@1 {
> >                   target-path = "/soc/spi@7e204000";
> > 
> >                   __overlay__ {
> >                           cs-gpios = <0xffffffff 0x08 0x01>;
> >                   };
> >           };
> > 
> >           __fixups__ {
> >                   /soc/gpio@7e200000 = "/fragment@1/__overlay__:cs-gpios:0";
> >           };
> >   };
> > 
> > Indeed, the node in __fixups__ has an invalid name.
> > 
> > I suspect this is uncommon because:
> > - it probably only occurs in overlays and not in self-contained trees,
> >   as a self-contained tree would likely produce an internal phandle and
> >   never store the full path anywhere.
> > - ...which does not attach to labels but full paths
> >   Labels being (probably ?) valid node names, they would avoid the issue.
> > - ...in arrays
> >   In a node overlay, the full path ends up as a quoted string, not as a
> >   name, so it is safe.
> > 
> > Is this a dtc bug ?
> 
> I've looked at this again and... not really.
> 
> Unfortunately, such a reference can't work given the specification of
> the overlay format.  The property name in fixups is the target of the
> reference, which works fine for labels, but will necessarily result in
> an invalid property name for path references.
> 
> dtc should, of course, have a less ugly failure mode.

I finally got a chance to tackle this, and just sent out a patch which
should make this case fail on attempting to build the dtbo in the
first place, rather than later when processing the bad output.

-- 
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: 833 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-07-31 12:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-27 14:04 dtc 1.6.0 overlay full-path reference in array produces broken property names Vincent Pelletier
     [not found] ` <20210927140456.4e45f05b-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2021-09-28 11:28   ` Vincent Pelletier
     [not found]     ` <20210928112859.79b55d5a-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2021-09-29  1:40       ` David Gibson
2021-11-01  6:19   ` David Gibson
2022-07-31 12:12     ` David Gibson

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.