Re: [PATCH v2 3/3] kselftest: Add new test for detecting unprobed Devicetree devices

From: Nícolas F. R. A. Prado
Date: Fri Aug 18 2023 - 12:39:17 EST


On Fri, Aug 18, 2023 at 10:05:00AM -0500, Rob Herring wrote:
> On Thu, Aug 17, 2023 at 6:36 PM Nícolas F. R. A. Prado
> <nfraprado@xxxxxxxxxxxxx> wrote:
[..]
> > tools/testing/selftests/Makefile | 1 +
> > tools/testing/selftests/dt/.gitignore | 1 +
> > tools/testing/selftests/dt/Makefile | 21 +++++
>
> Please add this path to DT maintainers entry.

OK.

>
> > .../selftests/dt/compatible_ignore_list | 1 +
> > tools/testing/selftests/dt/ktap_helpers.sh | 57 +++++++++++++
>
> As Mark said, looks common.

Yes, I'll move it one folder up.

>
[..]
> > --- /dev/null
> > +++ b/tools/testing/selftests/dt/.gitignore
> > @@ -0,0 +1 @@
> > +compatible_list
>
> Not sure on the selftests, but is this enough that it gets cleaned?

I've just double-checked that compatible_list does get removed with make clean.
Not because it is in this gitignore, but because it is listed in TEST_GEN_FILES
in the Makefile.

>
[..]
> > --- /dev/null
> > +++ b/tools/testing/selftests/dt/test_unprobed_devices.sh
[..]
> > +PDT=/proc/device-tree/
>
> This is considered the legacy path though we will probably never get
> rid of it. Use the sysfs path instead.

The /sys/firmware/devicetree/* entry in
Documentation/ABI/testing/sysfs-firmware-ofw reads:

Userspace must not use the /sys/firmware/devicetree/base
path directly, but instead should follow /proc/device-tree
symlink. It is possible that the absolute path will change
in the future, but the symlink is the stable ABI.

So is this information outdated?

>
[..]
> > +nodes_compatible=$(
> > + for node_compat in $(find ${PDT} -name compatible); do
> > + node=$(dirname "${node_compat}")
> > + # Check if node is available
> > + [[ -e "${node}"/status && $(tr -d '\000' < "${node}"/status) != "okay" ]] && continue
>
> Note that "ok" is accepted by the kernel and does show up some. But
> for your use, probably okay as is.

Right, good point. Actually I think we should probably check for "ok" here as
well. Even though it's not valid based on the spec and not used in any upstream
Devicetree anymore, it's still supported by the kernel. If this test was to be
run with older or downstream Devicetrees, it should still detect that a node
with 'status = "ok"' is not having its driver probed, rather than ignore it.

Thanks,
Nícolas

>
[..]