From: Richard Weinberger <richard@sigma-star.at>
To: devicetree@vger.kernel.org, Saravana Kannan <saravanak@google.com>
Cc: robh@kernel.org, linux-kernel@vger.kernel.org,
upstream+devicetree@sigma-star.at
Subject: Re: [PATCH] [RFC] of: Add debug aid to find unused device tree properties
Date: Mon, 14 Oct 2024 08:52:35 +0200 [thread overview]
Message-ID: <3316101.aeNJFYEL58@somecomputer> (raw)
In-Reply-To: <CAGETcx_+Poy8b_QhKY21Wg9=TBjtxrhCmFWTq8Qv6rLSJMURCw@mail.gmail.com>
Saravana,
Am Montag, 14. Oktober 2024, 04:37:10 CEST schrieb 'Saravana Kannan' via upstream:
> On Sun, Oct 13, 2024 at 1:07 PM Richard Weinberger <richard@nod.at> wrote:
> >
> > This is a proof-of-concept patch that introduces a debug feature I find
> > particularly useful. I frequently encounter situations where I'm
> > uncertain if my device tree configuration is correct or being utilized
> > by the kernel. This is especially common when porting device trees
> > from vendor kernels, as some properties may have slightly different
> > names in the upstream kernel, or upstream drivers may not use certain
> > properties at all.
>
> Why not just add debug logs? You can print the full path of the
> properties being read and it should be easy to grep for the property
> you care about.
This approach works only well when I know what property I care about.
The problem I'm addressing is more like importing a device tree (usually
something wonky from vendor tree) and want check whether all properties
stated in the device tree get actually used.
If something is not being used, I need to investigate...
>
> > By writing 'y' to <debugfs>/of_mark_queried, every queried device tree
>
> A lot of querying is going to happen at boot time. So, I'm not sure if
> this method of enabling it is helpful. If we do this, make it a kernel
> command line.
It works differently.
As soon CONFIG_OF_DEBUG is enabled, every queried property gets ->queried
set to true.
Writing to of_mark_queried updates just the sysfs representation of the
device tree.
That way one can analyze the tree also step by step.
E.g. learning what properties have been queried while bootup and later,
what was queried after loading kernel modules.
>
> > property will gain S_IWUSR in sysfs. While abusing S_IWUSR is
> > admittedly a crude hack, it works for now. I'm open to better ideas,
> > perhaps using an xattr?
>
> This seems quite convoluted. Why not just add another file per node
> that lists all the queried properties?
AFAICT, adding another file will confuse dtc since dtc treats every file
in sysfs as property.
>
> > That way, dtc can easily add an annotation to unused device trees when
> > reading from /proc/device-tree.
>
> I'm not too familiar with this part. Can you elaborate more?
E.g.
$ ./dtc/dtc -I fs -O dts /proc/device-tree
...
intc@8000000 {
...
v2m@8020000 {
msi-controller;
compatible = "arm,gic-v2m-frame";
reg = <0x00 0x8020000 0x00 0x1000>;
lala = "lulu"; /* not queried */
};
};
...
With my kernel patch and minimal changes to dtc, it is able to tell me that
nobody has read the property "lala" in my device tree.
Thanks,
//richard
--
sigma star gmbh | Eduard-Bodem-Gasse 6, 6020 Innsbruck, AUT
UID/VAT Nr: ATU 66964118 | FN: 374287y
next prev parent reply other threads:[~2024-10-14 6:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-13 20:07 [PATCH] [RFC] of: Add debug aid to find unused device tree properties Richard Weinberger
2024-10-14 2:37 ` Saravana Kannan
2024-10-14 6:52 ` Richard Weinberger [this message]
2024-10-14 7:49 ` Krzysztof Kozlowski
2024-10-14 8:51 ` Richard Weinberger
2024-10-14 14:41 ` Rob Herring
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=3316101.aeNJFYEL58@somecomputer \
--to=richard@sigma-star.at \
--cc=devicetree@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh@kernel.org \
--cc=saravanak@google.com \
--cc=upstream+devicetree@sigma-star.at \
/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).