All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pantelis Antoniou <panto@antoniou-consulting.com>
To: Grant Likely <grant.likely@secretlab.ca>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>, Russ Dill <Russ.Dill@ti.com>,
	Felipe Balbi <balbi@ti.com>, Benoit Cousson <b-cousson@ti.com>,
	Tony Lindgren <tony@atomide.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Koen Kooi <koen@dominion.thruhere.net>,
	Matt Porter <mporter@ti.com>,
	linux-omap@vger.kernel.org, Kevin Hilman <khilman@ti.com>,
	Paul Walmsley <paul@pwsan.com>,
	devicetree-discuss@lists.ozlabs.org,
	Rob Herring <robherring2@gmail.com>
Subject: Re: [PATCH 0/3] capebus moving omap_devices to mach-omap2
Date: Mon, 5 Nov 2012 20:54:26 +0100	[thread overview]
Message-ID: <18667A4E-5513-4D74-922F-30D091609F16@antoniou-consulting.com> (raw)
In-Reply-To: <CACxGe6v9cyybV4+5tQJ-DG8qdyEHfsLa7t+-3CTL+97Q9msrFw@mail.gmail.com>

Hi Grant,

On Nov 5, 2012, at 8:10 PM, Grant Likely wrote:

> On Mon, Nov 5, 2012 at 3:37 PM, Pantelis Antoniou
> <panto@antoniou-consulting.com> wrote:
>> Hi Grant,
>> 
>> On Nov 5, 2012, at 1:37 AM, Grant Likely wrote:
>> 
>>> On Fri, Nov 2, 2012 at 12:32 PM, Pantelis Antoniou
>>> <panto@antoniou-consulting.com> wrote:
>>>> The i2c2 alias cannot be resolved at compile time; there has to be
>>>> 
>>>> a) A DT object format where unresolved aliases (symbols) are tracked
>>>> b) A runtime DT linker that will resolve the alias, and will insert the
>>>>  i2c2-devices child nodes as children in the i2c2 node.
>>>> c) A method to trigger platform device creation for the child nodes just
>>>>  inserted.
>>>> 
>>>> DT core changes aren't bound to be easily accepted, so without having a clear
>>>> signal from the DT maintainers that they would consider such a method people
>>>> are just hesitant to go down this road.
>>> 
>>> I do agree and will accept such a method.
>>> 
>>> g.
>> 
>> Understood.
>> 
>> I'll think about the issues and come up with a design for the format, but
>> let's talk about this in the open for a while.
> 
> Agreed. I'm planning to post my first draft/RFC tonight.
> 
>> I don't want to modify the DTB format, in order to avoid impacting any other
>> DT users.
> 
> Ditto. It should be a direct extension.
> 

Avoiding mobs of angry users with broken bootloader/kernel combos is a good
thing...

>> So would something like this work for you?
> [...]
>> The dt-resolution node, can be appended to the dt fragment contents and
>> can be generated by the compiler.
>> 
>> Upon injection of the DT fragment the in-kernel loader can perform
>> symbol resolution and replace the phandles with the in-kernel values.
>> 
>> I know there's an aliases node, but I don't know if it's wise to modify it.
>> 
>> What do you think?
> 
> If I'm reading your intent correctly, your primary worry is the
> problem of matching up phandles from the base dt with (potentially
> different) phandle values in the overlay. This solution solves it by
> encoding all of the phandle locations as offsets from the start of the
> file into the dt-resolution node. Correct? My concern with this
> approach is that it is fragile. Any changes to the fragment file, such
> as to add extra properties or nodes, or even to repack the tree will
> break all the offsets; probably silently.
> 

Yes, this will not survive modification of the fragment file.
For the use case I'm targeting the DT fragment is going to be quite
minimal, a few tens of nodes at the most. Modification of a single
fragment file is not expected.

Modifications to the base tree, those would work just fine. The base
tree by definition will not have external references.

> It would be less fragile if each property containing phandles had some
> kind of .<prop>-phandle-offsets companion property that listed the
> phandles that need to be fixed up as an offset to the beginning of
> only that properties' data. Better, in that modifying the tree won't
> break the links, but I still worry that it is fragile and possibly too
> complex.

