Re: [PATCH] [RFC] of: Add debug aid to find unused device tree properties

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxx> 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







[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux