mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00

Filter out nodes that have one of its ancestors disabled as they aren't
expected to probe.
This removes the following false-positive failures on the
sc7180-trogdor-lazor-limozeen-nots-r5 platform:
/soc@0/geniqup@8c0000/i2c@894000/proximity@28
/soc@0/geniqup@ac0000/spi@a90000/ec@0
/soc@0/remoteproc@62400000/glink-edge/apr
/soc@0/remoteproc@62400000/glink-edge/apr/service@3
/soc@0/remoteproc@62400000/glink-edge/apr/service@4
/soc@0/remoteproc@62400000/glink-edge/apr/service@4/clock-controller
/soc@0/remoteproc@62400000/glink-edge/apr/service@4/dais
/soc@0/remoteproc@62400000/glink-edge/apr/service@7
/soc@0/remoteproc@62400000/glink-edge/apr/service@7/dais
/soc@0/remoteproc@62400000/glink-edge/apr/service@8
/soc@0/remoteproc@62400000/glink-edge/apr/service@8/routing
/soc@0/remoteproc@62400000/glink-edge/fastrpc
/soc@0/remoteproc@62400000/glink-edge/fastrpc/compute-cb@3
/soc@0/remoteproc@62400000/glink-edge/fastrpc/compute-cb@4
/soc@0/remoteproc@62400000/glink-edge/fastrpc/compute-cb@5
/soc@0/spmi@c440000/pmic@0/pon@800/pwrkey
Fixes: 14571ab1ad
("kselftest: Add new test for detecting unprobed Devicetree devices")
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Link: https://lore.kernel.org/r/20240729-dt-kselftest-parent-disabled-v2-1-d7a001c4930d@collabora.com
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
93 lines
2.2 KiB
Bash
Executable file
93 lines
2.2 KiB
Bash
Executable file
#!/bin/bash
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
#
|
|
# Copyright (c) 2023 Collabora Ltd
|
|
#
|
|
# Based on Frank Rowand's dt_stat script.
|
|
#
|
|
# This script tests for devices that were declared on the Devicetree and are
|
|
# expected to bind to a driver, but didn't.
|
|
#
|
|
# To achieve this, two lists are used:
|
|
# * a list of the compatibles that can be matched by a Devicetree node
|
|
# * a list of compatibles that should be ignored
|
|
#
|
|
|
|
DIR="$(dirname $(readlink -f "$0"))"
|
|
|
|
source "${DIR}"/../kselftest/ktap_helpers.sh
|
|
|
|
PDT=/proc/device-tree/
|
|
COMPAT_LIST="${DIR}"/compatible_list
|
|
IGNORE_LIST="${DIR}"/compatible_ignore_list
|
|
|
|
ktap_print_header
|
|
|
|
if [[ ! -d "${PDT}" ]]; then
|
|
ktap_skip_all "${PDT} doesn't exist."
|
|
exit "${KSFT_SKIP}"
|
|
fi
|
|
|
|
nodes_compatible=$(
|
|
for node in $(find ${PDT} -type d); do
|
|
[ ! -f "${node}"/compatible ] && continue
|
|
# Check if node is available
|
|
if [[ -e "${node}"/status ]]; then
|
|
status=$(tr -d '\000' < "${node}"/status)
|
|
if [[ "${status}" != "okay" && "${status}" != "ok" ]]; then
|
|
if [ -n "${disabled_nodes_regex}" ]; then
|
|
disabled_nodes_regex="${disabled_nodes_regex}|${node}"
|
|
else
|
|
disabled_nodes_regex="${node}"
|
|
fi
|
|
continue
|
|
fi
|
|
fi
|
|
|
|
# Ignore this node if one of its ancestors was disabled
|
|
if [ -n "${disabled_nodes_regex}" ]; then
|
|
echo "${node}" | grep -q -E "${disabled_nodes_regex}" && continue
|
|
fi
|
|
|
|
echo "${node}" | sed -e 's|\/proc\/device-tree||'
|
|
done | sort
|
|
)
|
|
|
|
nodes_dev_bound=$(
|
|
IFS=$'\n'
|
|
for dev_dir in $(find /sys/devices -type d); do
|
|
[ ! -f "${dev_dir}"/uevent ] && continue
|
|
[ ! -d "${dev_dir}"/driver ] && continue
|
|
|
|
grep '^OF_FULLNAME=' "${dev_dir}"/uevent | sed -e 's|OF_FULLNAME=||'
|
|
done
|
|
)
|
|
|
|
num_tests=$(echo ${nodes_compatible} | wc -w)
|
|
ktap_set_plan "${num_tests}"
|
|
|
|
retval="${KSFT_PASS}"
|
|
for node in ${nodes_compatible}; do
|
|
if ! echo "${nodes_dev_bound}" | grep -E -q "(^| )${node}( |\$)"; then
|
|
compatibles=$(tr '\000' '\n' < "${PDT}"/"${node}"/compatible)
|
|
|
|
for compatible in ${compatibles}; do
|
|
if grep -x -q "${compatible}" "${IGNORE_LIST}"; then
|
|
continue
|
|
fi
|
|
|
|
if grep -x -q "${compatible}" "${COMPAT_LIST}"; then
|
|
ktap_test_fail "${node}"
|
|
retval="${KSFT_FAIL}"
|
|
continue 2
|
|
fi
|
|
done
|
|
ktap_test_skip "${node}"
|
|
else
|
|
ktap_test_pass "${node}"
|
|
fi
|
|
|
|
done
|
|
|
|
ktap_print_totals
|
|
exit "${retval}"
|