I believe this is considerably more complex, without fixing the 
fragility problem.

> 
> However, the problem is based on the assumption that phandles are
> effectively random and could change ever time the tree is recompiled.
> Well, what if they weren't? What if dtc generated phandles using a
> hash of the node full name so that the value changed rarely? Also,
> what if the format was oriented around detecting if the phandles don't
> match instead of fixing things up? The solution becomes a lot simpler
> if the parser only has to verify that the referenced phandles already
> exist at the right path in the tree.
> 
> Something like this:
> 
> /include/ "base-file.dts"  /* include might not be the right syntax here */
> &i2c0 {         /* i2c0 resolved by label */
>        touchpad@10 {
>                compatible = "acme,touchpad";
>                reg = <0x10>;
>                interrupt-parent = <&intc>;
>                interrupts = <100>;
>        };
> };
> 
> And the generated overlay dtb may look like this:
> 
> / {
>        .readonly;
>        interrupt-controller@0x10005000 {
>                .readonly;
>                phandle = <0x1234>;
>        };
> 
>        peripheral-bus {
>                .readonly;
>                i2c@20001000 {
>                        touchpad@10 {
>                                compatible = "acme,touchpad";
>                                reg = <0x10>;
>                                interrupt-parent = <0x1234>;
>                                interrupts = <100>;
>                        };
>                };
>        };
> };
> 
> Which is obviously missing a bunch of information for the rest of the
> system, but contains enough data to ensure that the path to the touchpad
> node is valid and that the phandle has not changed.

I see what you mean. It will work, provided you 'link' (I don't know what
the proper terminology is) against the correct board dts file.
> 
> This handles many of the use cases, but it assumes that an overlay is
> board specific. If it ever is required to support multiple base boards
> with a single overlay file then there is a problem. The .dtb overlays
> generated in this manor cannot handle different phandles or nodes that
> are in a different place. On the other hand, the overlay source files
> should have no problem being compiled for multiple targets, so maybe
> it isn't an issue. Plus if dtc is installed on the target, then the
> live tree from /proc can be used as the reference when compiling the
> overlay.

My worry is that this format is dependent on linking against the board
DTS file. One of the ideas thrown around here was that it might make
sense to store the DTB fragment in the EEPROM of the device. 

In that case you have a OS independent hardware description, which can 
be even used even by the bootloader to access devices it knows not about
at compile time.

Other than that, I have no other objections.

> 
> g.

Regards

-- Pantelis



WARNING: multiple messages have this Message-ID (diff)
From: Pantelis Antoniou <panto@antoniou-consulting.com>
To: Grant Likely <grant.likely@secretlab.ca>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>, Russ Dill <Russ.Dill@ti.com>,
	Felipe Balbi <balbi@ti.com>, Benoit Cousson <b-cousson@ti.com>,
	Tony Lindgren <tony@atomide.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Koen Kooi <koen@dominion.thruhere.net>,
	Matt Porter <mporter@ti.com>,
	linux-omap@vger.kernel.org, Kevin Hilman <khilman@ti.com>,
	Paul Walmsley <paul@pwsan.com>,
	devicetree-discuss@lists.ozlabs.org,
	Rob Herring <robherring2@gmail.com>
Subject: Re: [PATCH 0/3] capebus moving omap_devices to mach-omap2
Date: Mon, 5 Nov 2012 20:54:26 +0100	[thread overview]
Message-ID: <18667A4E-5513-4D74-922F-30D091609F16@antoniou-consulting.com> (raw)
In-Reply-To: <CACxGe6v9cyybV4+5tQJ-DG8qdyEHfsLa7t+-3CTL+97Q9msrFw@mail.gmail.com>

Hi Grant,

On Nov 5, 2012, at 8:10 PM, Grant Likely wrote:

