tools/testing/selftests/pcie_bwctrl/set_pcie_cooling_state.sh
Source file repositories/reference/linux-study-clean/tools/testing/selftests/pcie_bwctrl/set_pcie_cooling_state.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/pcie_bwctrl/set_pcie_cooling_state.sh- Extension
.sh- Size
- 2275 bytes
- Lines
- 123
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: tools
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0-or-later
SYSFS=
# Kselftest framework requirement - SKIP code is 4.
ksft_skip=4
retval=0
skipmsg="skip all tests:"
PCIEPORTTYPE="PCIe_Port_Link_Speed"
prerequisite()
{
local ports
if [ $UID != 0 ]; then
echo $skipmsg must be run as root >&2
exit $ksft_skip
fi
SYSFS=`mount -t sysfs | head -1 | awk '{ print $3 }'`
if [ ! -d "$SYSFS" ]; then
echo $skipmsg sysfs is not mounted >&2
exit $ksft_skip
fi
if ! ls $SYSFS/class/thermal/cooling_device* > /dev/null 2>&1; then
echo $skipmsg thermal cooling devices missing >&2
exit $ksft_skip
fi
ports=`grep -e "^$PCIEPORTTYPE" $SYSFS/class/thermal/cooling_device*/type | wc -l`
if [ $ports -eq 0 ]; then
echo $skipmsg pcie cooling devices missing >&2
exit $ksft_skip
fi
}
testport=
find_pcie_port()
{
local patt="$1"
local pcieports
local max
local cur
local delta
local bestdelta=-1
pcieports=`grep -l -F -e "$patt" /sys/class/thermal/cooling_device*/type`
if [ -z "$pcieports" ]; then
return
fi
pcieports=${pcieports//\/type/}
# Find the port with the highest PCIe Link Speed
for port in $pcieports; do
max=`cat $port/max_state`
cur=`cat $port/cur_state`
delta=$((max-cur))
if [ $delta -gt $bestdelta ]; then
testport="$port"
bestdelta=$delta
fi
done
}
sysfspcidev=
find_sysfs_pci_dev()
{
local typefile="$1/type"
Annotation
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.