From: Ayush Singh <ayush@beagleboard.org>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: d-gole@ti.com, lorforlinux@beagleboard.org,
jkridner@beagleboard.org, robertcnelson@beagleboard.org,
nenad.marinkovic@mikroe.com, Andrew Davis <afd@ti.com>,
Geert Uytterhoeven <geert@linux-m68k.org>,
Robert Nelson <robertcnelson@gmail.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Saravana Kannan <saravanak@google.com>,
Herve Codina <herve.codina@bootlin.com>,
devicetree-compiler@vger.kernel.org
Subject: Re: [PATCH] checks: Add support for export-symbols
Date: Mon, 10 Mar 2025 10:48:11 +0530 [thread overview]
Message-ID: <a730a8b4-b253-4c22-b232-d396c6f12b58@beagleboard.org> (raw)
In-Reply-To: <Z8k0VeNXbuJ3kFj3@zatzit>
On 3/6/25 11:06, David Gibson wrote:
> On Fri, Jan 10, 2025 at 11:18:55PM +0530, Ayush Singh wrote:
>> The export symbols node adds some additional symbols that can be used
>> in the symbols resolution. The resolver tries to match unresolved
>> symbols first using the export symbols node and, if a match is not
>> found, it tries the normal route and walks the tree.
>>
>> Contrary to symbols available in the global __symbols__ node, symbols
>> listed in the export symbols node can be considered as local symbols.
>> Indeed, they can be changed depending on the node the overlay is going
>> to be applied to and are only visible from the current node properties.
>>
>> export-symbols are phandle based as opposed to global __symbols__. This
>> allows for much simpler use with overlays as opposed to __symbols__
>> where paths require resizing of overlays as show in [0].
>>
>> [0]:
>> https://lore.kernel.org/devicetree-compiler/6b2dba90-3c52-4933-88f3-b47f96dc7710@beagleboard.org/T/#m8259c8754f680b9da7b91f7b7dd89f10da91d8ed
> I'm not sold on the concept of export-symbols in the first place. But
> at the very least this commit message needs to explain what actually
> needs to be done within dtc to handle them. It's not obvious to me
> why it needs to do anything here, as opposed to in dtc consumers.
It would be great if we can take the discussion regarding export-symbols
here [0].
What do you mean my consumers? The kernel should do it at runtime or
something?
>> Signed-off-by: Ayush Singh <ayush@beagleboard.org>
>> ---
>> As discussed in the export-symbols kernel patch series [0], the
>> following patch series adds support for export-symbols in the base
>> devicetree compiler.
>>
>> This patch series is mostly a prototype for the functionality. Depending
>> on the direction, next revision of the patch will add tests.
>>
>> Support for export-symbols in overlays will be part of a seperate patch
>> series.
>>
>> [0]: https://lore.kernel.org/all/20241209151830.95723-1-herve.codina@bootlin.com/
>> ---
>> checks.c | 42 ++++++++++++++++++++++++++++++++++++++++--
>> 1 file changed, 40 insertions(+), 2 deletions(-)
>>
>> diff --git a/checks.c b/checks.c
>> index 123f2eb425f4a2f8ac22bfe10a842bf08e296ba1..e577f30a3ed9b762aee073fa1ff9d866f5de60b6 100644
>> --- a/checks.c
>> +++ b/checks.c
>> @@ -600,11 +600,37 @@ ERROR(name_properties, check_name_properties, NULL, &name_is_string);
>> * Reference fixup functions
>> */
>>
>> +static const char *fixup_export_symbol(struct node *export_symbols,
>> + struct marker *m)
>> +{
>> + struct property *prop;
>> + struct marker *em;
>> +
>> + for_each_property(export_symbols, prop) {
>> + if (streq(m->ref, prop->name)) {
>> + em = prop->val.markers;
>> + for_each_marker_of_type(em, REF_PHANDLE) {
>> + return em->ref;
> This requires the contents of the symbol to be defined as a reference
> to work. Yes, that's the obvious way to do it, but in existing things
> if you really want to hand code a phandle value, you can do that.
>
> This makes it so that trees that would otherwise have byte-for-byte
> identical dtb output don't work the same way.
I see, I did not consider hardcoding phandle value.
>> + }
>> + }
>> + }
>> +
>> + return NULL;
>> +}
>> +
>> static void fixup_phandle_references(struct check *c, struct dt_info *dti,
>> struct node *node)
>> {
>> struct node *dt = dti->dt;
>> struct property *prop;
>> + struct node *child, *export_symbols = NULL;
>> +
>> + for_each_child(node, child) {
>> + if (streq(child->name, "export-symbols")) {
>> + export_symbols = child;
>> + break;
>> + }
>> + }
>>
>> for_each_property(node, prop) {
>> struct marker *m = prop->val.markers;
>> @@ -612,13 +638,25 @@ static void fixup_phandle_references(struct check *c, struct dt_info *dti,
>> cell_t phandle;
>>
>> for_each_marker_of_type(m, REF_PHANDLE) {
>> + const char *ref = NULL;
>> +
>> assert(m->offset + sizeof(cell_t) <= prop->val.len);
>>
>> - refnode = get_node_by_ref(dt, m->ref);
>> + /* Check export-symbols if present */
>> + if (export_symbols)
>> + ref = fixup_export_symbol(export_symbols, m);
>> +
>> + /* If entry not found in export-symbols (or export-symbols not present),
>> + * search the normal way.
>> + */
>> + if (!ref)
>> + ref = m->ref;
> This muddles semantic layers together. In dtc, the *contents* of
> nodes and properties doesn't affect the output other than that node or
> property (though it might affect warnings). Only actual dts syntax
> affects output non-locally. This changes that, which I think is a
> very bad idea for understandability.
Don't __symbols__ and aliases already do this in a way, just globally I
guess?
>> +
>> + refnode = get_node_by_ref(dt, ref);
>> if (! refnode) {
>> if (!(dti->dtsflags & DTSF_PLUGIN))
>> FAIL(c, dti, node, "Reference to non-existent node or "
>> - "label \"%s\"\n", m->ref);
>> + "label \"%s\"\n", ref);
>> else /* mark the entry as unresolved */
>> *((fdt32_t *)(prop->val.val + m->offset)) =
>> cpu_to_fdt32(0xffffffff);
>>
>> ---
>> base-commit: 18f4f305fdd7e14c8941658a29c7b85c27d41de4
>> change-id: 20250110-export-symbols-e2ea3df01ea9
>>
>> Best regards,
[0]:
https://lore.kernel.org/all/20250225-export-symbols-v1-1-693049e3e187@beagleboard.org/
Ayush Singh
prev parent reply other threads:[~2025-03-10 5:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-10 17:48 [PATCH] checks: Add support for export-symbols Ayush Singh
2025-03-06 5:36 ` David Gibson
2025-03-10 5:18 ` Ayush Singh [this message]
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=a730a8b4-b253-4c22-b232-d396c6f12b58@beagleboard.org \
--to=ayush@beagleboard.org \
--cc=afd@ti.com \
--cc=arnd@arndb.de \
--cc=conor+dt@kernel.org \
--cc=d-gole@ti.com \
--cc=david@gibson.dropbear.id.au \
--cc=devicetree-compiler@vger.kernel.org \
--cc=geert@linux-m68k.org \
--cc=gregkh@linuxfoundation.org \
--cc=herve.codina@bootlin.com \
--cc=jkridner@beagleboard.org \
--cc=krzk+dt@kernel.org \
--cc=lorforlinux@beagleboard.org \
--cc=nenad.marinkovic@mikroe.com \
--cc=robertcnelson@beagleboard.org \
--cc=robertcnelson@gmail.com \
--cc=robh@kernel.org \
--cc=saravanak@google.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 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).