> On Mon, Nov 5, 2012 at 3:37 PM, Pantelis Antoniou
> <panto@antoniou-consulting.com> wrote:
>> Hi Grant,
>> 
>> On Nov 5, 2012, at 1:37 AM, Grant Likely wrote:
>> 
>>> On Fri, Nov 2, 2012 at 12:32 PM, Pantelis Antoniou
>>> <panto@antoniou-consulting.com> wrote:
>>>> The i2c2 alias cannot be resolved at compile time; there has to be
>>>> 
>>>> a) A DT object format where unresolved aliases (symbols) are tracked
>>>> b) A runtime DT linker that will resolve the alias, and will insert the
>>>>  i2c2-devices child nodes as children in the i2c2 node.
>>>> c) A method to trigger platform device creation for the child nodes just
>>>>  inserted.
>>>> 
>>>> DT core changes aren't bound to be easily accepted, so without having a clear
>>>> signal from the DT maintainers that they would consider such a method people
>>>> are just hesitant to go down this road.
>>> 
>>> I do agree and will accept such a method.
>>> 
>>> g.
>> 
>> Understood.
>> 
>> I'll think about the issues and come up with a design for the format, but
>> let's talk about this in the open for a while.
> 
> Agreed. I'm planning to post my first draft/RFC tonight.
> 
>> I don't want to modify the DTB format, in order to avoid impacting any other
>> DT users.
> 
> Ditto. It should be a direct extension.
> 

Avoiding mobs of angry users with broken bootloader/kernel combos is a good
thing...

>> So would something like this work for you?
> [...]
>> The dt-resolution node, can be appended to the dt fragment contents and
>> can be generated by the compiler.
>> 
>> Upon injection of the DT fragment the in-kernel loader can perform
>> symbol resolution and replace the phandles with the in-kernel values.
>> 
>> I know there's an aliases node, but I don't know if it's wise to modify it.
>> 
>> What do you think?
> 
> If I'm reading your intent correctly, your primary worry is the
> problem of matching up phandles from the base dt with (potentially
> different) phandle values in the overlay. This solution solves it by
> encoding all of the phandle locations as offsets from the start of the
> file into the dt-resolution node. Correct? My concern with this
> approach is that it is fragile. Any changes to the fragment file, such
> as to add extra properties or nodes, or even to repack the tree will
> break all the offsets; probably silently.
> 

Yes, this will not survive modification of the fragment file.
For the use case I'm targeting the DT fragment is going to be quite
minimal, a few tens of nodes at the most. Modification of a single
fragment file is not expected.

Modifications to the base tree, those would work just fine. The base
tree by definition will not have external references.

> It would be less fragile if each property containing phandles had some
> kind of .<prop>-phandle-offsets companion property that listed the
> phandles that need to be fixed up as an offset to the beginning of
> only that properties' data. Better, in that modifying the tree won't
> break the links, but I still worry that it is fragile and possibly too
> complex.

I believe this is considerably more complex, without fixing the 
fragility problem.

> 
> However, the problem is based on the assumption that phandles are
> effectively random and could change ever time the tree is recompiled.
> Well, what if they weren't? What if dtc generated phandles using a
> hash of the node full name so that the value changed rarely? Also,
> what if the format was oriented around detecting if the phandles don't
> match instead of fixing things up? The solution becomes a lot simpler
> if the parser only has to verify that the referenced phandles already
> exist at the right path in the tree.
> 
> Something like this:
> 
> /include/ "base-file.dts"  /* include might not be the right syntax here */
> &i2c0 {         /* i2c0 resolved by label */
>        touchpad@10 {
>                compatible = "acme,touchpad";
>                reg = <0x10>;
>                interrupt-parent = <&intc>;
>                interrupts = <100>;
>        };
> };
> 
> And the generated overlay dtb may look like this:
> 
> / {
>        .readonly;
>        interrupt-controller@0x10005000 {
>                .readonly;
>                phandle = <0x1234>;
>        };
> 
>        peripheral-bus {
>                .readonly;
>                i2c@20001000 {
>                        touchpad@10 {
>                                compatible = "acme,touchpad";
>                                reg = <0x10>;
>                                interrupt-parent = <0x1234>;
>                                interrupts = <100>;
>                        };
>                };
>        };
> };
> 
> Which is obviously missing a bunch of information for the rest of the
> system, but contains enough data to ensure that the path to the touchpad
> node is valid and that the phandle has not changed.

I see what you mean. It will work, provided you 'link' (I don't know what
the proper terminology is) against the correct board dts file.
> 
> This handles many of the use cases, but it assumes that an overlay is
> board specific. If it ever is required to support multiple base boards
> with a single overlay file then there is a problem. The .dtb overlays
> generated in this manor cannot handle different phandles or nodes that
> are in a different place. On the other hand, the overlay source files
> should have no problem being compiled for multiple targets, so maybe
> it isn't an issue. Plus if dtc is installed on the target, then the
> live tree from /proc can be used as the reference when compiling the
> overlay.

My worry is that this format is dependent on linking against the board
DTS file. One of the ideas thrown around here was that it might make
sense to store the DTB fragment in the EEPROM of the device. 

In that case you have a OS independent hardware description, which can 
be even used even by the bootloader to access devices it knows not about
at compile time.

Other than that, I have no other objections.

> 
> g.

Regards

-- Pantelis

  reply	other threads:[~2012-11-05 19:54 UTC|newest]

Thread overview: 107+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-01 15:17 [PATCH 0/3] capebus moving omap_devices to mach-omap2 Pantelis Antoniou
2012-10-31 17:52 ` Tony Lindgren
2012-10-31 18:04   ` Pantelis Antoniou
2012-10-31 18:09     ` Tony Lindgren
2012-10-31 18:24       ` Pantelis Antoniou
2012-10-31 19:55       ` Benoit Cousson
2012-10-31 19:55         ` Benoit Cousson
2012-10-31 20:12         ` Pantelis Antoniou
2012-10-31 20:12           ` Pantelis Antoniou
2012-10-31 21:26           ` Tony Lindgren
2012-10-31 21:36             ` Pantelis Antoniou
2012-10-31 21:43               ` Tony Lindgren
2012-10-31 22:00                 ` Pantelis Antoniou
2012-10-31 22:16                   ` Tony Lindgren
2012-10-31 22:14               ` Felipe Balbi
2012-10-31 22:14                 ` Felipe Balbi
2012-11-01  7:02                 ` Pantelis Antoniou
2012-11-01  7:02                   ` Pantelis Antoniou
2012-11-01 10:23                   ` Cousson, Benoit
2012-11-01 10:23                     ` Cousson, Benoit
2012-11-01 10:39                     ` Pantelis Antoniou
2012-11-01 10:39                       ` Pantelis Antoniou
2012-11-01 11:04                       ` Felipe Balbi
2012-11-01 11:04                         ` Felipe Balbi
2012-11-01 11:26                         ` Pantelis Antoniou
2012-11-01 11:26                           ` Pantelis Antoniou
2012-11-01 12:40                           ` Felipe Balbi
2012-11-01 12:40                             ` Felipe Balbi
2012-11-01 12:57                             ` Pantelis Antoniou
2012-11-01 12:57                               ` Pantelis Antoniou
2012-11-01 13:16                               ` Felipe Balbi
2012-11-01 13:16                                 ` Felipe Balbi
2012-11-01 13:35                                 ` Pantelis Antoniou
2012-11-01 13:35                                   ` Pantelis Antoniou
2012-11-01 13:51                                   ` Alan Cox
2012-11-01 13:51                                     ` Alan Cox
2012-11-01 13:59                                     ` Pantelis Antoniou
2012-11-01 13:59                                       ` Pantelis Antoniou
2012-11-01 22:05                                       ` Felipe Balbi
2012-11-01 22:05                                         ` Felipe Balbi
2012-11-01 23:49                                         ` Russ Dill
2012-11-02  8:57                                           ` Felipe Balbi
2012-11-02  8:57                                             ` Felipe Balbi
2012-11-02  9:42                                             ` Russ Dill
2012-11-02 10:39                                               ` Koen Kooi
2012-11-02 10:39                                                 ` Koen Kooi
2012-11-02 11:00                                               ` Felipe Balbi
2012-11-02 11:00                                                 ` Felipe Balbi
2012-11-02 16:44                                                 ` Russ Dill
2012-11-02 11:21                                           ` Alan Cox
2012-11-02 12:32                                             ` Pantelis Antoniou
2012-11-05  0:37                                               ` Grant Likely
2012-11-05 15:37                                                 ` Pantelis Antoniou
2012-11-05 15:37                                                   ` Pantelis Antoniou
2012-11-05 19:10                                                   ` Grant Likely
2012-11-05 19:54                                                     ` Pantelis Antoniou [this message]
2012-11-05 19:54                                                       ` Pantelis Antoniou
2012-11-05 20:14                                                       ` Grant Likely
2012-11-05 22:59                                                         ` Joel A Fernandes
2012-11-05 23:58                                                           ` Grant Likely
2012-11-05 23:58                                                             ` Grant Likely
2012-11-06  3:06                                                             ` Joel A Fernandes
2012-11-06  8:14                                                               ` Pantelis Antoniou
2012-11-06  8:14                                                                 ` Pantelis Antoniou
2012-11-06 11:16                                                                 ` Grant Likely
2012-11-06 13:54                                                                   ` Pantelis Antoniou
2012-11-06 13:54                                                                     ` Pantelis Antoniou
2012-11-02 16:07                                             ` Jason Kridner
2012-11-02 16:07                                               ` Jason Kridner
2012-11-02 16:28                                               ` Alan Cox
2012-11-05  1:05                                               ` Grant Likely
2012-11-01 11:26                       ` Cousson, Benoit
2012-11-01 11:26                         ` Cousson, Benoit
2012-11-01 11:39                         ` Pantelis Antoniou
2012-11-01 11:39                           ` Pantelis Antoniou
2012-11-01 12:00                         ` Koen Kooi
2012-11-01 12:00                           ` Koen Kooi
2012-11-01 13:06                           ` Felipe Balbi
2012-11-01 13:06                             ` Felipe Balbi
2012-11-01 13:33                             ` Koen Kooi
2012-11-01 13:33                               ` Koen Kooi
2012-11-02  8:15                           ` Cousson, Benoit
2012-11-02  8:15                             ` Cousson, Benoit
2012-11-02  8:43                             ` Pantelis Antoniou
2012-11-03  8:23                               ` Kevin Hilman
2012-11-05  0:22                               ` Grant Likely
2012-11-05  0:22                                 ` Grant Likely
2012-11-05 13:25                                 ` Pantelis Antoniou
2012-11-05 13:25                                   ` Pantelis Antoniou
2012-11-05 14:34                                   ` Grant Likely
2012-11-05 15:34                                     ` Tony Lindgren
2012-11-05 15:34                                       ` Tony Lindgren
2012-11-05 15:56                                     ` Rob Herring
2012-11-05 15:56                                       ` Rob Herring
2012-11-05 19:40                                       ` Grant Likely
2012-11-01 15:18 ` [PATCH 1/3] omap-device: Remove __init from omap_device_build family functions Pantelis Antoniou
2012-11-01 15:18 ` [PATCH 2/3] da8xx-dt: Create da8xx DT adapter device Pantelis Antoniou
2012-11-01 14:36   ` Tomi Valkeinen
2012-11-01 14:38     ` Pantelis Antoniou
2012-11-01 15:18 ` [PATCH 3/3] ti-tscadc-dt: Create ti-tscadc-dt " Pantelis Antoniou
2012-11-01 18:50 [PATCH 0/3] capebus moving omap_devices to mach-omap2 Jason Kridner
2012-11-01 19:07 ` Tony Lindgren
2012-11-02  9:26 ` Cousson, Benoit
2012-11-02  9:26   ` Cousson, Benoit
2012-11-02 10:19   ` Koen Kooi
2012-11-02 10:19     ` Koen Kooi
2012-11-05  0:32     ` Grant Likely

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=18667A4E-5513-4D74-922F-30D091609F16@antoniou-consulting.com \
    --to=panto@antoniou-consulting.com \
    --cc=Russ.Dill@ti.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=b-cousson@ti.com \
    --cc=balbi@ti.com \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=grant.likely@secretlab.ca \
    --cc=khilman@ti.com \
    --cc=koen@dominion.thruhere.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=mporter@ti.com \
    --cc=paul@pwsan.com \
    --cc=robherring2@gmail.com \
    --cc=tony@atomide.com \
    /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.